// @HEADER // ***************************************************************************** // LOCA: Library of Continuation Algorithms Package // // Copyright 2001-2005 NTESS and the LOCA contributors. // SPDX-License-Identifier: BSD-3-Clause // ***************************************************************************** // @HEADER #ifndef ANASAZI_LOCA_MULTIVECTRAITS_H #define ANASAZI_LOCA_MULTIVECTRAITS_H // Anasazi includes #include "AnasaziMultiVecTraits.hpp" // NOX/LOCA includes #include "NOX_Abstract_MultiVector.H" namespace Anasazi { /*! * \brief Implementation of the Anasazi::MultiVecTraits for * NOX::Abstract::MultiVectors. */ /*! * This class provides an implementation of the Anasazi::MultiVecTraits class * for NOX::Abstract::MultiVector's, to be used in conjunction with the * Anasazi::LOCA::Matrix class. */ template <> class MultiVecTraits { public: //! Synony for double typedef double ScalarType; //! Synonym for NOX::Abstract::MultiVector typedef NOX::Abstract::MultiVector MV; //@{ \name Creation methods /*! * \brief Creates a new empty \c MV containing \c numvecs columns. * * \return Reference-counted pointer to the new multivector of type \c MV. */ static Teuchos::RCP Clone( const MV& mv, const int numvecs ) { return mv.clone(numvecs); } /*! * \brief Creates a new \c MV and copies contents of \c mv into the new * vector (deep copy). * * \return Reference-counted pointer to the new multivector of type \c MV. */ static Teuchos::RCP CloneCopy( const MV& mv ) { return mv.clone(NOX::DeepCopy); } /*! * \brief Creates a new \c MV and copies the selected contents of \c mv * into the new vector (deep copy). * * The copied vectors from \c mv are indicated by the \c index.size() * indices in \c index. * \return Reference-counted pointer to the new multivector of type \c MV. */ static Teuchos::RCP CloneCopy( const MV& mv, const std::vector& index ) { return mv.subCopy(index); } /*! * \brief Creates a new \c MV that shares the selected contents of * \c mv (shallow copy). * * The index of the \c numvecs vectors shallow copied from \c mv are * indicated by the indices given in \c index. * \return Reference-counted pointer to the new multivector of type \c MV. */ static Teuchos::RCP CloneViewNonConst( MV& mv, const std::vector& index ) { return mv.subView(index); } /*! * \brief Creates a new const \c MV that shares the selected contents of * \c mv (shallow copy). * * The index of the \c numvecs vectors shallow copied from \c mv are * indicated by the indices given in \c index. * \return Reference-counted pointer to the new const multivector of * type \c MV. */ static Teuchos::RCP CloneView( const MV& mv, const std::vector& index ) { return mv.subView(index).getConst(); } //@} //@{ \name Attribute methods //! Obtain the vector length of \c mv. static ptrdiff_t GetGlobalLength( const MV& mv ) { return mv.length(); } //! Obtain the number of vectors in \c mv static int GetNumberVecs( const MV& mv ) { return mv.numVectors(); } //@} //@{ \name Update methods /*! * \brief Update \c mv with \f$ \alpha AB + \beta mv \f$. */ static void MvTimesMatAddMv( const ScalarType alpha, const MV& A, const Teuchos::SerialDenseMatrix& B, const ScalarType beta, MV& mv ) { mv.update(Teuchos::NO_TRANS, alpha, A, B, beta); } /*! * \brief Replace \c mv with \f$\alpha A + \beta B\f$. */ static void MvAddMv( const ScalarType alpha, const MV& A, const ScalarType beta, const MV& B, MV& mv ) { mv.update(alpha, A, beta, B); } /*! * \brief Compute a dense matrix \c B through the matrix-matrix multiply * \f$ \alpha A^Hmv \f$. */ static void MvTransMv( const ScalarType alpha, const MV& A, const MV& mv, Teuchos::SerialDenseMatrix& B) { mv.multiply(alpha, A, B); } /*! * \brief Compute a vector \c b where the components are the individual * dot-products of the \c i-th columns of \c A and \c mv, i.e. * \f$b[i] = A[i]^Hmv[i]\f$. */ static void MvDot ( const MV& mv, const MV& A, std::vector &b) { for (unsigned int i=0; i& alpha ) { for (unsigned int i=0; i &normvec ) { mv.norm(normvec); } //@} //@{ \name Initialization methods /*! * \brief Copy the vectors in \c A to a set of vectors in \c mv indicated * by the indices given in \c index. * * The \c numvecs vectors in \c A are copied to a subset of vectors in * \c mv indicated by the indices given in \c index, * i.e. mv[index[i]] = A[i]. */ static void SetBlock( const MV& A, const std::vector& index, MV& mv ) { mv.setBlock(A, index); } /*! * \brief Replace the vectors in \c mv with random vectors. */ static void MvRandom( MV& mv ) { mv.random(); } /*! * \brief Replace each element of the vectors in \c mv with \c alpha. */ static void MvInit( MV& mv, const ScalarType alpha = 0.0 ) { mv.init(alpha); } //@} //@{ \name Print method /*! * \brief Print the \c mv multi-vector to the \c os output stream. */ static void MvPrint( const MV& mv, std::ostream& os ) { mv.print(os); } //@} }; // class MultiVecTraits } // namespace Anasazi #endif