org.apache.commons.math.linear
Class IterativeLinearSolver

java.lang.Object
  extended by org.apache.commons.math.linear.IterativeLinearSolver
Direct Known Subclasses:
PreconditionedIterativeLinearSolver

public abstract class IterativeLinearSolver
extends java.lang.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
Version:
$Id: IterativeLinearSolver.java 1178306 2011-10-03 06:33:21Z celestin $

Constructor Summary
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
protected static void checkParameters(RealLinearOperator a, RealVector b, RealVector x0)
          Performs all dimension checks on the parameters of solve and solveInPlace, and throws an exception if one of the checks fails.
 IterationManager getIterationManager()
          Returns the IterationManager 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IterativeLinearSolver

public IterativeLinearSolver(int maxIterations)
Creates a new instance of this class, with default iteration manager.

Parameters:
maxIterations - Maximum number of iterations.

IterativeLinearSolver

public IterativeLinearSolver(IterationManager manager)
                      throws NullArgumentException
Creates a new instance of this class, with custom iteration manager.

Parameters:
manager - Custom iteration manager.
Throws:
NullArgumentException - if manager is null.
Method Detail

checkParameters

protected static void checkParameters(RealLinearOperator a,
                                      RealVector b,
                                      RealVector x0)
                               throws NullArgumentException,
                                      NonSquareOperatorException,
                                      DimensionMismatchException
Performs all dimension checks on the parameters of solve and solveInPlace, and throws an exception if one of the checks fails.

Parameters:
a - Linear operator A of the system.
b - Right-hand side vector.
x0 - Initial guess of the solution.
Throws:
NullArgumentException - if one of the parameters is null.
NonSquareOperatorException - if a is not square.
DimensionMismatchException - if b or x0 have dimensions inconsistent with a.

getIterationManager

public IterationManager getIterationManager()
Returns the IterationManager 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 - Linear operator A of the system.
b - Right-hand side vector.
Returns:
A new vector containing the solution.
Throws:
NullArgumentException - if one of the parameters is null.
NonSquareOperatorException - if a is not square.
DimensionMismatchException - if b has dimensions inconsistent with a.
MaxCountExceededException - at exhaustion of the iteration count, unless a custom callback has been set at construction.

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 - Linear operator A of the system.
b - Right-hand side vector.
x0 - Initial guess of the solution.
Returns:
A new vector containing the solution.
Throws:
NullArgumentException - if one of the parameters is null.
NonSquareOperatorException - if a is not square.
DimensionMismatchException - if b or x0 have dimensions inconsistent with a.
MaxCountExceededException - at exhaustion of the iteration count, unless a custom callback has been set at construction.

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 - Linear operator A of the system.
b - Right-hand side vector.
x0 - Initial guess of the solution.
Returns:
A reference to x0 (shallow copy) updated with the solution.
Throws:
NullArgumentException - if one of the parameters is null.
NonSquareOperatorException - if a is not square.
DimensionMismatchException - if b or x0 have dimensions inconsistent with a.
MaxCountExceededException - at exhaustion of the iteration count, unless a custom callback has been set at construction.


Copyright © 2003-2011 The Apache Software Foundation. All Rights Reserved.