## org.apache.commons.math3.linear
Class IterativeLinearSolver

    java.lang.Object
      org.apache.commons.math3.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 1416643 2012-12-03 19:37:14Z tn $

Field Summary
`private IterationManager` `manager` The object in charge of managing the iterations.

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 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.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### manager

    private final IterationManager manager

  The object in charge of managing the iterations.

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` - 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` - the linear operator A of the system
    `b` - the right-hand side vector
    `x0` - the 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 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 system
    `b` - the 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 of the `IterationManager`

### 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 system
    `b` - the right-hand side vector
    `x0` - the 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 of the `IterationManager`

### 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 system
    `b` - the 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 of the `IterationManager`

Copyright (c) 2003-2013 Apache Software Foundation