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

operator/gmres.hh
Go to the documentation of this file.
00001 /* Iterative linear solver: GMRes
00002  */
00003 
00004 #ifndef gmres_hh
00005 #define gmres_hh
00006 
00007 #include <string>
00008 
00009 #include "basics/noConvException.hh"
00010 #include "basics/typedefs.hh"
00011 #include "compositions.hh"
00012 
00013 namespace concepts {
00014 
00015   // ***************************************************************** GMRes **
00016 
00021   template<class F>
00022   class GMRes : public VecOperator<F> {
00023   public:
00032     GMRes(Operator<F>& A, Real maxeps, int maxit = 0, uint rs = 0,
00033           uint relres = 0, Operator<F>* W = 0)
00034       : VecOperator<F>(A.dimY(), A.dimX()), W_(W), A_(A), maxeps_(maxeps), maxit_(maxit)
00035       , eps_(1.0), it_(0), rs_(rs ? rs : maxit), relres_(relres) {}
00036     virtual ~GMRes();
00037 
00041     uint iterations() const { return it_; }
00042 
00046     Real epsilon() const { return eps_; }
00047   protected:
00048     virtual std::ostream& info(std::ostream& os) const;
00049   private:
00050     struct R {
00051       R* right;
00052       R* left;
00053       Vector<F>* v;
00054       F sin;
00055       Real cos;
00056       F* h;
00057 
00058       R(uint szh, R* lnk = 0) : right(0), v(0) {
00059         if ((left = lnk)) lnk->right = this;
00060         h = szh ? new F[szh] : 0;
00061         std::memset(h, 0, szh * sizeof(F));
00062       }
00063       ~R() { delete v;  delete[] h;}
00064     };
00065 
00067     Operator<F>*  W_;
00069     Operator<F>&  A_;
00070 
00072     Real maxeps_;
00074     uint maxit_;
00076     Real eps_;
00078     uint it_;
00080     uint rs_;
00082     uint relres_;
00083 
00084     virtual void apply_(const Vector<F>& fncY, Vector<F>& fncX)
00085       throw(NoConvergence, MissingFeature);
00086   };
00087 
00088 } // namespace concepts
00089 
00090 #endif // gmres_hh

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