Belos Version of the Day
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 the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00008 // the U.S. Government retains certain rights in this software.
00009 //
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Michael A. Heroux (maherou@sandia.gov)
00038 //
00039 // ************************************************************************
00040 //@HEADER
00041 
00042 #ifndef BELOS_MULTI_VEC_HPP
00043 #define BELOS_MULTI_VEC_HPP
00044 
00049 #include "BelosMultiVecTraits.hpp"
00050 #include "BelosTypes.hpp"
00051 #include "BelosConfigDefs.hpp"
00052 
00064 namespace Belos {
00065 
00066 template <class ScalarType>
00067 class MultiVec {
00068 public:
00070 
00071 
00072   MultiVec() {};
00073   
00075   virtual ~MultiVec () {};
00076   
00078 
00079 
00080   
00086   virtual MultiVec<ScalarType> * Clone ( const int numvecs ) const = 0;
00087   
00094   virtual MultiVec<ScalarType> * CloneCopy () const = 0;
00095   
00103   virtual MultiVec<ScalarType> * CloneCopy ( const std::vector<int>& index ) const = 0;
00104   
00112   virtual MultiVec<ScalarType> * CloneViewNonConst ( const std::vector<int>& index ) = 0;
00113   
00121   virtual const MultiVec<ScalarType> * CloneView ( const std::vector<int>& index ) const = 0;
00123   
00125 
00126 
00127   
00128   virtual int GetVecLength () const = 0;
00129   
00131   
00132   virtual int GetNumberVecs () const = 0;
00133   
00135 
00136 
00137 
00140   virtual void MvTimesMatAddMv ( const ScalarType alpha, const MultiVec<ScalarType>& A, 
00141          const Teuchos::SerialDenseMatrix<int,ScalarType>& B, const ScalarType beta ) = 0;
00142   
00146   virtual void MvAddMv ( const ScalarType alpha, const MultiVec<ScalarType>& A, const ScalarType beta, const MultiVec<ScalarType>& B ) = 0;
00147   
00151   virtual void MvScale ( const ScalarType alpha ) = 0;
00152   
00156   virtual void MvScale ( const std::vector<ScalarType>& alpha ) = 0;
00157   
00162   virtual void MvTransMv ( const ScalarType alpha, const MultiVec<ScalarType>& A, Teuchos::SerialDenseMatrix<int,ScalarType>& B) const = 0;
00163   
00167   virtual void MvDot ( const MultiVec<ScalarType>& A, std::vector<ScalarType>& b ) const = 0;
00168   
00170 
00171 
00172   
00177   virtual void MvNorm ( std::vector<typename Teuchos::ScalarTraits<ScalarType>::magnitudeType>& normvec, NormType type = TwoNorm ) const = 0;
00178   
00180 
00181 
00182 
00187   virtual void SetBlock ( const MultiVec<ScalarType>& A, const std::vector<int>& index ) = 0;
00188   
00192   virtual void MvRandom () = 0;
00193   
00197   virtual void MvInit ( const ScalarType alpha ) = 0;
00198   
00200 
00201 
00202 
00204   virtual void MvPrint ( std::ostream& os ) const = 0;
00206 };
00207 
00208 
00210   //
00211   // Implementation of the Belos::MultiVecTraits for Belos::MultiVec.
00212   //
00214 
00215 
00222   template<class ScalarType>
00223   class MultiVecTraits<ScalarType,MultiVec<ScalarType> >
00224   {
00225   public:
00226 
00228     static Teuchos::RCP<MultiVec<ScalarType> > Clone( const MultiVec<ScalarType>& mv, const int numvecs )
00229     { return Teuchos::rcp( const_cast<MultiVec<ScalarType>&>(mv).Clone(numvecs) ); }
00231     static Teuchos::RCP<MultiVec<ScalarType> > CloneCopy( const MultiVec<ScalarType>& mv )
00232     { return Teuchos::rcp( const_cast<MultiVec<ScalarType>&>(mv).CloneCopy() ); }
00234     static Teuchos::RCP<MultiVec<ScalarType> > CloneCopy( const MultiVec<ScalarType>& mv, const std::vector<int>& index )
00235     { return Teuchos::rcp( const_cast<MultiVec<ScalarType>&>(mv).CloneCopy(index) ); }
00237     static Teuchos::RCP<MultiVec<ScalarType> > CloneViewNonConst( MultiVec<ScalarType>& mv, const std::vector<int>& index )
00238     { return Teuchos::rcp( mv.CloneViewNonConst(index) ); }
00240     static Teuchos::RCP<const MultiVec<ScalarType> > CloneView( const MultiVec<ScalarType>& mv, const std::vector<int>& index )
00241     { return Teuchos::rcp( const_cast<MultiVec<ScalarType>&>(mv).CloneView(index) ); }
00243     static int GetVecLength( const MultiVec<ScalarType>& mv )
00244     { return mv.GetVecLength(); }
00246     static int GetNumberVecs( const MultiVec<ScalarType>& mv )
00247     { return mv.GetNumberVecs(); }
00249     static void MvTimesMatAddMv( ScalarType alpha, const MultiVec<ScalarType>& A, 
00250          const Teuchos::SerialDenseMatrix<int,ScalarType>& B, 
00251          ScalarType beta, MultiVec<ScalarType>& mv )
00252     { mv.MvTimesMatAddMv(alpha, A, B, beta); }
00254     static void MvAddMv( ScalarType alpha, const MultiVec<ScalarType>& A, ScalarType beta, const MultiVec<ScalarType>& B, MultiVec<ScalarType>& mv )
00255     { mv.MvAddMv(alpha, A, beta, B); }
00257     static void MvScale ( MultiVec<ScalarType>& mv, const ScalarType alpha )
00258     { mv.MvScale( alpha ); } 
00259 
00260     static void MvScale ( MultiVec<ScalarType>& mv, const std::vector<ScalarType>& alpha )
00261     { mv.MvScale(alpha); }
00263     static void MvTransMv( const ScalarType alpha, const MultiVec<ScalarType>& A, const MultiVec<ScalarType>& mv, Teuchos::SerialDenseMatrix<int,ScalarType>& B )
00264     { mv.MvTransMv(alpha, A, B); }
00266     static void MvDot( const MultiVec<ScalarType>& mv, const MultiVec<ScalarType>& A, std::vector<ScalarType>& b )
00267     { mv.MvDot( A, b ); }
00269     static void MvNorm( const MultiVec<ScalarType>& mv, std::vector<typename Teuchos::ScalarTraits<ScalarType>::magnitudeType>& normvec, NormType type = TwoNorm )
00270     { mv.MvNorm(normvec,type); }
00272     static void SetBlock( const MultiVec<ScalarType>& A, const std::vector<int>& index, MultiVec<ScalarType>& mv )
00273     { mv.SetBlock(A, index); }
00275     static void MvRandom( MultiVec<ScalarType>& mv )
00276     { mv.MvRandom(); }
00278     static void MvInit( MultiVec<ScalarType>& mv, ScalarType alpha = Teuchos::ScalarTraits<ScalarType>::zero() )
00279     { mv.MvInit(alpha); }
00281     static void MvPrint( const MultiVec<ScalarType>& mv, std::ostream& os )
00282     { mv.MvPrint(os); }
00283     
00284   };
00285 
00286 
00287 } // namespace Belos
00288 
00289 #endif
00290 
00291 // end of file BelosMultiVec.hpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines