ru.sscc.matrix.solve
Class CrautSolver

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

public class CrautSolver
extends RealDenseSolver

Performs the solving of SLAE with Square Dense Matrix by the Craut method with partial pivoting by column. A matrix is presented by a DenseMatrix instance attached. The solver is useful for square nonsingular matrices.

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
CrautSolver()
          Constructs an instance without attached matrix.
CrautSolver(DenseMatrix matrix)
          Constructs an instance upon a dense matrix.
CrautSolver(int size)
          Constructs an instance with clear matrix of the double[] type.
CrautSolver(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 Craut factorization method with partial pivoting by column.
 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

CrautSolver

public CrautSolver()
Constructs an instance without attached matrix.

CrautSolver

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

CrautSolver

public CrautSolver(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

CrautSolver

public CrautSolver(DenseMatrix matrix)
Constructs an instance upon a dense matrix.
Parameters:
matrix - the square 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 Craut factorization method with partial pivoting by column. Does nothing if the matrix is already factorized. If the matrix is nonalgebraic, throws the IllegalStateException. If the matrix is ill-posed, the CalculatingException will be thrown.
Overrides:
factorize in class RealDirectSolver
Returns:
itself
Throws:
CalculatingException - is thrown when the matrix is ill-posed

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