Belos::StatusTestGenResNorm< ScalarType, MV, OP > Class Template Reference

An implementation of StatusTestResNorm using a family of residual norms. More...

#include <BelosStatusTestGenResNorm.hpp>

Inheritance diagram for Belos::StatusTestGenResNorm< 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
 Implicit
 Explicit
Enums.
enum  ResType { Implicit, Explicit }
 Select how the residual std::vector is produced. More...

Public Member Functions

Constructors/destructors.
 StatusTestGenResNorm (MagnitudeType Tolerance, int quorum=-1, bool showMaxResNormOnly=false)
 Constructor.
virtual ~StatusTestGenResNorm ()
 Destructor.
Form and parameter definition methods.
int defineResForm (ResType TypeOfResidual, NormType TypeOfNorm)
 Define form of the residual, its norm and optional weighting std::vector.
int defineScaleForm (ScaleType TypeOfScaling, NormType TypeOfNorm, MagnitudeType ScaleValue=Teuchos::ScalarTraits< MagnitudeType >::one())
 Define form of the scaling, its norm, its optional weighting std::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.
std::vector< int > convIndices ()
 Returns the std::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.
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 std::vector.

Detailed Description

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

An implementation of StatusTestResNorm using a family of residual norms.

StatusTestGenResNorm is an implementation of StatusTestResNorm that allows a user to construct one of a family of residual tests for use as a status/convergence test for Belos. The form of the test is

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

where

Definition at line 66 of file BelosStatusTestGenResNorm.hpp.


Member Typedef Documentation

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

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

Definition at line 71 of file BelosStatusTestGenResNorm.hpp.

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

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

Definition at line 72 of file BelosStatusTestGenResNorm.hpp.

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

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

Definition at line 73 of file BelosStatusTestGenResNorm.hpp.


Member Enumeration Documentation

template<class ScalarType, class MV, class OP>
enum Belos::StatusTestGenResNorm::ResType

Select how the residual std::vector is produced.

Enumerator:
Implicit  Use the residual std::vector produced by the iterative solver.
Explicit  Explicitly compute the residual std::vector r = b - A*x using the linear problem.

Definition at line 81 of file BelosStatusTestGenResNorm.hpp.


Constructor & Destructor Documentation

template<class ScalarType, class MV, class OP>
Belos::StatusTestGenResNorm< ScalarType, MV, OP >::StatusTestGenResNorm ( 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 std::vector in a form that would be exact in infinite precision arithmetic. This std::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 316 of file BelosStatusTestGenResNorm.hpp.

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

Destructor.

Definition at line 338 of file BelosStatusTestGenResNorm.hpp.


Member Function Documentation

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

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

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

Definition at line 355 of file BelosStatusTestGenResNorm.hpp.

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

Define form of the scaling, its norm, its optional weighting std::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 std::vector, or to none.
    • Define norm to be used on the scaling std::vector (this may be different than the norm used in DefineResForm()).

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

Definition at line 368 of file BelosStatusTestGenResNorm.hpp.

template<class ScalarType, class MV, class OP>
int Belos::StatusTestGenResNorm< 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 150 of file BelosStatusTestGenResNorm.hpp.

template<class ScalarType, class MV, class OP>
int Belos::StatusTestGenResNorm< 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 154 of file BelosStatusTestGenResNorm.hpp.

template<class ScalarType, class MV, class OP>
int Belos::StatusTestGenResNorm< 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 157 of file BelosStatusTestGenResNorm.hpp.

template<class ScalarType, class MV, class OP>
StatusType Belos::StatusTestGenResNorm< 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 383 of file BelosStatusTestGenResNorm.hpp.

template<class ScalarType, class MV, class OP>
StatusType Belos::StatusTestGenResNorm< 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 173 of file BelosStatusTestGenResNorm.hpp.

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

Resets the internal configuration to the initial state.

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

Definition at line 342 of file BelosStatusTestGenResNorm.hpp.

template<class ScalarType, class MV, class OP>
void Belos::StatusTestGenResNorm< 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 519 of file BelosStatusTestGenResNorm.hpp.

template<class ScalarType, class MV, class OP>
void Belos::StatusTestGenResNorm< 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 569 of file BelosStatusTestGenResNorm.hpp.

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

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

Note:
This is useful for explicit residual tests, if this test is an implicit residual test a null pointer will be returned.

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

Definition at line 200 of file BelosStatusTestGenResNorm.hpp.

template<class ScalarType, class MV, class OP>
int Belos::StatusTestGenResNorm< 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 204 of file BelosStatusTestGenResNorm.hpp.

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

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

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

Definition at line 207 of file BelosStatusTestGenResNorm.hpp.

template<class ScalarType, class MV, class OP>
MagnitudeType Belos::StatusTestGenResNorm< 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 210 of file BelosStatusTestGenResNorm.hpp.

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

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

Definition at line 213 of file BelosStatusTestGenResNorm.hpp.

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

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

Definition at line 216 of file BelosStatusTestGenResNorm.hpp.

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

Returns the scaled norm value, $ \sigma $.

Definition at line 219 of file BelosStatusTestGenResNorm.hpp.

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

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

Note:
This status test does not check for loss of accuracy, so this method will always return false.

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

Definition at line 223 of file BelosStatusTestGenResNorm.hpp.

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

Call to setup initial scaling std::vector.

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

Definition at line 589 of file BelosStatusTestGenResNorm.hpp.


The documentation for this class was generated from the following file:
Generated on Tue Oct 20 12:48:36 2009 for Belos by doxygen 1.4.7