ru.sscc.matrix.solve
Class CholeskySolver

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

public class CholeskySolver
extends RealDenseSolver

Performs the solving of SLAE with Positive Definite Symmetric Dense Matrix by the Cholesky method (eg Square Root factorization). A matrix is presented by a DenseMatrix instance attached.

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

Fields inherited from class ru.sscc.matrix.solve.RealDenseSolver
matrix
 
Constructor Summary
CholeskySolver()
          Constructs an instance without attached matrix.
CholeskySolver(DenseMatrix matrix)
          Constructs an instance upon a dense matrix.
CholeskySolver(int size)
          Constructs an instance with clear matrix of the double[] type.
CholeskySolver(RealContainer entries, int size)
          Constructs an instance based on a user's real data container.
 
Method Summary
 void attach(DenseMatrix matrix)
          Attaches a matrix to the solver and sets the initial state for the solver and matrix.
 RealDirectSolver factorize()
          Factorizes the matrix using the Cholesky (Square Root) factorization method in assumption that the matrix is positive definite.
 void solve(RealVector source, RealVector target)
          Solves SLAE using already factorized matrix.
 
Methods inherited from class ru.sscc.matrix.solve.RealDenseSolver
clone, forwardSubstitution, getMatrix, reuse, solveLowerTriangular, solveUpperTriangular, sourceSize, targetSize
 
Methods inherited from class ru.sscc.matrix.solve.RealDirectSolver
constructInverse, constructRefinedInverse, ensureFactorized, isFactorized, setFactorized, solveAndRefine
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CholeskySolver

public CholeskySolver()
Constructs an instance without attached matrix.

CholeskySolver

public CholeskySolver(int size)
Constructs an instance with clear matrix of the double[] type.
Parameters:
size - the matrix dimension

CholeskySolver

public CholeskySolver(RealContainer entries,
                      int size)
Constructs an instance based on a user's real data container.
Parameters:
entries - the matrix container consisting of entries ordered by rows
size - the matrix dimension

CholeskySolver

public CholeskySolver(DenseMatrix matrix)
Constructs an instance upon a dense matrix.
Parameters:
matrix - the positive definite symmetric dense matrix
Method Detail

attach

public void attach(DenseMatrix 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 turned off. If the matrix is non-square, the IllegalArgumentException is thrown. To clean the solver, use attach(null).
Overrides:
attach in class RealDenseSolver

factorize

public RealDirectSolver factorize()
                           throws CalculatingException
Factorizes the matrix using the 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 will be thrown. The lower triangle of the matrix is used in factorization.
Overrides:
factorize in class RealDirectSolver
Returns:
itself
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