ru.sscc.matrix.solve
Class RealDenseSolver

java.lang.Object
  |
  +--ru.sscc.matrix.solve.RealDirectSolver
        |
        +--ru.sscc.matrix.solve.RealDenseSolver
Direct Known Subclasses:
CholeskySolver, CrautSolver, GaussSolver, GreenSolver, RealCommonSolver

public abstract class RealDenseSolver
extends RealDirectSolver

Basic abstract class for direct solvers of SLAE with a real dense matrix.

See Also:
Serialized Form

Field Summary
protected  DenseMatrix matrix
          The attached matrix.
 
Constructor Summary
RealDenseSolver()
           
 
Method Summary
 void attach(DenseMatrix matrix)
          Attaches a matrix to the solver and sets the initial state for the solver and matrix.
 java.lang.Object clone()
          Returns a clear clone of the solver without attached matrix.
static void forwardSubstitution(RealContainer entries, int startIndex, int rowStep, int columnStep, RealPointer diag, RealPointer source, RealPointer target, int size)
          Uxecutes the forward substitution algorithm corresponding to the solving of SLAE with the lower triangular matrix.
 DenseMatrix getMatrix()
          Returns the matrix attached to the solver.
 void reuse()
          Clears the factorization tag to reuse the attached matrix once more.
static void solveLowerTriangular(DenseMatrix matrix, boolean hasUnitDiagonal, RealVector source, RealVector target)
          Solves SLAE with the lower triangular matrix stored in the square dense matrix.
static void solveUpperTriangular(DenseMatrix matrix, boolean hasUnitDiagonal, RealVector source, RealVector target)
          Solves SLAE with the upper triangular matrix stored in the square dense 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, factorize, isFactorized, setFactorized, solve, solveAndRefine
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

matrix

protected DenseMatrix matrix
The attached matrix.
Constructor Detail

RealDenseSolver

public RealDenseSolver()
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. To clean solver, use attach(null).

clone

public java.lang.Object clone()
Returns a clear clone of the solver without attached matrix.
Overrides:
clone in class RealDirectSolver

getMatrix

public final DenseMatrix getMatrix()
Returns the matrix attached to the solver.

sourceSize

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

targetSize

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

reuse

public void reuse()
Clears the factorization tag to reuse the attached matrix once more.

solveLowerTriangular

public static void solveLowerTriangular(DenseMatrix matrix,
                                        boolean hasUnitDiagonal,
                                        RealVector source,
                                        RealVector target)
Solves SLAE with the lower triangular matrix stored in the square dense matrix. If the matrix has the main diagonal consisting of units, the hasUnitDiagonal must be set to true. The algebraicity of the matrix isn't tested. The method doesn't test the main diagonal entries to be nonzeroes. The source and target vectors may be identic.
Parameters:
matrix - the square dense matrix containing the required triangular matrix in its lower corner
hasUnitDiagonal - is true, if the main matrix diagonal has unit values and isn't stored in the matrix
source - a source vector (the right-hand side of SLAE)
target - a target vector to write the solution

solveUpperTriangular

public static void solveUpperTriangular(DenseMatrix matrix,
                                        boolean hasUnitDiagonal,
                                        RealVector source,
                                        RealVector target)
Solves SLAE with the upper triangular matrix stored in the square dense matrix. If the matrix has the main diagonal consisting of units, the hasUnitDiagonal must be set to true. The algebraicity of the matrix isn't tested. The method doesn't test the main diagonal entries to be nonzeroes. The source and target vectors may be identic.
Parameters:
matrix - the square dense matrix containing the required triangular matrix in its upper corner
hasUnitDiagonal - is true, if the main matrix diagonal has unit values and isn't stored in the matrix
source - the source vector (the right-hand side of SLAE)
target - the target vector to write the solution

forwardSubstitution

public static void forwardSubstitution(RealContainer entries,
                                       int startIndex,
                                       int rowStep,
                                       int columnStep,
                                       RealPointer diag,
                                       RealPointer source,
                                       RealPointer target,
                                       int size)
Uxecutes the forward substitution algorithm corresponding to the solving of SLAE with the lower triangular matrix. The matrix is stored in the container as the lower part of the square dense matrix. The main matrix diagonal may be stored separately. The method doesn't test the main diagonal entries to be nonzeroes. The position of (i,j)-th matrix entry in the container is calculated by the formula: startIndex+i*rowStep+j*columnStep.

Implementation note: The pointers to the source and target vectors may be identic. The pointers passed as parameters are changed while the method is executed and not restored.

Parameters:
entries - the matrix container
startIndex - the index of (0,0)-th matrix entry in the container
rowStep - the distance between two neighbour entries of the same column
columnStep - the distance between two neighbour entries of the same row
diag - the pointer to the vector of main diagonal entries
source - the pointer to the source vector (the right hand side of SLAE)
target - the pointer to the target vector to write the solution
size - the matrix size (the number of linear equations)