Package org.hipparchus.linear
Class DefaultIterativeLinearSolverEvent
- java.lang.Object
-
- java.util.EventObject
-
- org.hipparchus.util.IterationEvent
-
- org.hipparchus.linear.IterativeLinearSolverEvent
-
- org.hipparchus.linear.DefaultIterativeLinearSolverEvent
-
- All Implemented Interfaces:
Serializable
public class DefaultIterativeLinearSolverEvent extends IterativeLinearSolverEvent
A default concrete implementation of the abstract classIterativeLinearSolverEvent
.- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class java.util.EventObject
source
-
-
Constructor Summary
Constructors Constructor Description DefaultIterativeLinearSolverEvent(Object source, int iterations, RealVector x, RealVector b, double rnorm)
Creates a new instance of this class.DefaultIterativeLinearSolverEvent(Object source, int iterations, RealVector x, RealVector b, RealVector r, double rnorm)
Creates a new instance of this class.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
getNormOfResidual()
Returns the norm of the residual.RealVector
getResidual()
Returns the residual.RealVector
getRightHandSideVector()
Returns the current right-hand side of the linear system to be solved.RealVector
getSolution()
Returns the current estimate of the solution to the linear system to be solved.boolean
providesResidual()
Returnstrue
ifIterativeLinearSolverEvent.getResidual()
is supported.-
Methods inherited from class org.hipparchus.util.IterationEvent
getIterations
-
Methods inherited from class java.util.EventObject
getSource, toString
-
-
-
-
Constructor Detail
-
DefaultIterativeLinearSolverEvent
public DefaultIterativeLinearSolverEvent(Object source, int iterations, RealVector x, RealVector b, RealVector r, double rnorm)
Creates a new instance of this class. This implementation does not deep copy the specified vectorsx
,b
,r
. Therefore the user must make sure that these vectors are either unmodifiable views or deep copies of the same vectors actually used by thesource
. Failure to do so may compromise subsequent iterations of thesource
. If the residual vectorr
isnull
, thengetResidual()
throws aMathRuntimeException
, andprovidesResidual()
returnsfalse
.- Parameters:
source
- the iterative solver which fired this eventiterations
- the number of iterations performed at the timethis
event is createdx
- the current estimate of the solutionb
- the right-hand side vectorr
- the current estimate of the residual (can benull
)rnorm
- the norm of the current estimate of the residual
-
DefaultIterativeLinearSolverEvent
public DefaultIterativeLinearSolverEvent(Object source, int iterations, RealVector x, RealVector b, double rnorm)
Creates a new instance of this class. This implementation does not deep copy the specified vectorsx
,b
. Therefore the user must make sure that these vectors are either unmodifiable views or deep copies of the same vectors actually used by thesource
. Failure to do so may compromise subsequent iterations of thesource
. CalllinggetResidual()
on instances returned by this constructor throws aMathRuntimeException
, whileprovidesResidual()
returnsfalse
.- Parameters:
source
- the iterative solver which fired this eventiterations
- the number of iterations performed at the timethis
event is createdx
- the current estimate of the solutionb
- the right-hand side vectorrnorm
- the norm of the current estimate of the residual
-
-
Method Detail
-
getNormOfResidual
public double getNormOfResidual()
Returns the norm of the residual. The returned value is not required to be exact. Instead, the norm of the so-called updated residual (if available) should be returned. For example, theconjugate gradient
method computes a sequence of residuals, the norm of which is cheap to compute. However, due to accumulation of round-off errors, this residual might differ from the true residual after some iterations. See e.g. A. Greenbaum and Z. Strakos, Predicting the Behavior of Finite Precision Lanzos and Conjugate Gradient Computations, Technical Report 538, Department of Computer Science, New York University, 1991 (available here).- Specified by:
getNormOfResidual
in classIterativeLinearSolverEvent
- Returns:
- the norm of the residual, ||r||
-
getResidual
public RealVector getResidual()
Returns the residual. This is an optional operation, as all iterative linear solvers do not provide cheap estimate of the updated residual vector, in which case
- this method should throw a
MathRuntimeException
, IterativeLinearSolverEvent.providesResidual()
returnsfalse
.
The default implementation throws a
This implementation throws aMathRuntimeException
. If this method is overriden, thenIterativeLinearSolverEvent.providesResidual()
should be overriden as well.MathRuntimeException
if no residual vectorr
was provided at construction time.- Overrides:
getResidual
in classIterativeLinearSolverEvent
- Returns:
- the updated residual, r
- this method should throw a
-
getRightHandSideVector
public RealVector getRightHandSideVector()
Returns the current right-hand side of the linear system to be solved. This method should return an unmodifiable view, or a deep copy of the actual right-hand side vector, in order not to compromise subsequent iterations of the sourceIterativeLinearSolver
.- Specified by:
getRightHandSideVector
in classIterativeLinearSolverEvent
- Returns:
- the right-hand side vector, b
-
getSolution
public RealVector getSolution()
Returns the current estimate of the solution to the linear system to be solved. This method should return an unmodifiable view, or a deep copy of the actual current solution, in order not to compromise subsequent iterations of the sourceIterativeLinearSolver
.- Specified by:
getSolution
in classIterativeLinearSolverEvent
- Returns:
- the solution, x
-
providesResidual
public boolean providesResidual()
Returnstrue
ifIterativeLinearSolverEvent.getResidual()
is supported. The default implementation returnsfalse
. This implementation returnstrue
if a non-null
value was specified for the residual vectorr
at construction time.- Overrides:
providesResidual
in classIterativeLinearSolverEvent
- Returns:
true
ifr != null
-
-