44 #ifndef BELOS_LSQR_STATUS_TEST_HPP
45 #define BELOS_LSQR_STATUS_TEST_HPP
64 template <
class ScalarType,
class MV,
class OP>
84 int term_iter_max = 1,
169 void print(std::ostream& os,
int indent = 0)
const;
190 std::ostringstream oss;
191 oss <<
"LSQRStatusTest<>: [ limit of condition number = " <<
condMax_ <<
" ]";
239 template <
class ScalarType,
class MV,
class OP>
246 term_iter_max_ (term_iter_max),
247 rel_rhs_err_ (rel_rhs_err),
248 rel_mat_err_ (rel_mat_err),
258 template <
class ScalarType,
class MV,
class OP>
262 template <
class ScalarType,
class MV,
class OP>
268 template <
class ScalarType,
class MV,
class OP>
273 if (condMax_ > MTzero )
275 rcondMin_ = MTone / condMax_;
282 bool termIterFlag =
false;
305 std::cout <<
" X " << state.
sol_norm
316 ScalarType stop_crit_1 = zero;
317 if( state.
bnorm > zero )
321 ScalarType stop_crit_2 = zero;
359 if (stop_crit_1 <= resid_tol )
360 std::cout <<
"Conv: stop_crit_1 " << stop_crit_1 <<
" resid_tol " << resid_tol << std::endl;
362 if (stop_crit_1 <= resid_tol_mach )
363 std::cout <<
"Conv: stop_crit_1 " << stop_crit_1 <<
" resid_tol_mach " << resid_tol_mach << std::endl;
365 if (stop_crit_2 <= rel_mat_err_ )
366 std::cout <<
"Conv: stop_crit_2 " << stop_crit_2 <<
" rel_mat_err " << rel_mat_err_ << std::endl;
371 if (stop_crit_3 <= rcondMin_ )
372 std::cout <<
"Conv: stop_crit_3 " << stop_crit_3 <<
" rcondMin_ " << rcondMin_ << std::endl;
394 template <
class ScalarType,
class MV,
class OP>
397 for (
int j = 0; j < indent; j++)
399 printStatus(os, status_);
400 os <<
"limit of condition number = " << condMax_ << std::endl;
401 os <<
"limit of condition number = " << condMax_ << std::endl;
404 template <
class ScalarType,
class MV,
class OP>
407 os << std::left << std::setw(13) << std::setfill(
'.');
420 os << std::left << std::setfill(
' ');
Teuchos::ScalarTraits< ScalarType > SCT
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.
void printStatus(std::ostream &os, Belos::StatusType type) const
Print message for each status specific to this stopping test.
static magnitudeType eps()
void print(std::ostream &os, int indent=0) const
Output formatted description of stopping test to output stream.
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.
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.
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.
Belos::StatusType checkStatus(Belos::Iteration< ScalarType, MV, OP > *iSolver)
Check convergence status of the iterative solver: Unconverged, Converged, Failed. ...
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.
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.
LSQRStatusTest(MagnitudeType condMax=0.0, int term_iter_max=1, MagnitudeType rel_rhs_err=0.0, MagnitudeType rel_mat_err=0.0)
Constructor.
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.
void reset()
Resets the status test to the initial internal state.
ScalarType bnorm
The norm of the RHS vector b.
virtual ~LSQRStatusTest()
Destructor.
#define TEUCHOS_ASSERT(assertion_test)
int setRelRhsErr(MagnitudeType rel_rhs_err)
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.