00001 /* @HEADER@ */ 00002 // 00003 /* @HEADER@ */ 00004 00005 #ifndef PLAYA_LINEAROPERATORDECL_HPP 00006 #define PLAYA_LINEAROPERATORDECL_HPP 00007 00008 #include "PlayaDefs.hpp" 00009 #include "PlayaHandle.hpp" 00010 #include "PlayaHandleable.hpp" 00011 #include "PlayaLinearOperatorBaseDecl.hpp" 00012 #include "PlayaLoadableMatrix.hpp" 00013 #include "Teuchos_TimeMonitor.hpp" 00014 #include "PlayaRowAccessibleOp.hpp" 00015 00016 00017 namespace Playa 00018 { 00019 using namespace Teuchos; 00020 00021 00022 template <class Scalar> class LinearSolver; 00023 template <class Scalar> class VectorSpace; 00024 template <class Scalar> class Vector; 00025 template <class Scalar> class VectorType; 00026 00027 /** 00028 * User-level linear operator class 00029 */ 00030 template <class Scalar> 00031 class LinearOperator : public Playa::Handle<LinearOperatorBase<Scalar> > 00032 { 00033 public: 00034 /** \name Constructors, Destructors, and Assignment Operators */ 00035 //@{ 00036 /** Empty constructor*/ 00037 LinearOperator(); 00038 00039 /** Constructor with smart pointer */ 00040 LinearOperator(const RCP<LinearOperatorBase<Scalar> >& smartPtr); 00041 //@} 00042 00043 /** Return the domain */ 00044 const VectorSpace<Scalar> domain() const ; 00045 00046 /** Return the range */ 00047 const VectorSpace<Scalar> range() const ; 00048 00049 00050 /** 00051 * Compute 00052 * \code 00053 * out = beta*out + alpha*op*in; 00054 * \endcode 00055 **/ 00056 void apply(const Vector<Scalar>& in, 00057 Vector<Scalar>& out) const ; 00058 00059 /** 00060 * Compute 00061 * \code 00062 * out = beta*out + alpha*op^T*in; 00063 * \endcode 00064 **/ 00065 void applyTranspose(const Vector<Scalar>& in, 00066 Vector<Scalar>& out) const ; 00067 00068 00069 // /** For the moment this does nothing*/ 00070 LinearOperator<Scalar> form() const {return *this;} 00071 00072 00073 /** Get a stopwatch for timing vector operations */ 00074 RCP<Time>& opTimer(); 00075 00076 /** 00077 * Return a TransposeOperator. 00078 */ 00079 LinearOperator<Scalar> transpose() const ; 00080 00081 00082 /** Return a Loadable Matrix */ 00083 RCP<LoadableMatrix<Scalar> > matrix(); 00084 00085 /** Get a row of the underlying matrix */ 00086 void getRow(const int& row, 00087 Teuchos::Array<int>& indices, 00088 Teuchos::Array<Scalar>& values) const ; 00089 00090 00091 /** \name Block operations */ 00092 //@{ 00093 00094 /** return number of block rows */ 00095 int numBlockRows() const ; 00096 00097 00098 /** return number of block cols */ 00099 int numBlockCols() const ; 00100 00101 00102 /** get the (i,j)-th block */ 00103 LinearOperator<Scalar> getBlock(const int &i, const int &j) const ; 00104 00105 00106 /** get a writeable copy of the (i,j)-th block */ 00107 LinearOperator<Scalar> getNonconstBlock(const int &i, const int &j) ; 00108 00109 /** set the (i,j)-th block 00110 * If the domain and/or the range are not set, then we 00111 * are building the operator 00112 */ 00113 void setBlock(int i, int j, 00114 const LinearOperator<Scalar>& sub); 00115 00116 /** Finalize block assembly */ 00117 void endBlockFill(); 00118 00119 //@} 00120 00121 00122 00123 private: 00124 00125 }; 00126 00127 } 00128 00129 00130 #endif