|
Belos Version of the Day
|
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 00216 template<class ScalarType> 00217 class MultiVecTraits<ScalarType,MultiVec<ScalarType> > 00218 { 00219 public: 00221 static Teuchos::RCP<MultiVec<ScalarType> > Clone( const MultiVec<ScalarType>& mv, const int numvecs ) 00222 { return Teuchos::rcp( const_cast<MultiVec<ScalarType>&>(mv).Clone(numvecs) ); } 00224 static Teuchos::RCP<MultiVec<ScalarType> > CloneCopy( const MultiVec<ScalarType>& mv ) 00225 { return Teuchos::rcp( const_cast<MultiVec<ScalarType>&>(mv).CloneCopy() ); } 00227 static Teuchos::RCP<MultiVec<ScalarType> > CloneCopy( const MultiVec<ScalarType>& mv, const std::vector<int>& index ) 00228 { return Teuchos::rcp( const_cast<MultiVec<ScalarType>&>(mv).CloneCopy(index) ); } 00230 static Teuchos::RCP<MultiVec<ScalarType> > CloneViewNonConst( MultiVec<ScalarType>& mv, const std::vector<int>& index ) 00231 { return Teuchos::rcp( mv.CloneViewNonConst(index) ); } 00233 static Teuchos::RCP<const MultiVec<ScalarType> > CloneView( const MultiVec<ScalarType>& mv, const std::vector<int>& index ) 00234 { return Teuchos::rcp( const_cast<MultiVec<ScalarType>&>(mv).CloneView(index) ); } 00236 static int GetVecLength( const MultiVec<ScalarType>& mv ) 00237 { return mv.GetVecLength(); } 00239 static int GetNumberVecs( const MultiVec<ScalarType>& mv ) 00240 { return mv.GetNumberVecs(); } 00242 static void MvTimesMatAddMv( ScalarType alpha, const MultiVec<ScalarType>& A, 00243 const Teuchos::SerialDenseMatrix<int,ScalarType>& B, 00244 ScalarType beta, MultiVec<ScalarType>& mv ) 00245 { mv.MvTimesMatAddMv(alpha, A, B, beta); } 00247 static void MvAddMv( ScalarType alpha, const MultiVec<ScalarType>& A, ScalarType beta, const MultiVec<ScalarType>& B, MultiVec<ScalarType>& mv ) 00248 { mv.MvAddMv(alpha, A, beta, B); } 00250 static void MvScale ( MultiVec<ScalarType>& mv, const ScalarType alpha ) 00251 { mv.MvScale( alpha ); } 00252 00253 static void MvScale ( MultiVec<ScalarType>& mv, const std::vector<ScalarType>& alpha ) 00254 { mv.MvScale(alpha); } 00256 static void MvTransMv( const ScalarType alpha, const MultiVec<ScalarType>& A, const MultiVec<ScalarType>& mv, Teuchos::SerialDenseMatrix<int,ScalarType>& B ) 00257 { mv.MvTransMv(alpha, A, B); } 00259 static void MvDot( const MultiVec<ScalarType>& mv, const MultiVec<ScalarType>& A, std::vector<ScalarType>& b ) 00260 { mv.MvDot( A, b ); } 00262 static void MvNorm( const MultiVec<ScalarType>& mv, std::vector<typename Teuchos::ScalarTraits<ScalarType>::magnitudeType>& normvec, NormType type = TwoNorm ) 00263 { mv.MvNorm(normvec,type); } 00265 static void SetBlock( const MultiVec<ScalarType>& A, const std::vector<int>& index, MultiVec<ScalarType>& mv ) 00266 { mv.SetBlock(A, index); } 00268 static void MvRandom( MultiVec<ScalarType>& mv ) 00269 { mv.MvRandom(); } 00271 static void MvInit( MultiVec<ScalarType>& mv, ScalarType alpha = Teuchos::ScalarTraits<ScalarType>::zero() ) 00272 { mv.MvInit(alpha); } 00274 static void MvPrint( const MultiVec<ScalarType>& mv, std::ostream& os ) 00275 { mv.MvPrint(os); } 00276 00277 }; 00278 00279 00280 } // namespace Belos 00281 00282 #endif 00283 00284 // end of file BelosMultiVec.hpp
1.7.4