TSFLinearOperatorDecl.hpp
Go to the documentation of this file.
00001 /* @HEADER@ */
00002 /* ***********************************************************************
00003 // 
00004 //           TSFExtended: Trilinos Solver Framework Extended
00005 //                 Copyright (2004) Sandia Corporation
00006 // 
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 // 
00010 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //  
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //  
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00025 // 
00026 // **********************************************************************/
00027  /* @HEADER@ */
00028 
00029 #ifndef TSFLINEAROPERATORDECL_HPP
00030 #define TSFLINEAROPERATORDECL_HPP
00031 
00032 #include "SundanceDefs.hpp"
00033 #include "SundanceHandle.hpp"
00034 #include "SundanceHandleable.hpp"
00035 #include "Thyra_LinearOpBase.hpp"
00036 #include "TSFLoadableMatrix.hpp"
00037 #include "Teuchos_TimeMonitor.hpp"
00038 #include "TSFRowAccessibleOp.hpp"
00039 
00040 
00041 namespace TSFExtended
00042 {
00043 using Thyra::Index;
00044 using namespace Teuchos;
00045 using namespace Thyra;
00046 using namespace Sundance;
00047 
00048 template <class Scalar>  class LinearSolver;
00049 template <class Scalar>  class VectorSpace;
00050 template <class Scalar>  class Vector;
00051 template <class Scalar>  class VectorType;
00052 
00053 /** 
00054  * User-level linear operator class
00055  */
00056 template <class Scalar>
00057 class LinearOperator : public Sundance::Handle<LinearOpBase<Scalar> >
00058 {
00059 public:
00060   /** \name Constructors, Destructors, and Assignment Operators */
00061   //@{
00062   /** Empty constructor*/
00063   LinearOperator();
00064 
00065   /** Constructor with smart pointer */
00066   LinearOperator(const RCP<LinearOpBase<Scalar> >& smartPtr);
00067   //@}
00068 
00069   /** Return the domain */
00070   const VectorSpace<Scalar> domain() const ;
00071 
00072   /** Return the range */
00073   const VectorSpace<Scalar> range() const ;
00074 
00075 
00076   /** 
00077    * Compute
00078    * \code
00079    * out = beta*out + alpha*op*in;
00080    * \endcode
00081    **/
00082   void apply(const Vector<Scalar>& in,
00083     Vector<Scalar>& out,
00084     const Scalar& alpha = 1.0,
00085     const Scalar& beta = 0.0) const ;
00086 
00087   /**  
00088    * Compute
00089    * \code
00090    * out = beta*out + alpha*op^T*in;
00091    * \endcode
00092    **/
00093   void applyTranspose(const Vector<Scalar>& in,
00094     Vector<Scalar>& out,
00095     const Scalar& alpha = 1.0,
00096     const Scalar& beta = 0.0) const ;
00097 
00098 
00099   //       /** For the moment this does nothing*/
00100   LinearOperator<Scalar> form() const {return *this;}
00101       
00102       
00103   /** Get a stopwatch for timing vector operations */
00104   RCP<Time>& opTimer();
00105 
00106   /**
00107    * Return a TransposeOperator.
00108    */
00109   LinearOperator<Scalar> transpose() const ; 
00110 
00111 
00112   /** Return a Loadable Matrix  */
00113   RCP<LoadableMatrix<Scalar> > matrix();
00114 
00115   /** Get a row of the underlying matrix */     
00116   void getRow(const int& row, 
00117     Teuchos::Array<int>& indices, 
00118     Teuchos::Array<Scalar>& values) const ;
00119     
00120 
00121   /** \name  Block operations  */
00122   //@{
00123       
00124   /** return number of block rows */
00125   int numBlockRows() const ;
00126       
00127 
00128   /** return number of block cols */
00129   int numBlockCols() const ;
00130       
00131 
00132   /** get the (i,j)-th block */
00133   LinearOperator<Scalar> getBlock(const int &i, const int &j) const ;
00134 
00135 
00136   /** get a writeable copy of the (i,j)-th block */
00137   LinearOperator<Scalar> getNonconstBlock(const int &i, const int &j) ;
00138 
00139   /** set the (i,j)-th block 
00140    *  If the domain and/or the range are not set, then we
00141    *  are building the operator
00142    */
00143   void setBlock(int i, int j, 
00144     const LinearOperator<Scalar>& sub);
00145 
00146   /** Finalize block assembly */
00147   void endBlockFill();
00148 
00149   //@}
00150 
00151       
00152 
00153 private:
00154   int verb_;
00155 };
00156 
00157 }
00158 
00159 
00160 #endif

Site Contact