00001 /* @HEADER@ */ 00002 // 00003 /* @HEADER@ */ 00004 00005 #ifndef PLAYA_PRECONDITIONER_HPP 00006 #define PLAYA_PRECONDITIONER_HPP 00007 00008 #include "PlayaDefs.hpp" 00009 #include "PlayaHandle.hpp" 00010 #include "PlayaPreconditionerBase.hpp" 00011 00012 namespace Playa 00013 { 00014 /** 00015 * \brief Preconditioner stores left and/or right operators for 00016 * use in preconditioning. 00017 */ 00018 template <class Scalar> 00019 class Preconditioner : public Playa::Handle<PreconditionerBase<Scalar> > 00020 { 00021 public: 00022 /* Boilerplate ctors */ 00023 HANDLE_CTORS(Preconditioner, PreconditionerBase<Scalar>); 00024 00025 /** Change the value of a double parameter */ 00026 void changeParameter(const std::string& name, const double& value); 00027 00028 /** Change the value of an integer parameter */ 00029 void changeParameter(const std::string& name, int value); 00030 00031 00032 00033 /** Left preconditioner */ 00034 LinearOperator<Scalar> left() const ; 00035 00036 /** Right preconditioner */ 00037 LinearOperator<Scalar> right() const ; 00038 00039 /** return true if this preconditioner has both left and 00040 * right components. */ 00041 bool isTwoSided() const {return hasLeft() && hasRight();} 00042 00043 /** return true if this preconditioner has a nontrivial left component */ 00044 bool hasLeft() const ; 00045 00046 /** return true if this preconditioner has 00047 * a nontrivial right component */ 00048 bool hasRight() const ; 00049 00050 /** return true if this preconditioner has neither left nor 00051 * right operators defined */ 00052 bool isIdentity() const {return !hasLeft() && !hasRight();} 00053 }; 00054 00055 00056 00057 template <class Scalar> inline 00058 LinearOperator<Scalar> Preconditioner<Scalar>::left() const 00059 { 00060 TEUCHOS_TEST_FOR_EXCEPTION(this->ptr().get()==0, std::runtime_error, 00061 "null pointer in Preconditioner<Scalar>::left()"); 00062 return this->ptr()->left(); 00063 } 00064 00065 template <class Scalar> inline 00066 LinearOperator<Scalar> Preconditioner<Scalar>::right() const 00067 { 00068 TEUCHOS_TEST_FOR_EXCEPTION(this->ptr().get()==0, std::runtime_error, 00069 "null pointer in Preconditioner<Scalar>::right()"); 00070 return this->ptr()->right(); 00071 } 00072 00073 template <class Scalar> inline 00074 bool Preconditioner<Scalar>::hasLeft() const 00075 { 00076 return (this->ptr().get()!=0 && this->ptr()->hasLeft()); 00077 } 00078 00079 template <class Scalar> inline 00080 bool Preconditioner<Scalar>::hasRight() const 00081 { 00082 return (this->ptr().get()!=0 && this->ptr()->hasRight()); 00083 } 00084 00085 00086 } 00087 00088 #endif