ru.sscc.matrix.solve
Class CholeskyBandSolver

java.lang.Object
  |
  +--ru.sscc.matrix.solve.RealDirectSolver
        |
        +--ru.sscc.matrix.solve.CholeskyBandSolver

public class CholeskyBandSolver
extends RealDirectSolver

Performs the solving of SLAE with Positive Definite Symmetric Banded Matrix by the Cholesky method (eg Square Root factorization). A banded matrix is presented by a SymBandedMatrix instance inside.

When a matrix is factorized, its algebraic properties are locked and matrix by vector multiplications are impossible. The solve() operation is permitted after the factorization only.

See Also:
Serialized Form

Field Summary
protected  SymBandedMatrix matrix
          The attached matrix.
 
Constructor Summary
CholeskyBandSolver()
          Constructs an instance without attached matrix.
CholeskyBandSolver(int size, int halfWidth, boolean toeplitz)
          Constructs an instance with clear matrix of the double[] type.
CholeskyBandSolver(RealContainer entries, int size, int halfWidth, boolean toeplitz)
          Constructs an instance based on a user's real data container.
CholeskyBandSolver(SymBandedMatrix matrix)
          Constructs an instance upon a matrix.
 
Method Summary
 void attach(SymBandedMatrix matrix)
          Attaches a matrix to the solver and sets the initial state for the solver and matrix.
 void factorize()
          Factorizes the matrix using Cholesky (Square Root) factorization method in assumption that the matrix is positive definite.
 SymBandedMatrix getMatrix()
          Returns a matrix attached with the solver.
 void reuse(boolean toeplitz)
          Clears the factorization tag to reuse the matrix once more and resets its toeplitz tag to new value.
 void solve(RealVector source, RealVector target)
          Solves SLAE using already factorized matrix.
 int sourceSize()
          Returns a size of right-hand side (rows number).
 int targetSize()
          Returns a size of solution (columns number).
 
Methods inherited from class ru.sscc.matrix.solve.RealDirectSolver
constructInverse, constructRefinedInverse, ensureFactorized, isFactorized, setFactorized, solveAndRefine
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

matrix

protected SymBandedMatrix matrix
The attached matrix.
Constructor Detail

CholeskyBandSolver

public CholeskyBandSolver()
Constructs an instance without attached matrix.

CholeskyBandSolver

public CholeskyBandSolver(int size,
                          int halfWidth,
                          boolean toeplitz)
Constructs an instance with clear matrix of the double[] type.
Parameters:
size - a matrix dimension
halfWidth - a width of matrix's half-band (k+1)
toeplitz - is true for Toeplitz matrix

CholeskyBandSolver

public CholeskyBandSolver(RealContainer entries,
                          int size,
                          int halfWidth,
                          boolean toeplitz)
Constructs an instance based on a user's real data container.
Parameters:
entries - an upper half-band container
size - a matrix dimension
halfWidth - a width of matrix's half-band (k+1)
toeplitz - is true for Toeplitz matrix

CholeskyBandSolver

public CholeskyBandSolver(SymBandedMatrix matrix)
Constructs an instance upon a matrix.
Parameters:
matrix - a positive symmetric banded matrix
Method Detail

attach

public void attach(SymBandedMatrix matrix)
Attaches a matrix to the solver and sets the initial state for the solver and matrix. The matrix is set to be algebraic and the solver factorize tag is cleared.

getMatrix

public final SymBandedMatrix getMatrix()
Returns a matrix attached with the solver.

sourceSize

public final int sourceSize()
Returns a size of right-hand side (rows number).
Overrides:
sourceSize in class RealDirectSolver

targetSize

public final int targetSize()
Returns a size of solution (columns number).
Overrides:
targetSize in class RealDirectSolver

reuse

public final void reuse(boolean toeplitz)
Clears the factorization tag to reuse the matrix once more and resets its toeplitz tag to new value.

factorize

public void factorize()
               throws CalculatingException
Factorizes the matrix using Cholesky (Square Root) factorization method in assumption that the matrix is positive definite. Does nothing if the matrix is already factorized. If the matrix is nonalgebraic, throws the IllegalStateException. If the matrix is ill-posed or nonpositive, the CalculatingException is thrown.
Overrides:
factorize in class RealDirectSolver
Throws:
CalculatingException - is thrown when the matrix is ill-posed or nonpositive

solve

public void solve(RealVector source,
                  RealVector target)
Solves SLAE using already factorized matrix. Throws the IllegalStateException if the matrix isn't factorized. The source and target vectors may be identic.
Overrides:
solve in class RealDirectSolver
Parameters:
source - a source vector (the right hand side of SLAE)
target - a target vector to write the solution