12#ifndef BELOS_LSQR_STATUS_TEST_HPP
13#define BELOS_LSQR_STATUS_TEST_HPP
32template <
class ScalarType,
class MV,
class OP>
38 typedef Teuchos::ScalarTraits<ScalarType>
SCT;
82 rcondMin_ = (
condMax > 0) ? (Teuchos::ScalarTraits< MagnitudeType >::one() /
condMax) : Teuchos::ScalarTraits< MagnitudeType >::eps();
87 if (term_iter_max_ < 1)
158 std::ostringstream
oss;
159 oss <<
"LSQRStatusTest<>: [ limit of condition number = " << condMax_ <<
" ]";
207template <
class ScalarType,
class MV,
class OP>
226template <
class ScalarType,
class MV,
class OP>
230template <
class ScalarType,
class MV,
class OP>
236template <
class ScalarType,
class MV,
class OP>
243 rcondMin_ =
MTone / condMax_;
247 rcondMin_ = Teuchos::ScalarTraits< MagnitudeType >::eps();
273 std::cout <<
" X " <<
state.sol_norm
274 <<
" b-AX " <<
state.resid_norm
275 <<
" Atr " <<
state.mat_resid_norm
276 <<
" A " <<
state.frob_mat_norm
277 <<
" cond " <<
state.mat_cond_num
278 <<
" relResNorm " <<
state.resid_norm/
state.bnorm
279 <<
" LS " <<
state.mat_resid_norm /(
state.resid_norm *
state.frob_mat_norm )
283 const ScalarType one = Teuchos::ScalarTraits<ScalarType>::one();
334 std::cout <<
"Conv: stop_crit_2 " <<
stop_crit_2 <<
" rel_mat_err " << rel_mat_err_ << std::endl;
336 if (
stop_crit_2 <= Teuchos::ScalarTraits< MagnitudeType >::eps() )
337 std::cout <<
"Conv: stop_crit_2 " <<
stop_crit_2 <<
" eps " << Teuchos::ScalarTraits< MagnitudeType >::eps() << std::endl;
340 std::cout <<
"Conv: stop_crit_3 " <<
stop_crit_3 <<
" rcondMin_ " << rcondMin_ << std::endl;
342 if (
stop_crit_3 <= Teuchos::ScalarTraits< MagnitudeType >::eps() )
343 std::cout <<
"Conv: stop_crit_3 " <<
stop_crit_3 <<
" eps " << Teuchos::ScalarTraits< MagnitudeType >::eps() << std::endl;
354 matCondNum_ =
state.mat_cond_num;
355 matNorm_ =
state.frob_mat_norm;
356 resNorm_ =
state.resid_norm;
357 matResNorm_ =
state.mat_resid_norm;
362template <
class ScalarType,
class MV,
class OP>
367 printStatus(
os, status_);
368 os <<
"limit of condition number = " << condMax_ << std::endl;
369 os <<
"limit of condition number = " << condMax_ << std::endl;
372template <
class ScalarType,
class MV,
class OP>
375 os << std::left << std::setw(13) << std::setfill(
'.');
388 os << std::left << std::setfill(
' ');
Belos concrete class that iterates LSQR.
Pure virtual base class for defining the status testing capabilities of Belos.
A Belos::StatusTest class for specifying convergence of LSQR. The outer status tests passes if an inn...
int setRelMatErr(MagnitudeType rel_mat_err)
int setRelRhsErr(MagnitudeType rel_rhs_err)
void printStatus(std::ostream &os, Belos::StatusType type) const
Print message for each status specific to this stopping test.
Belos::MultiVecTraits< ScalarType, MV > MVT
virtual ~LSQRStatusTest()
Destructor.
void reset()
Resets the status test to the initial internal state.
Teuchos::ScalarTraits< ScalarType > SCT
int getTermIter() const
!Returns the current number of successful iterations from the most recent StatusTest call.
MagnitudeType getMatNorm() const
Returns the value of the observed (Frobenius) norm of A.
int setCondLim(MagnitudeType condMax)
Set the tolerances.
void print(std::ostream &os, int indent=0) const
Output formatted description of stopping test to output stream.
Belos::StatusType firstCallCheckStatusSetup(Belos::Iteration< ScalarType, MV, OP > *iSolver)
Called in checkStatus exactly once, on the first call to checkStatus.
int getTermIterMax() const
Returns the number of successful convergent iterations required set in the constructor.
MagnitudeType getMatErr() const
Returns the value of the estimate of the relative error in the data defining A set in the constructor...
SCT::magnitudeType MagnitudeType
MagnitudeType getResidNorm() const
Returns the value of the observed norm of the residual r = b-Ax.
MagnitudeType getCondMaxLim() const
Returns the value of the upper limit of the condition number of Abar set in the constructor.
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...
Belos::StatusType checkStatus(Belos::Iteration< ScalarType, MV, OP > *iSolver)
Check convergence status of the iterative solver: Unconverged, Converged, Failed.
MagnitudeType getLSResidNorm() const
Returns the value of the observed norm of the Least Squares residual A^T r.
int setTermIterMax(int term_iter_max)
std::string description() const
Method to return description of the maximum iteration status test
LSQRStatusTest(MagnitudeType condMax=0.0, int term_iter_max=1, MagnitudeType rel_rhs_err=0.0, MagnitudeType rel_mat_err=0.0)
Constructor.
MagnitudeType getMatCondNum() const
Returns the value of the observed condition number of Abar.
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.