Class IterativeLinearSolver
- java.lang.Object
-
- org.apache.commons.math4.legacy.linear.IterativeLinearSolver
-
- Direct Known Subclasses:
PreconditionedIterativeLinearSolver
public abstract class IterativeLinearSolver extends Object
This abstract class defines an iterative solver for the linear system A · x = b. In what follows, the residual r is defined as r = b - A · x, where A is the linear operator of the linear system, b is the right-hand side vector, and x the current estimate of the solution.- Since:
- 3.0
-
-
Constructor Summary
Constructors Constructor Description IterativeLinearSolver(int maxIterations)
Creates a new instance of this class, with default iteration manager.IterativeLinearSolver(IterationManager manager)
Creates a new instance of this class, with custom iteration manager.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected static void
checkParameters(RealLinearOperator a, RealVector b, RealVector x0)
Performs all dimension checks on the parameters ofsolve
andsolveInPlace
, and throws an exception if one of the checks fails.IterationManager
getIterationManager()
Returns the iteration manager attached to this solver.RealVector
solve(RealLinearOperator a, RealVector b)
Returns an estimate of the solution to the linear system A · x = b.RealVector
solve(RealLinearOperator a, RealVector b, RealVector x0)
Returns an estimate of the solution to the linear system A · x = b.abstract RealVector
solveInPlace(RealLinearOperator a, RealVector b, RealVector x0)
Returns an estimate of the solution to the linear system A · x = b.
-
-
-
Constructor Detail
-
IterativeLinearSolver
public IterativeLinearSolver(int maxIterations)
Creates a new instance of this class, with default iteration manager.- Parameters:
maxIterations
- the maximum number of iterations
-
IterativeLinearSolver
public IterativeLinearSolver(IterationManager manager) throws NullArgumentException
Creates a new instance of this class, with custom iteration manager.- Parameters:
manager
- the custom iteration manager- Throws:
NullArgumentException
- ifmanager
isnull
-
-
Method Detail
-
checkParameters
protected static void checkParameters(RealLinearOperator a, RealVector b, RealVector x0) throws NullArgumentException, NonSquareOperatorException, DimensionMismatchException
Performs all dimension checks on the parameters ofsolve
andsolveInPlace
, and throws an exception if one of the checks fails.- Parameters:
a
- the linear operator A of the systemb
- the right-hand side vectorx0
- the initial guess of the solution- Throws:
NullArgumentException
- if one of the parameters isnull
NonSquareOperatorException
- ifa
is not squareDimensionMismatchException
- ifb
orx0
have dimensions inconsistent witha
-
getIterationManager
public IterationManager getIterationManager()
Returns the iteration manager attached to this solver.- Returns:
- the manager
-
solve
public RealVector solve(RealLinearOperator a, RealVector b) throws NullArgumentException, NonSquareOperatorException, DimensionMismatchException, MaxCountExceededException
Returns an estimate of the solution to the linear system A · x = b.- Parameters:
a
- the linear operator A of the systemb
- the right-hand side vector- Returns:
- a new vector containing the solution
- Throws:
NullArgumentException
- if one of the parameters isnull
NonSquareOperatorException
- ifa
is not squareDimensionMismatchException
- ifb
has dimensions inconsistent witha
MaxCountExceededException
- at exhaustion of the iteration count, unless a customcallback
has been set at construction of theIterationManager
-
solve
public RealVector solve(RealLinearOperator a, RealVector b, RealVector x0) throws NullArgumentException, NonSquareOperatorException, DimensionMismatchException, MaxCountExceededException
Returns an estimate of the solution to the linear system A · x = b.- Parameters:
a
- the linear operator A of the systemb
- the right-hand side vectorx0
- the initial guess of the solution- Returns:
- a new vector containing the solution
- Throws:
NullArgumentException
- if one of the parameters isnull
NonSquareOperatorException
- ifa
is not squareDimensionMismatchException
- ifb
orx0
have dimensions inconsistent witha
MaxCountExceededException
- at exhaustion of the iteration count, unless a customcallback
has been set at construction of theIterationManager
-
solveInPlace
public abstract RealVector solveInPlace(RealLinearOperator a, RealVector b, RealVector x0) throws NullArgumentException, NonSquareOperatorException, DimensionMismatchException, MaxCountExceededException
Returns an estimate of the solution to the linear system A · x = b. The solution is computed in-place (initial guess is modified).- Parameters:
a
- the linear operator A of the systemb
- the right-hand side vectorx0
- initial guess of the solution- Returns:
- a reference to
x0
(shallow copy) updated with the solution - Throws:
NullArgumentException
- if one of the parameters isnull
NonSquareOperatorException
- ifa
is not squareDimensionMismatchException
- ifb
orx0
have dimensions inconsistent witha
MaxCountExceededException
- at exhaustion of the iteration count, unless a customcallback
has been set at construction of theIterationManager
-
-