Belos Package Browser (Single Doxygen Collection) Development
Public Types
Belos::StatusTestImpResNorm< ScalarType, MV, OP > Class Template Reference

An implementation of StatusTest using an implicit residual norm test with a check for loss of accuracy. More...

#include <BelosStatusTestImpResNorm.hpp>

Inheritance diagram for Belos::StatusTestImpResNorm< ScalarType, MV, OP >:
Inheritance graph
[legend]

List of all members.

Public Types

typedef Teuchos::ScalarTraits
< ScalarType > 
SCT
typedef SCT::magnitudeType MagnitudeType
typedef MultiVecTraits
< ScalarType, MV > 
MVT

Constructors/destructors.

 StatusTestImpResNorm (MagnitudeType Tolerance, int quorum=-1, bool showMaxResNormOnly=false)
 Constructor.
virtual ~StatusTestImpResNorm ()
 Destructor.

Form and parameter definition methods.

int defineResForm (NormType TypeOfNorm)
 Define form of the residual, its norm and optional weighting vector.
int defineScaleForm (ScaleType TypeOfScaling, NormType TypeOfNorm, MagnitudeType ScaleValue=Teuchos::ScalarTraits< MagnitudeType >::one())
 Define form of the scaling, its norm, its optional weighting vector, or, alternatively, define an explicit value.
int setTolerance (MagnitudeType tolerance)
 Set the value of the tolerance.
int setQuorum (int quorum)
 Sets the number of residuals that must pass the convergence test before Passed is returned.
int setShowMaxResNormOnly (bool showMaxResNormOnly)
 Set whether the only maximum residual norm is displayed when the print() method is called.

Status methods

StatusType checkStatus (Iteration< ScalarType, MV, OP > *iSolver)
 Check convergence status: Passed, Failed, or Undefined.
StatusType getStatus () const
 Return the result of the most recent CheckStatus call.

Reset methods

void reset ()
 Resets the internal configuration to the initial state.

Print methods

void print (std::ostream &os, int indent=0) const
 Output formatted description of stopping test to output stream.
void printStatus (std::ostream &os, StatusType type) const
 Print message for each status specific to this stopping test.

Methods to access data members.

Teuchos::RCP< MV > getSolution ()
 Returns the current solution estimate that was computed for the most recent residual test.
int getQuorum () const
 Returns the number of residuals that must pass the convergence test before Passed is returned.
bool getShowMaxResNormOnly ()
 Returns whether the only maximum residual norm is displayed when the print() method is called.
std::vector< int > convIndices ()
 Returns the vector containing the indices of the residuals that passed the test.
MagnitudeType getTolerance () const
 ! Returns the value of the tolerance, $ \tau $, set in the constructor.
MagnitudeType getCurrTolerance () const
 Returns the current value of the tolerance which may be modified if there is a loss of accuracy.
const std::vector
< MagnitudeType > * 
getTestValue () const
 Returns the test value, $ \frac{\|r\|}{\sigma} $, computed in most recent call to CheckStatus.
const std::vector
< MagnitudeType > * 
getResNormValue () const
 Returns the residual norm value, $ \|r\| $, computed in most recent call to CheckStatus.
const std::vector
< MagnitudeType > * 
getScaledNormValue () const
 Returns the scaled norm value, $ \sigma $.
bool getLOADetected () const
 Returns a boolean indicating a loss of accuracy has been detected in computing the residual.

Misc.

StatusType firstCallCheckStatusSetup (Iteration< ScalarType, MV, OP > *iSolver)
 Call to setup initial scaling vector.

Overridden from Teuchos::Describable

std::string description () const
 Method to return description of the maximum iteration status test.

Private methods.

std::string resFormStr () const
 Description of current residual form.

Private data members.

MagnitudeType tolerance_
 Current tolerance used to determine convergence and the default tolerance set by user.
MagnitudeType currTolerance_
int quorum_
 Number of residuals that must pass the convergence test before Passed is returned.
bool showMaxResNormOnly_
 Determines if the entries for all of the residuals are shown or just the max.
NormType resnormtype_
 Type of norm to use on residual (OneNorm, TwoNorm, or InfNorm).
ScaleType scaletype_
 Type of scaling to use (Norm of RHS, Norm of Initial Residual, None or User provided)
NormType scalenormtype_
 Type of norm to use on the scaling (OneNorm, TwoNorm, or InfNorm)
MagnitudeType scalevalue_
 Scaling value.
std::vector< MagnitudeTypescalevector_
 Scaling vector.
std::vector< MagnitudeTyperesvector_
 Residual norm vector.
std::vector< MagnitudeTypetestvector_
 Test vector = resvector_ / scalevector_.
Teuchos::RCP< MV > curSoln_
 Current solution vector.
std::vector< int > ind_
 Vector containing the indices for the vectors that passed the test.
StatusType status_
 Status.
int curBlksz_
 The current blocksize of the linear system being solved.
int curNumRHS_
 The current number of right-hand sides being solved for.
std::vector< int > curLSIdx_
 The indices of the current number of right-hand sides being solved for.
int curLSNum_
 The current number of linear systems that have been loaded into the linear problem.
int numrhs_
 The total number of right-hand sides being solved for.
bool firstcallCheckStatus_
 Is this the first time CheckStatus is called?
bool firstcallDefineResForm_
 Is this the first time DefineResForm is called?
bool firstcallDefineScaleForm_
 Is this the first time DefineScaleForm is called?
bool lossDetected_
 Has a loss in accuracy been detected?

Detailed Description

template<class ScalarType, class MV, class OP>
class Belos::StatusTestImpResNorm< ScalarType, MV, OP >

An implementation of StatusTest using an implicit residual norm test with a check for loss of accuracy.

The form of the test is

\[ \frac{\|r_i\|}{\sigma_i} \le \tau \]

where

Definition at line 78 of file BelosStatusTestImpResNorm.hpp.


Member Typedef Documentation

template<class ScalarType , class MV , class OP >
typedef Teuchos::ScalarTraits<ScalarType> Belos::StatusTestImpResNorm< ScalarType, MV, OP >::SCT

Reimplemented from Belos::StatusTestResNorm< ScalarType, MV, OP >.

Definition at line 83 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
typedef SCT::magnitudeType Belos::StatusTestImpResNorm< ScalarType, MV, OP >::MagnitudeType

Reimplemented from Belos::StatusTestResNorm< ScalarType, MV, OP >.

Definition at line 84 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
typedef MultiVecTraits<ScalarType,MV> Belos::StatusTestImpResNorm< ScalarType, MV, OP >::MVT

Reimplemented from Belos::StatusTestResNorm< ScalarType, MV, OP >.

Definition at line 85 of file BelosStatusTestImpResNorm.hpp.


Constructor & Destructor Documentation

template<class ScalarType , class MV , class OP >
Belos::StatusTestImpResNorm< ScalarType, MV, OP >::StatusTestImpResNorm ( MagnitudeType  Tolerance,
int  quorum = -1,
bool  showMaxResNormOnly = false 
)

Constructor.

The constructor takes a single argument specifying the tolerance ( $\tau$). If none of the form definition methods are called, we use $\|r\|_2/\|r^{(0)}\|_2 \le \tau$ as the stopping criterion, where $\|r\|_2$ uses the least costly form of the 2-norm of residual available from the iterative method and $\|r^{(0)}\|_2$ is the corresponding norm of the initial residual. The least costly form of the 2-norm depends on the chosen iterative method. Most Krylov methods produce the preconditioned residual vector in a form that would be exact in infinite precision arithmetic. This vector may be different from the true residual either because left scaling or preconditioning was used, or because round-off error has introduced significant error, or both.

You can also state the number of vectors that must pass the convergence criteria before the status test passes by using the quorum argument.

Definition at line 356 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
Belos::StatusTestImpResNorm< ScalarType, MV, OP >::~StatusTestImpResNorm ( ) [virtual]

Destructor.

Definition at line 379 of file BelosStatusTestImpResNorm.hpp.


Member Function Documentation

template<class ScalarType , class MV , class OP >
int Belos::StatusTestImpResNorm< ScalarType, MV, OP >::defineResForm ( NormType  TypeOfNorm)

Define form of the residual, its norm and optional weighting vector.

This method defines the form of $\|r\|$. We specify:

  • The norm to be used on the residual (this may be different than the norm used in DefineScaleForm()).

Definition at line 398 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
int Belos::StatusTestImpResNorm< ScalarType, MV, OP >::defineScaleForm ( ScaleType  TypeOfScaling,
NormType  TypeOfNorm,
MagnitudeType  ScaleValue = Teuchos::ScalarTraits<MagnitudeType>::one() 
) [virtual]

Define form of the scaling, its norm, its optional weighting vector, or, alternatively, define an explicit value.

This method defines the form of how the residual is scaled (if at all). It operates in two modes:

  1. User-provided scaling value:

    • Set argument TypeOfScaling to UserProvided.
    • Set ScaleValue to a non-zero value that the residual norm will be divided by.
    • TypeOfNorm argument will be ignored.
    • Sample use: Define ScaleValue = $\|A\|_{\infty}$ where $ A $ is the matrix of the linear problem.

  2. Use a supported Scaling Form:
    • Define TypeOfScaling to be the norm of the right hand side, the initial residual vector, or to none.
    • Define norm to be used on the scaling vector (this may be different than the norm used in DefineResForm()).

Implements Belos::StatusTestResNorm< ScalarType, MV, OP >.

Definition at line 410 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
int Belos::StatusTestImpResNorm< ScalarType, MV, OP >::setTolerance ( MagnitudeType  tolerance) [inline, virtual]

Set the value of the tolerance.

We allow the tolerance to be reset for cases where, in the process of testing the residual, we find that the initial tolerance was too tight or too lax.

Implements Belos::StatusTestResNorm< ScalarType, MV, OP >.

Definition at line 148 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
int Belos::StatusTestImpResNorm< ScalarType, MV, OP >::setQuorum ( int  quorum) [inline, virtual]

Sets the number of residuals that must pass the convergence test before Passed is returned.

Note:
If quorum=-1 then all residuals must pass the convergence test before Passed is returned.

Implements Belos::StatusTestResNorm< ScalarType, MV, OP >.

Definition at line 152 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
int Belos::StatusTestImpResNorm< ScalarType, MV, OP >::setShowMaxResNormOnly ( bool  showMaxResNormOnly) [inline, virtual]

Set whether the only maximum residual norm is displayed when the print() method is called.

Implements Belos::StatusTestResNorm< ScalarType, MV, OP >.

Definition at line 155 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
StatusType Belos::StatusTestImpResNorm< ScalarType, MV, OP >::checkStatus ( Iteration< ScalarType, MV, OP > *  iSolver) [virtual]

Check convergence status: Passed, Failed, or Undefined.

This method checks to see if the convergence criteria are met. Depending on how the residual test is constructed this method will return the appropriate status type.

Returns:
StatusType: Passed, Failed, or Undefined.

Implements Belos::StatusTest< ScalarType, MV, OP >.

Definition at line 425 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
StatusType Belos::StatusTestImpResNorm< ScalarType, MV, OP >::getStatus ( ) const [inline, virtual]

Return the result of the most recent CheckStatus call.

Implements Belos::StatusTest< ScalarType, MV, OP >.

Definition at line 171 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
void Belos::StatusTestImpResNorm< ScalarType, MV, OP >::reset ( ) [virtual]

Resets the internal configuration to the initial state.

Implements Belos::StatusTest< ScalarType, MV, OP >.

Definition at line 383 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
void Belos::StatusTestImpResNorm< ScalarType, MV, OP >::print ( std::ostream &  os,
int  indent = 0 
) const [virtual]

Output formatted description of stopping test to output stream.

Implements Belos::StatusTest< ScalarType, MV, OP >.

Definition at line 596 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
void Belos::StatusTestImpResNorm< ScalarType, MV, OP >::printStatus ( std::ostream &  os,
StatusType  type 
) const [virtual]

Print message for each status specific to this stopping test.

Reimplemented from Belos::StatusTest< ScalarType, MV, OP >.

Definition at line 628 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
Teuchos::RCP<MV> Belos::StatusTestImpResNorm< ScalarType, MV, OP >::getSolution ( ) [inline, virtual]

Returns the current solution estimate that was computed for the most recent residual test.

Implements Belos::StatusTestResNorm< ScalarType, MV, OP >.

Definition at line 196 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
int Belos::StatusTestImpResNorm< ScalarType, MV, OP >::getQuorum ( ) const [inline, virtual]

Returns the number of residuals that must pass the convergence test before Passed is returned.

Note:
If quorum=-1 then all residuals must pass the convergence test before Passed is returned.

Implements Belos::StatusTestResNorm< ScalarType, MV, OP >.

Definition at line 200 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
bool Belos::StatusTestImpResNorm< ScalarType, MV, OP >::getShowMaxResNormOnly ( ) [inline, virtual]

Returns whether the only maximum residual norm is displayed when the print() method is called.

Implements Belos::StatusTestResNorm< ScalarType, MV, OP >.

Definition at line 203 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
std::vector<int> Belos::StatusTestImpResNorm< ScalarType, MV, OP >::convIndices ( ) [inline, virtual]

Returns the vector containing the indices of the residuals that passed the test.

Implements Belos::StatusTestResNorm< ScalarType, MV, OP >.

Definition at line 206 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
MagnitudeType Belos::StatusTestImpResNorm< ScalarType, MV, OP >::getTolerance ( ) const [inline, virtual]

! Returns the value of the tolerance, $ \tau $, set in the constructor.

Implements Belos::StatusTestResNorm< ScalarType, MV, OP >.

Definition at line 209 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
MagnitudeType Belos::StatusTestImpResNorm< ScalarType, MV, OP >::getCurrTolerance ( ) const [inline]

Returns the current value of the tolerance which may be modified if there is a loss of accuracy.

Definition at line 212 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
const std::vector<MagnitudeType>* Belos::StatusTestImpResNorm< ScalarType, MV, OP >::getTestValue ( ) const [inline, virtual]

Returns the test value, $ \frac{\|r\|}{\sigma} $, computed in most recent call to CheckStatus.

Implements Belos::StatusTestResNorm< ScalarType, MV, OP >.

Definition at line 215 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
const std::vector<MagnitudeType>* Belos::StatusTestImpResNorm< ScalarType, MV, OP >::getResNormValue ( ) const [inline]

Returns the residual norm value, $ \|r\| $, computed in most recent call to CheckStatus.

Definition at line 218 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
const std::vector<MagnitudeType>* Belos::StatusTestImpResNorm< ScalarType, MV, OP >::getScaledNormValue ( ) const [inline]

Returns the scaled norm value, $ \sigma $.

Definition at line 221 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
bool Belos::StatusTestImpResNorm< ScalarType, MV, OP >::getLOADetected ( ) const [inline, virtual]

Returns a boolean indicating a loss of accuracy has been detected in computing the residual.

Implements Belos::StatusTestResNorm< ScalarType, MV, OP >.

Definition at line 224 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
StatusType Belos::StatusTestImpResNorm< ScalarType, MV, OP >::firstCallCheckStatusSetup ( Iteration< ScalarType, MV, OP > *  iSolver)

Call to setup initial scaling vector.

After this function is called getScaledNormValue() can be called to get the scaling vector.

Definition at line 651 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
std::string Belos::StatusTestImpResNorm< ScalarType, MV, OP >::description ( ) const [inline, virtual]

Method to return description of the maximum iteration status test.

Reimplemented from Teuchos::Describable.

Definition at line 243 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
std::string Belos::StatusTestImpResNorm< ScalarType, MV, OP >::resFormStr ( ) const [inline, private]

Description of current residual form.

Definition at line 259 of file BelosStatusTestImpResNorm.hpp.


Member Data Documentation

template<class ScalarType , class MV , class OP >
MagnitudeType Belos::StatusTestImpResNorm< ScalarType, MV, OP >::tolerance_ [private]

Current tolerance used to determine convergence and the default tolerance set by user.

Definition at line 287 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
MagnitudeType Belos::StatusTestImpResNorm< ScalarType, MV, OP >::currTolerance_ [private]

Definition at line 287 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
int Belos::StatusTestImpResNorm< ScalarType, MV, OP >::quorum_ [private]

Number of residuals that must pass the convergence test before Passed is returned.

Definition at line 290 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
bool Belos::StatusTestImpResNorm< ScalarType, MV, OP >::showMaxResNormOnly_ [private]

Determines if the entries for all of the residuals are shown or just the max.

Definition at line 293 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
NormType Belos::StatusTestImpResNorm< ScalarType, MV, OP >::resnormtype_ [private]

Type of norm to use on residual (OneNorm, TwoNorm, or InfNorm).

Definition at line 296 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
ScaleType Belos::StatusTestImpResNorm< ScalarType, MV, OP >::scaletype_ [private]

Type of scaling to use (Norm of RHS, Norm of Initial Residual, None or User provided)

Definition at line 299 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
NormType Belos::StatusTestImpResNorm< ScalarType, MV, OP >::scalenormtype_ [private]

Type of norm to use on the scaling (OneNorm, TwoNorm, or InfNorm)

Definition at line 302 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
MagnitudeType Belos::StatusTestImpResNorm< ScalarType, MV, OP >::scalevalue_ [private]

Scaling value.

Definition at line 305 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
std::vector<MagnitudeType> Belos::StatusTestImpResNorm< ScalarType, MV, OP >::scalevector_ [private]

Scaling vector.

Definition at line 308 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
std::vector<MagnitudeType> Belos::StatusTestImpResNorm< ScalarType, MV, OP >::resvector_ [private]

Residual norm vector.

Definition at line 311 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
std::vector<MagnitudeType> Belos::StatusTestImpResNorm< ScalarType, MV, OP >::testvector_ [private]

Test vector = resvector_ / scalevector_.

Definition at line 314 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
Teuchos::RCP<MV> Belos::StatusTestImpResNorm< ScalarType, MV, OP >::curSoln_ [private]

Current solution vector.

Definition at line 317 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
std::vector<int> Belos::StatusTestImpResNorm< ScalarType, MV, OP >::ind_ [private]

Vector containing the indices for the vectors that passed the test.

Definition at line 320 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
StatusType Belos::StatusTestImpResNorm< ScalarType, MV, OP >::status_ [private]

Status.

Definition at line 323 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
int Belos::StatusTestImpResNorm< ScalarType, MV, OP >::curBlksz_ [private]

The current blocksize of the linear system being solved.

Definition at line 326 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
int Belos::StatusTestImpResNorm< ScalarType, MV, OP >::curNumRHS_ [private]

The current number of right-hand sides being solved for.

Definition at line 329 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
std::vector<int> Belos::StatusTestImpResNorm< ScalarType, MV, OP >::curLSIdx_ [private]

The indices of the current number of right-hand sides being solved for.

Definition at line 332 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
int Belos::StatusTestImpResNorm< ScalarType, MV, OP >::curLSNum_ [private]

The current number of linear systems that have been loaded into the linear problem.

Definition at line 335 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
int Belos::StatusTestImpResNorm< ScalarType, MV, OP >::numrhs_ [private]

The total number of right-hand sides being solved for.

Definition at line 338 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
bool Belos::StatusTestImpResNorm< ScalarType, MV, OP >::firstcallCheckStatus_ [private]

Is this the first time CheckStatus is called?

Definition at line 341 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
bool Belos::StatusTestImpResNorm< ScalarType, MV, OP >::firstcallDefineResForm_ [private]

Is this the first time DefineResForm is called?

Definition at line 344 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
bool Belos::StatusTestImpResNorm< ScalarType, MV, OP >::firstcallDefineScaleForm_ [private]

Is this the first time DefineScaleForm is called?

Definition at line 347 of file BelosStatusTestImpResNorm.hpp.

template<class ScalarType , class MV , class OP >
bool Belos::StatusTestImpResNorm< ScalarType, MV, OP >::lossDetected_ [private]

Has a loss in accuracy been detected?

Definition at line 350 of file BelosStatusTestImpResNorm.hpp.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines