C++ main module for emicrom Package  1.0
MATH_P1.h
Go to the documentation of this file.
1 #ifndef MATH_P1_H
2 #define MATH_P1_H
3 
4 #include "MATH_P0.h"
5 
14 
15 class MATH_P1 : public MATH_P0 {
16 
17 
19 
20  // ATTRIBUTES
21 
22 
23 
24 private:
25 
26 
27 public:
28  // METHODS
29 
30  // CONSTRUCTORS
31 
34  MATH_P1(void): MATH_P0(1) {
35  }
36 
37 protected:
41  MATH_P1(const tUIndex& n): MATH_P0(n) {
42  }
43 
44  // DESTRUCTORS
45 public:
46 
49  virtual ~MATH_P1(void) {
50  }
51 
52 
53 public:
54 
55  // CONSTRUCTORS
56 
59  inline static SP::MATH_P1 New() {
60  SP::MATH_P1 ret(new MATH_P1(),
61  MATH_P1::Delete());
62  ret->setThis(ret);
63  return ret;
64  };
69  inline static SP::MATH_P1 New(const tReal a[]) {
70  SP::MATH_P1 p=New();
71  p->setCoefficients(a);
72  return p;
73  };
74 
75 
76 public:
77 
78 
79 
80  // GET methods
81 
82 
83 
84 public:
85 
86 
91  virtual tUInteger solve(tReal x[]) const {
92  const tReal *a=getCoefficients();
93  if (a[1]!=0) {
94  x[0]=-a[0]/a[1];
95  return 1;
96  } else {
97  MATH_P0::solve(x);
98  }
99  return 0;
100  }
101 
102 
103 
104 
105 
106 
107 
108 };
109 
110 #endif
MATH_P1(const tUIndex &n)
create a polynom of degre n
Definition: MATH_P1.h:41
This class describes a polynom of degre 0.
Definition: MATH_P0.h:15
static SP::MATH_P1 New(const tReal a[])
builds a Polynom of 1-degree with coefficients
Definition: MATH_P1.h:69
#define tUInteger
Definition: types.h:91
SP_OBJECT(MATH_P1)
const tReal * getCoefficients() const
get the coefficients
Definition: MATH_Pn.h:117
virtual ~MATH_P1(void)
destroy
Definition: MATH_P1.h:49
virtual tUInteger solve(tReal x[]) const
solve the equation P(x)=0.
Definition: MATH_P0.h:93
MATH_P1(void)
create a polynome of degree 1
Definition: MATH_P1.h:34
static SP::MATH_P1 New()
builds a Polynom of 1-degree
Definition: MATH_P1.h:59
#define tUIndex
Definition: types.h:126
DEFINE_SPTR(MATH_P1)
virtual tUInteger solve(tReal x[]) const
solve the equation P(x)=0.
Definition: MATH_P1.h:91
This class describes a polynom of degre 1.
Definition: MATH_P1.h:15
#define tReal
Definition: types.h:118
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:141