12#ifndef BELOS_LSQR_STATUS_TEST_HPP
13#define BELOS_LSQR_STATUS_TEST_HPP
33template <
class ScalarType,
class MV,
class OP,
class DM = Belos::DefaultDenseMatrix<
int, ScalarType>>
39 typedef Teuchos::ScalarTraits<ScalarType>
SCT;
83 rcondMin_ = (
condMax > 0) ? (Teuchos::ScalarTraits< MagnitudeType >::one() /
condMax) : Teuchos::ScalarTraits< MagnitudeType >::eps();
88 if (term_iter_max_ < 1)
159 std::ostringstream
oss;
160 oss <<
"LSQRStatusTest<>: [ limit of condition number = " << condMax_ <<
" ]";
208template <
class ScalarType,
class MV,
class OP,
class DM>
227template <
class ScalarType,
class MV,
class OP,
class DM>
231template <
class ScalarType,
class MV,
class OP,
class DM>
237template <
class ScalarType,
class MV,
class OP,
class DM>
244 rcondMin_ =
MTone / condMax_;
248 rcondMin_ = Teuchos::ScalarTraits< MagnitudeType >::eps();
274 std::cout <<
" X " <<
state.sol_norm
275 <<
" b-AX " <<
state.resid_norm
276 <<
" Atr " <<
state.mat_resid_norm
277 <<
" A " <<
state.frob_mat_norm
278 <<
" cond " <<
state.mat_cond_num
279 <<
" relResNorm " <<
state.resid_norm/
state.bnorm
280 <<
" LS " <<
state.mat_resid_norm /(
state.resid_norm *
state.frob_mat_norm )
284 const ScalarType one = Teuchos::ScalarTraits<ScalarType>::one();
335 std::cout <<
"Conv: stop_crit_2 " <<
stop_crit_2 <<
" rel_mat_err " << rel_mat_err_ << std::endl;
337 if (
stop_crit_2 <= Teuchos::ScalarTraits< MagnitudeType >::eps() )
338 std::cout <<
"Conv: stop_crit_2 " <<
stop_crit_2 <<
" eps " << Teuchos::ScalarTraits< MagnitudeType >::eps() << std::endl;
341 std::cout <<
"Conv: stop_crit_3 " <<
stop_crit_3 <<
" rcondMin_ " << rcondMin_ << std::endl;
343 if (
stop_crit_3 <= Teuchos::ScalarTraits< MagnitudeType >::eps() )
344 std::cout <<
"Conv: stop_crit_3 " <<
stop_crit_3 <<
" eps " << Teuchos::ScalarTraits< MagnitudeType >::eps() << std::endl;
355 matCondNum_ =
state.mat_cond_num;
356 matNorm_ =
state.frob_mat_norm;
357 resNorm_ =
state.resid_norm;
358 matResNorm_ =
state.mat_resid_norm;
363template <
class ScalarType,
class MV,
class OP,
class DM>
368 printStatus(
os, status_);
369 os <<
"limit of condition number = " << condMax_ << std::endl;
370 os <<
"limit of condition number = " << condMax_ << std::endl;
373template <
class ScalarType,
class MV,
class OP,
class DM>
376 os << std::left << std::setw(13) << std::setfill(
'.');
389 os << std::left << std::setfill(
' ');
Belos concrete class that iterates LSQR.
Pure virtual base class for defining the status testing capabilities of Belos.
Collection of types and exceptions used within the Belos solvers.
A Belos::StatusTest class for specifying convergence of LSQR. The outer status tests passes if an inn...
MagnitudeType getResidNorm() const
Returns the value of the observed norm of the residual r = b-Ax.
Teuchos::ScalarTraits< ScalarType > SCT
Belos::MultiVecTraits< ScalarType, MV, DM > MVT
virtual ~LSQRStatusTest()
Destructor.
MagnitudeType getLSResidNorm() const
Returns the value of the observed norm of the Least Squares residual A^T r.
SCT::magnitudeType MagnitudeType
int setRelRhsErr(MagnitudeType rel_rhs_err)
Belos::StatusType firstCallCheckStatusSetup(Belos::Iteration< ScalarType, MV, OP, DM > *iSolver)
Called in checkStatus exactly once, on the first call to checkStatus.
void printStatus(std::ostream &os, Belos::StatusType type) const
Print message for each status specific to this stopping test.
std::string description() const
Method to return description of the maximum iteration status test
void reset()
Resets the status test to the initial internal state.
int getTermIterMax() const
Returns the number of successful convergent iterations required set in the constructor.
int getTermIter() const
!Returns the current number of successful iterations from the most recent StatusTest call.
Belos::StatusType getStatus() const
Return the result of the most recent CheckStatus call.
MagnitudeType getRelRhsErr() const
Returns the value of the estimate of the relative error in the data defining b set in the constructor...
MagnitudeType getMatNorm() const
Returns the value of the observed (Frobenius) norm of A.
int setRelMatErr(MagnitudeType rel_mat_err)
LSQRStatusTest(MagnitudeType condMax=0.0, int term_iter_max=1, MagnitudeType rel_rhs_err=0.0, MagnitudeType rel_mat_err=0.0)
Constructor.
Belos::StatusType checkStatus(Belos::Iteration< ScalarType, MV, OP, DM > *iSolver)
Check convergence status of the iterative solver: Unconverged, Converged, Failed.
MagnitudeType getMatCondNum() const
Returns the value of the observed condition number of Abar.
MagnitudeType getMatErr() const
Returns the value of the estimate of the relative error in the data defining A set in the constructor...
int setTermIterMax(int term_iter_max)
MagnitudeType getCondMaxLim() const
Returns the value of the upper limit of the condition number of Abar set in the constructor.
void print(std::ostream &os, int indent=0) const
Output formatted description of stopping test to output stream.
int setCondLim(MagnitudeType condMax)
Set the tolerances.
Alternative run-time polymorphic interface for operators.
Operator()
Default constructor (does nothing).
A pure virtual class for defining the status tests for the Belos iterative solvers.
StatusType
Whether the StatusTest wants iteration to stop.