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,
118 term_iter_max_ = term_iter_max;
119 if (term_iter_max_ < 1)
124 rel_rhs_err_ = rel_rhs_err;
128 rel_mat_err_ = rel_mat_err;
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>
242 term_iter_max_ (term_iter_max),
243 rel_rhs_err_ (rel_rhs_err),
244 rel_mat_err_ (rel_mat_err),
253 template <
class ScalarType,
class MV,
class OP>
257 template <
class ScalarType,
class MV,
class OP>
263 template <
class ScalarType,
class MV,
class OP>
268 if (condMax_ > MTzero )
270 rcondMin_ = MTone / condMax_;
277 bool termIterFlag =
false;
299 std::cout <<
" X " << state.sol_norm
300 <<
" b-AX " << state.resid_norm
301 <<
" Atr " << state.mat_resid_norm
302 <<
" A " << state.frob_mat_norm
303 <<
" cond " << state.mat_cond_num
304 <<
" relResNorm " << state.resid_norm/state.bnorm
305 <<
" LS " << state.mat_resid_norm /( state.resid_norm * state.frob_mat_norm )
310 ScalarType stop_crit_1 = zero;
311 if( state.bnorm > zero )
313 stop_crit_1 = state.resid_norm / state.bnorm;
315 ScalarType stop_crit_2 = zero;
316 if( state.frob_mat_norm > zero && state.resid_norm > zero )
318 stop_crit_2 = (state.resid_norm > zero) ? state.mat_resid_norm / (state.frob_mat_norm * state.resid_norm) : zero;
322 if( state.resid_norm == zero )
331 ScalarType stop_crit_3 = one / state.mat_cond_num;
332 ScalarType resid_tol = rel_rhs_err_ + rel_mat_err_ * state.frob_mat_norm * state.sol_norm / state.bnorm;
353 if (stop_crit_1 <= resid_tol )
354 std::cout <<
"Conv: stop_crit_1 " << stop_crit_1 <<
" resid_tol " << resid_tol << std::endl;
356 if (stop_crit_1 <= resid_tol_mach )
357 std::cout <<
"Conv: stop_crit_1 " << stop_crit_1 <<
" resid_tol_mach " << resid_tol_mach << std::endl;
359 if (stop_crit_2 <= rel_mat_err_ )
360 std::cout <<
"Conv: stop_crit_2 " << stop_crit_2 <<
" rel_mat_err " << rel_mat_err_ << std::endl;
365 if (stop_crit_3 <= rcondMin_ )
366 std::cout <<
"Conv: stop_crit_3 " << stop_crit_3 <<
" rcondMin_ " << rcondMin_ << std::endl;
380 matCondNum_ = state.mat_cond_num;
381 matNorm_ = state.frob_mat_norm;
382 resNorm_ = state.resid_norm;
383 matResNorm_ = state.mat_resid_norm;
388 template <
class ScalarType,
class MV,
class OP>
391 for (
int j = 0; j < indent; j++)
393 printStatus(os, status_);
394 os <<
"limit of condition number = " << condMax_ << std::endl;
395 os <<
"limit of condition number = " << condMax_ << std::endl;
398 template <
class ScalarType,
class MV,
class OP>
401 os << std::left << std::setw(13) << std::setfill(
'.');
414 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 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)
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.
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.
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.
Traits class which defines basic operations on multivectors.
Belos::StatusType getStatus() const
Return the result of the most recent CheckStatus call.
SCT::magnitudeType MagnitudeType
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...
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)
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.
virtual ~LSQRStatusTest()
Destructor.
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.