Package org.hipparchus.linear
Class PreconditionedIterativeLinearSolver
- java.lang.Object
-
- org.hipparchus.linear.IterativeLinearSolver
-
- org.hipparchus.linear.PreconditionedIterativeLinearSolver
-
- Direct Known Subclasses:
ConjugateGradient
,SymmLQ
public abstract class PreconditionedIterativeLinearSolver extends IterativeLinearSolver
This abstract class defines preconditioned iterative solvers. When A is ill-conditioned, instead of solving system A · x = b directly, it is preferable to solve either
(M · A) · x = M · b (left preconditioning), or(A · M) · y = b, followed by M · y = x (right preconditioning), where M approximates in some way A-1, while matrix-vector products of the type M · y remain comparatively easy to compute. In this library, M (not M-1!) is called the preconditionner.Concrete implementations of this abstract class must be provided with the preconditioner M, as a
RealLinearOperator
.
-
-
Constructor Summary
Constructors Constructor Description PreconditionedIterativeLinearSolver(int maxIterations)
Creates a new instance of this class, with default iteration manager.PreconditionedIterativeLinearSolver(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, RealLinearOperator m, RealVector b, RealVector x0)
Performs all dimension checks on the parameters ofsolve
andsolveInPlace
, and throws an exception if one of the checks fails.RealVector
solve(RealLinearOperator a, RealLinearOperator m, RealVector b)
Returns an estimate of the solution to the linear system A · x = b.RealVector
solve(RealLinearOperator a, RealLinearOperator m, RealVector b, RealVector x0)
Returns an estimate of the solution to the linear system A · x = b.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, RealLinearOperator m, RealVector b, RealVector x0)
Returns an estimate of the solution to the linear system A · x = b.RealVector
solveInPlace(RealLinearOperator a, RealVector b, RealVector x0)
Returns an estimate of the solution to the linear system A · x = b.-
Methods inherited from class org.hipparchus.linear.IterativeLinearSolver
checkParameters, getIterationManager
-
-
-
-
Constructor Detail
-
PreconditionedIterativeLinearSolver
public PreconditionedIterativeLinearSolver(int maxIterations)
Creates a new instance of this class, with default iteration manager.- Parameters:
maxIterations
- the maximum number of iterations
-
PreconditionedIterativeLinearSolver
public PreconditionedIterativeLinearSolver(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
-
solve
public RealVector solve(RealLinearOperator a, RealLinearOperator m, RealVector b, RealVector x0) throws MathIllegalArgumentException, NullArgumentException, MathIllegalStateException
Returns an estimate of the solution to the linear system A · x = b.- Parameters:
a
- the linear operator A of the systemm
- the preconditioner, M (can benull
)b
- 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
MathIllegalArgumentException
- ifa
orm
is not squareMathIllegalArgumentException
- ifm
,b
orx0
have dimensions inconsistent witha
MathIllegalStateException
- at exhaustion of the iteration count, unless a customcallback
has been set at construction of theIterationManager
-
solve
public RealVector solve(RealLinearOperator a, RealVector b) throws MathIllegalArgumentException, NullArgumentException, MathIllegalStateException
Returns an estimate of the solution to the linear system A · x = b.- Overrides:
solve
in classIterativeLinearSolver
- Parameters:
a
- the linear operator A of the systemb
- the right-hand side vector- Returns:
- a new vector containing the solution
- Throws:
MathIllegalArgumentException
- ifa
is not squareNullArgumentException
- if one of the parameters isnull
MathIllegalStateException
- 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 MathIllegalArgumentException, NullArgumentException, MathIllegalStateException
Returns an estimate of the solution to the linear system A · x = b.- Overrides:
solve
in classIterativeLinearSolver
- 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:
MathIllegalArgumentException
- ifa
is not squareNullArgumentException
- if one of the parameters isnull
MathIllegalStateException
- at exhaustion of the iteration count, unless a customcallback
has been set at construction of theIterationManager
-
checkParameters
protected static void checkParameters(RealLinearOperator a, RealLinearOperator m, RealVector b, RealVector x0) throws MathIllegalArgumentException, NullArgumentException
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 systemm
- the preconditioner, M (can benull
)b
- the right-hand side vectorx0
- the initial guess of the solution- Throws:
NullArgumentException
- if one of the parameters isnull
MathIllegalArgumentException
- ifa
orm
is not squareMathIllegalArgumentException
- ifm
,b
orx0
have dimensions inconsistent witha
-
solve
public RealVector solve(RealLinearOperator a, RealLinearOperator m, RealVector b) throws MathIllegalArgumentException, NullArgumentException, MathIllegalStateException
Returns an estimate of the solution to the linear system A · x = b.- Parameters:
a
- the linear operator A of the systemm
- the preconditioner, M (can benull
)b
- the right-hand side vector- Returns:
- a new vector containing the solution
- Throws:
NullArgumentException
- if one of the parameters isnull
MathIllegalArgumentException
- ifa
orm
is not squareMathIllegalArgumentException
- ifm
orb
have dimensions inconsistent witha
MathIllegalStateException
- at exhaustion of the iteration count, unless a customcallback
has been set at construction of theIterationManager
-
solveInPlace
public abstract RealVector solveInPlace(RealLinearOperator a, RealLinearOperator m, RealVector b, RealVector x0) throws MathIllegalArgumentException, NullArgumentException, MathIllegalStateException
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 systemm
- the preconditioner, M (can benull
)b
- the right-hand side vectorx0
- the initial guess of the solution- Returns:
- a reference to
x0
(shallow copy) updated with the solution - Throws:
NullArgumentException
- if one of the parameters isnull
MathIllegalArgumentException
- ifa
orm
is not squareMathIllegalArgumentException
- ifm
,b
orx0
have dimensions inconsistent witha
MathIllegalStateException
- at exhaustion of the iteration count, unless a customcallback
has been set at construction of theIterationManager
-
solveInPlace
public RealVector solveInPlace(RealLinearOperator a, RealVector b, RealVector x0) throws MathIllegalArgumentException, NullArgumentException, MathIllegalStateException
Returns an estimate of the solution to the linear system A · x = b. The solution is computed in-place (initial guess is modified).- Specified by:
solveInPlace
in classIterativeLinearSolver
- 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:
MathIllegalArgumentException
- ifa
is not squareNullArgumentException
- if one of the parameters isnull
MathIllegalStateException
- at exhaustion of the iteration count, unless a customcallback
has been set at construction of theIterationManager
-
-