Belos Version of the Day
BelosMultiVecTraits.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_TRAITS_HPP
00043 #define BELOS_MULTI_VEC_TRAITS_HPP
00044 
00055 
00056 #include "BelosTypes.hpp"
00057 #include "BelosStubTsqrAdapter.hpp"
00058 #include "Teuchos_Range1D.hpp"
00059 #include "Teuchos_RCP.hpp"
00060 #include "Teuchos_SerialDenseMatrix.hpp"
00061 
00062 namespace Belos {
00063 
00070   template<class ScalarType, class MV>
00071   struct UndefinedMultiVecTraits
00072   {
00079     static inline ScalarType notDefined() {
00080       return MV::this_type_is_missing_a_specialization();
00081     }
00082   };
00083 
00128   template<class ScalarType, class MV>
00129   class MultiVecTraits {
00130   public:
00132 
00133 
00138     static Teuchos::RCP<MV> Clone( const MV& mv, const int numvecs )
00139     { UndefinedMultiVecTraits<ScalarType, MV>::notDefined(); return Teuchos::null; }
00140 
00145     static Teuchos::RCP<MV> CloneCopy( const MV& mv )
00146     { UndefinedMultiVecTraits<ScalarType, MV>::notDefined(); return Teuchos::null; }
00147 
00153     static Teuchos::RCP<MV> CloneCopy( const MV& mv, const std::vector<int>& index )
00154     { UndefinedMultiVecTraits<ScalarType, MV>::notDefined(); return Teuchos::null; }
00155 
00165     static Teuchos::RCP<MV> CloneCopy( const MV& mv, const Teuchos::Range1D& index )
00166     { UndefinedMultiVecTraits<ScalarType, MV>::notDefined(); return Teuchos::null; }
00167 
00173     static Teuchos::RCP<MV> CloneViewNonConst( MV& mv, const std::vector<int>& index )
00174     { UndefinedMultiVecTraits<ScalarType, MV>::notDefined(); return Teuchos::null; }
00175 
00184     static Teuchos::RCP<MV> CloneViewNonConst( MV& mv, const Teuchos::Range1D& index )
00185     { UndefinedMultiVecTraits<ScalarType, MV>::notDefined(); return Teuchos::null; }
00186 
00192     static Teuchos::RCP<const MV> CloneView( const MV& mv, const std::vector<int>& index )
00193     { UndefinedMultiVecTraits<ScalarType, MV>::notDefined(); return Teuchos::null; }
00194 
00203     static Teuchos::RCP<MV> CloneView( MV& mv, const Teuchos::Range1D& index )
00204     { UndefinedMultiVecTraits<ScalarType, MV>::notDefined(); return Teuchos::null; }
00205 
00207 
00209 
00210 
00218     static int GetVecLength( const MV& mv )
00219     { UndefinedMultiVecTraits<ScalarType, MV>::notDefined(); return 0; }
00220 
00222     static int GetNumberVecs( const MV& mv )
00223     { UndefinedMultiVecTraits<ScalarType, MV>::notDefined(); return 0; }
00224 
00247     static bool HasConstantStride( const MV& mv )
00248     { UndefinedMultiVecTraits<ScalarType, MV>::notDefined(); return false; }
00249 
00251 
00253 
00254 
00257     static void MvTimesMatAddMv( const ScalarType alpha, const MV& A,
00258                                  const Teuchos::SerialDenseMatrix<int,ScalarType>& B,
00259                                  const ScalarType beta, MV& mv )
00260     { UndefinedMultiVecTraits<ScalarType, MV>::notDefined(); }
00261 
00264     static void MvAddMv( const ScalarType alpha, const MV& A, const ScalarType beta, const MV& B, MV& mv )
00265     { UndefinedMultiVecTraits<ScalarType, MV>::notDefined(); }
00266 
00269     static void MvScale ( MV& mv, const ScalarType alpha )
00270     { UndefinedMultiVecTraits<ScalarType, MV>::notDefined(); }
00271 
00274     static void MvScale ( MV& mv, const std::vector<ScalarType>& alpha )
00275     { UndefinedMultiVecTraits<ScalarType, MV>::notDefined(); }
00276 
00279     static void MvTransMv( const ScalarType alpha, const MV& A, const MV& mv, Teuchos::SerialDenseMatrix<int,ScalarType>& B)
00280     { UndefinedMultiVecTraits<ScalarType, MV>::notDefined(); }
00281 
00284     static void MvDot ( const MV& mv, const MV& A, std::vector<ScalarType> &b)
00285     { UndefinedMultiVecTraits<ScalarType, MV>::notDefined(); }
00286 
00288 
00289 
00290 
00294     static void MvNorm( const MV& mv, std::vector<typename Teuchos::ScalarTraits<ScalarType>::magnitudeType>& normvec, NormType type = TwoNorm )
00295     { UndefinedMultiVecTraits<ScalarType, MV>::notDefined(); }
00296 
00298 
00300 
00301 
00306     static void SetBlock( const MV& A, const std::vector<int>& index, MV& mv )
00307     { UndefinedMultiVecTraits<ScalarType, MV>::notDefined(); }
00308 
00321     static void SetBlock( const MV& A, const Teuchos::Range1D& index, MV& mv )
00322     { UndefinedMultiVecTraits<ScalarType, MV>::notDefined(); }
00323 
00327     static void Assign( const MV& A, MV& mv )
00328     { UndefinedMultiVecTraits<ScalarType, MV>::notDefined(); }
00329 
00332     static void MvRandom( MV& mv )
00333     { UndefinedMultiVecTraits<ScalarType, MV>::notDefined(); }
00334 
00337     static void MvInit( MV& mv, const ScalarType alpha = Teuchos::ScalarTraits<ScalarType>::zero() )
00338     { UndefinedMultiVecTraits<ScalarType, MV>::notDefined(); }
00339 
00341 
00343 
00344 
00347     static void MvPrint( const MV& mv, std::ostream& os )
00348     { UndefinedMultiVecTraits<ScalarType, MV>::notDefined(); }
00349 
00351 
00352 #ifdef HAVE_BELOS_TSQR
00353 
00354 
00355 
00356 
00357 
00358 
00359 
00360 
00361 
00362 
00363 
00364 
00365     typedef Belos::details::StubTsqrAdapter<MV> tsqr_adaptor_type;
00366 #endif // HAVE_BELOS_TSQR
00367   };
00368 
00394   template<class ScalarType, class MV>
00395   class MultiVecTraitsExt {
00396   public:
00398 
00399 
00402     static ptrdiff_t GetGlobalLength( const MV& mv )
00403     { return static_cast<ptrdiff_t>( MultiVecTraits<ScalarType, MV>::GetVecLength( mv ) ); }
00404 
00406   };
00407 
00408 
00409 } // namespace Belos
00410 
00411 #endif // BELOS_MULTI_VEC_TRAITS_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines