IterativeSolverT.hh 2.33 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
//=============================================================================
//
//  CLASS IterativeSolverT
//
//=============================================================================

#ifndef COMISO_ITERATIVESOLVERT_HH
#define COMISO_ITERATIVESOLVERT_HH

//== INCLUDES =================================================================

Max Lyon's avatar
Max Lyon committed
12
#include <CoMISo/Utils/gmm.hh>
13
14
15
16
17
18
19
#include <deque>
#include <set>

//== FORWARDDECLARATIONS ======================================================

//== NAMESPACES ===============================================================

20
21
namespace COMISO
{
22
23
24
25
26
27

//== CLASS DEFINITION =========================================================

/** \class IterativeSolverT IterativeSolverT.hh <COMISO/.../IterativeSolverT.hh>

    Brief Description.
28

29
30
31
    A more elaborate description follows.
*/

32
template <class RealT> class IterativeSolverT
33
34
35
{
public:
  typedef RealT Real;
36
37
38
  typedef std::vector<Real> Vector;
  typedef gmm::csc_matrix<Real> Matrix;

39
  // local gauss_seidel
40
41
42
  bool gauss_seidel_local(const Matrix& _A, Vector& _x, const Vector& _rhs,
      const std::vector<unsigned int>& _idxs, const int _max_iter,
      const Real& _tolerance);
43
44

  // local gauss_seidel
45
46
47
  bool gauss_seidel_local2(const Matrix& _A, Vector& _x, const Vector& _rhs,
      const std::vector<unsigned int>& _idxs, const int _max_iter,
      const Real& _tolerance);
48
49

  // conjugate gradient
50
51
52
  bool conjugate_gradient(const Matrix& _A, Vector& _x, const Vector& _rhs,
      int& _max_iter, Real& _tolerance);

53
54
private:
  // compute relative norm
55
  Real vect_norm_rel(const Vector& _v, const Vector& _diag) const;
56
57
58

private:
  // helper for conjugate gradient
59
60
61
62
  Vector p_;
  Vector q_;
  Vector r_;
  Vector d_;
63
64

  //  helper for local gauss seidel
65
  std::vector<unsigned int> i_temp;
66
67
68
69
70
71
72
73
74
75
76
77
78
79
  std::deque<unsigned int> q;
  std::set<int> s;
};

//=============================================================================
} // namespace COMISO
//=============================================================================
#if defined(INCLUDE_TEMPLATES) && !defined(COMISO_ITERATIVESOLVERT_C)
#define COMISO_ITERATIVESOLVERT_TEMPLATES
#include "IterativeSolverT.cc"
#endif
//=============================================================================
#endif // COMISO_ITERATIVESOLVERT_HH defined
//=============================================================================