LAMA
lama::ResidualStagnation Class Reference

Stagnation stopping criterion. More...

#include <ResidualStagnation.hpp>

Inheritance diagram for lama::ResidualStagnation:

Public Types

enum  BooleanOperator { AND, OR }
 Defines the operators which can be used to connect Criterions with. More...

Public Member Functions

 ResidualStagnation (NormPtr norm)
 Creates a new Stagnation based stopping criterion.
 ResidualStagnation (NormPtr norm, IndexType lookback, Scalar precision)
 Creates a new Stagnation based stopping criterion.
 ResidualStagnation (const ResidualStagnation &other)
virtual ~ResidualStagnation ()
virtual Criterioncopy () const
virtual bool isSatisfied (const IterativeSolver &solver)
 Checks if the criterion is satisfied.
IndexType getLookback () const
 Gets the amount of calculations used for the criterion check.
const NormPtr getNorm () const
 Gets the Norm which the criterion uses for the check.
const Scalar getPrecision () const
 Returns the precision for floating point number calculations related to the Norm.
void setLookback (const IndexType lookback)
 Sets the amount of calculations used for the criterion check.
void setPrecision (const Scalar precision)
 Sets the precision for floating point number calculations related to the Norm.
virtual void writeAt (std::ostream &stream) const
 Writes some Information about this to the passed stream.
const CriterionPtr getLeftChild () const
const CriterionPtr getRightChild () const
BooleanOperator getOperation () const
void setLeftChild (const CriterionPtr leftChild)
void setRightChild (const CriterionPtr rightChild)
void setOperation (const BooleanOperator operation)
bool hasLeftChild () const
 Returns true if the boolean condition has a left child Do not use getLeftChild() to compare pointers.
bool hasRightChild () const
 Returns true if the boolean condition has a right child Do not use getRightChild() to compare pointers.

Protected Member Functions

 LAMA_LOG_DECL_STATIC_LOGGER (logger)

Private Attributes

const NormPtr mNorm
 The norm used in the residual-norm-calculation.
IndexType mLookback
 The amount of calculations used for the criterion check.
std::vector< ScalarmLastResidualNorms
 Stores the results of the residual-norm-calculations.
IndexType mNextEntry
 Index.
bool mEntriesReady
 Used to check, if enough data have been gathered to check the criterion.
Scalar mPrecision
 The precision used for the stagnation check.

Detailed Description

Stagnation stopping criterion.

Parameters:
IterativeSolverThe type solver in which this criterion is used. Most commonly this is the abstract sblas::IterativeSolver type.

Member Enumeration Documentation

Defines the operators which can be used to connect Criterions with.

Enumerator:
AND 

stands for logical and composition

OR 

stands for logical or composition


Constructor & Destructor Documentation

Creates a new Stagnation based stopping criterion.

Parameters:
normThe norm which shall be used to check the criterion. Has to be compatible with the Matrix/Vector types of the solver.

Referenced by copy().

Creates a new Stagnation based stopping criterion.

Parameters:
normThe norm which shall be used to check the criterion. Has to be compatible with the Matrix/Vector types of the solver.
lookbackThe amount of residual-norm-calculation results used for the criterion check.

Member Function Documentation

Gets the amount of calculations used for the criterion check.

return Amount of calculations.

References mLookback.

Referenced by writeAt().

Gets the Norm which the criterion uses for the check.

Returns:
The Norm used.

References mNorm.

Returns the precision for floating point number calculations related to the Norm.

Returns:
mPrecision The precision given in a Scalar object.

References mPrecision.

Referenced by writeAt().

bool lama::Criterion::hasLeftChild ( ) const [inherited]

Returns true if the boolean condition has a left child Do not use getLeftChild() to compare pointers.

Logical operations are overwritten

return Returns true if the boolean condition has a left child. If pointer is not set: false

References lama::Criterion::mLeftChild.

Referenced by lama::Criterion::isSatisfied(), and lama::Criterion::writeAt().

bool lama::Criterion::hasRightChild ( ) const [inherited]

Returns true if the boolean condition has a right child Do not use getRightChild() to compare pointers.

Logical operations are overwritten

return Returns true if the boolean condition has a right child. If pointer is not set: false

References lama::Criterion::mRightChild.

Referenced by lama::Criterion::isSatisfied(), and lama::Criterion::writeAt().

bool lama::ResidualStagnation::isSatisfied ( const IterativeSolver solver) [virtual]

Checks if the criterion is satisfied.

The Stagnation criterion needs a certain amount (specified by m_lookback) to be able to perform the check. If this method is called and not enough data has been gathered, false is returned. Anyhow the norm of the residual is calculated and stored. This process continues, until enough data has been gathered.

Parameters:
solverThe solver which calls this method. Needed for residual computation.
Returns:
Boolean value which determines if the criterion is satisfied or not.

Reimplemented from lama::Criterion.

References lama::Solver::getResidual(), lama::max(), mEntriesReady, lama::min(), mLastResidualNorms, mLookback, mNextEntry, and mPrecision.

lama::Criterion::LAMA_LOG_DECL_STATIC_LOGGER ( logger  ) [protected, inherited]

Reimplemented in lama::IterationCount.

void lama::Criterion::setLeftChild ( const CriterionPtr  leftChild) [inherited]

Sets the amount of calculations used for the criterion check.

References mLookback.

void lama::Criterion::setOperation ( const BooleanOperator  operation) [inherited]

Sets the precision for floating point number calculations related to the Norm.

Parameters:
precisionThe precision given in a Scalar object.

References mPrecision.

void lama::Criterion::setRightChild ( const CriterionPtr  rightChild) [inherited]
void lama::ResidualStagnation::writeAt ( std::ostream &  stream) const [virtual]

Writes some Information about this to the passed stream.

If a deriving class does not overrides writeAt, typeid(this).name() is written to stream.

Parameters:
[out]streamthe stream to write to.

Reimplemented from lama::Criterion.

References getLookback(), and getPrecision().


Field Documentation

Used to check, if enough data have been gathered to check the criterion.

Referenced by isSatisfied().

Stores the results of the residual-norm-calculations.

Referenced by isSatisfied().

The amount of calculations used for the criterion check.

Referenced by getLookback(), isSatisfied(), and setLookback().

Index.

Needed for circular use of the vector.

Referenced by isSatisfied().

The norm used in the residual-norm-calculation.

Referenced by getNorm().

The precision used for the stagnation check.

Referenced by getPrecision(), isSatisfied(), and setPrecision().


The documentation for this class was generated from the following files: