Home | Doxygen Documentation | Tutorials | Developer Tools (restricted)

operator/bicgstab.hh
Go to the documentation of this file.
00001 /* Iterative linear solver: BICGSTAB
00002  */
00003 
00004 #ifndef bicgstab_hh
00005 #define bicgstab_hh
00006 
00007 #include <string>
00008 #include "basics/typedefs.hh"
00009 #include "toolbox/sequence.hh"
00010 #include "compositions.hh"
00011 
00012 namespace concepts {
00013 
00014   // ******************************************************************* CG **
00015 
00031   template<class F, class G = F>
00032   class BiCGStab : public VecOperator<F> {
00033   public:
00042     BiCGStab(Operator<F>& A, Real maxeps, int maxit = 0,
00043              uint relres = false, bool throwing = true)
00044       : VecOperator<F>(A.dimY(), A.dimX()), W_(0), A_(A), M_(0)
00045       , maxeps_(maxeps), maxit_(maxit), eps_(1.0), it_(0)
00046       , relres_(relres), throwing_(throwing), stag_(false) {}
00047 
00059     BiCGStab(Operator<F>& A, Operator<G>& Minv, Real maxeps, int maxit = 0,
00060              bool relres = 0, bool throwing = true, Operator<G>* M = 0)
00061       : VecOperator<F>(A.dimY(), A.dimX()), W_(&Minv), A_(A), M_(M)
00062       , maxeps_(maxeps), maxit_(maxit), eps_(1.0), it_(0)
00063       , relres_(relres), throwing_(throwing), stag_(false) {}
00064 
00065 //     virtual void operator()(const Function<F,G>& fncY, Function<F,G>& fncX);
00066 //     void operator()(const Vector<F,G>& fncY, Vector<F,G>& fncX);
00067 
00071     uint iterations() const { return it_; }
00072 
00076     Real epsilon() const { return eps_; }
00078     bool stagnated() const { return stag_; }
00079   protected:
00080     std::ostream& info(std::ostream& os) const;
00081   private:
00083     Operator<G>*  W_;
00085     Operator<F>&  A_;
00087     Operator<G>*  M_;
00088 
00090     Real maxeps_;
00092     uint maxit_;
00094     Real eps_;
00096     concepts::Sequence<Real> epsVec_;
00098     uint it_;
00100     bool relres_;
00104     bool throwing_;
00106     bool stag_;
00107 
00108     virtual void apply_(const Vector<F>& fncY, Vector<F>& fncX);
00109 
00113     template<class I>
00114     bool scalarTooSmall_(I& scalar, const std::string name, const uint& it,
00115                          const Real& eps, const Real& maxeps) const;
00119     bool converged_(const Vector<F>& fncY, Vector<F>& fncX,
00120                     const Vector<F>& x, const uint& it, Real& eps,
00121                     const Real& maxeps, const Real& l2Y);
00122     bool stagnated_(const Vector<F>& x, const Vector<F>& s_p,
00123                     F& alpha_omega);
00124   };
00125 
00126 } // namespace concepts
00127 
00128 #endif // bicgstab_hh

Home | Doxygen Documentation | Tutorials | Developer Tools (restricted)