10 #ifndef BELOS_GMRESPOLYOP_HPP
11 #define BELOS_GMRESPOLYOP_HPP
47 #ifdef BELOS_TEUCHOS_TIME_MONITOR
49 #endif // BELOS_TEUCHOS_TIME_MONITOR
64 template <
class ScalarType,
class MV>
74 mv_ = Teuchos::rcp_const_cast<MV>( mv_in );
162 template <
class ScalarType,
class MV,
class OP>
175 LP_(problem_in->getLeftPrec()),
176 RP_(problem_in->getRightPrec())
181 #ifdef BELOS_TEUCHOS_TIME_MONITOR
183 #endif // BELOS_TEUCHOS_TIME_MONITOR
191 "Belos::GmresPolyOp: \"Polynomial Type\" must be either \"Arnoldi\", \"Gmres\", or \"Roots\".");
236 void ApplyPoly (
const MV& x, MV& y )
const;
255 #ifdef BELOS_TEUCHOS_TIME_MONITOR
257 #endif // BELOS_TEUCHOS_TIME_MONITOR
320 template <
class ScalarType,
class MV,
class OP>
325 polyType_ = params_in->
get(
"Polynomial Type", polyType_default_);
329 if (params_in->
isParameter(
"Polynomial Tolerance")) {
331 polyTol_ = params_in->
get (
"Polynomial Tolerance",
341 maxDegree_ = params_in->
get(
"Maximum Degree", maxDegree_default_);
346 randomRHS_ = params_in->
get(
"Random RHS", randomRHS_default_);
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");
360 orthoType_ = params_in->
get(
"Orthogonalization",orthoType_default_);
365 label_ = params_in->
get(
"Timer Label", label_default_);
370 outputStream_ = Teuchos::getParameter<Teuchos::RCP<std::ostream> >(*params_in,
"Output Stream");
375 damp_ = params_in->
get(
"Damped Poly", damp_default_);
380 addRoots_ = params_in->
get(
"Add Roots", addRoots_default_);
384 template <
class ScalarType,
class MV,
class OP>
390 std::vector<int> index(1,0);
393 MVT::MvRandom( *V0 );
395 MVT::Assign( *problem_->getRHS(), *V0 );
397 if ( !LP_.is_null() ) {
399 problem_->applyLeftPrec( *Vtemp, *V0);
403 problem_->apply( *Vtemp, *V0);
406 for(
int i=0; i< maxDegree_; i++)
412 problem_->apply( *Vi, *Vip1);
421 MVT::MvTransMv( SCT::one(), *AV, *AV, AVtransAV);
430 while( status && dim_ >= 1)
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);
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);
493 MVT::MvInit( *newX, SCT::zero() );
495 MVT::MvRandom( *newB );
498 MVT::Assign( *(MVT::CloneView(*(problem_->getRHS()), idx)), *newB );
502 newProblem->setInitResVec( newB );
503 newProblem->setLeftPrec( problem_->getLeftPrec() );
504 newProblem->setRightPrec( problem_->getRightPrec() );
505 newProblem->setLabel(polyLabel);
506 newProblem->setProblem();
507 newProblem->setLSIndex( idx );
513 polyList.
set(
"Num Blocks",maxDegree_);
514 polyList.
set(
"Block Size",1);
515 polyList.
set(
"Keep Hessenberg",
true);
521 if (ortho_.is_null()) {
522 params_->set(
"Orthogonalization", orthoType_);
548 if ( !LP_.is_null() )
549 newProblem->applyLeftPrec( *newB, *V_0 );
553 newProblem->apply( *Vtemp, *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_);
569 gmres_iter->initializeGmres(newstate);
573 gmres_iter->iterate();
577 gmres_iter->updateLSQR( gmres_iter->getCurSubspaceDim() );
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"){
610 y_.values(), y_.stride() );
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();
627 ScalarType Hlast = (*gmresState.
H)(dim_,dim_-1);
633 E(dim_-1,0) = SCT::one();
636 HSolver.
setMatrix( Teuchos::rcpFromRef(Htemp));
638 HSolver.
setVectors( Teuchos::rcpFromRef(F), Teuchos::rcpFromRef(E));
645 std::cout <<
"Hsolver factor: info = " << info << std::endl;
647 info = HSolver.
solve();
649 std::cout <<
"Hsolver solve : info = " << info << std::endl;
653 F.scale(Hlast*Hlast);
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);
671 work.resize( lwork );
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;
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_);
703 for(
unsigned int i=0; i<cmplxHRitz.size(); ++i){
704 cmplxHRitz[i] = std::complex<MagnitudeType>( theta_(i,0), theta_(i,1) );
709 std::vector<MagnitudeType> pof (dim_,one);
710 for(
int j=0; j<dim_; ++j) {
711 for(
int i=0; i<dim_; ++i) {
713 pof[j] = std::abs(pof[j]*(one-(cmplxHRitz[j]/cmplxHRitz[i])));
719 std::vector<int> extra (dim_);
721 for(
int i=0; i<dim_; ++i){
722 if (pof[i] > MCT::zero())
727 totalExtra += extra[i];
731 printer_->stream(
Warnings) <<
"Warning: Need to add " << totalExtra <<
" extra roots." << std::endl;}
734 if(addRoots_ && totalExtra>0)
736 theta_.reshape(dim_+totalExtra,2);
742 for(
int i=0; i<dim_; ++i){
743 for(
int j=0; j< extra[i]; ++j){
744 theta_(count,0) = theta_(i,0);
745 theta_(count,1) = theta_(i,1);
746 thetaPert(count,0) = theta_(i,0)+(j+MCT::one())*
MagnitudeType(5e-8);
747 thetaPert(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){
762 SortModLeja(thetaPert,index2);
764 for(
int i=0; i<dim_; ++i)
766 thetaPert(i,0) = theta_(index2[i],0);
767 thetaPert(i,1) = theta_(index2[i],1);
776 template <
class ScalarType,
class MV,
class OP>
782 int dimN = index.size();
783 std::vector<int> newIndex(dimN);
789 for(
int i = 0; i < dimN; i++){
790 absVal(i) = hypot(thetaN(i,0), thetaN(i,1));
792 MagnitudeType * maxPointer = std::max_element(absVal.values(), (absVal.values()+dimN));
793 int maxIndex = int (maxPointer- absVal.values());
796 sorted(0,0) = thetaN(maxIndex,0);
797 sorted(0,1) = thetaN(maxIndex,1);
798 newIndex[0] = index[maxIndex];
802 if(sorted(0,1)!= SCT::zero() && !SCT::isComplex)
804 sorted(1,0) = thetaN(maxIndex,0);
805 sorted(1,1) = -thetaN(maxIndex,1);
806 newIndex[1] = index[maxIndex+1];
819 for(
int i = 0; i < dimN; i++)
821 prod(i) = MCT::one();
822 for(
int k = 0; k < j; k++)
824 a = thetaN(i,0) - sorted(k,0);
825 b = thetaN(i,1) - sorted(k,1);
826 if (a*a + b*b > MCT::zero())
827 prod(i) = prod(i) + log10(hypot(a,b));
829 prod(i) = -std::numeric_limits<MagnitudeType>::infinity();
836 maxPointer = std::max_element(prod.values(), (prod.values()+dimN));
837 maxIndex = int (maxPointer- prod.values());
838 sorted(j,0) = thetaN(maxIndex,0);
839 sorted(j,1) = thetaN(maxIndex,1);
840 newIndex[j] = index[maxIndex];
843 if(sorted(j,1)!= SCT::zero() && !SCT::isComplex)
846 sorted(j,0) = thetaN(maxIndex,0);
847 sorted(j,1) = -thetaN(maxIndex,1);
848 newIndex[j] = index[maxIndex+1];
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>
882 if (!LP_.is_null()) {
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++)
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()) {
919 problem_->applyRightPrec( *Ytmp, y );
923 template <
class ScalarType,
class MV,
class OP>
926 MVT::MvInit( y, SCT::zero() );
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);
948 problem_->apply(*prod, *Xtmp);
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);
960 problem_->apply(*prod, *Xtmp);
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);
970 problem_->apply(*Xtmp, *Xtmp2);
972 #ifdef BELOS_TEUCHOS_TIME_MONITOR
975 MVT::MvAddMv(SCT::one(), *prod, -SCT::one()/mod, *Xtmp2, *prod);
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()) {
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 );
1013 std::vector<int> idxi(1), idxi2, idxj(1);
1016 for (
int j=0; j<n; ++j) {
1022 if (!LP_.is_null()) {
1024 problem_->applyLeftPrec( *x_view, *v_curr );
1026 MVT::SetBlock( *x_view, idxi, *V_ );
1029 for (
int i=0; i<dim_-1; ++i) {
1033 for (
int ii=0; ii<i+1; ++ii) { idxi2[ii] = ii; }
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 );
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 );
ScaleType convertStringToScaleType(const std::string &scaleType)
Convert the given string to its ScaleType enum value.
ScalarType * values() const
GmresPolyMv(const Teuchos::RCP< const MV > &mv_in)
Collection of types and exceptions used within the Belos solvers.
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 TRSM(ESide side, EUplo uplo, ETransp transa, EDiag diag, const OrdinalType &m, const OrdinalType &n, const alpha_type alpha, const A_type *A, const OrdinalType &lda, ScalarType *B, const OrdinalType &ldb) const
Belos's basic output manager for sending information of select verbosity levels to the appropriate ou...
static constexpr bool randomRHS_default_
void MvScale(const std::vector< ScalarType > &alpha)
Scale each element of the i-th vector in *this with alpha[i].
Class which manages the output and verbosity of the Belos solvers.
static void MvDot(const MV &mv, const MV &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 ...
void MvAddMv(const ScalarType alpha, const MultiVec< ScalarType > &A, const ScalarType beta, const MultiVec< ScalarType > &B)
Replace *this with alpha * A + beta * B.
GmresPolyMv * CloneCopy() const
Create a new MultiVec and copy contents of *this into it (deep copy).
void MvScale(const ScalarType alpha)
Scale each element of the vectors in *this with alpha.
Teuchos::RCP< OutputManager< ScalarType > > printer_
static magnitudeType eps()
ptrdiff_t GetGlobalLength() const
The number of rows in the multivector.
static constexpr const char * label_default_
static void MvRandom(MV &mv)
Replace the vectors in mv with random vectors.
This class implements the block GMRES iteration, where a block Krylov subspace is constructed...
Teuchos::RCP< const MV > V
The current Krylov basis.
Teuchos::RCP< MV > getMV()
T & get(ParameterList &l, const std::string &name)
void ApplyGmresPoly(const MV &x, MV &y) const
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
static Teuchos::RCP< const MV > CloneView(const MV &mv, const std::vector< int > &index)
Creates a new const MV that shares the selected contents of mv (shallow copy).
void generateGmresPoly()
This routine takes the matrix, preconditioner, and vectors from the linear problem as well as the par...
MultiVecTraits< ScalarType, MV > MVT
Declaration of basic traits for the multivector type.
void POTRS(const char &UPLO, const OrdinalType &n, const OrdinalType &nrhs, const ScalarType *A, const OrdinalType &lda, ScalarType *B, const OrdinalType &ldb, OrdinalType *info) const
Teuchos::RCP< const Teuchos::SerialDenseMatrix< int, ScalarType > > z
The current right-hand side of the least squares system RY = Z.
An implementation of StatusTestResNorm using a family of residual norms.
Teuchos::RCP< const OP > RP_
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...
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...
MultiVecTraits< ScalarType, MV > MVT
ParameterList & set(std::string const &name, T &&value, std::string const &docString="", RCP< const ParameterEntryValidator > const &validator=null)
void MvRandom()
Fill all the vectors in *this with random numbers.
Structure to contain pointers to GmresIteration state variables.
static constexpr int verbosity_default_
Teuchos::RCP< LinearProblem< ScalarType, MV, OP > > problem_
GmresPolyOp(const Teuchos::RCP< LinearProblem< ScalarType, MV, OP > > &problem_in, const Teuchos::RCP< Teuchos::ParameterList > ¶ms_in)
Basic contstructor.
Belos::StatusTest class for specifying a maximum number of iterations.
static void MvInit(MV &mv, const ScalarType alpha=Teuchos::ScalarTraits< ScalarType >::zero())
Replace each element of the vectors in mv with alpha.
static const double polyTol
Relative residual tolerance for matrix polynomial construction.
static void MvTransMv(const ScalarType alpha, const MV &A, const MV &mv, Teuchos::SerialDenseMatrix< int, ScalarType > &B)
Compute a dense matrix B through the matrix-matrix multiply .
Class which defines basic traits for the operator type.
int GetNumberVecs() const
The number of vectors (i.e., columns) in the multivector.
static int GetNumberVecs(const MV &mv)
Obtain the number of vectors in mv.
Teuchos::RCP< MatOrthoManager< ScalarType, MV, OP > > ortho_
A factory class for generating StatusTestOutput objects.
static constexpr const char * polyType_default_
static void MvAddMv(const ScalarType alpha, const MV &A, const ScalarType beta, const MV &B, MV &mv)
Replace mv with .
Teuchos::ScalarTraits< MagnitudeType > MCT
ETrans
Whether to apply the (conjugate) transpose of an operator.
Traits class which defines basic operations on multivectors.
Belos::StatusTest for logically combining several status tests.
bool isParameter(const std::string &name) const
static void SetBlock(const MV &A, const std::vector< int > &index, MV &mv)
Copy the vectors in A to a set of vectors in mv indicated by the indices given in index...
A Belos::StatusTest class for specifying a maximum number of iterations.
static constexpr int maxDegree_default_
static Teuchos::RCP< MV > CloneViewNonConst(MV &mv, const std::vector< int > &index)
Creates a new MV that shares the selected contents of mv (shallow 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).
static Teuchos::RCP< MV > Clone(const MV &mv, const int numvecs)
Creates a new empty MV containing numvecs columns.
Alternative run-time polymorphic interface for operators.
Teuchos::SerialDenseMatrix< OT, ScalarType > y_
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
int curDim
The current dimension of the reduction.
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 POTRF(const char &UPLO, const OrdinalType &n, ScalarType *A, const OrdinalType &lda, OrdinalType *info) const
Teuchos::RCP< const Teuchos::SerialDenseMatrix< int, ScalarType > > R
The current upper-triangular matrix from the QR reduction of H.
int putScalar(const ScalarType value=Teuchos::ScalarTraits< ScalarType >::zero())
void factorWithEquilibration(bool flag)
void ApplyArnoldiPoly(const MV &x, MV &y) const
void MvNorm(std::vector< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > &normvec, NormType type=TwoNorm) const
Compute the norm of each vector in *this.
void solveWithTransposeFlag(Teuchos::ETransp trans)
A linear system to solve, and its associated information.
Teuchos::RCP< const OP > LP_
Class which describes the linear problem to be solved by the iterative solver.
GmresPolyOpOrthoFailure(const std::string &what_arg)
void SetBlock(const MultiVec< ScalarType > &A, const std::vector< int > &index)
Copy the vectors in A to a set of vectors in *this.
void ApplyRootsPoly(const MV &x, MV &y) const
static Teuchos::RCP< MV > CloneCopy(const MV &mv)
Creates a new MV and copies contents of mv into the new vector (deep copy).
Teuchos::SerialDenseMatrix< OT, MagnitudeType > theta_
Teuchos::RCP< const MV > getConstMV() const
static void MvTimesMatAddMv(const ScalarType alpha, const MV &A, const Teuchos::SerialDenseMatrix< int, ScalarType > &B, const ScalarType beta, MV &mv)
Update mv with .
Belos's class for applying the GMRES polynomial operator that is used by the hybrid-GMRES linear solv...
Teuchos::SerialDenseMatrix< OT, ScalarType > pCoeff_
Belos concrete class for performing the block GMRES iteration.
std::string polyUpdateLabel_
Teuchos::ScalarTraits< ScalarType >::magnitudeType MagnitudeType
OrdinalType numCols() const
Teuchos::ScalarTraits< ScalarType > SCT
static ptrdiff_t GetGlobalLength(const MV &mv)
Return the number of rows in the given multivector mv.
void SortModLeja(Teuchos::SerialDenseMatrix< OT, MagnitudeType > &thetaN, std::vector< int > &index) const
NormType
The type of vector norm to compute.
void MvInit(const ScalarType alpha)
Replace each element of the vectors in *this with alpha.
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 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).
int setVectors(const RCP< SerialDenseMatrix< OrdinalType, ScalarType > > &X, const RCP< SerialDenseMatrix< OrdinalType, ScalarType > > &B)
Alternative run-time polymorphic interface for operators.
virtual ~GmresPolyOp()
Destructor.
void GEEV(const char &JOBVL, const char &JOBVR, const OrdinalType &n, ScalarType *A, const OrdinalType &lda, MagnitudeType *WR, MagnitudeType *WI, ScalarType *VL, const OrdinalType &ldvl, ScalarType *VR, const OrdinalType &ldvr, ScalarType *WORK, const OrdinalType &lwork, MagnitudeType *RWORK, OrdinalType *info) const
Teuchos::RCP< Teuchos::ParameterList > params_
static constexpr bool damp_default_
GmresPolyMv * Clone(const int numvecs) const
Create a new MultiVec with numvecs columns.
Belos::StatusTestResNorm for specifying general residual norm stopping criteria.
Belos::StatusTest for specifying an implicit residual norm stopping criteria that checks for loss of ...
bool isType(const std::string &name) const
A class for extending the status testing capabilities of Belos via logical combinations.
Interface for multivectors used by Belos' linear solvers.
GmresPolyOp(const Teuchos::RCP< LinearProblem< ScalarType, MV, OP > > &problem_in)
Given no ParameterList, constructor creates no polynomial and only applies the given operator...
static void MvNorm(const MV &mv, std::vector< typename Teuchos::ScalarTraits< ScalarType >::magnitudeType > &normvec, NormType type=TwoNorm)
Compute the norm of each individual vector of mv. Upon return, normvec[i] holds the value of ...
void generateArnoldiPoly()
This routine takes the matrix, preconditioner, and vectors from the linear problem as well as the par...
static void MvScale(MV &mv, const ScalarType alpha)
Scale each element of the vectors in mv with alpha.
Parent class to all Belos exceptions.
int shape(OrdinalType numRows, OrdinalType numCols)
static constexpr bool addRoots_default_
Pure virtual base class which augments the basic interface for a Gmres linear solver iteration...
GmresIterationOrthoFailure is thrown when the GmresIteration object is unable to compute independent ...
Belos header file which uses auto-configuration information to include necessary C++ headers...
static void MvPrint(const MV &mv, std::ostream &os)
Print the mv multi-vector to the os output stream.
static constexpr const char * orthoType_default_
GmresPolyOpOrthoFailure is thrown when the orthogonalization manager is unable to generate orthonorma...
void MvPrint(std::ostream &os) const
Print *this multivector to the os output stream.
Teuchos::SerialDenseMatrix< OT, ScalarType > H_
OrdinalType stride() const
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...
Teuchos::RCP< std::ostream > outputStream_
Teuchos::SerialDenseVector< OT, ScalarType > r0_
void setParameters(const Teuchos::RCP< Teuchos::ParameterList > ¶ms_in)
Process the passed in parameters.
OrdinalType numRows() const
int setMatrix(const RCP< SerialDenseMatrix< OrdinalType, ScalarType > > &A)
Interface for multivectors used by Belos' linear solvers.
GmresPolyMv(const Teuchos::RCP< MV > &mv_in)
Teuchos::RCP< const Teuchos::SerialDenseMatrix< int, ScalarType > > H
The current Hessenberg matrix.
Teuchos::RCP< Belos::MatOrthoManager< Scalar, MV, OP > > makeMatOrthoManager(const std::string &ortho, const Teuchos::RCP< const OP > &M, const Teuchos::RCP< OutputManager< Scalar > > &, const std::string &label, const Teuchos::RCP< Teuchos::ParameterList > ¶ms)
Return an instance of the specified MatOrthoManager subclass.