SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.matrix.doubles.matrixtype.sparse.solver.iterative
Class RelativeTolerance

java.lang.Object
  extended by com.numericalmethod.suanshu.matrix.doubles.matrixtype.sparse.solver.iterative.RelativeTolerance
All Implemented Interfaces:
Tolerance

public class RelativeTolerance
extends java.lang.Object
implements Tolerance

The stopping criteria is that the norm of the residual r relative to the input base is equal to or smaller than the specified tolerance, that is,

 ||r||2
 ------ ≤ tolerance
  base
 
For example, a Tolerance instance which compares the residual norm relative to the right-hand side b of a linear system Ax = b can be created as follows:
Tolerance tolerance = new RelativeTolerance(b.norm());
Or, one which compares the residual norm relative to the initial residual can be created as follows:
Tolerance tolerance = new RelativeTolerance(b.minus(A.multiply(x0)).norm());


Field Summary
static double DEFAULT_TOLERANCE
          default tolerance
 
Constructor Summary
RelativeTolerance(double base)
          Create an instance which uses DEFAULT_TOLERANCE.
RelativeTolerance(double base, double tolerance)
          Create an instance which uses the specified tolerance.
 
Method Summary
 boolean updateResidualNorm(double norm)
          Check if the updated residual satisfies the tolerance criteria.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_TOLERANCE

public static final double DEFAULT_TOLERANCE
default tolerance

See Also:
Constant Field Values
Constructor Detail

RelativeTolerance

public RelativeTolerance(double base)
Create an instance which uses DEFAULT_TOLERANCE.


RelativeTolerance

public RelativeTolerance(double base,
                         double tolerance)
Create an instance which uses the specified tolerance.

Parameters:
tolerance - the residual norm criteria
Method Detail

updateResidualNorm

public boolean updateResidualNorm(double norm)
Description copied from interface: Tolerance
Check if the updated residual satisfies the tolerance criteria.

Specified by:
updateResidualNorm in interface Tolerance
Parameters:
norm - the norm of the updated residual
Returns:
true if the residual norm is small enough

SuanShu, a Java numerical and statistical library

Copyright © 2011 Numerical Method Inc. Ltd. All Rights Reserved.