C++ main module for emicrom Package  1.0
MATH_TestFunction.h
Go to the documentation of this file.
1 #ifndef MATH_TestFunction_H
2 #define MATH_TestFunction_H
3 
5 
6 
15 
18 
19  // ATTRIBUTES
20 
21 public:
22 
23 
24 private:
26 
27 private:
28 
29 
30 
31 
32 protected:
33  // METHODS
34 
35  // CONSTRUCTORS
36 
39  mType=0;
40  }
41 
42 
43 
44  // DESTRUCTORS
45 
46 
49  virtual ~MATH_TestFunction(void) {
50  }
51 
52 
53 public:
54 
55  // NEW methods
56 
59  static SP::MATH_TestFunction New() {
60  SP::MATH_TestFunction p(new MATH_TestFunction(),
62  p->setThis(p);
63  return p;
64  };
65 
66 
67 
68  // COPY methods
69 
70  // ----------------
71  // FUNCTION METHOD
72  // ----------------
73 
80  inline void setType(const tFlag& t) {
81  mType=t;
82  }
85  virtual tReal computeFunction(const tUSInt& n,const tReal X[]) {
86  tReal ret=0;
87  const tReal *x=X;
88  tUSInt i;
89 
90  switch(mType) {
91  case 0:
92  //f(x,y,z)=xyz
93  ret=(*x);
94  for (i=1;i<n;i++) {
95  x++;
96  ret*=(*x);
97  }
98  break;
99  case 1:
100  //f(x,y,z)=1/sqrt(x^2+y^2+z^2)^3-3*x^2/sqrt(x^2+y^2+z^2)^5
101  ret=(*x)*(*x);
102  for (i=1;i<n;i++) {
103  x++;
104  ret+=(*x)*(*x);
105  }
106  ret=pow(ret,-1.5)-3*(*X)*(*X)*pow(ret,-2.5);
107  break;
108  case 2:
109  //f(x,y,z)=-3*x*y/sqrt(x^2+y^2+z^2)^5
110  ret=(*x)*(*x);
111  for (i=1;i<n;i++) {
112  x++;
113  ret+=(*x)*(*x);
114  }
115  ret=pow(ret,-2.5);
116  x=X;
117  ret*=(*x);
118  x++;
119  ret*=(*x);
120  ret*=-3.;
121  break;
122  }
123  return ret;
124  }
125 
126 
127 
128 
129 
130 };
131 
132 
133 #endif
tFlag mType
Definition: MATH_TestFunction.h:25
virtual tReal computeFunction(const tUSInt &n, const tReal X[])
compute the function at the point
Definition: MATH_TestFunction.h:85
SP_OBJECT(MATH_TestFunction)
void setType(const tFlag &t)
set the type of the function
Definition: MATH_TestFunction.h:80
#define tUSInt
Definition: types.h:28
This class describes a test function to integrate.
Definition: MATH_TestFunction.h:16
static SP::MATH_TestFunction New()
create a copy of MATH_TestFunction
Definition: MATH_TestFunction.h:59
virtual ~MATH_TestFunction(void)
destroy an TestFunction Object.
Definition: MATH_TestFunction.h:49
MATH_TestFunction(void)
create a TestFunction object
Definition: MATH_TestFunction.h:38
DEFINE_SPTR(MATH_TestFunction)
This class describes a function to integrate. the method computeFunction() has to be defined...
Definition: MATH_IntegrandFunction.h:16
#define tReal
Definition: types.h:118
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:141
#define tFlag
Definition: types.h:74