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 
00036 #include "BelosMultiVecTraits.hpp"
00037 #include "BelosTypes.hpp"
00038 #include "BelosConfigDefs.hpp"
00039 
00051 namespace Belos {
00052 
00053 template <class ScalarType>
00054 class MultiVec {
00055 public:
00057 
00058 
00059   MultiVec() {};
00060   
00062   virtual ~MultiVec () {};
00063   
00065 
00066 
00067   
00073   virtual MultiVec<ScalarType> * Clone ( const int numvecs ) const = 0;
00074   
00081   virtual MultiVec<ScalarType> * CloneCopy () const = 0;
00082   
00090   virtual MultiVec<ScalarType> * CloneCopy ( const std::vector<int>& index ) const = 0;
00091   
00099   virtual MultiVec<ScalarType> * CloneViewNonConst ( const std::vector<int>& index ) = 0;
00100   
00108   virtual const MultiVec<ScalarType> * CloneView ( const std::vector<int>& index ) const = 0;
00110   
00112 
00113 
00114   
00115   virtual int GetVecLength () const = 0;
00116   
00118   
00119   virtual int GetNumberVecs () const = 0;
00120   
00122 
00123 
00124 
00127   virtual void MvTimesMatAddMv ( const ScalarType alpha, const MultiVec<ScalarType>& A, 
00128          const Teuchos::SerialDenseMatrix<int,ScalarType>& B, const ScalarType beta ) = 0;
00129   
00133   virtual void MvAddMv ( const ScalarType alpha, const MultiVec<ScalarType>& A, const ScalarType beta, const MultiVec<ScalarType>& B ) = 0;
00134   
00138   virtual void MvScale ( const ScalarType alpha ) = 0;
00139   
00143   virtual void MvScale ( const std::vector<ScalarType>& alpha ) = 0;
00144   
00149   virtual void MvTransMv ( const ScalarType alpha, const MultiVec<ScalarType>& A, Teuchos::SerialDenseMatrix<int,ScalarType>& B) const = 0;
00150   
00154   virtual void MvDot ( const MultiVec<ScalarType>& A, std::vector<ScalarType>& b ) const = 0;
00155   
00157 
00158 
00159   
00164   virtual void MvNorm ( std::vector<typename Teuchos::ScalarTraits<ScalarType>::magnitudeType>& normvec, NormType type = TwoNorm ) const = 0;
00165   
00167 
00168 
00169 
00174   virtual void SetBlock ( const MultiVec<ScalarType>& A, const std::vector<int>& index ) = 0;
00175   
00179   virtual void MvRandom () = 0;
00180   
00184   virtual void MvInit ( const ScalarType alpha ) = 0;
00185   
00187 
00188 
00189 
00191   virtual void MvPrint ( std::ostream& os ) const = 0;
00193 };
00194 
00195 
00197   //
00198   // Implementation of the Belos::MultiVecTraits for Belos::MultiVec.
00199   //
00201 
00202 
00203   template<class ScalarType>
00204   class MultiVecTraits<ScalarType,MultiVec<ScalarType> >
00205   {
00206   public:
00208     static Teuchos::RCP<MultiVec<ScalarType> > Clone( const MultiVec<ScalarType>& mv, const int numvecs )
00209     { return Teuchos::rcp( const_cast<MultiVec<ScalarType>&>(mv).Clone(numvecs) ); }
00211     static Teuchos::RCP<MultiVec<ScalarType> > CloneCopy( const MultiVec<ScalarType>& mv )
00212     { return Teuchos::rcp( const_cast<MultiVec<ScalarType>&>(mv).CloneCopy() ); }
00214     static Teuchos::RCP<MultiVec<ScalarType> > CloneCopy( const MultiVec<ScalarType>& mv, const std::vector<int>& index )
00215     { return Teuchos::rcp( const_cast<MultiVec<ScalarType>&>(mv).CloneCopy(index) ); }
00217     static Teuchos::RCP<MultiVec<ScalarType> > CloneViewNonConst( MultiVec<ScalarType>& mv, const std::vector<int>& index )
00218     { return Teuchos::rcp( mv.CloneViewNonConst(index) ); }
00220     static Teuchos::RCP<const MultiVec<ScalarType> > CloneView( const MultiVec<ScalarType>& mv, const std::vector<int>& index )
00221     { return Teuchos::rcp( const_cast<MultiVec<ScalarType>&>(mv).CloneView(index) ); }
00223     static int GetVecLength( const MultiVec<ScalarType>& mv )
00224     { return mv.GetVecLength(); }
00226     static int GetNumberVecs( const MultiVec<ScalarType>& mv )
00227     { return mv.GetNumberVecs(); }
00229     static void MvTimesMatAddMv( ScalarType alpha, const MultiVec<ScalarType>& A, 
00230          const Teuchos::SerialDenseMatrix<int,ScalarType>& B, 
00231          ScalarType beta, MultiVec<ScalarType>& mv )
00232     { mv.MvTimesMatAddMv(alpha, A, B, beta); }
00234     static void MvAddMv( ScalarType alpha, const MultiVec<ScalarType>& A, ScalarType beta, const MultiVec<ScalarType>& B, MultiVec<ScalarType>& mv )
00235     { mv.MvAddMv(alpha, A, beta, B); }
00237     static void MvScale ( MultiVec<ScalarType>& mv, const ScalarType alpha )
00238     { mv.MvScale( alpha ); } 
00239 
00240     static void MvScale ( MultiVec<ScalarType>& mv, const std::vector<ScalarType>& alpha )
00241     { mv.MvScale(alpha); }
00243     static void MvTransMv( const ScalarType alpha, const MultiVec<ScalarType>& A, const MultiVec<ScalarType>& mv, Teuchos::SerialDenseMatrix<int,ScalarType>& B )
00244     { mv.MvTransMv(alpha, A, B); }
00246     static void MvDot( const MultiVec<ScalarType>& mv, const MultiVec<ScalarType>& A, std::vector<ScalarType>& b )
00247     { mv.MvDot( A, b ); }
00249     static void MvNorm( const MultiVec<ScalarType>& mv, std::vector<typename Teuchos::ScalarTraits<ScalarType>::magnitudeType>& normvec, NormType type = TwoNorm )
00250     { mv.MvNorm(normvec,type); }
00252     static void SetBlock( const MultiVec<ScalarType>& A, const std::vector<int>& index, MultiVec<ScalarType>& mv )
00253     { mv.SetBlock(A, index); }
00255     static void MvRandom( MultiVec<ScalarType>& mv )
00256     { mv.MvRandom(); }
00258     static void MvInit( MultiVec<ScalarType>& mv, ScalarType alpha = Teuchos::ScalarTraits<ScalarType>::zero() )
00259     { mv.MvInit(alpha); }
00261     static void MvPrint( const MultiVec<ScalarType>& mv, std::ostream& os )
00262     { mv.MvPrint(os); }
00263     
00264   };
00265 
00266 
00267 } // namespace Belos
00268 
00269 #endif
00270 
00271 // end of file BelosMultiVec.hpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Wed Apr 13 10:05:06 2011 for Belos by  doxygen 1.6.3