C++ main module for mmsd Package  1.0
MATH_CubicPolynom.h
Go to the documentation of this file.
1 #ifndef MATH_CubicPolynom_H
2 #define MATH_CubicPolynom_H
3 
4 
5 #include "MATH_Function.h"
6 
7 
15  SP_OBJECT(MATH_CubicPolynom);
16 
17 public:
18 
19 
20  // ATTRIBUTES
21 private:
22 
23  //
24  // ASSOCIATIONS
25  tReal mCoef[3];
26 
27 protected:
28  // METHODS
29 
30  // CONSTRUCTORS
31 
33  MATH_CubicPolynom(void);
34 
35 
36 
37  // DESTRUCTORS
38 
39 
42  virtual ~MATH_CubicPolynom(void);
43 
44  // NEW methods
45 
46 public:
49  static inline SP::MATH_CubicPolynom New() {
50  SP::MATH_CubicPolynom p(new MATH_CubicPolynom(),MATH_CubicPolynom::Delete());
51  p->setThis(p);
52  return p;
53  };
54 
55 
56 
57  //SET & GET methods
60  void copy(const MATH_CubicPolynom& poly);
61 
64  tReal& operator[](const int& i) {
65  ASSERT_IN(i<=3);
66  return mCoef[i];
67  }
70  const tReal& operator[](const int& i) const {
71  ASSERT_IN(i<=3);
72  return mCoef[i];
73  }
74 
75  /* ! \brief solve the eqtion a*x*x+b*x+c=0
76  * the method used is explain as follow:
77  * https://fr.wikipedia.org/wiki/M%C3%A9thode_de_Cardan
78  */
79  template<class T>
80  static void solve(const tReal& a,const tReal& b,const tReal& c,const tReal& d,
81  int& n,T solutions[3]);
82 
83  /* ! \brief solve this=0
84  */
85  inline void solve(int& n,long double solutions[3]) const {
86  MATH_CubicPolynom::solve<long double>(mCoef[3],mCoef[2],mCoef[1],mCoef[0],n,solutions);
87  }
88  /* ! \brief solve this=0
89  */
90  inline void solve(int& n,double solutions[3]) const {
91  MATH_CubicPolynom::solve<double>(mCoef[3],mCoef[2],mCoef[1],mCoef[0],n,solutions);
92  }
93 
94 
95  //SAVER & LOADER
96 
99  void loadFromUIClass(const UI_Class& mclass);
102  void saveToUIClass(UI_Class& mclass) const;
103 
104  // OTHERS methods
105 
106 
110  virtual tReal computeFunction(const tReal& x) {
111  return ComputeFunction(mCoef[3],mCoef[2],mCoef[1],mCoef[0],x);
112  }
113 
117  static tReal ComputeFunction(const tReal& a,const tReal& b, const tReal& c,const tReal& d,const tReal& x) {
118  return ((a*x+b)*x+c)*x+d;
119  }
120 
123  virtual tString toString() const;
124 
125 };
126 #include "MATH_CubicPolynom.hpp"
127 #endif
This class describes the quadratic function.
Definition: MATH_CubicPolynom.h:14
This class describes a function function.
Definition: MATH_Function.h:16
DEFINE_SPTR(MATH_CubicPolynom)
virtual tReal computeFunction(const tReal &x)
compute the function return
Definition: MATH_CubicPolynom.h:110
void solve(int &n, double solutions[3]) const
Definition: MATH_CubicPolynom.h:90
void saveToUIClass(UI_Class &mclass) const
save the class to the backup class
Definition: MATH_CubicPolynom.cpp:22
This class describes the main interface class for a soft user interface (R,matlab,python etc...) class.
Definition: UI_Class.h:38
static void solve(const tReal &a, const tReal &b, const tReal &c, const tReal &d, int &n, T solutions[3])
Definition: MATH_CubicPolynom.hpp:7
static SP::MATH_CubicPolynom New()
create a trigamma function
Definition: MATH_CubicPolynom.h:49
virtual tString toString() const
return the strin representation of the class
Definition: MATH_CubicPolynom.cpp:35
void copy(const MATH_CubicPolynom &poly)
copy
Definition: MATH_CubicPolynom.cpp:30
const tReal & operator[](const int &i) const
the the coeficient of the monome of degre i
Definition: MATH_CubicPolynom.h:70
MATH_CubicPolynom(void)
create a trigamma function
Definition: MATH_CubicPolynom.cpp:5
virtual ~MATH_CubicPolynom(void)
destroy an trigamma funtion
Definition: MATH_CubicPolynom.cpp:10
void solve(int &n, long double solutions[3]) const
Definition: MATH_CubicPolynom.h:85
#define tString
Definition: types.h:49
tReal & operator[](const int &i)
the the coeficient of the monome of degre i
Definition: MATH_CubicPolynom.h:64
void loadFromUIClass(const UI_Class &mclass)
load the class from the backup class
Definition: MATH_CubicPolynom.cpp:14
static tReal ComputeFunction(const tReal &a, const tReal &b, const tReal &c, const tReal &d, const tReal &x)
compute the function return
Definition: MATH_CubicPolynom.h:117
#define tReal
Definition: types.h:18
#define ASSERT_IN(a)
Definition: types.h:96
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:106