C++ main module for emicrom Package  1.0
MATH_Integration.h
Go to the documentation of this file.
1 #ifndef MATH_Integration_H
2 #define MATH_Integration_H
3 
4 #include "CORE_Object.h"
5 
6 #include "CORE_Array.h"
7 
9 
18 
21 
22  // ATTRIBUTES
23 
24 public:
25 private:
26 
27 
28 private:
29  //bounds of intergration
31 
32  // ASSOCIATIONS
33 
34  //function to integrate
35  WP::MATH_IntegrandFunction mFunction;
36 
37 protected:
38  // METHODS
39 
40  // CONSTRUCTORS
41 
44  mBounds.setSize(2);
45  mBounds[0]=-1;
46  mBounds[1]=1;
47  }
48 
49 
50 
51  // DESTRUCTORS
52 
53 
56  virtual ~MATH_Integration(void) {
57  }
58 
59 
60 public:
61 
62  // NEW methods
63 
64 
65  // COPY methods
66 
70  virtual void copy(const MATH_Integration& integral) {
71  mBounds.copy(integral.getBounds());
72 
73  }
74 
75 
76 
77 
78 public:
79 
80 
84  inline void setFunction(SP::MATH_IntegrandFunction f) {
85  mFunction=f;
86  };
87 
88 
94  void setBounds(const tUSInt& n,const tReal I[]);
95 
100  inline void setBounds(const tReal& a,const tReal& b) {
101  mBounds.setSize(2);
102  mBounds[0]=(a<b)?a:b;
103  mBounds[1]=(a>b)?a:b;
104  setBoundsCalled();
105  }
112  inline void setBounds(const tReal& a1,const tReal& b1,const tReal& a2,const tReal& b2) {
113  mBounds.setSize(4);
114  mBounds[0]=(a1<b1)?a1:b1;
115  mBounds[1]=(a1>b1)?a1:b1;
116  mBounds[2]=(a2<b2)?a2:b2;
117  mBounds[3]=(a2>b2)?a2:b2;
118  setBoundsCalled();
119  }
128  inline void setBounds(const tReal& a1,const tReal& b1,const tReal& a2,const tReal& b2,const tReal& a3,const tReal& b3) {
129  mBounds.setSize(6);
130  mBounds[0]=(a1<b1)?a1:b1;
131  mBounds[1]=(a1>b1)?a1:b1;
132  mBounds[2]=(a2<b2)?a2:b2;
133  mBounds[3]=(a2>b2)?a2:b2;
134  mBounds[4]=(a3<b3)?a3:b3;
135  mBounds[5]=(a3>b3)?a3:b3;
136  setBoundsCalled();
137  }
138 protected:
141  virtual void setBoundsCalled()=0;
142 
143  // GET methods
144 
145 public:
146 
147 
148 
152  inline tBoolean hasFunction() const {
153  return (mFunction.lock().get()!=null);
154  }
155 
159  inline const MATH_IntegrandFunction& getFunction() const {
160  SPC::MATH_IntegrandFunction p=mFunction.lock();
161  return *p.get();
162  };
167  SP::MATH_IntegrandFunction p=mFunction.lock();
168  return *p.get();
169  };
170 
171 
175  inline const CORE_RealArray& getBounds() const {
176  return mBounds;
177  }
184  inline const tReal& getBound(const tUSInt& i) const {
185  return mBounds[i];
186  }
187 
192  inline tUSInt getDimension() const {
193  return mBounds.getSize()/2;
194 
195  }
196 public:
197  // ------------------
198  // INTEGRATE function
199  // ------------------
200 
205  virtual tReal integrate(SP::MATH_IntegrandFunction f) {
206  setFunction(f);
207  return integrate();
208  }
209 
213  virtual tReal integrate()=0;
214 
215 
216 
217 };
218 
219 
220 #endif
SP_OBJECT(MATH_Integration)
void setFunction(SP::MATH_IntegrandFunction f)
set function to integrate
Definition: MATH_Integration.h:84
const tUIndex & getSize() const
return the size of the array for reading
Definition: CORE_Array.h:1018
virtual void copy(const MATH_Integration &integral)
copy the parameters of the optimization method
Definition: MATH_Integration.h:70
void setBounds(const tReal &a, const tReal &b)
set the interval of integration [a,b]
Definition: MATH_Integration.h:100
MATH_IntegrandFunction & getFunction()
get the integrand function
Definition: MATH_Integration.h:166
virtual void setBoundsCalled()=0
method called when intervals is modified
tUSInt getDimension() const
get the dimension of the integration
Definition: MATH_Integration.h:192
#define tUSInt
Definition: types.h:28
void setBounds(const tReal &a1, const tReal &b1, const tReal &a2, const tReal &b2)
set the integration domain to [a1,b1]x[a2,b2]
Definition: MATH_Integration.h:112
#define tBoolean
Definition: types.h:139
virtual ~MATH_Integration(void)
destroy an Integration Object.
Definition: MATH_Integration.h:56
void setSize(const tUIndex &n)
set the size
Definition: CORE_Array.h:292
#define null
Definition: types.h:144
void setBounds(const tUSInt &n, const tReal I[])
set the bounds of the domain of integration
Definition: MATH_Integration.cpp:3
virtual tReal integrate(SP::MATH_IntegrandFunction f)
integrate the function in the bounds of integration
Definition: MATH_Integration.h:205
const CORE_RealArray & getBounds() const
return the bounds of integration
Definition: MATH_Integration.h:175
virtual tReal integrate()=0
integrate the function in the bounds of integration
WP::MATH_IntegrandFunction mFunction
Definition: MATH_Integration.h:35
This class integrates integrand function MATH_IntegrandFunction where a,b,t,dt in d=(1...
Definition: MATH_Integration.h:19
abstract base class for most classes.
Definition: CORE_Object.h:53
tBoolean hasFunction() const
return true if the integrand is set
Definition: MATH_Integration.h:152
void setBounds(const tReal &a1, const tReal &b1, const tReal &a2, const tReal &b2, const tReal &a3, const tReal &b3)
set the integration domain to [a1,b1]x[a2,b2]x[a3,b3]
Definition: MATH_Integration.h:128
DEFINE_SPTR(MATH_IntegrandFunction)
This class describes a function to integrate. the method computeFunction() has to be defined...
Definition: MATH_IntegrandFunction.h:16
const MATH_IntegrandFunction & getFunction() const
get the integrand function
Definition: MATH_Integration.h:159
#define tReal
Definition: types.h:118
const tReal & getBound(const tUSInt &i) const
return the bound of the interval of integration
Definition: MATH_Integration.h:184
MATH_Integration(void)
create a Integration object
Definition: MATH_Integration.h:43
void copy(const CORE_Array< Q > &f)
copy the array
Definition: CORE_Array.hpp:16
CORE_RealArray mBounds
Definition: MATH_Integration.h:30