C++ main module for emicrom Package  1.0
MATH_Pn.h
Go to the documentation of this file.
1 #ifndef MATH_Pn_H
2 #define MATH_Pn_H
3 
4 #include "CORE_Object.h"
5 #include "CORE_Integer.h"
6 #include "CORE_Exception.h"
7 
20 class MATH_Pn : public CORE_Object {
21 
22 
24 
25  // ATTRIBUTES
26 
27 
28 
29 private:
30 
33  mutable SP::MATH_Pn mQ;
34 
35 protected:
36  // METHODS
37 
38  // CONSTRUCTORS
39 
42  MATH_Pn();
43 
46  MATH_Pn(const tUIndex& n);
47 
48 
49 
50 
51  // DESTRUCTORS
52 
53 
56  virtual ~MATH_Pn(void);
57 
58 
59 public:
60 
61  // CONSTRUCTORS
62 
63 
64 
65  //operator
66 public:
67 
72  inline const tReal& operator[](const tUIndex& i) const {
73  if (i>mDegree) throw CORE_Exception("emicrom/math","MATH_Pn[]",CORE_Integer::toString(i)+" index out of bound <="+CORE_Integer::toString(mDegree));
74  return mA[i];
75  }
80  inline tReal& operator[](const tUIndex& i) {
81  if (i>mDegree) throw CORE_Exception("emicrom/math","MATH_Pn[]",CORE_Integer::toString(i)+" index out of bound <="+CORE_Integer::toString(mDegree));
82  return mA[i];
83  }
88  inline tReal operator()(const tReal& x) {
89  return evaluate(x);
90  }
91 public:
95  void setDegree(const tUIndex& n);
96 
97 
98 
103  void setCoefficients(const tReal a[]);
104 
105 
106  // GET methods
107 
108 
111  inline const tUIndex& getDegree() const {
112  return mDegree;
113  }
117  inline const tReal* getCoefficients() const {
118  return mA;
119  }
123  inline tReal* getCoefficients() {
124  return mA;
125  }
126 protected:
130  inline SP::MATH_Pn getQ() const {
131  return mQ;
132  }
133 public:
134  // OTHERS methods
137  virtual tReal evaluate(const tReal& x) const;
138 
139 
140 
145  virtual tUInteger computeExtrenums(tReal x[]) const;
146 
147 
154 
161 
167  virtual tUInteger solve(tReal x[]) const=0;
168 
169 
170 
174  virtual tString toString() const;
175 
176 };
177 
178 #endif
const tReal & operator[](const tUIndex &i) const
get the coeeficient of degre i in [0,getDegree()]
Definition: MATH_Pn.h:72
tReal operator()(const tReal &x)
evaluate the polynom at x
Definition: MATH_Pn.h:88
#define tUInteger
Definition: types.h:91
void setCoefficients(const tReal a[])
set coeficients of the polynom
Definition: MATH_Pn.cpp:52
virtual tString toString() const
return the string representation of the class
Definition: MATH_Pn.cpp:161
const tUIndex & getDegree() const
retun the degree
Definition: MATH_Pn.h:111
const tReal * getCoefficients() const
get the coefficients
Definition: MATH_Pn.h:117
virtual ~MATH_Pn(void)
destroy
Definition: MATH_Pn.cpp:21
SP::MATH_Pn getQ() const
return the temporary polynom
Definition: MATH_Pn.h:130
#define tBoolean
Definition: types.h:139
tString toString() const
return the string associated to the integer
Definition: CORE_Integer.h:106
void setDegree(const tUIndex &n)
et the degree of the polynom
Definition: MATH_Pn.cpp:45
tReal * getCoefficients()
get the coefficients
Definition: MATH_Pn.h:123
this class describes the exceptions raised for CORE package
Definition: CORE_Exception.h:15
tBoolean firstPositiveMaximum(tReal x[]) const
compute the first postive point where the polynom is maximum
Definition: MATH_Pn.cpp:97
#define tUIndex
Definition: types.h:126
abstract base class for most classes.
Definition: CORE_Object.h:53
#define tString
Definition: types.h:135
DEFINE_SPTR(MATH_Pn)
This class describes a polynom of degree n .
Definition: MATH_Pn.h:20
SP_OBJECT(MATH_Pn)
SP::MATH_Pn mQ
Definition: MATH_Pn.h:33
virtual tReal evaluate(const tReal &x) const
evaluate the polynom at x
Definition: MATH_Pn.cpp:25
tReal & operator[](const tUIndex &i)
get the coeeficient of degre i in [0,getDegree()]
Definition: MATH_Pn.h:80
virtual tUInteger computeExtrenums(tReal x[]) const
find the x extrenums.
Definition: MATH_Pn.cpp:57
#define tReal
Definition: types.h:118
MATH_Pn()
create
Definition: MATH_Pn.cpp:15
tReal * mA
Definition: MATH_Pn.h:31
virtual tUInteger solve(tReal x[]) const =0
solve the equation P(x)=0.
tUIndex mDegree
Definition: MATH_Pn.h:32
tBoolean firstPositiveMinimum(tReal x[]) const
compute the first positive point where the polynom is minimum
Definition: MATH_Pn.cpp:130