Go to the documentation of this file.00001
00002
00003
00004 #ifndef cg_hh
00005 #define cg_hh
00006
00007 #include <string>
00008
00009 #include "basics/typedefs.hh"
00010 #include "compositions.hh"
00011
00012 namespace concepts {
00013
00014
00015
00031 template<class F>
00032 class CG : public VecOperator<F> {
00033 public:
00042 CG(Operator<F>& A, Real maxeps, int maxit = 0, uint relres = false,
00043 bool throwing = true)
00044 : VecOperator<F>(A.dimY(), A.dimX()), W_(0), A_(A)
00045 , maxeps_(maxeps*maxeps), maxit_(maxit), eps_(1.0), it_(0)
00046 , relres_(relres), throwing_(throwing) {}
00047
00058 CG(Operator<F>& A, Operator<F>& Minv, Real maxeps, int maxit = 0,
00059 bool relres = 0, bool throwing = true)
00060 : VecOperator<F>(A.dimY(), A.dimX()), W_(&Minv), A_(A)
00061 , maxeps_(maxeps*maxeps), maxit_(maxit), eps_(1.0), it_(0)
00062 , relres_(relres), throwing_(throwing) {}
00063
00067 uint iterations() const { return it_; }
00068
00072 Real epsilon() const { return eps_; }
00073 protected:
00074 std::ostream& info(std::ostream& os) const;
00075 private:
00077 Operator<F>* W_;
00079 Operator<F>& A_;
00080
00082 Real maxeps_;
00084 uint maxit_;
00086 Real eps_;
00088 uint it_;
00090 bool relres_;
00094 bool throwing_;
00095
00096 virtual void apply_(const Vector<F>& fncY, Vector<F>& fncX);
00097 };
00098
00099 }
00100
00101 #endif // cg_hh