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> * CloneView ( const std::vector<int>& index ) = 0;
00101   
00103 
00104 
00105   
00106   virtual int GetVecLength () const = 0;
00107   
00109   
00110   virtual int GetNumberVecs () const = 0;
00111   
00113 
00114 
00115 
00118   virtual void MvTimesMatAddMv ( const ScalarType alpha, const MultiVec<ScalarType>& A, 
00119          const Teuchos::SerialDenseMatrix<int,ScalarType>& B, const ScalarType beta ) = 0;
00120   
00124   virtual void MvAddMv ( const ScalarType alpha, const MultiVec<ScalarType>& A, const ScalarType beta, const MultiVec<ScalarType>& B ) = 0;
00125   
00129   virtual void MvScale ( const ScalarType alpha ) = 0;
00130   
00134   virtual void MvScale ( const std::vector<ScalarType>& alpha ) = 0;
00135   
00140   virtual void MvTransMv ( const ScalarType alpha, const MultiVec<ScalarType>& A, Teuchos::SerialDenseMatrix<int,ScalarType>& B) const = 0;
00141   
00145   virtual void MvDot ( const MultiVec<ScalarType>& A, std::vector<ScalarType>& b ) const = 0;
00146   
00148 
00149 
00150   
00155   virtual void MvNorm ( std::vector<typename Teuchos::ScalarTraits<ScalarType>::magnitudeType>& normvec, NormType type = TwoNorm ) const = 0;
00156   
00158 
00159 
00160 
00165   virtual void SetBlock ( const MultiVec<ScalarType>& A, const std::vector<int>& index ) = 0;
00166   
00170   virtual void MvRandom () = 0;
00171   
00175   virtual void MvInit ( const ScalarType alpha ) = 0;
00176   
00178 
00179 
00180 
00182   virtual void MvPrint ( std::ostream& os ) const = 0;
00184 };
00185 
00186 
00188   //
00189   // Implementation of the Belos::MultiVecTraits for Belos::MultiVec.
00190   //
00192 
00193 
00194   template<class ScalarType>
00195   class MultiVecTraits<ScalarType,MultiVec<ScalarType> >
00196   {
00197   public:
00199     static Teuchos::RCP<MultiVec<ScalarType> > Clone( const MultiVec<ScalarType>& mv, const int numvecs )
00200     { return Teuchos::rcp( const_cast<MultiVec<ScalarType>&>(mv).Clone(numvecs) ); }
00202     static Teuchos::RCP<MultiVec<ScalarType> > CloneCopy( const MultiVec<ScalarType>& mv )
00203     { return Teuchos::rcp( const_cast<MultiVec<ScalarType>&>(mv).CloneCopy() ); }
00205     static Teuchos::RCP<MultiVec<ScalarType> > CloneCopy( const MultiVec<ScalarType>& mv, const std::vector<int>& index )
00206     { return Teuchos::rcp( const_cast<MultiVec<ScalarType>&>(mv).CloneCopy(index) ); }
00208     static Teuchos::RCP<MultiVec<ScalarType> > CloneView( MultiVec<ScalarType>& mv, const std::vector<int>& index )
00209     { return Teuchos::rcp( mv.CloneView(index) ); }
00211     static Teuchos::RCP<const MultiVec<ScalarType> > CloneView( const MultiVec<ScalarType>& mv, const std::vector<int>& index )
00212     { return Teuchos::rcp( const_cast<MultiVec<ScalarType>&>(mv).CloneView(index) ); }
00214     static int GetVecLength( const MultiVec<ScalarType>& mv )
00215     { return mv.GetVecLength(); }
00217     static int GetNumberVecs( const MultiVec<ScalarType>& mv )
00218     { return mv.GetNumberVecs(); }
00220     static void MvTimesMatAddMv( ScalarType alpha, const MultiVec<ScalarType>& A, 
00221          const Teuchos::SerialDenseMatrix<int,ScalarType>& B, 
00222          ScalarType beta, MultiVec<ScalarType>& mv )
00223     { mv.MvTimesMatAddMv(alpha, A, B, beta); }
00225     static void MvAddMv( ScalarType alpha, const MultiVec<ScalarType>& A, ScalarType beta, const MultiVec<ScalarType>& B, MultiVec<ScalarType>& mv )
00226     { mv.MvAddMv(alpha, A, beta, B); }
00228     static void MvScale ( MultiVec<ScalarType>& mv, const ScalarType alpha )
00229     { mv.MvScale( alpha ); } 
00230 
00231     static void MvScale ( MultiVec<ScalarType>& mv, const std::vector<ScalarType>& alpha )
00232     { mv.MvScale(alpha); }
00234     static void MvTransMv( const ScalarType alpha, const MultiVec<ScalarType>& A, const MultiVec<ScalarType>& mv, Teuchos::SerialDenseMatrix<int,ScalarType>& B )
00235     { mv.MvTransMv(alpha, A, B); }
00237     static void MvDot( const MultiVec<ScalarType>& mv, const MultiVec<ScalarType>& A, std::vector<ScalarType>& b )
00238     { mv.MvDot( A, b ); }
00240     static void MvNorm( const MultiVec<ScalarType>& mv, std::vector<typename Teuchos::ScalarTraits<ScalarType>::magnitudeType>& normvec, NormType type = TwoNorm )
00241     { mv.MvNorm(normvec,type); }
00243     static void SetBlock( const MultiVec<ScalarType>& A, const std::vector<int>& index, MultiVec<ScalarType>& mv )
00244     { mv.SetBlock(A, index); }
00246     static void MvRandom( MultiVec<ScalarType>& mv )
00247     { mv.MvRandom(); }
00249     static void MvInit( MultiVec<ScalarType>& mv, ScalarType alpha = Teuchos::ScalarTraits<ScalarType>::zero() )
00250     { mv.MvInit(alpha); }
00252     static void MvPrint( const MultiVec<ScalarType>& mv, std::ostream& os )
00253     { mv.MvPrint(os); }
00254     
00255   };
00256 
00257 
00258 } // namespace Belos
00259 
00260 #endif
00261 
00262 // end of file BelosMultiVec.hpp

Generated on Tue Jul 13 09:27:02 2010 for Belos by  doxygen 1.4.7