Go to the documentation of this file.
44 #ifndef BELOS_LSQR_STATUS_TEST_HPP
45 #define BELOS_LSQR_STATUS_TEST_HPP
64 template <
class ScalarType,
class MV,
class OP>
70 typedef Teuchos::ScalarTraits<ScalarType>
SCT;
84 int term_iter_max = 1,
114 rcondMin_ = (condMax > 0) ? (Teuchos::ScalarTraits< MagnitudeType >::one() / condMax) : Teuchos::ScalarTraits< MagnitudeType >::eps();
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>
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>
271 const MagnitudeType MTzero = Teuchos::ScalarTraits<MagnitudeType>::zero();
272 const MagnitudeType MTone = Teuchos::ScalarTraits<MagnitudeType>::one();
273 if (condMax_ > MTzero )
275 rcondMin_ = MTone / condMax_;
279 rcondMin_ = Teuchos::ScalarTraits< MagnitudeType >::eps();
282 bool termIterFlag =
false;
284 TEUCHOS_ASSERT(solver != NULL);
305 std::cout <<
" X " << state.
sol_norm
314 const MagnitudeType zero = Teuchos::ScalarTraits<MagnitudeType>::zero();
315 const ScalarType one = Teuchos::ScalarTraits<ScalarType>::one();
316 ScalarType stop_crit_1 = zero;
317 if( state.
bnorm > zero )
321 ScalarType stop_crit_2 = zero;
339 ScalarType resid_tol_mach = Teuchos::ScalarTraits< MagnitudeType >::eps() + Teuchos::ScalarTraits< MagnitudeType >::eps() * state.
frob_mat_norm * state.
sol_norm / state.
bnorm;
356 if (stop_crit_1 <= resid_tol || stop_crit_2 <= rel_mat_err_ || stop_crit_3 <= rcondMin_ || stop_crit_1 <= resid_tol_mach || stop_crit_2 <= Teuchos::ScalarTraits< MagnitudeType >::eps() || stop_crit_3 <= Teuchos::ScalarTraits< MagnitudeType >::eps()) {
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;
368 if (stop_crit_2 <= Teuchos::ScalarTraits< MagnitudeType >::eps() )
369 std::cout <<
"Conv: stop_crit_2 " << stop_crit_2 <<
" eps " << Teuchos::ScalarTraits< MagnitudeType >::eps() << std::endl;
371 if (stop_crit_3 <= rcondMin_ )
372 std::cout <<
"Conv: stop_crit_3 " << stop_crit_3 <<
" rcondMin_ " << rcondMin_ << std::endl;
374 if (stop_crit_3 <= Teuchos::ScalarTraits< MagnitudeType >::eps() )
375 std::cout <<
"Conv: stop_crit_3 " << stop_crit_3 <<
" eps " << Teuchos::ScalarTraits< MagnitudeType >::eps() << 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(
' ');
int setRelRhsErr(MagnitudeType rel_rhs_err)
Teuchos::ScalarTraits< ScalarType > SCT
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.
ScalarType mat_cond_num
An approximation to the condition number of A.
MagnitudeType getMatNorm() const
Returns the value of the observed (Frobenius) norm of A.
int setTermIterMax(int term_iter_max)
ScalarType resid_norm
The current residual norm.
ScalarType frob_mat_norm
An approximation to the Frobenius norm of A.
SCT::magnitudeType MagnitudeType
Belos concrete class that iterates LSQR.
std::string description() const
Method to return description of the maximum iteration status test
Belos::StatusType getStatus() const
Return the result of the most recent CheckStatus call.
ScalarType sol_norm
An estimate of the norm of the solution.
ScalarType mat_resid_norm
An estimate of the norm of A^T*resid.
StatusType
Whether the StatusTest wants iteration to stop.
MagnitudeType getRelRhsErr() const
Returns the value of the estimate of the relative error in the data defining b set in the constructor...
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.
int setCondLim(MagnitudeType condMax)
Set the tolerances.
Belos::StatusType checkStatus(Belos::Iteration< ScalarType, MV, OP > *iSolver)
Check convergence status of the iterative solver: Unconverged, Converged, Failed.
Belos::MultiVecTraits< ScalarType, MV > MVT
LSQRStatusTest(MagnitudeType condMax=0.0, int term_iter_max=1, MagnitudeType rel_rhs_err=0.0, MagnitudeType rel_mat_err=0.0)
Constructor.
MagnitudeType getLSResidNorm() const
Returns the value of the observed norm of the Least Squares residual A^T r.
Structure to contain pointers to LSQRIteration state variables, ...
A pure virtual class for defining the status tests for the Belos iterative solvers.
void reset()
Resets the status test to the initial internal state.
virtual ~LSQRStatusTest()
Destructor.
int setRelMatErr(MagnitudeType rel_mat_err)
MagnitudeType getMatCondNum() const
Returns the value of the observed condition number of Abar.
ScalarType bnorm
The norm of the RHS vector b.
MagnitudeType getMatErr() const
Returns the value of the estimate of the relative error in the data defining A set in the constructor...
void print(std::ostream &os, int indent=0) const
Output formatted description of stopping test to output stream.
MagnitudeType getCondMaxLim() const
Returns the value of the upper limit of the condition number of Abar set in the constructor.
int getTermIter() const
!Returns the current number of successful iterations from the most recent StatusTest call.
Traits class which defines basic operations on multivectors.
Implementation of the LSQR iteration.
LSQRIterationState< ScalarType, MV > getState() const
Get the current state of the linear solver.
void printStatus(std::ostream &os, Belos::StatusType type) const
Print message for each status specific to this stopping test.
Generated on Thu Feb 27 2020 16:06:46 for Belos by
1.8.16