14#ifndef ANASAZI_THYRA_DEBUG_ADAPTER_HPP
15#define ANASAZI_THYRA_DEBUG_ADAPTER_HPP
23#include <Thyra_DetachedMultiVectorView.hpp>
24#include <Thyra_MultiVectorBase.hpp>
25#include <Thyra_MultiVectorStdOps.hpp>
27#include "Teuchos_Assert.hpp"
28#include "Teuchos_SerialDenseMatrix.hpp"
29#include "Teuchos_RCP.hpp"
30#include "Teuchos_TimeMonitor.hpp"
49 template<
class ScalarType>
54 typedef Teuchos::ScalarTraits<ScalarType> SCT;
55 typedef typename Teuchos::ScalarTraits<ScalarType>::magnitudeType MagnitudeType;
56 typedef Teuchos::ScalarTraits<MagnitudeType> MT;
66 ThyraMultiVec(
const Teuchos::RCP<Thyra::MultiVectorBase< ScalarType > > & mv ) :
67 _timerCreate(Teuchos::TimeMonitor::getNewTimer(
"ThyraMultiVec::create")),
68 _timerClone(Teuchos::TimeMonitor::getNewTimer(
"ThyraMultiVec::clone")),
69 _timerDestroy(Teuchos::TimeMonitor::getNewTimer(
"ThyraMultiVec::destroy")),
70 _timerMvTimesMatAddMv(Teuchos::TimeMonitor::getNewTimer(
"ThyraMultiVec::mvtimesmataddmv")),
71 _timerMvTransMv(Teuchos::TimeMonitor::getNewTimer(
"ThyraMultiVec::mvtransmv")),
72 _timerMvAddMv(Teuchos::TimeMonitor::getNewTimer(
"ThyraMultiVec::mvaddmv")),
73 _timerMvDot(Teuchos::TimeMonitor::getNewTimer(
"ThyraMultiVec::mvdot")),
74 _timerMvNorm(Teuchos::TimeMonitor::getNewTimer(
"ThyraMultiVec::mvnorm")),
75 _timerMvScale(Teuchos::TimeMonitor::getNewTimer(
"ThyraMultiVec::mvscale")),
76 _timerSetBlock(Teuchos::TimeMonitor::getNewTimer(
"ThyraMultiVec::setblock")),
77 _timerMvInit(Teuchos::TimeMonitor::getNewTimer(
"ThyraMultiVec::mvinit")),
78 _timerMvRandom(Teuchos::TimeMonitor::getNewTimer(
"ThyraMultiVec::mvrandom"))
80 Teuchos::TimeMonitor timer(*_timerCreate);
90 ThyraMultiVec(
const Teuchos::RCP<Thyra::MultiVectorBase< ScalarType > > & mv, std::vector<Teuchos::RCP<Teuchos::Time> >& timers )
93 Teuchos::TimeMonitor timer(*_timerCreate);
105 Teuchos::TimeMonitor timer(*_timerCreate);
123 Teuchos::TimeMonitor timer(*_timerClone);
124 std::vector<Teuchos::RCP<Teuchos::Time> > myTimers =
getTimers();
134 Teuchos::TimeMonitor timer(*_timerClone);
135 std::vector<Teuchos::RCP<Teuchos::Time> > myTimers =
getTimers();
148 Teuchos::TimeMonitor timer(*_timerClone);
149 std::vector<Teuchos::RCP<Teuchos::Time> > myTimers =
getTimers();
162 Teuchos::TimeMonitor timer(*_timerClone);
163 std::vector<Teuchos::RCP<Teuchos::Time> > myTimers =
getTimers();
176 Teuchos::TimeMonitor timer(*_timerClone);
177 std::vector<Teuchos::RCP<Teuchos::Time> > myTimers =
getTimers();
178 Teuchos::RCP<Thyra::MultiVectorBase<ScalarType> > nonconst_ptr_to_const_view = Teuchos::rcp_const_cast<Thyra::MultiVectorBase<ScalarType> >(
MVT::CloneView(*Thyra_MV,index) );
201 const Teuchos::SerialDenseMatrix<int,ScalarType>& B,
204 Teuchos::TimeMonitor timer(*_timerMvTimesMatAddMv);
214 Teuchos::TimeMonitor timer(*_timerMvAddMv);
223#ifdef HAVE_ANASAZI_EXPERIMENTAL
228 Teuchos::TimeMonitor timer(*_timerMvTransMv);
236#ifdef HAVE_ANASAZI_EXPERIMENTAL
241 Teuchos::TimeMonitor timer(*_timerMvDot);
248 void MvScale ( ScalarType alpha ) { Teuchos::TimeMonitor timer(*_timerMvScale);
MVT::MvScale( *Thyra_MV, alpha ); }
252 void MvScale (
const std::vector<ScalarType>& alpha ) { Teuchos::TimeMonitor timer(*_timerMvScale);
MVT::MvScale( *Thyra_MV, alpha ); }
261 void MvNorm ( std::vector<
typename Teuchos::ScalarTraits<ScalarType>::magnitudeType> &normvec )
const { Teuchos::TimeMonitor timer(*_timerMvNorm);
MVT::MvNorm( *Thyra_MV, normvec ); }
273 Teuchos::TimeMonitor timer(*_timerSetBlock);
284 void MvInit ( ScalarType alpha ) { Teuchos::TimeMonitor timer(*_timerMvInit);
MVT::MvInit( *Thyra_MV, alpha ); }
290 Teuchos::RCP< Thyra::MultiVectorBase<ScalarType> >
getRCP() {
return Thyra_MV; }
294 Teuchos::RCP< const Thyra::MultiVectorBase<ScalarType> >
getRCP()
const {
return Thyra_MV; }
298 std::vector<Teuchos::RCP<Teuchos::Time> >
getTimers()
const {
299 std::vector<Teuchos::RCP<Teuchos::Time> > timers;
300 timers.push_back( _timerCreate );
301 timers.push_back( _timerClone );
302 timers.push_back( _timerDestroy );
303 timers.push_back( _timerMvTimesMatAddMv );
304 timers.push_back( _timerMvTransMv );
305 timers.push_back( _timerMvAddMv );
306 timers.push_back( _timerMvDot );
307 timers.push_back( _timerMvNorm );
308 timers.push_back( _timerMvScale );
309 timers.push_back( _timerSetBlock );
310 timers.push_back( _timerMvInit );
311 timers.push_back( _timerMvRandom );
318 void copyTimers(
const std::vector<Teuchos::RCP<Teuchos::Time> >& timers ) {
319 _timerCreate = timers[0];
320 _timerClone = timers[1];
321 _timerDestroy = timers[2];
322 _timerMvTimesMatAddMv = timers[3];
323 _timerMvTransMv = timers[4];
324 _timerMvAddMv = timers[5];
325 _timerMvDot = timers[6];
326 _timerMvNorm = timers[7];
327 _timerMvScale = timers[8];
328 _timerSetBlock = timers[9];
329 _timerMvInit = timers[10];
330 _timerMvRandom = timers[11];
344 Teuchos::RCP<Thyra::MultiVectorBase<ScalarType> > Thyra_MV;
345 Teuchos::RCP<Teuchos::Time> _timerCreate, _timerClone, _timerDestroy;
346 Teuchos::RCP<Teuchos::Time> _timerMvTimesMatAddMv, _timerMvTransMv, _timerMvAddMv, _timerMvDot;
347 Teuchos::RCP<Teuchos::Time> _timerMvNorm, _timerMvScale, _timerSetBlock, _timerMvInit, _timerMvRandom;
363 template<
class ScalarType>
373 ThyraOp(
const Teuchos::RCP<
const Thyra::LinearOpBase<ScalarType> > &Op ) { Thyra_Op = Op; }
395 Teuchos::RCP<const Thyra::LinearOpBase<ScalarType> > Thyra_Op;
Anasazi header file which uses auto-configuration information to include necessary C++ headers.
Interface for multivectors used by Anasazi' linear solvers.
Templated virtual class for creating operators that can interface with the Anasazi::OperatorTraits cl...
Specializations of the Anasazi multi-vector and operator traits classes using Thyra base classes Line...
Types and exceptions used within Anasazi solvers and interfaces.
Template specialization of Anasazi::MultiVecTraits class using the Thyra::MultiVectorBase class.
static void MvTimesMatAddMv(const ScalarType alpha, const TMVB &A, const Teuchos::SerialDenseMatrix< int, ScalarType > &B, const ScalarType beta, TMVB &mv)
Update mv with .
static void MvRandom(TMVB &mv)
Replace the vectors in mv with random vectors.
static Teuchos::RCP< const TMVB > CloneView(const TMVB &mv, const std::vector< int > &index)
Creates a new const MultiVectorBase that shares the selected contents of mv (shallow copy).
static Teuchos::RCP< TMVB > CloneViewNonConst(TMVB &mv, const std::vector< int > &index)
Creates a new MultiVectorBase that shares the selected contents of mv (shallow copy).
static void SetBlock(const TMVB &A, const std::vector< int > &index, TMVB &mv)
Copy the vectors in A to a set of vectors in mv indicated by the indices given in index.
static void MvTransMv(const ScalarType alpha, const TMVB &A, const TMVB &mv, Teuchos::SerialDenseMatrix< int, ScalarType > &B)
Compute a dense matrix B through the matrix-matrix multiply .
static Teuchos::RCP< TMVB > Clone(const TMVB &mv, const int numvecs)
Creates a new empty MultiVectorBase containing numvecs columns.
static void MvInit(TMVB &mv, ScalarType alpha=Teuchos::ScalarTraits< ScalarType >::zero())
Replace each element of the vectors in mv with alpha.
static ptrdiff_t GetGlobalLength(const TMVB &mv)
Obtain the vector length of mv.
static void MvAddMv(const ScalarType alpha, const TMVB &A, const ScalarType beta, const TMVB &B, TMVB &mv)
Replace mv with .
static void MvScale(TMVB &mv, const ScalarType alpha)
Scale each element of the vectors in *this with alpha.
static Teuchos::RCP< TMVB > CloneCopy(const TMVB &mv)
Creates a new MultiVectorBase and copies contents of mv into the new vector (deep copy).
static void MvDot(const TMVB &mv, const TMVB &A, std::vector< ScalarType > &b)
Compute a vector b where the components are the individual dot-products of the i-th columns of A and ...
static int GetNumberVecs(const TMVB &mv)
Obtain the number of vectors in mv.
static void MvPrint(const TMVB &mv, std::ostream &os)
Print the mv multi-vector to the os output stream.
static void MvNorm(const TMVB &mv, std::vector< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > &normvec)
Compute the 2-norm of each individual vector of mv. Upon return, normvec[i] holds the value of ,...
Traits class which defines basic operations on multivectors.
Interface for multivectors used by Anasazi's linear solvers.
Template specialization of Anasazi::OperatorTraits class using the Thyra::LinearOpBase virtual base c...
static void Apply(const Thyra::LinearOpBase< ScalarType > &Op, const Thyra::MultiVectorBase< ScalarType > &x, Thyra::MultiVectorBase< ScalarType > &y)
This method takes the MultiVectorBase x and applies the LinearOpBase Op to it resulting in the MultiV...
Virtual base class which defines basic traits for the operator type.
Anasazi's templated virtual class for constructing an operator that can interface with the OperatorTr...
Basic adapter class for Anasazi::MultiVec that uses Thyra::MultiVectorBase<ScalarType>.
std::vector< Teuchos::RCP< Teuchos::Time > > getTimers() const
Return a std::vector<> of timers held by this object.
ThyraMultiVec(const Teuchos::RCP< Thyra::MultiVectorBase< ScalarType > > &mv)
Basic ThyraMultiVec constructor (wraps Thyra::MultiVectorBase<> object).
void MvAddMv(ScalarType alpha, const MultiVec< ScalarType > &A, ScalarType beta, const MultiVec< ScalarType > &B)
Replace *this with .
MultiVec< ScalarType > * CloneCopy() const
Creates a new ThyraMultiVec and copies contents of *this into the new vector (deep copy).
int GetNumberVecs() const
Obtain the vector length of *this.
Teuchos::RCP< Thyra::MultiVectorBase< ScalarType > > getRCP()
Return the reference-counted pointer held by this object.
void copyTimers(const std::vector< Teuchos::RCP< Teuchos::Time > > &timers)
Copy a std::vector<> of timers into this object.
virtual ~ThyraMultiVec()
Destructor.
void SetBlock(const MultiVec< ScalarType > &A, const std::vector< int > &index)
Copy the vectors in A to a set of vectors in *this.
void MvDot(const MultiVec< ScalarType > &A, std::vector< ScalarType > &b) const
Compute a vector b where the components are the individual dot-products, i.e. where A[i] is the i-th...
void MvTimesMatAddMv(ScalarType alpha, const MultiVec< ScalarType > &A, const Teuchos::SerialDenseMatrix< int, ScalarType > &B, ScalarType beta)
Update *this with .
void MvInit(ScalarType alpha)
Replace each element of the vectors in *this with alpha.
ThyraMultiVec(const Teuchos::RCP< Thyra::MultiVectorBase< ScalarType > > &mv, std::vector< Teuchos::RCP< Teuchos::Time > > &timers)
Basic ThyraMultiVec constructor (wraps Thyra::MultiVectorBase<> object).
void MvPrint(std::ostream &os) const
Print *this ThyraMultiVec.
MultiVec< ScalarType > * CloneCopy(const std::vector< int > &index) const
Creates a new ThyraMultiVec and copies the selected contents of *this into the new vector (deep copy)...
Teuchos::RCP< const Thyra::MultiVectorBase< ScalarType > > getRCP() const
Return the const reference-counted pointer held by this object.
void MvNorm(std::vector< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > &normvec) const
Compute the 2-norm of each individual vector of *this. Upon return, normvec[i] holds the 2-norm of th...
void MvTransMv(ScalarType alpha, const MultiVec< ScalarType > &A, Teuchos::SerialDenseMatrix< int, ScalarType > &B) const
Compute a dense matrix B through the matrix-matrix multiply .
void MvScale(ScalarType alpha)
Scale each element of the vectors in *this with alpha.
MultiVec< ScalarType > * CloneViewNonConst(const std::vector< int > &index)
Creates a new ThyraMultiVec that shares the selected contents of *this.
void MvScale(const std::vector< ScalarType > &alpha)
Scale each element of the i-th vector in *this with alpha[i].
ptrdiff_t GetGlobalLength() const
Obtain the number of vectors in *this.
void MvRandom()
Fill the vectors in *this with random numbers.
const MultiVec< ScalarType > * CloneView(const std::vector< int > &index) const
Creates a new ThyraMultiVec that shares the selected contents of *this.
MultiVec< ScalarType > * Clone(const int numvecs) const
Creates a new empty ThyraMultiVec containing numvecs columns.
ThyraMultiVec(const ThyraMultiVec< ScalarType > &mv)
Copy constructor.
Basic adapter class for Anasazi::Operator that uses Thyra_Operator.
ThyraOp(const Teuchos::RCP< const Thyra::LinearOpBase< ScalarType > > &Op)
Basic constructor. Accepts reference-counted pointer to an Thyra_Operator.
void Apply(const MultiVec< ScalarType > &X, MultiVec< ScalarType > &Y) const
This method takes the Anasazi::MultiVec X and applies the operator to it resulting in the Anasazi::Mu...
Namespace Anasazi contains the classes, structs, enums and utilities used by the Anasazi package.
ConjType
Enumerated types used to specify conjugation arguments.