46#ifndef ANASAZI_THYRA_DEBUG_ADAPTER_HPP
47#define ANASAZI_THYRA_DEBUG_ADAPTER_HPP
55#include <Thyra_DetachedMultiVectorView.hpp>
56#include <Thyra_MultiVectorBase.hpp>
57#include <Thyra_MultiVectorStdOps.hpp>
59#include "Teuchos_Assert.hpp"
60#include "Teuchos_SerialDenseMatrix.hpp"
61#include "Teuchos_RCP.hpp"
62#include "Teuchos_TimeMonitor.hpp"
81 template<
class ScalarType>
86 typedef Teuchos::ScalarTraits<ScalarType> SCT;
87 typedef typename Teuchos::ScalarTraits<ScalarType>::magnitudeType MagnitudeType;
88 typedef Teuchos::ScalarTraits<MagnitudeType> MT;
98 ThyraMultiVec(
const Teuchos::RCP<Thyra::MultiVectorBase< ScalarType > > & mv ) :
99 _timerCreate(Teuchos::TimeMonitor::getNewTimer(
"ThyraMultiVec::create")),
100 _timerClone(Teuchos::TimeMonitor::getNewTimer(
"ThyraMultiVec::clone")),
101 _timerDestroy(Teuchos::TimeMonitor::getNewTimer(
"ThyraMultiVec::destroy")),
102 _timerMvTimesMatAddMv(Teuchos::TimeMonitor::getNewTimer(
"ThyraMultiVec::mvtimesmataddmv")),
103 _timerMvTransMv(Teuchos::TimeMonitor::getNewTimer(
"ThyraMultiVec::mvtransmv")),
104 _timerMvAddMv(Teuchos::TimeMonitor::getNewTimer(
"ThyraMultiVec::mvaddmv")),
105 _timerMvDot(Teuchos::TimeMonitor::getNewTimer(
"ThyraMultiVec::mvdot")),
106 _timerMvNorm(Teuchos::TimeMonitor::getNewTimer(
"ThyraMultiVec::mvnorm")),
107 _timerMvScale(Teuchos::TimeMonitor::getNewTimer(
"ThyraMultiVec::mvscale")),
108 _timerSetBlock(Teuchos::TimeMonitor::getNewTimer(
"ThyraMultiVec::setblock")),
109 _timerMvInit(Teuchos::TimeMonitor::getNewTimer(
"ThyraMultiVec::mvinit")),
110 _timerMvRandom(Teuchos::TimeMonitor::getNewTimer(
"ThyraMultiVec::mvrandom"))
112 Teuchos::TimeMonitor timer(*_timerCreate);
122 ThyraMultiVec(
const Teuchos::RCP<Thyra::MultiVectorBase< ScalarType > > & mv, std::vector<Teuchos::RCP<Teuchos::Time> >& timers )
125 Teuchos::TimeMonitor timer(*_timerCreate);
137 Teuchos::TimeMonitor timer(*_timerCreate);
138 Thyra_MV = MVT::CloneCopy( *(mv.
getRCP()) );
155 Teuchos::TimeMonitor timer(*_timerClone);
156 std::vector<Teuchos::RCP<Teuchos::Time> > myTimers =
getTimers();
166 Teuchos::TimeMonitor timer(*_timerClone);
167 std::vector<Teuchos::RCP<Teuchos::Time> > myTimers =
getTimers();
180 Teuchos::TimeMonitor timer(*_timerClone);
181 std::vector<Teuchos::RCP<Teuchos::Time> > myTimers =
getTimers();
194 Teuchos::TimeMonitor timer(*_timerClone);
195 std::vector<Teuchos::RCP<Teuchos::Time> > myTimers =
getTimers();
208 Teuchos::TimeMonitor timer(*_timerClone);
209 std::vector<Teuchos::RCP<Teuchos::Time> > myTimers =
getTimers();
210 Teuchos::RCP<Thyra::MultiVectorBase<ScalarType> > nonconst_ptr_to_const_view = Teuchos::rcp_const_cast<Thyra::MultiVectorBase<ScalarType> >( MVT::CloneView(*Thyra_MV,index) );
233 const Teuchos::SerialDenseMatrix<int,ScalarType>& B,
236 Teuchos::TimeMonitor timer(*_timerMvTimesMatAddMv);
238 MVT::MvTimesMatAddMv( alpha, *(vec_A->
getRCP()), B, beta, *Thyra_MV );
246 Teuchos::TimeMonitor timer(*_timerMvAddMv);
249 MVT::MvAddMv( alpha, *(vec_A->
getRCP()), beta, *(vec_B->
getRCP()), *Thyra_MV );
255#ifdef HAVE_ANASAZI_EXPERIMENTAL
260 Teuchos::TimeMonitor timer(*_timerMvTransMv);
262 MVT::MvTransMv( alpha, *(vec_A->
getRCP()), *Thyra_MV, B );
268#ifdef HAVE_ANASAZI_EXPERIMENTAL
273 Teuchos::TimeMonitor timer(*_timerMvDot);
275 MVT::MvDot( *Thyra_MV, *(vec_A->
getRCP()), b );
280 void MvScale ( ScalarType alpha ) { Teuchos::TimeMonitor timer(*_timerMvScale); MVT::MvScale( *Thyra_MV, alpha ); }
284 void MvScale (
const std::vector<ScalarType>& alpha ) { Teuchos::TimeMonitor timer(*_timerMvScale); MVT::MvScale( *Thyra_MV, alpha ); }
293 void MvNorm ( std::vector<
typename Teuchos::ScalarTraits<ScalarType>::magnitudeType> &normvec )
const { Teuchos::TimeMonitor timer(*_timerMvNorm); MVT::MvNorm( *Thyra_MV, normvec ); }
305 Teuchos::TimeMonitor timer(*_timerSetBlock);
307 MVT::SetBlock( *(vec_A->
getRCP()), index, *Thyra_MV );
312 void MvRandom() { Teuchos::TimeMonitor timer(*_timerMvRandom); MVT::MvRandom( *Thyra_MV ); }
316 void MvInit ( ScalarType alpha ) { Teuchos::TimeMonitor timer(*_timerMvInit); MVT::MvInit( *Thyra_MV, alpha ); }
322 Teuchos::RCP< Thyra::MultiVectorBase<ScalarType> >
getRCP() {
return Thyra_MV; }
326 Teuchos::RCP< const Thyra::MultiVectorBase<ScalarType> >
getRCP()
const {
return Thyra_MV; }
330 std::vector<Teuchos::RCP<Teuchos::Time> >
getTimers()
const {
331 std::vector<Teuchos::RCP<Teuchos::Time> > timers;
332 timers.push_back( _timerCreate );
333 timers.push_back( _timerClone );
334 timers.push_back( _timerDestroy );
335 timers.push_back( _timerMvTimesMatAddMv );
336 timers.push_back( _timerMvTransMv );
337 timers.push_back( _timerMvAddMv );
338 timers.push_back( _timerMvDot );
339 timers.push_back( _timerMvNorm );
340 timers.push_back( _timerMvScale );
341 timers.push_back( _timerSetBlock );
342 timers.push_back( _timerMvInit );
343 timers.push_back( _timerMvRandom );
350 void copyTimers(
const std::vector<Teuchos::RCP<Teuchos::Time> >& timers ) {
351 _timerCreate = timers[0];
352 _timerClone = timers[1];
353 _timerDestroy = timers[2];
354 _timerMvTimesMatAddMv = timers[3];
355 _timerMvTransMv = timers[4];
356 _timerMvAddMv = timers[5];
357 _timerMvDot = timers[6];
358 _timerMvNorm = timers[7];
359 _timerMvScale = timers[8];
360 _timerSetBlock = timers[9];
361 _timerMvInit = timers[10];
362 _timerMvRandom = timers[11];
371 void MvPrint( std::ostream& os )
const { MVT::MvPrint( *Thyra_MV, os ); }
376 Teuchos::RCP<Thyra::MultiVectorBase<ScalarType> > Thyra_MV;
377 Teuchos::RCP<Teuchos::Time> _timerCreate, _timerClone, _timerDestroy;
378 Teuchos::RCP<Teuchos::Time> _timerMvTimesMatAddMv, _timerMvTransMv, _timerMvAddMv, _timerMvDot;
379 Teuchos::RCP<Teuchos::Time> _timerMvNorm, _timerMvScale, _timerSetBlock, _timerMvInit, _timerMvRandom;
395 template<
class ScalarType>
405 ThyraOp(
const Teuchos::RCP<
const Thyra::LinearOpBase<ScalarType> > &Op ) { Thyra_Op = Op; }
421 OPT::Apply( *Thyra_Op, *(vec_X->
getRCP()), *(vec_Y->
getRCP()) );
427 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.
Traits class which defines basic operations on multivectors.
Interface for multivectors used by Anasazi's linear solvers.
MultiVec()
Default constructor.
Virtual base class which defines basic traits for the operator type.
Operator()
Default constructor.
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.
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.