12 #ifndef BELOS_LSQR_STATUS_TEST_HPP
13 #define BELOS_LSQR_STATUS_TEST_HPP
32 template <
class ScalarType,
class MV,
class OP>
52 int term_iter_max = 1,
137 void print(std::ostream& os,
int indent = 0)
const;
158 std::ostringstream oss;
159 oss <<
"LSQRStatusTest<>: [ limit of condition number = " <<
condMax_ <<
" ]";
207 template <
class ScalarType,
class MV,
class OP>
214 term_iter_max_ (term_iter_max),
215 rel_rhs_err_ (rel_rhs_err),
216 rel_mat_err_ (rel_mat_err),
226 template <
class ScalarType,
class MV,
class OP>
230 template <
class ScalarType,
class MV,
class OP>
236 template <
class ScalarType,
class MV,
class OP>
241 if (condMax_ > MTzero )
243 rcondMin_ = MTone / condMax_;
250 bool termIterFlag =
false;
273 std::cout <<
" X " << state.
sol_norm
284 ScalarType stop_crit_1 = zero;
285 if( state.
bnorm > zero )
289 ScalarType stop_crit_2 = zero;
327 if (stop_crit_1 <= resid_tol )
328 std::cout <<
"Conv: stop_crit_1 " << stop_crit_1 <<
" resid_tol " << resid_tol << std::endl;
330 if (stop_crit_1 <= resid_tol_mach )
331 std::cout <<
"Conv: stop_crit_1 " << stop_crit_1 <<
" resid_tol_mach " << resid_tol_mach << std::endl;
333 if (stop_crit_2 <= rel_mat_err_ )
334 std::cout <<
"Conv: stop_crit_2 " << stop_crit_2 <<
" rel_mat_err " << rel_mat_err_ << std::endl;
339 if (stop_crit_3 <= rcondMin_ )
340 std::cout <<
"Conv: stop_crit_3 " << stop_crit_3 <<
" rcondMin_ " << rcondMin_ << std::endl;
362 template <
class ScalarType,
class MV,
class OP>
365 for (
int j = 0; j < indent; j++)
367 printStatus(os, status_);
368 os <<
"limit of condition number = " << condMax_ << std::endl;
369 os <<
"limit of condition number = " << condMax_ << std::endl;
372 template <
class ScalarType,
class MV,
class OP>
375 os << std::left << std::setw(13) << std::setfill(
'.');
388 os << std::left << std::setfill(
' ');
Belos::StatusType checkStatus(Belos::Iteration< ScalarType, MV, OP > *iSolver)
Check convergence status of the iterative solver: Unconverged, Converged, Failed. ...
Teuchos::ScalarTraits< ScalarType > SCT
void print(std::ostream &os, int indent=0) const
Output formatted description of stopping test to output stream.
Belos concrete class that iterates LSQR.
MagnitudeType getMatCondNum() const
Returns the value of the observed condition number of Abar.
MagnitudeType rcondMin_
One of the tolerances defining convergence, the reciprocal of condMax_ or, if that is zero...
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)
ScalarType resid_norm
The current residual norm.
static magnitudeType eps()
MagnitudeType getResidNorm() const
Returns the value of the observed norm of the residual r = b-Ax.
int term_iter_max_
How many iterations in a row a passing test for convergence is required.
Pure virtual base class for defining the status testing capabilities of Belos.
MagnitudeType getMatNorm() const
Returns the value of the observed (Frobenius) norm of A.
MagnitudeType condMax_
Upper limit of condition number of Abar.
ScalarType sol_norm
An estimate of the norm of the solution.
void printStatus(std::ostream &os, Belos::StatusType type) const
Print message for each status specific to this stopping test.
ScalarType mat_cond_num
An approximation to the condition number of A.
A pure virtual class for defining the status tests for the Belos iterative solvers.
StatusType
Whether the StatusTest wants iteration to stop.
std::string description() const
Method to return description of the maximum iteration status test.
MagnitudeType matResNorm_
Traits class which defines basic operations on multivectors.
Belos::StatusType getStatus() const
Return the result of the most recent CheckStatus call.
ScalarType frob_mat_norm
An approximation to the Frobenius norm of A.
A Belos::StatusTest class for specifying convergence of LSQR. The outer status tests passes if an inn...
SCT::magnitudeType MagnitudeType
MagnitudeType rel_mat_err_
Error in data defining A.
ScalarType mat_resid_norm
An estimate of the norm of A^T*resid.
LSQRStatusTest(MagnitudeType condMax=0.0, int term_iter_max=1, MagnitudeType rel_rhs_err=0.0, MagnitudeType rel_mat_err=0.0)
Constructor.
Belos::MultiVecTraits< ScalarType, MV > MVT
Belos::StatusType firstCallCheckStatusSetup(Belos::Iteration< ScalarType, MV, OP > *iSolver)
Called in checkStatus exactly once, on the first call to checkStatus.
void reset()
Resets the status test to the initial internal state.
int setCondLim(MagnitudeType condMax)
Set the tolerances.
MagnitudeType getRelRhsErr() const
Returns the value of the estimate of the relative error in the data defining b set in the constructor...
int getTermIter() const
!Returns the current number of successful iterations from the most recent StatusTest call...
MagnitudeType matCondNum_
MagnitudeType rel_rhs_err_
Error in data defining b.
int getTermIterMax() const
Returns the number of successful convergent iterations required set in the constructor.
int setRelMatErr(MagnitudeType rel_mat_err)
Belos::StatusType status_
Status.
MagnitudeType getCondMaxLim() const
Returns the value of the upper limit of the condition number of Abar set in the constructor.
LSQRIterationState< ScalarType, MV > getState() const
Get the current state of the linear solver.
Implementation of the LSQR iteration.
ScalarType bnorm
The norm of the RHS vector b.
#define TEUCHOS_ASSERT(assertion_test)
int setRelRhsErr(MagnitudeType rel_rhs_err)
virtual ~LSQRStatusTest()
Destructor.
Structure to contain pointers to LSQRIteration state variables, ...
MagnitudeType getLSResidNorm() const
Returns the value of the observed norm of the Least Squares residual A^T r.