|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--ru.sscc.matrix.solve.RealDirectSolver | +--ru.sscc.matrix.solve.RealDenseSolver | +--ru.sscc.matrix.solve.RealCommonSolver
Basic abstract class for direct solvers of SLAE with a real rectangular dense matrix. Usually, the QU decomposition of the matrix is used where Q is an orthogonal matrix and U is an upper triangular matrix. If the matrix rows number is greater than the columns number, all superfluous rows will be ignored after their annulment in factorization. This case corresponds to the solving of the system by the Least Square Method, and its solution is called the pseudosolution. The factorization never fails. So, a solution or pseudosolution may be found for any SLAE. If the matrix has nontrivial null space (e.g. some matrix columns depend on other columns), the solution is not unique, but there exists the unique normal solution having the minimum Euqlidian norm. The null space orthonormal base it calculated in this class on the factorization step, and the normal pseudosolution of the SLAE is constructed by the solve method.
When the matrix is factorized by factors, the matrix range is calculated. Then it is compared with the possible maximal range (the minimum of row and column numbers) and if the factorized matrix has non-maximal range, the CalculatingException will be thrown at the end of factorization. You can ignore the exception and solve the system in this case also. The solving of transposed SLAE is also possible.
The additional solveT() method allows to solve systems with the transposed matrix basing on the factorization of the original matrix. To minimaze memory use, we recommend to factorize the matrix having more rows than columns and then use solve() or solveT() method for the solving.
The balancing of the matrix before the factorization may improve the accuracy of the result. We use a special row balancing algorithm for this purpose. Try to set the balance tag before the factorization if you don't like the solution.
Special abstract methods are added to the solver because they are
useful in the GreenSolver
and may also have the self-dependent
interest.
Note: nonorthogonal decomposition is also useful, but in this case the solution of the system having more rows than columns will be non-pseudosolution.
Field Summary | |
protected double[] |
balanceVector
The balance vector. |
protected int |
range
The calculated matrix range. |
Fields inherited from class ru.sscc.matrix.solve.RealDenseSolver |
matrix |
Constructor Summary | |
RealCommonSolver()
|
Method Summary | |
void |
attach(DenseMatrix matrix)
Attaches a matrix to the solver and sets the initial state for the solver and matrix. |
void |
backSubstitution(RealVector source,
RealVector target)
Applies the back substitution to the vector (the last step of solving SLAE with already factorized matrix) and constructs the normal solution if the null space is nontrivial. |
void |
backSubstitutionT(RealVector source,
RealVector target)
Applies the transposed back substituon to the vector with the upper triangular matrix from the last step of solving SLAE (this is the first step of solving SLAE with the transposed matrix). |
protected void |
balance()
The matrix balancing algorithm. |
double[] |
balanceVector()
Returns the balance vector calculated on the factorization or null if the factorization was proceeded without balancing. |
protected void |
columnFactorized(int i)
This method must be called at the end of i-th column factorization. |
protected void |
doBackSubstitution(RealVector source,
RealVector target)
The kernal method for the back substitution. |
protected void |
doBackSubstitutionT(RealVector source,
RealVector target)
The kernal method for the transposed back substitution. |
protected abstract void |
doFactorize()
The kernal method for the factorization. |
protected void |
ensureTransformable(DenseMatrix matrix)
Tests the dense matrix to be transformable by the orthogonal transformation. |
RealDirectSolver |
factorize()
Factorizes the dense rectangular matrix. |
double |
getReductionAccuracy()
Returns the reduction accuracy level. |
boolean |
hasBalanceTag()
Returns true if the balance tag is turned on. |
int |
matrixRange()
Returns the calculated matrix range. |
DenseMatrix |
nullSpace()
Returns the matrix of null space base or null if the factorized matrix has the trivial null space. |
int |
nullSpaceRange()
Returns the calculated null space range. |
protected void |
prepareNullVector(int i)
Prepares a new basic vector of the matrix null space by i-th matrix column. |
void |
reuse()
Clears the factorization tag to reuse the attached matrix once more and frees additional memory occupied from the previous use. |
void |
setBalanceTag(boolean balanceTag)
Sets the balance tag. |
void |
setReductionAccuracy(double accuracy)
Sets the reduction accuracy level affecting on making the decision ether a matrix column depends on previous columns or not. |
void |
solve(RealVector source,
RealVector target)
Solves SLAE with already factorized matrix. |
void |
solveT(RealVector source,
RealVector target)
Solves transposed SLAE with already factorized original matrix. |
abstract void |
transform(DenseMatrix matrix)
Applies the orthogonal transformation to the dense matrix in the same order as it was done at the factorization of the attached matrix. |
abstract void |
transform(RealVector vector)
Applies the orthogonal transformation to the vector in the same order as it was done at the factorization of the attached matrix (the first step of solving SLAE with already factorized matrix). |
abstract void |
transformT(RealVector vector)
Applies the transpose orthogonal transformation to the vector. |
Methods inherited from class ru.sscc.matrix.solve.RealDenseSolver |
clone,
forwardSubstitution,
getMatrix,
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 |
protected int range
protected double[] balanceVector
Constructor Detail |
public RealCommonSolver()
Method Detail |
public void attach(DenseMatrix matrix)
public void reuse()
public final void setReductionAccuracy(double accuracy)
public final double getReductionAccuracy()
public final void setBalanceTag(boolean balanceTag)
public final boolean hasBalanceTag()
public final double[] balanceVector()
public final int matrixRange()
public final int nullSpaceRange()
public final DenseMatrix nullSpace()
protected void balance()
public RealDirectSolver factorize() throws CalculatingException
CalculatingException
.
Any case the method sets the factorization tag to true.protected abstract void doFactorize()
factorize()
method when all preliminary
actions for the factorization are already made: the balancing of the
matrix is done if necessary and the initial matrix and null space ranges
are set to zero.
The method should do the factorization in column-per-column order.
It must start the factorization of i-th column from the testing its linear
dependency. To do this, the norm of the first range column entries
(norm1) is compared with the norm of the rest of column (norm2).
If norm2<=eps*norm1 for the sufficiently small eps, the column is
considered to be depending on previous columns. In this case, the
prepareNullVector(i)
method must be called
and the processing of the current column is finished. Otherwise,
the method must factorize the column, increase the range, and
call the columnFactorized(i)
method.
The result of the factorization must be stored in the
first range columns of the matrix. If some column was not
factorized in the main cycle, the columns following after it must be
moved to the left to remove empty column. The movement of any column
should be done when it is factorized. So, a column may change the position
in the matrix only while its factorization is proceeded.protected final void columnFactorized(int i)
protected void prepareNullVector(int i)
public void solve(RealVector source, RealVector target)
source
- a source vector (the right hand side of SLAE)target
- a target vector to write the solutionpublic void solveT(RealVector source, RealVector target)
source
- a source vector (the right hand side of transposed SLAE)target
- a target vector to write the solutionpublic void backSubstitution(RealVector source, RealVector target)
source
- the source vector (only the first range its
entries are used)target
- the vector to store the result (must have at least
nColumns entries)protected void doBackSubstitution(RealVector source, RealVector target)
source
- the source vector (the range entries are used)target
- the target vector (the range entries are filled in)public void backSubstitutionT(RealVector source, RealVector target)
source
- the source vector (must have at least
nColumns entries).target
- the vector to store the result (only the first range
its entries are used)protected void doBackSubstitutionT(RealVector source, RealVector target)
source
- the source vector (the range entries are used)
$param target the target vector (the range entries are filled in)public abstract void transform(DenseMatrix matrix)
public abstract void transform(RealVector vector)
public abstract void transformT(RealVector vector)
protected final void ensureTransformable(DenseMatrix matrix)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |