C++ main module for gpm Package  1.0
CORE_Real.h
Go to the documentation of this file.
1 #ifndef CORE_REAL_H
2 #define CORE_REAL_H
3 
4 #include "CORE_Object.h"
5 #include "CORE_Pointers.h"
6 
7 
21 
22 class CORE_Real : public CORE_Object {
23 
24  // ATTRIBUTES
25  private:
26  tReal mReal;
27  static tString mSystemDigitalDot;
28 
29  //ASSOCIATIONS
30 
31  private:
32 
33 
34 
35  //CONSTRUCTOR
36 
37  protected:
40  CORE_Real();
43  CORE_Real(const tReal& i);
44 
45  //DESTRUCTOR
46  protected:
49  virtual ~CORE_Real();
50 
51  // NEW METHODS
52  public:
55  static inline SP::CORE_Real New() {
56  SP::CORE_Real ret(new CORE_Real(),CORE_Real::Delete());
57  return ret;
58  };
61  static inline SP::CORE_Real New(const tReal& i) {
62  SP::CORE_Real ret(new CORE_Real(i),CORE_Real::Delete());
63  return ret;
64  };
65 
66  // SET METHODS
67  public:
70  inline void setReal(const tReal& r) {mReal=r;};
73  inline void setReal(const tString& r) {
74  setReal(parseReal(r));
75  };
76 
77  // GET METHODS
78  public:
82  tReal getReal() const {return mReal;};
83 
84  // OTHERS METHODS
85  public:
89  tString toString() const {return toString(mReal);};
90 
97  static tString toString(long double i,int n);
98 
105  static tString toString(double i,int n) {
106  return toString((long double)i,n);
107  };
108 
109 
110 
111 
115  inline static tString toString(float i){
116  return toString((long double)i,6);
117  };
121  inline static tString toString(double i){
122  return toString((long double)i,12);
123  };
127  inline static tString toString(long double i){
128  return toString(i,24);
129  };
135  static tString toString(tReal r,tReal eps);
136 
143  static void shellSort(tReal a[],int N);
144 
147  static long double parseReal(const tString& str);
148 
149 
153  static void solveEq2(const tReal& a,const tReal& b,const tReal& c,
154  vector<tReal>& x);
159  static void solveEq3(const tReal& a,const tReal& b,const tReal& c,const tReal& d,
160  vector<tReal>& x);
161 
162  // VIRTUAl METHODS
163  public:
164 
165  // PRIVATE METHODS
166  private:
167  static int sgn(tReal x);
168  static tReal surround(tReal x);
169  };
170 
171 #endif // end of ifndef
DEFINE_SPTR(CORE_Real)
static tString toString(long double i)
return the string associated to the real
Definition: CORE_Real.h:127
static SP::CORE_Real New(const tReal &i)
create a class Real
Definition: CORE_Real.h:61
static tString toString(double i, int n)
return the string associated to the real
Definition: CORE_Real.h:105
static void shellSort(tReal a[], int N)
sort the array tb a shell sorting method
Definition: CORE_Real.cpp:55
tReal getReal() const
get the real
Definition: CORE_Real.h:82
void setReal(const tString &r)
set the real to r
Definition: CORE_Real.h:73
static tString toString(double i)
return the string associated to the real
Definition: CORE_Real.h:121
static void solveEq3(const tReal &a, const tReal &b, const tReal &c, const tReal &d, vector< tReal > &x)
solve a 3nd order equation ax3+bx2+cx+d=0
Definition: CORE_Real.cpp:137
virtual ~CORE_Real()
delete class
Definition: CORE_Real.cpp:18
static SP::CORE_Real New()
create a class Real
Definition: CORE_Real.h:55
void setReal(const tReal &r)
set the real to r
Definition: CORE_Real.h:70
abstract base class for most classes.
Definition: CORE_Object.h:30
#define tString
Definition: types.h:36
tString toString() const
return the string associated to the real
Definition: CORE_Real.h:89
static long double parseReal(const tString &str)
return the real associated to the string
Definition: CORE_Real.cpp:78
static void solveEq2(const tReal &a, const tReal &b, const tReal &c, vector< tReal > &x)
solve a 2nd order equation ax2+bx+c=0
Definition: CORE_Real.cpp:202
static tString toString(float i)
return the string associated to the real
Definition: CORE_Real.h:115
CORE_Real()
create a real
Definition: CORE_Real.cpp:12
#define tReal
Definition: types.h:18
this class describes a real Attributes:
Definition: CORE_Real.h:22
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:106