10#ifndef BELOS_GMRESPOLYOP_HPP
11#define BELOS_GMRESPOLYOP_HPP
38#include "Teuchos_BLAS.hpp"
39#include "Teuchos_LAPACK.hpp"
40#include "Teuchos_as.hpp"
41#include "Teuchos_RCP.hpp"
42#include "Teuchos_SerialDenseMatrix.hpp"
43#include "Teuchos_SerialDenseVector.hpp"
44#include "Teuchos_SerialDenseSolver.hpp"
45#include "Teuchos_ParameterList.hpp"
47#ifdef BELOS_TEUCHOS_TIME_MONITOR
48 #include "Teuchos_TimeMonitor.hpp"
64 template <
class ScalarType,
class MV,
class DM = DefaultDenseMatrix<
int, ScalarType>>
74 mv_ = Teuchos::rcp_const_cast<MV>(
mv_in );
76 Teuchos::RCP<MV>
getMV() {
return mv_; }
77 Teuchos::RCP<const MV>
getConstMV()
const {
return mv_; }
111 MVT::MvTimesMatAddMv( alpha, *(
A_in.getConstMV()), B, beta, *mv_ );
117 MVT::MvAddMv( alpha, *(
A_in.getConstMV()), beta, *(
B_in.getConstMV()), *mv_ );
120 void MvScale (
const std::vector<ScalarType>& alpha ) { MVT::MvScale( *mv_, alpha ); }
124 MVT::MvTransMv( alpha, *(
A_in.getConstMV()), *mv_, B );
129 MVT::MvDot( *(
A_in.getConstMV()), *mv_,
b );
133 MVT::MvNorm( *mv_,
normvec, type );
138 MVT::SetBlock( *(
A_in.getConstMV()), index, *mv_ );
142 void MvPrint ( std::ostream&
os )
const { MVT::MvPrint( *mv_,
os ); }
148 Teuchos::RCP<MV> mv_;
162 template <
class ScalarType,
class MV,
class OP,
class DM>
174 const Teuchos::RCP<Teuchos::ParameterList>&
params_in
183 polyUpdateLabel_ = label_ +
": Hybrid Gmres: Vector Update";
184#ifdef BELOS_TEUCHOS_TIME_MONITOR
188 if (polyType_ ==
"Arnoldi" || polyType_==
"Roots")
190 else if (polyType_ ==
"Gmres")
194 "Belos::GmresPolyOp: \"Polynomial Type\" must be either \"Arnoldi\", \"Gmres\", or \"Roots\".");
258#ifdef BELOS_TEUCHOS_TIME_MONITOR
261 std::string polyUpdateLabel_;
265 typedef Teuchos::ScalarTraits<ScalarType> SCT ;
266 typedef typename Teuchos::ScalarTraits<ScalarType>::magnitudeType MagnitudeType;
267 typedef Teuchos::ScalarTraits<MagnitudeType> MCT ;
270 static constexpr int maxDegree_default_ = 25;
272 static constexpr bool randomRHS_default_ =
true;
273 static constexpr const char * label_default_ =
"Belos";
274 static constexpr const char * polyType_default_ =
"Roots";
275 static constexpr const char * orthoType_default_ =
"DGKS";
276 static constexpr bool damp_default_ =
false;
277 static constexpr bool addRoots_default_ =
true;
280 Teuchos::RCP<LinearProblem<ScalarType,MV,OP,DM> > problem_;
281 Teuchos::RCP<Teuchos::ParameterList> params_;
282 Teuchos::RCP<const OP> LP_, RP_;
285 Teuchos::RCP<OutputManager<ScalarType> > printer_;
286 Teuchos::RCP<std::ostream> outputStream_ = Teuchos::rcpFromRef(std::cout);
289 Teuchos::RCP<MatOrthoManager<ScalarType,MV,OP,DM> > ortho_;
293 int maxDegree_ = maxDegree_default_;
294 int verbosity_ = verbosity_default_;
295 bool randomRHS_ = randomRHS_default_;
296 std::string label_ = label_default_;
297 std::string polyType_ = polyType_default_;
298 std::string orthoType_ = orthoType_default_;
300 bool damp_ = damp_default_;
301 bool addRoots_ = addRoots_default_;
304 mutable Teuchos::RCP<MV> V_, wL_, wR_;
309 bool autoDeg =
false;
313 Teuchos::SerialDenseMatrix< OT, MagnitudeType > theta_;
317 void SortModLeja(Teuchos::SerialDenseMatrix< OT, MagnitudeType > &
thetaN, std::vector<int> &index)
const ;
320 void ComputeAddedRoots();
323 template <
class ScalarType,
class MV,
class OP,
class DM>
327 if (
params_in->isParameter(
"Polynomial Type")) {
328 polyType_ =
params_in->get(
"Polynomial Type", polyType_default_);
332 if (
params_in->isParameter(
"Polynomial Tolerance")) {
333 if (
params_in->isType<MagnitudeType> (
"Polynomial Tolerance")) {
334 polyTol_ =
params_in->get (
"Polynomial Tolerance",
343 if (
params_in->isParameter(
"Maximum Degree")) {
344 maxDegree_ =
params_in->get(
"Maximum Degree", maxDegree_default_);
348 if (
params_in->isParameter(
"Random RHS")) {
349 randomRHS_ =
params_in->get(
"Random RHS", randomRHS_default_);
353 if (
params_in->isParameter(
"Verbosity")) {
354 if (Teuchos::isParameterType<int>(*
params_in,
"Verbosity")) {
355 verbosity_ =
params_in->get(
"Verbosity", verbosity_default_);
358 verbosity_ = (
int)Teuchos::getParameter<Belos::MsgType>(*
params_in,
"Verbosity");
362 if (
params_in->isParameter(
"Orthogonalization")) {
363 orthoType_ =
params_in->get(
"Orthogonalization",orthoType_default_);
367 if (
params_in->isParameter(
"Timer Label")) {
368 label_ =
params_in->get(
"Timer Label", label_default_);
372 if (
params_in->isParameter(
"Output Stream")) {
373 outputStream_ = Teuchos::getParameter<Teuchos::RCP<std::ostream> >(*
params_in,
"Output Stream");
377 if (
params_in->isParameter(
"Damped Poly")) {
378 damp_ =
params_in->get(
"Damped Poly", damp_default_);
382 if (
params_in->isParameter(
"Add Roots")) {
383 addRoots_ =
params_in->get(
"Add Roots", addRoots_default_);
387 template <
class ScalarType,
class MV,
class OP,
class DM>
390 Teuchos::RCP< MV > V = MVT::Clone( *problem_->getRHS(), maxDegree_+1 );
393 std::vector<int> index(1,0);
394 Teuchos::RCP< MV >
V0 = MVT::CloneViewNonConst(*V, index);
396 MVT::MvRandom( *
V0 );
398 MVT::Assign( *problem_->getRHS(), *
V0 );
400 if ( !LP_.is_null() ) {
401 Teuchos::RCP< MV >
Vtemp = MVT::CloneCopy(*
V0);
402 problem_->applyLeftPrec( *
Vtemp, *
V0);
405 Teuchos::RCP< MV >
Vtemp = MVT::CloneCopy(*
V0);
409 for(
int i=0;
i< maxDegree_;
i++)
412 Teuchos::RCP< const MV >
Vi = MVT::CloneView(*V, index);
414 Teuchos::RCP< MV >
Vip1 = MVT::CloneViewNonConst(*V, index);
415 problem_->apply( *
Vi, *
Vip1);
419 Teuchos::Range1D
range( 1, maxDegree_);
420 Teuchos::RCP< const MV >
AV = MVT::CloneView( *V,
range);
423 DM
AVtransAV = *DMT::Create( maxDegree_, maxDegree_);
427 Teuchos::LAPACK< OT, ScalarType > lapack;
433 while(
status && dim_ >= 1)
438 DMT::SyncHostToDevice(
lhstemp);
444 std::cout <<
"BelosGmresPolyOp.hpp: LAPACK POTRF was not successful!!" << std::endl;
445 std::cout <<
"Error code: " <<
infoInt << std::endl;
466 DMT::Reshape(pCoeff_, 1, 1);
467 DMT::Value(pCoeff_, 0,0) = SCT::one();
468 std::cout <<
"Poly Degree is zero. No preconditioner created." << std::endl;
472 DMT::Reshape(pCoeff_, dim_, 1);
474 Teuchos::Range1D
rangeSub( 1, dim_);
475 Teuchos::RCP< const MV >
AVsub = MVT::CloneView( *V,
rangeSub);
478 MVT::MvTransMv( SCT::one(), *
AVsub, *
V0, pCoeff_);
479 lapack.POTRS(
'U', dim_, 1, DMT::GetRawHostPtr(
lhs), DMT::GetStride(
lhs), DMT::GetRawHostPtr(pCoeff_), DMT::GetStride(pCoeff_), &
infoInt);
480 DMT::SyncHostToDevice(pCoeff_);
483 std::cout <<
"BelosGmresPolyOp.hpp: LAPACK POTRS was not successful!!" << std::endl;
484 std::cout <<
"Error code: " <<
infoInt << std::endl;
489 template <
class ScalarType,
class MV,
class OP,
class DM>
492 std::string
polyLabel = label_ +
": GmresPolyOp creation";
495 std::vector<int>
idx(1,0);
496 Teuchos::RCP<MV>
newX = MVT::Clone( *(problem_->getLHS()), 1 );
497 Teuchos::RCP<MV>
newB = MVT::Clone( *(problem_->getRHS()), 1 );
498 MVT::MvInit( *
newX, SCT::zero() );
500 MVT::MvRandom( *
newB );
503 MVT::Assign( *(MVT::CloneView(*(problem_->getRHS()),
idx)), *
newB );
505 Teuchos::RCP<LinearProblem<ScalarType,MV,OP,DM> >
newProblem =
508 newProblem->setLeftPrec( problem_->getLeftPrec() );
509 newProblem->setRightPrec( problem_->getRightPrec() );
518 polyList.set(
"Num Blocks",maxDegree_);
520 polyList.set(
"Keep Hessenberg",
true);
526 if (ortho_.is_null()) {
527 params_->set(
"Orthogonalization", orthoType_);
535 Teuchos::RCP<StatusTestMaxIters<ScalarType,MV,OP,DM> >
maxItrTst =
539 Teuchos::RCP<StatusTestGenResNorm<ScalarType,MV,OP,DM> >
convTst =
544 Teuchos::RCP<StatusTestCombo<ScalarType,MV,OP,DM> >
polyTest =
548 Teuchos::RCP<BlockGmresIter<ScalarType,MV,OP,DM> >
gmres_iter;
552 Teuchos::RCP<MV>
V_0 = MVT::CloneCopy( *
newB );
553 if ( !LP_.is_null() )
557 Teuchos::RCP< MV >
Vtemp = MVT::CloneCopy(*
V_0);
562 DMT::Reshape(r0_, 1, 1);
565 int rank = ortho_->normalize( *
V_0, Teuchos::rcpFromRef(r0_) );
567 "Belos::GmresPolyOp::generateArnoldiPoly(): Failed to compute initial block of orthonormal vectors for polynomial generation.");
569 DMT::SyncDeviceToHost(r0_);
573 newstate.z = Teuchos::rcpFromRef( r0_);
585 catch (std::exception&
e) {
587 printer_->stream(
Errors) <<
"Error! Caught exception in BlockGmresIter::iterate() at iteration "
588 <<
gmres_iter->getNumIters() << endl <<
e.what () << endl;
603 if(polyType_ ==
"Arnoldi"){
606 y_ = *DMT::SubviewCopy(*
gmresState.z, dim_, 1);
612 Teuchos::BLAS<OT,ScalarType>
blas;
613 blas.TRSM( Teuchos::LEFT_SIDE, Teuchos::UPPER_TRI, Teuchos::NO_TRANS,
614 Teuchos::NON_UNIT_DIAG, dim_, 1, SCT::one(),
616 DMT::GetRawHostPtr(y_), DMT::GetStride(y_) );
618 DMT::SyncHostToDevice(y_);
624 H_ = *DMT::SubviewCopy(*
gmresState.H, dim_, dim_);
626 for(
int i=0;
i <= dim_-3;
i++) {
627 for(
int k=
i+2;
k <= dim_-1;
k++) {
628 DMT::Value(H_,
k,
i) = SCT::zero();
632 DMT::SyncHostToDevice(H_);
633 DM
Htemp = *DMT::CreateCopy(H_);
637 DM
HlastCol = *DMT::Subview(H_, dim_, 1, 0, dim_-1);
640 DM
F = *DMT::Create(dim_,1);
641 DM
E = *DMT::Create(dim_,1);
642 DMT::PutScalar(
E, SCT::zero());
643 DMT::Value(
E, dim_-1,0) = SCT::one();
645 auto HSolver = DMT::createDenseSolver();
647 HSolver->solveWithTransposeFlag( Teuchos::CONJ_TRANS );
648 HSolver->setVectors( Teuchos::rcpFromRef(
F), Teuchos::rcpFromRef(
E));
649 HSolver->factorWithEquilibration(
true );
655 std::cout <<
"Hsolver factor: info = " <<
info << std::endl;
659 std::cout <<
"Hsolver solve : info = " <<
info << std::endl;
667 Teuchos::LAPACK< OT, ScalarType > lapack;
668 theta_.shape(dim_,2);
675 std::vector<ScalarType>
work(1);
676 std::vector<MagnitudeType>
rwork(2*dim_);
679 lapack.GEEV(
'N',
'N',dim_,DMT::GetRawHostPtr(H_),DMT::GetStride(H_),theta_[0],theta_[1],
vlr,
ldv,
vlr,
ldv, &
work[0],
lwork, &
rwork[0], &
info);
680 lwork = std::abs (
static_cast<int> (Teuchos::ScalarTraits<ScalarType>::real (
work[0])));
683 lapack.GEEV(
'N',
'N',dim_,DMT::GetRawHostPtr(H_),DMT::GetStride(H_),theta_[0],theta_[1],
vlr,
ldv,
vlr,
ldv, &
work[0],
lwork, &
rwork[0], &
info);
686 std::cout <<
"GEEV solve : info = " <<
info << std::endl;
691 const MagnitudeType
tol = 10.0 * Teuchos::ScalarTraits<MagnitudeType>::eps();
692 std::vector<int> index(dim_);
693 for(
int i=0;
i<dim_; ++
i){
696 TEUCHOS_TEST_FOR_EXCEPTION(
hypot(theta_(
i,0),theta_(
i,1)) <
tol, std::runtime_error,
"BelosGmresPolyOp Error: One of the computed polynomial roots is approximately zero. This will cause a divide by zero error! Your matrix may be close to singular. Please select a lower polynomial degree or give a shifted matrix.");
698 SortModLeja(theta_,index);
707 template <
class ScalarType,
class MV,
class OP,
class DM>
712 std::vector<std::complex<MagnitudeType>>
cmplxHRitz (dim_);
714 cmplxHRitz[
i] = std::complex<MagnitudeType>( theta_(
i,0), theta_(
i,1) );
718 const MagnitudeType
one(1.0);
719 std::vector<MagnitudeType>
pof (dim_,
one);
720 for(
int j=0;
j<dim_; ++
j) {
721 for(
int i=0;
i<dim_; ++
i) {
729 std::vector<int>
extra (dim_);
731 for(
int i=0;
i<dim_; ++
i){
732 if (
pof[
i] > MCT::zero())
741 printer_->stream(
Warnings) <<
"Warning: Need to add " <<
totalExtra <<
" extra roots." << std::endl;}
748 Teuchos::SerialDenseMatrix<OT,MagnitudeType>
thetaPert (Teuchos::Copy, theta_, dim_+
totalExtra, 2);
752 for(
int i=0;
i<dim_; ++
i){
754 theta_(
count,0) = theta_(
i,0);
755 theta_(
count,1) = theta_(
i,1);
765 printer_->stream(
Warnings) <<
"New poly degree is: " << dim_ << std::endl;}
768 std::vector<int>
index2(dim_);
769 for(
int i=0;
i<dim_; ++
i){
774 for(
int i=0;
i<dim_; ++
i)
786 template <
class ScalarType,
class MV,
class OP,
class DM>
787 void GmresPolyOp<ScalarType, MV, OP, DM>::SortModLeja(Teuchos::SerialDenseMatrix< OT, MagnitudeType > &thetaN, std::vector<int> &index)
const
792 int dimN = index.size();
794 Teuchos::SerialDenseMatrix< OT, MagnitudeType >
sorted (
thetaN.numRows(),
thetaN.numCols());
795 Teuchos::SerialDenseVector< OT, MagnitudeType >
absVal (
thetaN.numRows());
796 Teuchos::SerialDenseVector< OT, MagnitudeType >
prod (
thetaN.numRows());
812 if(
sorted(0,1)!= SCT::zero() && !SCT::isComplex)
831 prod(
i) = MCT::one();
832 for(
int k = 0;
k <
j;
k++)
836 if (
a*
a +
b*
b > MCT::zero())
839 prod(
i) = -std::numeric_limits<MagnitudeType>::infinity();
853 if(
sorted(
j,1)!= SCT::zero() && !SCT::isComplex)
868 template <
class ScalarType,
class MV,
class OP,
class DM>
872 if (polyType_ ==
"Arnoldi")
873 ApplyArnoldiPoly(
x, y);
874 else if (polyType_ ==
"Gmres")
875 ApplyGmresPoly(
x, y);
876 else if (polyType_ ==
"Roots")
877 ApplyRootsPoly(
x, y);
881 problem_->applyOp(
x, y );
885 template <
class ScalarType,
class MV,
class OP,
class DM>
888 Teuchos::RCP<MV>
AX = MVT::CloneCopy(
x);
889 Teuchos::RCP<MV>
AX2 = MVT::Clone(
x, MVT::GetNumberVecs(
x) );
892 if (!LP_.is_null()) {
893 Teuchos::RCP<MV>
Xtmp = MVT::Clone(
x, MVT::GetNumberVecs(
x) );
894 problem_->applyLeftPrec( *
AX, *
Xtmp );
899#ifdef BELOS_TEUCHOS_TIME_MONITOR
902 MVT::MvAddMv(DMT::ValueConst(pCoeff_,0,0), *
AX, SCT::zero(), y, y);
904 for(
int i=1;
i < dim_;
i++)
906 Teuchos::RCP<MV>
X, Y;
917 problem_->apply(*
X, *Y);
919#ifdef BELOS_TEUCHOS_TIME_MONITOR
922 MVT::MvAddMv(DMT::ValueConst(pCoeff_,
i,0), *Y, SCT::one(), y, y);
927 if (!RP_.is_null()) {
928 Teuchos::RCP<MV>
Ytmp = MVT::CloneCopy(y);
929 problem_->applyRightPrec( *
Ytmp, y );
933 template <
class ScalarType,
class MV,
class OP,
class DM>
936 MVT::MvInit( y, SCT::zero() );
937 Teuchos::RCP<MV>
prod = MVT::CloneCopy(
x);
938 Teuchos::RCP<MV>
Xtmp = MVT::Clone(
x, MVT::GetNumberVecs(
x) );
939 Teuchos::RCP<MV>
Xtmp2 = MVT::Clone(
x, MVT::GetNumberVecs(
x) );
942 if (!LP_.is_null()) {
943 problem_->applyLeftPrec( *
prod, *
Xtmp );
950 if(theta_(
i,1)== SCT::zero() || SCT::isComplex)
953#ifdef BELOS_TEUCHOS_TIME_MONITOR
956 MVT::MvAddMv(SCT::one(), y, SCT::one()/theta_(
i,0), *
prod, y);
960#ifdef BELOS_TEUCHOS_TIME_MONITOR
963 MVT::MvAddMv(SCT::one(), *
prod, -SCT::one()/theta_(
i,0), *
Xtmp, *
prod);
969 MagnitudeType
mod = theta_(
i,0)*theta_(
i,0) + theta_(
i,1)*theta_(
i,1);
972#ifdef BELOS_TEUCHOS_TIME_MONITOR
975 MVT::MvAddMv(2*theta_(
i,0), *
prod, -SCT::one(), *
Xtmp, *
Xtmp);
976 MVT::MvAddMv(SCT::one(), y, SCT::one()/
mod, *
Xtmp, y);
982#ifdef BELOS_TEUCHOS_TIME_MONITOR
991 if(theta_(dim_-1,1)== SCT::zero() || SCT::isComplex)
993#ifdef BELOS_TEUCHOS_TIME_MONITOR
996 MVT::MvAddMv(SCT::one(), y, SCT::one()/theta_(dim_-1,0), *
prod, y);
1000 if (!RP_.is_null()) {
1001 Teuchos::RCP<MV>
Ytmp = MVT::CloneCopy(y);
1002 problem_->applyRightPrec( *
Ytmp, y );
1006 template <
class ScalarType,
class MV,
class OP,
class DM>
1011 V_ = MVT::Clone(
x, dim_ );
1012 if (!LP_.is_null()) {
1013 wL_ = MVT::Clone( y, 1 );
1015 if (!RP_.is_null()) {
1016 wR_ = MVT::Clone( y, 1 );
1022 int n = MVT::GetNumberVecs(
x );
1026 for (
int j=0;
j<
n; ++
j) {
1030 Teuchos::RCP<const MV>
x_view = MVT::CloneView(
x,
idxj );
1031 Teuchos::RCP<MV>
y_view = MVT::CloneViewNonConst( y,
idxj );
1032 if (!LP_.is_null()) {
1033 Teuchos::RCP<MV>
v_curr = MVT::CloneViewNonConst( *V_,
idxi );
1039 for (
int i=0;
i<dim_-1; ++
i) {
1044 Teuchos::RCP<const MV>
v_prev = MVT::CloneView( *V_,
idxi2 );
1047 Teuchos::RCP<MV>
v_curr = MVT::CloneViewNonConst( *V_,
idxi );
1049 Teuchos::RCP<MV>
v_next = MVT::CloneViewNonConst( *V_,
idxi );
1055 if (!RP_.is_null()) {
1056 problem_->applyRightPrec( *
v_curr, *wR_ );
1061 if (LP_.is_null()) {
1065 problem_->applyOp( *wR_, *wL_ );
1067 if (!LP_.is_null()) {
1068 problem_->applyLeftPrec( *wL_, *
v_next );
1073 auto h = DMT::SubviewConst(H_,
i+1,1,0,
i);
1075#ifdef BELOS_TEUCHOS_TIME_MONITOR
1078 MVT::MvTimesMatAddMv( -SCT::one(), *
v_prev, *
h, SCT::one(), *
v_next );
1082 MVT::MvScale( *
v_next, SCT::one()/DMT::ValueConst(H_,
i+1,
i) );
1086 if (!RP_.is_null()) {
1088#ifdef BELOS_TEUCHOS_TIME_MONITOR
1091 MVT::MvTimesMatAddMv( SCT::one()/DMT::ValueConst(r0_, 0, 0), *V_, y_, SCT::zero(), *wR_ );
1093 problem_->applyRightPrec( *wR_, *
y_view );
1096#ifdef BELOS_TEUCHOS_TIME_MONITOR
1099 MVT::MvTimesMatAddMv( SCT::one()/DMT::ValueConst(r0_, 0, 0), *V_, y_, SCT::zero(), *
y_view );
Belos concrete class for performing the block GMRES iteration.
Belos header file which uses auto-configuration information to include necessary C++ headers.
Pure virtual base class which augments the basic interface for a Gmres linear solver iteration.
Class which describes the linear problem to be solved by the iterative solver.
Interface for multivectors used by Belos' linear solvers.
Declaration of basic traits for the multivector type.
Alternative run-time polymorphic interface for operators.
Class which defines basic traits for the operator type.
Class which manages the output and verbosity of the Belos solvers.
Belos::StatusTest for logically combining several status tests.
Belos::StatusTestResNorm for specifying general residual norm stopping criteria.
Belos::StatusTest class for specifying a maximum number of iterations.
A factory class for generating StatusTestOutput objects.
Collection of types and exceptions used within the Belos solvers.
Parent class to all Belos exceptions.
GmresIterationOrthoFailure is thrown when the GmresIteration object is unable to compute independent ...
void MvNorm(std::vector< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > &normvec, NormType type=TwoNorm) const
Compute the norm of each vector in *this.
GmresPolyMv(const Teuchos::RCP< const MV > &mv_in)
void MvInit(const ScalarType alpha)
Replace each element of the vectors in *this with alpha.
GmresPolyMv * CloneCopy(const std::vector< int > &index) const
Creates a new Belos::MultiVec and copies the selected contents of *this into the new multivector (dee...
GmresPolyMv * CloneViewNonConst(const std::vector< int > &index)
Creates a new Belos::MultiVec that shares the selected contents of *this. The index of the numvecs ve...
int GetNumberVecs() const
The number of vectors (i.e., columns) in the multivector.
void SetBlock(const MultiVec< ScalarType, DM > &A, const std::vector< int > &index)
Copy the vectors in A to a set of vectors in *this.
Teuchos::RCP< const MV > getConstMV() const
GmresPolyMv(const Teuchos::RCP< MV > &mv_in)
GmresPolyMv * Clone(const int numvecs) const
Create a new MultiVec with numvecs columns.
void MvScale(const std::vector< ScalarType > &alpha)
Scale each element of the i-th vector in *this with alpha[i].
const GmresPolyMv * CloneView(const std::vector< int > &index) const
Creates a new Belos::MultiVec that shares the selected contents of *this. The index of the numvecs ve...
Teuchos::RCP< MV > getMV()
void MvRandom()
Fill all the vectors in *this with random numbers.
void MvAddMv(const ScalarType alpha, const MultiVec< ScalarType, DM > &A, const ScalarType beta, const MultiVec< ScalarType, DM > &B)
Replace *this with alpha * A + beta * B.
ptrdiff_t GetGlobalLength() const
The number of rows in the multivector.
void MvTransMv(const ScalarType alpha, const MultiVec< ScalarType, DM > &A, DM &B) const
Compute a dense matrix B through the matrix-matrix multiply alpha * A^T * (*this).
void MvScale(const ScalarType alpha)
Scale each element of the vectors in *this with alpha.
GmresPolyMv * CloneCopy() const
Create a new MultiVec and copy contents of *this into it (deep copy).
void MvDot(const MultiVec< ScalarType, DM > &A, std::vector< ScalarType > &b) const
Compute the dot product of each column of *this with the corresponding column of A.
void MvPrint(std::ostream &os) const
Print *this multivector to the os output stream.
void MvTimesMatAddMv(const ScalarType alpha, const MultiVec< ScalarType, DM > &A, const DM &B, const ScalarType beta)
Update *this with alpha * A * B + beta * (*this).
Belos's class for applying the GMRES polynomial operator that is used by the hybrid-GMRES linear solv...
void Apply(const MultiVec< ScalarType, DM > &x, MultiVec< ScalarType, DM > &y, ETrans=NOTRANS) const
This routine casts the MultiVec to GmresPolyMv to retrieve the MV. Then the above apply method is cal...
void setParameters(const Teuchos::RCP< Teuchos::ParameterList > ¶ms_in)
Process the passed in parameters.
void generateArnoldiPoly()
This routine takes the matrix, preconditioner, and vectors from the linear problem as well as the par...
void ApplyPoly(const MV &x, MV &y) const
This routine takes the MV x and applies the polynomial operator phi(OP) to it resulting in the MV y,...
GmresPolyOp(const Teuchos::RCP< LinearProblem< ScalarType, MV, OP, DM > > &problem_in, const Teuchos::RCP< Teuchos::ParameterList > ¶ms_in)
Basic contstructor.
void ApplyRootsPoly(const MV &x, MV &y) const
virtual ~GmresPolyOp()
Destructor.
GmresPolyOp(const Teuchos::RCP< LinearProblem< ScalarType, MV, OP, DM > > &problem_in)
Given no ParameterList, constructor creates no polynomial and only applies the given operator.
void ApplyGmresPoly(const MV &x, MV &y) const
void ApplyArnoldiPoly(const MV &x, MV &y) const
void generateGmresPoly()
This routine takes the matrix, preconditioner, and vectors from the linear problem as well as the par...
GmresPolyOpOrthoFailure is thrown when the orthogonalization manager is unable to generate orthonorma...
GmresPolyOpOrthoFailure(const std::string &what_arg)
Interface for multivectors used by Belos' linear solvers.
Alternative run-time polymorphic interface for operators.
Operator()
Default constructor (does nothing).
A class for extending the status testing capabilities of Belos via logical combinations.
ScaleType convertStringToScaleType(const std::string &scaleType)
Convert the given string to its ScaleType enum value.
NormType
The type of vector norm to compute.
ETrans
Whether to apply the (conjugate) transpose of an operator.
static const double polyTol
Relative residual tolerance for matrix polynomial construction.