C++ main module for emicrom Package  1.0
MATH_Solver.h
Go to the documentation of this file.
1 #ifndef MATH_Solver_H
2 #define MATH_Solver_H
3 
4 #include "CORE_Object.h"
5 
6 
7 #include "MATH_Matrix.h"
8 
9 
17 
18 class MATH_Solver : public CORE_Object {
20 
21 
22 private:
27 
28  SP::MATH_Vector mW;
29 
30 protected:
33  MATH_Solver(void) {
34  mMaxIterationsNumber=100;
35  mTolerance=1.e-12;
36  mIterationsNumber=0;
37  mError=0;
38  }
39 
40 
41 
42  // DESTRUCTORS
43 
44 
47  virtual ~MATH_Solver(void) {
48  }
49 
50 public:
51  // copy
55  inline void copy(const MATH_Solver& solver) {
56  mMaxIterationsNumber=solver.getMaximumIterationsNumber();
57  mTolerance=solver.getTolerance();
58  mIterationsNumber=solver.getIterationsNumber();
59  mError=solver.getError();
60  }
61 
62  //SET Methods
63  //==========
64 
68  inline void setMaximumIterationsNumber(const tUInt& nIterations) {
69  mMaxIterationsNumber=nIterations;
70  }
74  inline void setTolerance(const tReal& eps) {
75  mTolerance=eps;
76  }
77  //GET Methods
78  //==========
79 
83  inline const tUInt& getMaximumIterationsNumber() const {
84  return mMaxIterationsNumber;
85  }
89  inline const tReal& getTolerance() const {
90  return mTolerance;
91  }
92 
96  inline const tUInt& getIterationsNumber() const {
97  return mIterationsNumber;
98  }
99 
104  return mIterationsNumber;
105  }
109  inline tReal& getError() {
110  return mError;
111  }
115  inline const tReal& getError() const {
116  return mError;
117  }
118 
119 
120  //SOLVER
121 public:
129  virtual tBoolean solve(const MATH_Matrix& A,MATH_Vector& b,MATH_Vector& x,MATH_Vector& w)=0;
130 
138  if (mW.get()==null) mW=b.NewInstance();
139  return solve(A,b,x,*mW.get());
140  }
141 
142 
143 
144 
145 
146 };
147 #endif
tUInt & getIterationsNumber()
get the iterations number
Definition: MATH_Solver.h:103
const tReal & getTolerance() const
get the tolerance value to detect convergence
Definition: MATH_Solver.h:89
tUInt mIterationsNumber
Definition: MATH_Solver.h:26
const tUInt & getIterationsNumber() const
get the iterations number
Definition: MATH_Solver.h:96
This class describes a general matrix interface used in solver.
Definition: MATH_Matrix.h:20
MATH_Solver(void)
create a solver
Definition: MATH_Solver.h:33
virtual SP::MATH_Vector NewInstance() const =0
return a share pointer to a new instance of this
tReal mTolerance
Definition: MATH_Solver.h:23
virtual ~MATH_Solver(void)
destroy a solver
Definition: MATH_Solver.h:47
void setTolerance(const tReal &eps)
set the tolerance value to detect convergence
Definition: MATH_Solver.h:74
#define tBoolean
Definition: types.h:139
SP_OBJECT(MATH_Solver)
tReal mError
Definition: MATH_Solver.h:24
tBoolean solve(const MATH_Matrix &A, MATH_Vector &b, MATH_Vector &x)
solve
Definition: MATH_Solver.h:137
#define null
Definition: types.h:144
tReal & getError()
get theerror of the solution
Definition: MATH_Solver.h:109
DEFINE_SPTR(MATH_Solver)
void setMaximumIterationsNumber(const tUInt &nIterations)
set the max iteration number
Definition: MATH_Solver.h:68
This class describes a masked vector.
Definition: MATH_Vector.h:16
#define tUInt
Definition: types.h:33
virtual tBoolean solve(const MATH_Matrix &A, MATH_Vector &b, MATH_Vector &x, MATH_Vector &w)=0
solve
This class describes a solver of Ax=b.
Definition: MATH_Solver.h:18
abstract base class for most classes.
Definition: CORE_Object.h:53
tUInt mMaxIterationsNumber
Definition: MATH_Solver.h:25
const tReal & getError() const
get theerror of the solution
Definition: MATH_Solver.h:115
void copy(const MATH_Solver &solver)
copy the attributes of the solver
Definition: MATH_Solver.h:55
SP::MATH_Vector mW
Definition: MATH_Solver.h:28
const tUInt & getMaximumIterationsNumber() const
get the max iteration number
Definition: MATH_Solver.h:83
#define tReal
Definition: types.h:118