cgFabric.hh

Go to the documentation of this file.
1 
6 #ifndef CGfabric_hh
7 #define CGfabric_hh
8 
9 #if __GNUC__ == 2
10 # include <float.h>
11 # define EPS DBL_EPSILON
12 #else
13 # include <limits>
14 # define EPS std::numeric_limits<double>::epsilon()
15 #endif
16 #include "cg.hh"
17 #include "solverFabric.hh"
18 
19 namespace concepts {
20 
21  // ************************************************************** CGFabric **
22 
26  template<typename F>
27  class CGFabric : public SolverFabric<F> {
28  public:
36  CGFabric(Real maxeps = EPS, int maxit = 0, bool relres = false,
37  bool throwing = true)
38  : maxeps_(maxeps), maxit_(maxit), relres_(relres), throwing_(throwing) {}
39  virtual Operator<F>* operator()(Operator<F>& matrix) {
40  return new CG<F>(matrix, maxeps_, maxit_, relres_, throwing_);
41  }
42  Operator<F>* operator()() { return NULL; }
43  protected:
44  virtual std::ostream& info(std::ostream& os) const {
45  return os << concepts::typeOf(*this)<<"(maxeps = " << maxeps_ << ", maxit = "
46  << maxit_ << ", relres = " << relres_ << ')';
47  }
48  private:
52  int maxit_;
54  bool relres_;
58  bool throwing_;
59  };
60 
61 } // concepts
62 
63 #endif // CGfabric_hh
Solves a symmetric system of linear equations with conjugate gradients (CG).
Definition: cg.hh:39
int maxit_
Convergence criteria for the solver.
Definition: cgFabric.hh:52
CGFabric(Real maxeps=EPS, int maxit=0, bool relres=false, bool throwing=true)
Constructor.
Definition: cgFabric.hh:36
Operator< F > * operator()()
Creates a linear solver from matrix.
Definition: cgFabric.hh:42
bool relres_
Convergence criteria for the solver.
Definition: cgFabric.hh:54
Real maxeps_
Convergence criteria for the solver.
Definition: cgFabric.hh:50
Abstract fabric class for linear solvers.
Definition: jdbsym.hh:16
virtual Operator< F > * operator()(Operator< F > &matrix)
Definition: cgFabric.hh:39
Abstract class for an operator.
Definition: ARPACK.hh:16
Fabric class for conjugate gradients: CG.
Definition: cgFabric.hh:27
bool throwing_
false: best solution is given, when non converging true: exception is thrown, when non converging
Definition: cgFabric.hh:58
virtual std::ostream & info(std::ostream &os) const
Definition: cgFabric.hh:44
std::string typeOf(const T &t)
Return the typeid name of a class object.
Definition: output.hh:43
#define EPS
Definition: cgFabric.hh:14
double Real
Type normally used for a floating point number.
Definition: typedefs.hh:36
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