00001
00002
00003
00004 #ifndef _STAT_ITERATIVELINEARSOLVER_H
00005 #define _STAT_ITERATIVELINEARSOLVER_H
00006
00007 #include <cstddef>
00008
00009 namespace std
00010 {
00011 template<class T> class valarray;
00012 }
00013
00014 namespace osl
00015 {
00016 namespace stat
00017 {
00018 class Preconditioner;
00019 class MatrixMultiplier;
00020
00024 class IterativeLinearSolver
00025 {
00026 public:
00027 typedef std::valarray<double> valarray_t;
00028 private:
00029 const MatrixMultiplier *m_A;
00030 const Preconditioner *m_M;
00031 size_t m_dim;
00032 size_t m_max_iteration;
00033 double m_tolerance;
00034 public:
00035
00036 IterativeLinearSolver(const MatrixMultiplier& A, const Preconditioner *M,
00037 size_t max_iteration=0,
00038 double tolerance=0.001);
00039 ~IterativeLinearSolver();
00040
00045 int solve_by_CG(const valarray_t& b, valarray_t& x,
00046 int *iterated=0, double *tol_achieved=0, bool verbose=true);
00047 int solve_by_BiCGSTAB(const valarray_t& b, valarray_t& x,
00048 int *iterated=0, double *tol_achieved=0, bool verbose=true);
00049
00050 };
00051
00052 }
00053 }
00054
00055 #endif
00056
00057
00058
00059
00060