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>
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_; }
108 const Teuchos::SerialDenseMatrix<int,ScalarType>& B,
const ScalarType beta)
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>
171 const Teuchos::RCP<Teuchos::ParameterList>&
params_in
180 polyUpdateLabel_ = label_ +
": Hybrid Gmres: Vector Update";
181#ifdef BELOS_TEUCHOS_TIME_MONITOR
185 if (polyType_ ==
"Arnoldi" || polyType_==
"Roots")
187 else if (polyType_ ==
"Gmres")
191 "Belos::GmresPolyOp: \"Polynomial Type\" must be either \"Arnoldi\", \"Gmres\", or \"Roots\".");
255#ifdef BELOS_TEUCHOS_TIME_MONITOR
258 std::string polyUpdateLabel_;
262 typedef Teuchos::ScalarTraits<ScalarType> SCT ;
263 typedef typename Teuchos::ScalarTraits<ScalarType>::magnitudeType MagnitudeType;
264 typedef Teuchos::ScalarTraits<MagnitudeType> MCT ;
267 static constexpr int maxDegree_default_ = 25;
269 static constexpr bool randomRHS_default_ =
true;
270 static constexpr const char * label_default_ =
"Belos";
271 static constexpr const char * polyType_default_ =
"Roots";
272 static constexpr const char * orthoType_default_ =
"DGKS";
273 static constexpr bool damp_default_ =
false;
274 static constexpr bool addRoots_default_ =
true;
277 Teuchos::RCP<LinearProblem<ScalarType,MV,OP> > problem_;
278 Teuchos::RCP<Teuchos::ParameterList> params_;
279 Teuchos::RCP<const OP> LP_, RP_;
282 Teuchos::RCP<OutputManager<ScalarType> > printer_;
283 Teuchos::RCP<std::ostream> outputStream_ = Teuchos::rcpFromRef(std::cout);
286 Teuchos::RCP<MatOrthoManager<ScalarType,MV,OP> > ortho_;
290 int maxDegree_ = maxDegree_default_;
291 int verbosity_ = verbosity_default_;
292 bool randomRHS_ = randomRHS_default_;
293 std::string label_ = label_default_;
294 std::string polyType_ = polyType_default_;
295 std::string orthoType_ = orthoType_default_;
297 bool damp_ = damp_default_;
298 bool addRoots_ = addRoots_default_;
301 mutable Teuchos::RCP<MV> V_, wL_, wR_;
302 Teuchos::SerialDenseMatrix<OT,ScalarType> H_, y_;
303 Teuchos::SerialDenseVector<OT,ScalarType> r0_;
306 bool autoDeg =
false;
307 Teuchos::SerialDenseMatrix< OT, ScalarType > pCoeff_;
310 Teuchos::SerialDenseMatrix< OT, MagnitudeType > theta_;
314 void SortModLeja(Teuchos::SerialDenseMatrix< OT, MagnitudeType > &
thetaN, std::vector<int> &index)
const ;
317 void ComputeAddedRoots();
320 template <
class ScalarType,
class MV,
class OP>
324 if (
params_in->isParameter(
"Polynomial Type")) {
325 polyType_ =
params_in->get(
"Polynomial Type", polyType_default_);
329 if (
params_in->isParameter(
"Polynomial Tolerance")) {
330 if (
params_in->isType<MagnitudeType> (
"Polynomial Tolerance")) {
331 polyTol_ =
params_in->get (
"Polynomial Tolerance",
340 if (
params_in->isParameter(
"Maximum Degree")) {
341 maxDegree_ =
params_in->get(
"Maximum Degree", maxDegree_default_);
345 if (
params_in->isParameter(
"Random RHS")) {
346 randomRHS_ =
params_in->get(
"Random RHS", randomRHS_default_);
350 if (
params_in->isParameter(
"Verbosity")) {
351 if (Teuchos::isParameterType<int>(*
params_in,
"Verbosity")) {
352 verbosity_ =
params_in->get(
"Verbosity", verbosity_default_);
355 verbosity_ = (
int)Teuchos::getParameter<Belos::MsgType>(*
params_in,
"Verbosity");
359 if (
params_in->isParameter(
"Orthogonalization")) {
360 orthoType_ =
params_in->get(
"Orthogonalization",orthoType_default_);
364 if (
params_in->isParameter(
"Timer Label")) {
365 label_ =
params_in->get(
"Timer Label", label_default_);
369 if (
params_in->isParameter(
"Output Stream")) {
370 outputStream_ = Teuchos::getParameter<Teuchos::RCP<std::ostream> >(*
params_in,
"Output Stream");
374 if (
params_in->isParameter(
"Damped Poly")) {
375 damp_ =
params_in->get(
"Damped Poly", damp_default_);
379 if (
params_in->isParameter(
"Add Roots")) {
380 addRoots_ =
params_in->get(
"Add Roots", addRoots_default_);
384 template <
class ScalarType,
class MV,
class OP>
387 Teuchos::RCP< MV > V = MVT::Clone( *problem_->getRHS(), maxDegree_+1 );
390 std::vector<int> index(1,0);
391 Teuchos::RCP< MV >
V0 = MVT::CloneViewNonConst(*V, index);
393 MVT::MvRandom( *
V0 );
395 MVT::Assign( *problem_->getRHS(), *
V0 );
397 if ( !LP_.is_null() ) {
398 Teuchos::RCP< MV >
Vtemp = MVT::CloneCopy(*
V0);
399 problem_->applyLeftPrec( *
Vtemp, *
V0);
402 Teuchos::RCP< MV >
Vtemp = MVT::CloneCopy(*
V0);
406 for(
int i=0;
i< maxDegree_;
i++)
409 Teuchos::RCP< const MV >
Vi = MVT::CloneView(*V, index);
411 Teuchos::RCP< MV >
Vip1 = MVT::CloneViewNonConst(*V, index);
412 problem_->apply( *
Vi, *
Vip1);
416 Teuchos::Range1D
range( 1, maxDegree_);
417 Teuchos::RCP< const MV >
AV = MVT::CloneView( *V,
range);
420 Teuchos::SerialDenseMatrix< OT, ScalarType >
AVtransAV( maxDegree_, maxDegree_);
424 Teuchos::LAPACK< OT, ScalarType > lapack;
429 Teuchos::SerialDenseMatrix< OT, ScalarType >
lhs;
430 while(
status && dim_ >= 1)
432 Teuchos::SerialDenseMatrix< OT, ScalarType >
lhstemp(Teuchos::Copy,
AVtransAV, dim_, dim_);
440 std::cout <<
"BelosGmresPolyOp.hpp: LAPACK POTRF was not successful!!" << std::endl;
441 std::cout <<
"Error code: " <<
infoInt << std::endl;
462 pCoeff_.shape( 1, 1);
463 pCoeff_(0,0) = SCT::one();
464 std::cout <<
"Poly Degree is zero. No preconditioner created." << std::endl;
468 pCoeff_.shape( dim_, 1);
470 Teuchos::Range1D
rangeSub( 1, dim_);
471 Teuchos::RCP< const MV >
AVsub = MVT::CloneView( *V,
rangeSub);
474 MVT::MvTransMv( SCT::one(), *
AVsub, *
V0, pCoeff_);
475 lapack.POTRS(
'U', dim_, 1,
lhs.values(),
lhs.stride(), pCoeff_.values(), pCoeff_.stride(), &
infoInt);
478 std::cout <<
"BelosGmresPolyOp.hpp: LAPACK POTRS was not successful!!" << std::endl;
479 std::cout <<
"Error code: " <<
infoInt << std::endl;
484 template <
class ScalarType,
class MV,
class OP>
487 std::string
polyLabel = label_ +
": GmresPolyOp creation";
490 std::vector<int>
idx(1,0);
491 Teuchos::RCP<MV>
newX = MVT::Clone( *(problem_->getLHS()), 1 );
492 Teuchos::RCP<MV>
newB = MVT::Clone( *(problem_->getRHS()), 1 );
493 MVT::MvInit( *
newX, SCT::zero() );
495 MVT::MvRandom( *
newB );
498 MVT::Assign( *(MVT::CloneView(*(problem_->getRHS()),
idx)), *
newB );
500 Teuchos::RCP<LinearProblem<ScalarType,MV,OP> >
newProblem =
503 newProblem->setLeftPrec( problem_->getLeftPrec() );
504 newProblem->setRightPrec( problem_->getRightPrec() );
513 polyList.set(
"Num Blocks",maxDegree_);
515 polyList.set(
"Keep Hessenberg",
true);
521 if (ortho_.is_null()) {
522 params_->set(
"Orthogonalization", orthoType_);
530 Teuchos::RCP<StatusTestMaxIters<ScalarType,MV,OP> >
maxItrTst =
534 Teuchos::RCP<StatusTestGenResNorm<ScalarType,MV,OP> >
convTst =
539 Teuchos::RCP<StatusTestCombo<ScalarType,MV,OP> >
polyTest =
543 Teuchos::RCP<BlockGmresIter<ScalarType,MV,OP> >
gmres_iter;
547 Teuchos::RCP<MV>
V_0 = MVT::CloneCopy( *
newB );
548 if ( !LP_.is_null() )
552 Teuchos::RCP< MV >
Vtemp = MVT::CloneCopy(*
V_0);
560 int rank = ortho_->normalize( *
V_0, Teuchos::rcpFromRef(r0_) );
562 "Belos::GmresPolyOp::generateArnoldiPoly(): Failed to compute initial block of orthonormal vectors for polynomial generation.");
567 newstate.z = Teuchos::rcpFromRef( r0_);
579 catch (std::exception&
e) {
581 printer_->stream(
Errors) <<
"Error! Caught exception in BlockGmresIter::iterate() at iteration "
582 <<
gmres_iter->getNumIters() << endl <<
e.what () << endl;
597 if(polyType_ ==
"Arnoldi"){
600 y_ = Teuchos::SerialDenseMatrix<OT,ScalarType>( Teuchos::Copy, *
gmresState.z, dim_, 1 );
606 Teuchos::BLAS<OT,ScalarType>
blas;
607 blas.TRSM( Teuchos::LEFT_SIDE, Teuchos::UPPER_TRI, Teuchos::NO_TRANS,
608 Teuchos::NON_UNIT_DIAG, dim_, 1, SCT::one(),
610 y_.values(), y_.stride() );
616 H_ = Teuchos::SerialDenseMatrix<OT,ScalarType>(Teuchos::Copy, *
gmresState.H, dim_, dim_);
618 for(
int i=0;
i <= dim_-3;
i++) {
619 for(
int k=
i+2;
k <= dim_-1;
k++) {
620 H_(
k,
i) = SCT::zero();
624 Teuchos::SerialDenseMatrix<OT,ScalarType>
Htemp (Teuchos::Copy, H_, dim_, dim_);
628 Teuchos::SerialDenseMatrix<OT,ScalarType>
HlastCol (Teuchos::View, H_, dim_, 1, 0, dim_-1);
631 Teuchos::SerialDenseMatrix< OT, ScalarType >
F(dim_,1),
E(dim_,1);
632 E.putScalar(SCT::zero());
633 E(dim_-1,0) = SCT::one();
635 Teuchos::SerialDenseSolver< OT, ScalarType >
HSolver;
637 HSolver.solveWithTransposeFlag( Teuchos::CONJ_TRANS );
638 HSolver.setVectors( Teuchos::rcpFromRef(
F), Teuchos::rcpFromRef(
E));
639 HSolver.factorWithEquilibration(
true );
645 std::cout <<
"Hsolver factor: info = " <<
info << std::endl;
649 std::cout <<
"Hsolver solve : info = " <<
info << std::endl;
657 Teuchos::LAPACK< OT, ScalarType > lapack;
658 theta_.shape(dim_,2);
665 std::vector<ScalarType>
work(1);
666 std::vector<MagnitudeType>
rwork(2*dim_);
669 lapack.GEEV(
'N',
'N',dim_,H_.values(),H_.stride(),theta_[0],theta_[1],
vlr,
ldv,
vlr,
ldv, &
work[0],
lwork, &
rwork[0], &
info);
670 lwork = std::abs (
static_cast<int> (Teuchos::ScalarTraits<ScalarType>::real (
work[0])));
673 lapack.GEEV(
'N',
'N',dim_,H_.values(),H_.stride(),theta_[0],theta_[1],
vlr,
ldv,
vlr,
ldv, &
work[0],
lwork, &
rwork[0], &
info);
676 std::cout <<
"GEEV solve : info = " <<
info << std::endl;
681 const MagnitudeType
tol = 10.0 * Teuchos::ScalarTraits<MagnitudeType>::eps();
682 std::vector<int> index(dim_);
683 for(
int i=0;
i<dim_; ++
i){
686 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.");
688 SortModLeja(theta_,index);
697 template <
class ScalarType,
class MV,
class OP>
702 std::vector<std::complex<MagnitudeType>>
cmplxHRitz (dim_);
704 cmplxHRitz[
i] = std::complex<MagnitudeType>( theta_(
i,0), theta_(
i,1) );
708 const MagnitudeType
one(1.0);
709 std::vector<MagnitudeType>
pof (dim_,
one);
710 for(
int j=0;
j<dim_; ++
j) {
711 for(
int i=0;
i<dim_; ++
i) {
719 std::vector<int>
extra (dim_);
721 for(
int i=0;
i<dim_; ++
i){
722 if (
pof[
i] > MCT::zero())
731 printer_->stream(
Warnings) <<
"Warning: Need to add " <<
totalExtra <<
" extra roots." << std::endl;}
738 Teuchos::SerialDenseMatrix<OT,MagnitudeType>
thetaPert (Teuchos::Copy, theta_, dim_+
totalExtra, 2);
742 for(
int i=0;
i<dim_; ++
i){
744 theta_(
count,0) = theta_(
i,0);
745 theta_(
count,1) = theta_(
i,1);
755 printer_->stream(
Warnings) <<
"New poly degree is: " << dim_ << std::endl;}
758 std::vector<int>
index2(dim_);
759 for(
int i=0;
i<dim_; ++
i){
764 for(
int i=0;
i<dim_; ++
i)
776 template <
class ScalarType,
class MV,
class OP>
777 void GmresPolyOp<ScalarType, MV, OP>::SortModLeja(Teuchos::SerialDenseMatrix< OT, MagnitudeType > &thetaN, std::vector<int> &index)
const
782 int dimN = index.size();
784 Teuchos::SerialDenseMatrix< OT, MagnitudeType >
sorted (
thetaN.numRows(),
thetaN.numCols());
785 Teuchos::SerialDenseVector< OT, MagnitudeType >
absVal (
thetaN.numRows());
786 Teuchos::SerialDenseVector< OT, MagnitudeType >
prod (
thetaN.numRows());
802 if(
sorted(0,1)!= SCT::zero() && !SCT::isComplex)
821 prod(
i) = MCT::one();
822 for(
int k = 0;
k <
j;
k++)
826 if (
a*
a +
b*
b > MCT::zero())
829 prod(
i) = -std::numeric_limits<MagnitudeType>::infinity();
843 if(
sorted(
j,1)!= SCT::zero() && !SCT::isComplex)
858 template <
class ScalarType,
class MV,
class OP>
862 if (polyType_ ==
"Arnoldi")
863 ApplyArnoldiPoly(
x, y);
864 else if (polyType_ ==
"Gmres")
865 ApplyGmresPoly(
x, y);
866 else if (polyType_ ==
"Roots")
867 ApplyRootsPoly(
x, y);
871 problem_->applyOp(
x, y );
875 template <
class ScalarType,
class MV,
class OP>
878 Teuchos::RCP<MV>
AX = MVT::CloneCopy(
x);
879 Teuchos::RCP<MV>
AX2 = MVT::Clone(
x, MVT::GetNumberVecs(
x) );
882 if (!LP_.is_null()) {
883 Teuchos::RCP<MV>
Xtmp = MVT::Clone(
x, MVT::GetNumberVecs(
x) );
884 problem_->applyLeftPrec( *
AX, *
Xtmp );
889#ifdef BELOS_TEUCHOS_TIME_MONITOR
892 MVT::MvAddMv(pCoeff_(0,0), *
AX, SCT::zero(), y, y);
894 for(
int i=1;
i < dim_;
i++)
896 Teuchos::RCP<MV>
X, Y;
907 problem_->apply(*
X, *Y);
909#ifdef BELOS_TEUCHOS_TIME_MONITOR
912 MVT::MvAddMv(pCoeff_(
i,0), *Y, SCT::one(), y, y);
917 if (!RP_.is_null()) {
918 Teuchos::RCP<MV>
Ytmp = MVT::CloneCopy(y);
919 problem_->applyRightPrec( *
Ytmp, y );
923 template <
class ScalarType,
class MV,
class OP>
926 MVT::MvInit( y, SCT::zero() );
927 Teuchos::RCP<MV>
prod = MVT::CloneCopy(
x);
928 Teuchos::RCP<MV>
Xtmp = MVT::Clone(
x, MVT::GetNumberVecs(
x) );
929 Teuchos::RCP<MV>
Xtmp2 = MVT::Clone(
x, MVT::GetNumberVecs(
x) );
932 if (!LP_.is_null()) {
933 problem_->applyLeftPrec( *
prod, *
Xtmp );
940 if(theta_(
i,1)== SCT::zero() || SCT::isComplex)
943#ifdef BELOS_TEUCHOS_TIME_MONITOR
946 MVT::MvAddMv(SCT::one(), y, SCT::one()/theta_(
i,0), *
prod, y);
950#ifdef BELOS_TEUCHOS_TIME_MONITOR
953 MVT::MvAddMv(SCT::one(), *
prod, -SCT::one()/theta_(
i,0), *
Xtmp, *
prod);
959 MagnitudeType
mod = theta_(
i,0)*theta_(
i,0) + theta_(
i,1)*theta_(
i,1);
962#ifdef BELOS_TEUCHOS_TIME_MONITOR
965 MVT::MvAddMv(2*theta_(
i,0), *
prod, -SCT::one(), *
Xtmp, *
Xtmp);
966 MVT::MvAddMv(SCT::one(), y, SCT::one()/
mod, *
Xtmp, y);
972#ifdef BELOS_TEUCHOS_TIME_MONITOR
981 if(theta_(dim_-1,1)== SCT::zero() || SCT::isComplex)
983#ifdef BELOS_TEUCHOS_TIME_MONITOR
986 MVT::MvAddMv(SCT::one(), y, SCT::one()/theta_(dim_-1,0), *
prod, y);
990 if (!RP_.is_null()) {
991 Teuchos::RCP<MV>
Ytmp = MVT::CloneCopy(y);
992 problem_->applyRightPrec( *
Ytmp, y );
996 template <
class ScalarType,
class MV,
class OP>
1001 V_ = MVT::Clone(
x, dim_ );
1002 if (!LP_.is_null()) {
1003 wL_ = MVT::Clone( y, 1 );
1005 if (!RP_.is_null()) {
1006 wR_ = MVT::Clone( y, 1 );
1012 int n = MVT::GetNumberVecs(
x );
1016 for (
int j=0;
j<
n; ++
j) {
1020 Teuchos::RCP<const MV>
x_view = MVT::CloneView(
x,
idxj );
1021 Teuchos::RCP<MV>
y_view = MVT::CloneViewNonConst( y,
idxj );
1022 if (!LP_.is_null()) {
1023 Teuchos::RCP<MV>
v_curr = MVT::CloneViewNonConst( *V_,
idxi );
1029 for (
int i=0;
i<dim_-1; ++
i) {
1034 Teuchos::RCP<const MV>
v_prev = MVT::CloneView( *V_,
idxi2 );
1037 Teuchos::RCP<MV>
v_curr = MVT::CloneViewNonConst( *V_,
idxi );
1039 Teuchos::RCP<MV>
v_next = MVT::CloneViewNonConst( *V_,
idxi );
1045 if (!RP_.is_null()) {
1046 problem_->applyRightPrec( *
v_curr, *wR_ );
1051 if (LP_.is_null()) {
1055 problem_->applyOp( *wR_, *wL_ );
1057 if (!LP_.is_null()) {
1058 problem_->applyLeftPrec( *wL_, *
v_next );
1062 Teuchos::SerialDenseMatrix<OT,ScalarType>
h(Teuchos::View,H_,
i+1,1,0,
i);
1064#ifdef BELOS_TEUCHOS_TIME_MONITOR
1067 MVT::MvTimesMatAddMv( -SCT::one(), *
v_prev,
h, SCT::one(), *
v_next );
1071 MVT::MvScale( *
v_next, SCT::one()/H_(
i+1,
i) );
1075 if (!RP_.is_null()) {
1077#ifdef BELOS_TEUCHOS_TIME_MONITOR
1080 MVT::MvTimesMatAddMv( SCT::one()/r0_(0), *V_, y_, SCT::zero(), *wR_ );
1082 problem_->applyRightPrec( *wR_, *
y_view );
1085#ifdef BELOS_TEUCHOS_TIME_MONITOR
1088 MVT::MvTimesMatAddMv( SCT::one()/r0_(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.
Declaration of basic traits for the multivector type.
Interface for multivectors used by Belos' linear solvers.
Class which defines basic traits for the operator type.
Alternative run-time polymorphic interface for operators.
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 for specifying an implicit residual norm stopping criteria that checks for loss of ...
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 ...
int GetNumberVecs() const
The number of vectors (i.e., columns) in the multivector.
void MvDot(const MultiVec< ScalarType > &A, std::vector< ScalarType > &b) const
Compute the dot product of each column of *this with the corresponding column of A.
void MvScale(const ScalarType alpha)
Scale each element of the vectors in *this with alpha.
void MvAddMv(const ScalarType alpha, const MultiVec< ScalarType > &A, const ScalarType beta, const MultiVec< ScalarType > &B)
Replace *this with alpha * A + beta * B.
Teuchos::RCP< const MV > getConstMV() const
void MvPrint(std::ostream &os) const
Print *this multivector to the os output stream.
void MvScale(const std::vector< ScalarType > &alpha)
Scale each element of the i-th vector in *this with alpha[i].
void MvRandom()
Fill all the vectors in *this with random numbers.
void SetBlock(const MultiVec< ScalarType > &A, const std::vector< int > &index)
Copy the vectors in A to a set of vectors in *this.
GmresPolyMv(const Teuchos::RCP< const MV > &mv_in)
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...
ptrdiff_t GetGlobalLength() const
The number of rows in the multivector.
GmresPolyMv(const Teuchos::RCP< MV > &mv_in)
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...
void MvNorm(std::vector< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > &normvec, NormType type=TwoNorm) const
Compute the norm of each vector in *this.
Teuchos::RCP< MV > getMV()
void MvTransMv(const ScalarType alpha, const MultiVec< ScalarType > &A, Teuchos::SerialDenseMatrix< int, ScalarType > &B) const
Compute a dense matrix B through the matrix-matrix multiply alpha * A^T * (*this).
GmresPolyMv * Clone(const int numvecs) const
Create a new MultiVec with numvecs columns.
GmresPolyMv * CloneCopy() const
Create a new MultiVec and copy contents of *this into it (deep copy).
void MvTimesMatAddMv(const ScalarType alpha, const MultiVec< ScalarType > &A, const Teuchos::SerialDenseMatrix< int, ScalarType > &B, const ScalarType beta)
Update *this with alpha * A * B + beta * (*this).
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...
void MvInit(const ScalarType alpha)
Replace each element of the vectors in *this with alpha.
GmresPolyOpOrthoFailure is thrown when the orthogonalization manager is unable to generate orthonorma...
GmresPolyOpOrthoFailure(const std::string &what_arg)
Belos's class for applying the GMRES polynomial operator that is used by the hybrid-GMRES linear solv...
void setParameters(const Teuchos::RCP< Teuchos::ParameterList > ¶ms_in)
Process the passed in parameters.
void ApplyRootsPoly(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...
GmresPolyOp(const Teuchos::RCP< LinearProblem< ScalarType, MV, OP > > &problem_in)
Given no ParameterList, constructor creates no polynomial and only applies the given operator.
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,...
void ApplyGmresPoly(const MV &x, MV &y) const
void generateArnoldiPoly()
This routine takes the matrix, preconditioner, and vectors from the linear problem as well as the par...
void ApplyArnoldiPoly(const MV &x, MV &y) const
virtual ~GmresPolyOp()
Destructor.
void Apply(const MultiVec< ScalarType > &x, MultiVec< ScalarType > &y, ETrans=NOTRANS) const
This routine casts the MultiVec to GmresPolyMv to retrieve the MV. Then the above apply method is cal...
GmresPolyOp(const Teuchos::RCP< LinearProblem< ScalarType, MV, OP > > &problem_in, const Teuchos::RCP< Teuchos::ParameterList > ¶ms_in)
Basic contstructor.
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.