ru.sscc.matrix.solve
Class GreenSolver

java.lang.Object
  |
  +--ru.sscc.matrix.solve.RealDirectSolver
        |
        +--ru.sscc.matrix.solve.RealDenseSolver
              |
              +--ru.sscc.matrix.solve.GreenSolver
Direct Known Subclasses:
GeneralGreenSolver

public class GreenSolver
extends RealDenseSolver

Performs the solving of SLAE having the form Cx+By=b with restriction BTx=0. Here C is a square m×m-matrix, B is a rectangular m×k-matrix, x and y are unknown vectors. The matrices C and B are merged into one m×n-matrix, n=m+k: first m columns occupies C matrix and last k columns ocupies B matrix. The unknown vectors x and y also merged into one vector of the length n: x goes first and y goes last.

The original algorithm is used to solve the system. The special transforms F and H are calculated in such a way to provide FB=U and HB=O, where U is the upper triangular k×k-matrix and O is the null n×k-matrix. Then the original system is transformed to HCHTz=Hb and the square matrix A=HCHT is factorized. Then the vectors x and y are easily calculated from z and Fb.

The solver and the transformer used in the algorithm may be selected by the user. The solver should be of RealDenseSolver's subtype and the transformer is any of RealCommonSolver's subtype. The default classes used for solver and transformer are CrautSolver and ReflectionSolver.

This method has especial benefits for spline construction systems, because A is always positive definite symmetric matrix. So, it may be factorized by CholeskySolver.

See Also:
Serialized Form

Field Summary
protected  RealDenseSolver solver
          The solver used for factorization of transformed matrix.
protected  RealCommonSolver transformer
          The solver used for transformation.
 
Fields inherited from class ru.sscc.matrix.solve.RealDenseSolver
matrix
 
Constructor Summary
GreenSolver()
          Constructs an instance without attached matrix with default internal solver and transformer instances (CrautSolver and ReflectionSolver).
GreenSolver(DenseMatrix matrix)
          Constructs an instance upon a dense matrix with default internal solver and transformer.
GreenSolver(int nRows, int nColumns)
          Constructs an instance with clear double[] type container and default internal solver and transformer.
GreenSolver(RealContainer entries, int nRows, int nColumns)
          Constructs an instance based on a user's real data container with default internal solver and transformer.
GreenSolver(RealDenseSolver solver, RealCommonSolver transformer)
          Constructs an instance without attached matrix and with specified solver and transformer.
 
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 original transformation technique.
 double getReductionAccuracy()
          Returns the transformation accuracy level.
 void setReductionAccuracy(double accuracy)
          Sets the transformation accuracy level affecting on making the decision ether B matrix column depends on previous columns or not.
 void solve(RealVector source, RealVector target)
          Solves SLAE using already factorized matrix.
 int transformationDefect()
          Returns the transformation defect (the range of null space).
 DenseMatrix transformationNullSpace()
          Returns the transformation null space.
 
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
 

Field Detail

solver

protected RealDenseSolver solver
The solver used for factorization of transformed matrix.

transformer

protected RealCommonSolver transformer
The solver used for transformation.
Constructor Detail

GreenSolver

public GreenSolver()
Constructs an instance without attached matrix with default internal solver and transformer instances (CrautSolver and ReflectionSolver).

GreenSolver

public GreenSolver(RealDenseSolver solver,
                   RealCommonSolver transformer)
Constructs an instance without attached matrix and with specified solver and transformer. The solver must permit the solve operation when source and target vectors are the same (all basic solvers allow this). The instances passed in parameters are not used in the GreenSolver. Their clones are used instead.
Parameters:
solver - a solver
transformer - a transformer

GreenSolver

public GreenSolver(int nRows,
                   int nColumns)
Constructs an instance with clear double[] type container and default internal solver and transformer.
Parameters:
nRows - a number of matrix rows
nColumns - a number of matrix columns

GreenSolver

public GreenSolver(RealContainer entries,
                   int nRows,
                   int nColumns)
Constructs an instance based on a user's real data container with default internal solver and transformer.
Parameters:
entries - a container of matrix entries
nRows - a number of matrix rows
nColumns - a number of matrix columns

GreenSolver

public GreenSolver(DenseMatrix matrix)
Constructs an instance upon a dense matrix with default internal solver and transformer.
Parameters:
matrix - a 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 number of matrix rows is greater than the columns number, the IllegalArgumentException is thrown. To clean the solver, use attach(null).
Overrides:
attach in class RealDenseSolver

setReductionAccuracy

public final void setReductionAccuracy(double accuracy)
Sets the transformation accuracy level affecting on making the decision ether B matrix column depends on previous columns or not.

getReductionAccuracy

public final double getReductionAccuracy()
Returns the transformation accuracy level.

transformationDefect

public final int transformationDefect()
Returns the transformation defect (the range of null space). Allowed if the matrix is factorized.

transformationNullSpace

public final DenseMatrix transformationNullSpace()
Returns the transformation null space. Allowed if the matrix is factorized.

factorize

public RealDirectSolver factorize()
                           throws CalculatingException
Factorizes the matrix using the original transformation technique.
Overrides:
factorize in class RealDirectSolver
Throws:
CalculatingException - if the factorization of the transformed matrix fails.

solve

public void solve(RealVector source,
                  RealVector target)
Solves SLAE using already factorized matrix.
Overrides:
solve in class RealDirectSolver
Parameters:
source - a source vector (the right hand side of SLAE)
target - a target vector to write the solution