BelosMultiVec.hpp

Go to the documentation of this file.
00001 // @HEADER
00002 // ***********************************************************************
00003 //
00004 //                 Belos: Block Linear Solvers Package
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 BELOS_MULTI_VEC_HPP
00030 #define BELOS_MULTI_VEC_HPP
00031 
00032 #include "BelosMultiVecTraits.hpp"
00033 #include "BelosTypes.hpp"
00034 #include "BelosConfigDefs.hpp"
00035 
00047 namespace Belos {
00048 
00049 template <class ScalarType>
00050 class MultiVec {
00051 public:
00053 
00054 
00055   MultiVec() {};
00056 
00058   virtual ~MultiVec () {};
00059 
00061 
00062 
00063 
00069   virtual MultiVec<ScalarType> * Clone ( const int numvecs ) const = 0;
00070 
00077   virtual MultiVec<ScalarType> * CloneCopy () const = 0;
00078   
00086   virtual MultiVec<ScalarType> * CloneCopy ( const std::vector<int>& index ) const = 0;
00087   
00095   virtual MultiVec<ScalarType> * CloneView ( const std::vector<int>& index ) = 0;
00097 
00099 
00100 
00101 
00102   virtual int GetVecLength () const = 0;
00103 
00105 
00106   virtual int GetNumberVecs () const = 0;
00107 
00109 
00110 
00111 
00114   virtual void MvTimesMatAddMv ( const ScalarType alpha, const MultiVec<ScalarType>& A, 
00115     const Teuchos::SerialDenseMatrix<int,ScalarType>& B, const ScalarType beta ) = 0;
00116 
00120   virtual void MvAddMv ( const ScalarType alpha, const MultiVec<ScalarType>& A, const ScalarType beta, const MultiVec<ScalarType>& B ) = 0;
00121 
00126   virtual void MvTransMv ( const ScalarType alpha, const MultiVec<ScalarType>& A, Teuchos::SerialDenseMatrix<int,ScalarType>& B) const = 0;
00127 
00131   virtual void MvDot ( const MultiVec<ScalarType>& A, std::vector<ScalarType>* b ) const = 0;
00132 
00134 
00135 
00136 
00141         virtual void MvNorm ( std::vector<typename Teuchos::ScalarTraits<ScalarType>::magnitudeType>* normvec, NormType type = TwoNorm ) const = 0;
00142 
00144 
00145 
00146 
00151   virtual void SetBlock ( const MultiVec<ScalarType>& A, const std::vector<int>& index ) = 0;
00152   
00156   virtual void MvRandom () = 0;
00157 
00161   virtual void MvInit ( const ScalarType alpha ) = 0;
00162 
00164 
00165 
00166 
00168   virtual void MvPrint ( ostream& os ) const = 0;
00170 };
00171 
00172 
00174   //
00175   // Implementation of the Belos::MultiVecTraits for Belos::MultiVec.
00176   //
00178 
00179 
00180   template<class ScalarType>
00181   class MultiVecTraits<ScalarType,MultiVec<ScalarType> >
00182   {
00183   public:
00185     static Teuchos::RefCountPtr<MultiVec<ScalarType> > Clone( const MultiVec<ScalarType>& mv, const int numvecs )
00186     { return Teuchos::rcp( const_cast<MultiVec<ScalarType>&>(mv).Clone(numvecs) ); }
00188     static Teuchos::RefCountPtr<MultiVec<ScalarType> > CloneCopy( const MultiVec<ScalarType>& mv )
00189     { return Teuchos::rcp( const_cast<MultiVec<ScalarType>&>(mv).CloneCopy() ); }
00191     static Teuchos::RefCountPtr<MultiVec<ScalarType> > CloneCopy( const MultiVec<ScalarType>& mv, const std::vector<int>& index )
00192     { return Teuchos::rcp( const_cast<MultiVec<ScalarType>&>(mv).CloneCopy(index) ); }
00194     static Teuchos::RefCountPtr<MultiVec<ScalarType> > CloneView( MultiVec<ScalarType>& mv, const std::vector<int>& index )
00195     { return Teuchos::rcp( mv.CloneView(index) ); }
00197     static Teuchos::RefCountPtr<const MultiVec<ScalarType> > CloneView( const MultiVec<ScalarType>& mv, const std::vector<int>& index )
00198     { return Teuchos::rcp( const_cast<MultiVec<ScalarType>&>(mv).CloneView(index) ); }
00200     static int GetVecLength( const MultiVec<ScalarType>& mv )
00201     { return mv.GetVecLength(); }
00203     static int GetNumberVecs( const MultiVec<ScalarType>& mv )
00204     { return mv.GetNumberVecs(); }
00206     static void MvTimesMatAddMv( ScalarType alpha, const MultiVec<ScalarType>& A, 
00207          const Teuchos::SerialDenseMatrix<int,ScalarType>& B, 
00208          ScalarType beta, MultiVec<ScalarType>& mv )
00209     { mv.MvTimesMatAddMv(alpha, A, B, beta); }
00211     static void MvAddMv( ScalarType alpha, const MultiVec<ScalarType>& A, ScalarType beta, const MultiVec<ScalarType>& B, MultiVec<ScalarType>& mv )
00212     { mv.MvAddMv(alpha, A, beta, B); }
00214     static void MvTransMv( ScalarType alpha, const MultiVec<ScalarType>& A, const MultiVec<ScalarType>& mv, Teuchos::SerialDenseMatrix<int,ScalarType>& B )
00215     { mv.MvTransMv(alpha, A, B); }
00217     static void MvDot( const MultiVec<ScalarType>& mv, const MultiVec<ScalarType>& A, std::vector<ScalarType>* b )
00218     { mv.MvDot( A, b ); }
00220     static void MvNorm( const MultiVec<ScalarType>& mv, std::vector<typename Teuchos::ScalarTraits<ScalarType>::magnitudeType>* normvec, NormType type = TwoNorm )
00221     { mv.MvNorm(normvec,type); }
00223     static void SetBlock( const MultiVec<ScalarType>& A, const std::vector<int>& index, MultiVec<ScalarType>& mv )
00224     { mv.SetBlock(A, index); }
00226     static void MvRandom( MultiVec<ScalarType>& mv )
00227     { mv.MvRandom(); }
00229     static void MvInit( MultiVec<ScalarType>& mv, ScalarType alpha = Teuchos::ScalarTraits<ScalarType>::zero() )
00230     { mv.MvInit(alpha); }
00232     static void MvPrint( const MultiVec<ScalarType>& mv, ostream& os )
00233     { mv.MvPrint(os); }
00234     
00235   };
00236 
00237 
00238 } // namespace Belos
00239 
00240 #endif
00241 
00242 // end of file BelosMultiVec.hpp

Generated on Thu Sep 18 12:30:12 2008 for Belos by doxygen 1.3.9.1