ru.sscc.matrix.solve
Class GaussSolver

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

public class GaussSolver
extends RealDenseSolver

Performs the solving of SLAE with Square Dense Matrix by the Gauss method without pivoting. A matrix is presented by a DenseMatrix instance attached. The solver is useful for matrices having diagonal dominance. It may be also used for positive or negative definite matrices, but in this case the accuracy of the solution may be unsatisfactory if the matrix asymmetric part is too large. To improve the solution accuracy, use the CrautSolver instead.

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

GaussSolver

public GaussSolver()
Constructs an instance without attached matrix.

GaussSolver

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

GaussSolver

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

GaussSolver

public GaussSolver(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 Gauss factorization method without pivoting. 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