gmres.hh

Go to the documentation of this file.
1 
6 #ifndef gmres_hh
7 #define gmres_hh
8 
9 #include <string>
10 
12 #include "basics/typedefs.hh"
13 #include "compositions.hh"
14 
15 namespace concepts {
16 
17  // ***************************************************************** GMRes **
18 
23  template<class F>
24  class GMRes : public VecOperator<F> {
25  public:
34  GMRes(Operator<F>& A, Real maxeps, int maxit = 0, uint rs = 0,
35  uint relres = 0, Operator<F>* W = 0)
36  : VecOperator<F>(A.dimY(), A.dimX()), W_(W), A_(A), maxeps_(maxeps), maxit_(maxit)
37  , eps_(1.0), it_(0), rs_(rs ? rs : maxit), relres_(relres) {}
38  virtual ~GMRes();
39 
43  uint iterations() const { return it_; }
44 
48  Real epsilon() const { return eps_; }
49  protected:
50  virtual std::ostream& info(std::ostream& os) const;
51  private:
52  struct R {
53  R* right;
54  R* left;
56  F sin;
58  F* h;
59 
60  R(uint szh, R* lnk = 0) : right(0), v(0) {
61  if ((left = lnk)) lnk->right = this;
62  h = szh ? new F[szh] : 0;
63  std::memset(h, 0, szh * sizeof(F));
64  }
65  ~R() { delete v; delete[] h;}
66  };
67 
72 
76  uint maxit_;
80  uint it_;
82  uint rs_;
84  uint relres_;
85 
86  virtual void apply_(const Vector<F>& fncY, Vector<F>& fncX)
88  virtual void apply_()
90  };
91 
92 } // namespace concepts
93 
94 #endif // gmres_hh
uint iterations() const
Returns the number of iterations.
Definition: gmres.hh:43
virtual std::ostream & info(std::ostream &os) const
Real maxeps_
Convergence criterion.
Definition: gmres.hh:74
virtual ~GMRes()
Exception indicating that the solver did not converge up to the desired accuracy in the given number ...
GMRes(Operator< F > &A, Real maxeps, int maxit=0, uint rs=0, uint relres=0, Operator< F > *W=0)
Constructor.
Definition: gmres.hh:34
virtual const uint dimX() const
Returns the size of the image space of the operator (number of rows of the corresponding matrix)
Definition: compositions.hh:93
uint rs_
Restart.
Definition: gmres.hh:82
uint relres_
relres = 0: absolute residual, relres = 1: relative residual
Definition: gmres.hh:84
uint it_
Number of iterations.
Definition: gmres.hh:80
Real epsilon() const
Returns the residual.
Definition: gmres.hh:48
R(uint szh, R *lnk=0)
Definition: gmres.hh:60
Abstract class for an operator.
Definition: ARPACK.hh:16
Real eps_
Current residual.
Definition: gmres.hh:78
virtual void apply_(const Vector< F > &fncY, Vector< F > &fncX)
Intrinsic application method, i.e.
Abstract class for an operator acting on vectors only, not arbitrary functions.
virtual void apply_()
Intrinsic application method without argument.
Exception class to express a missing feature.
Definition: exceptions.hh:206
Solves a system of linear equations with general minimal residuals (GMRes).
Definition: gmres.hh:24
uint maxit_
Maximal number of iterations until abortion.
Definition: gmres.hh:76
Operator< F > & A_
Operator which is solved.
Definition: gmres.hh:71
virtual const uint dimY() const
Returns the size of the source space of the operator (number of columns of the corresponding matrix)
Definition: compositions.hh:98
Operator< F > * W_
Optional preconditioner.
Definition: gmres.hh:69
double Real
Type normally used for a floating point number.
Definition: typedefs.hh:36
Vector< F > * v
Definition: gmres.hh:55
Basic namespace for Concepts-2.
Definition: pml_formula.h:16
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich