Class Solver
java.lang.Object
org.apache.sis.referencing.operation.matrix.Solver
- All Implemented Interfaces:
org.opengis.referencing.operation.Matrix
Computes the value of U which solves
X
× U = Y
.
The solve(double[], Matrix, double[], int, int)
method in this class is adapted from the
LUDecomposition
class of the JAMA matrix package.
JAMA is provided in the public domain.
This class implements the Matrix
interface as an implementation convenience.
This implementation details can be ignored.
- Since:
- 0.4
- Version:
- 0.4
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final org.opengis.referencing.operation.Matrix
A immutable identity matrix without defined size.private static final int
The size of the (i, j, s) tuples used internally bysolve(Matrix, Matrix, double[], int, int, boolean)
for storing information about the NaN values. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.opengis.referencing.operation.Matrix
clone()
Returnsthis
since this matrix is immutable.double
getElement
(int j, int i) Returns 1 for elements on the diagonal, 0 otherwise.int
Arbitrarily returns 0.int
Arbitrarily returns 0.(package private) static MatrixSIS
inverse
(org.opengis.referencing.operation.Matrix X, boolean noChange) Computes the inverse of the given matrix.boolean
Returnstrue
since this matrix is the identity matrix.void
setElement
(int j, int i, double d) Unsupported operation since this matrix is immutable.private static MatrixSIS
solve
(double[] LU, org.opengis.referencing.operation.Matrix Y, double[] eltY, int size, int innerSize) Implementation ofsolve
andinverse
methods.(package private) static MatrixSIS
solve
(org.opengis.referencing.operation.Matrix X, org.opengis.referencing.operation.Matrix Y) SolvesX
× U =Y
.private static MatrixSIS
solve
(org.opengis.referencing.operation.Matrix X, org.opengis.referencing.operation.Matrix Y, double[] eltY, int size, int innerSize, boolean noChange) Implementation ofsolve
andinverse
methods, with filtering of NaN values.
-
Field Details
-
TUPLE_SIZE
private static final int TUPLE_SIZEThe size of the (i, j, s) tuples used internally bysolve(Matrix, Matrix, double[], int, int, boolean)
for storing information about the NaN values.- See Also:
-
IDENTITY
private static final org.opengis.referencing.operation.Matrix IDENTITYA immutable identity matrix without defined size. This is used only for computing the inverse.
-
-
Constructor Details
-
Solver
private Solver()For theIDENTITY
constant only.
-
-
Method Details
-
isIdentity
public boolean isIdentity()Returnstrue
since this matrix is the identity matrix.- Specified by:
isIdentity
in interfaceorg.opengis.referencing.operation.Matrix
-
getElement
public double getElement(int j, int i) Returns 1 for elements on the diagonal, 0 otherwise. This method never thrown exception.- Specified by:
getElement
in interfaceorg.opengis.referencing.operation.Matrix
-
setElement
public void setElement(int j, int i, double d) Unsupported operation since this matrix is immutable.- Specified by:
setElement
in interfaceorg.opengis.referencing.operation.Matrix
-
clone
public org.opengis.referencing.operation.Matrix clone()Returnsthis
since this matrix is immutable. This method is defined because required byMatrix
interface. -
getNumRow
public int getNumRow()Arbitrarily returns 0. The actual value does not matter for the purpose ofSolver
.- Specified by:
getNumRow
in interfaceorg.opengis.referencing.operation.Matrix
-
getNumCol
public int getNumCol()Arbitrarily returns 0. The actual value does not matter for the purpose ofSolver
.- Specified by:
getNumCol
in interfaceorg.opengis.referencing.operation.Matrix
-
inverse
static MatrixSIS inverse(org.opengis.referencing.operation.Matrix X, boolean noChange) throws NoninvertibleMatrixException Computes the inverse of the given matrix. This method shall be invoked only for square matrices.- Parameters:
X
- the matrix to invert, which must be square.noChange
- iftrue
, do not allow modifications to theX
matrix.- Throws:
NoninvertibleMatrixException
- if theX
matrix is not square or singular.
-
solve
static MatrixSIS solve(org.opengis.referencing.operation.Matrix X, org.opengis.referencing.operation.Matrix Y) throws NoninvertibleMatrixException SolvesX
× U =Y
. This method is an adaptation of theLUDecomposition
class of the JAMA matrix package.- Parameters:
X
- the matrix to invert.Y
- the desired result ofX
× U.- Throws:
NoninvertibleMatrixException
- if theX
matrix is not square or singular.
-
solve
private static MatrixSIS solve(org.opengis.referencing.operation.Matrix X, org.opengis.referencing.operation.Matrix Y, double[] eltY, int size, int innerSize, boolean noChange) throws NoninvertibleMatrixException Implementation ofsolve
andinverse
methods, with filtering of NaN values. This method searches for NaN values before to attempt solving or inverting the matrix. If some NaN values are found but the matrix is written in such a way that each NaN value is used for exactly one coordinate value (i.e. a matrix row is used for a one-dimensional conversion which is independent of all other dimensions), then we will edit the matrix in such a way that this NaN value does not prevent the inverse matrix to be computed.This method does not checks the matrix size. Check for matrix size shall be performed by the caller like below:
- Parameters:
X
- the matrix to invert, which must be square.Y
- the desired result ofX
× U.eltY
- elements and error terms of theY
matrix, ornull
if not available.size
- the value ofX.getNumRow()
,X.getNumCol()
andY.getNumRow()
.innerSize
- the value ofY.getNumCol()
.noChange
- iftrue
, do not allow modifications to theX
matrix.- Throws:
NoninvertibleMatrixException
- if theX
matrix is not square or singular.
-
solve
private static MatrixSIS solve(double[] LU, org.opengis.referencing.operation.Matrix Y, double[] eltY, int size, int innerSize) throws NoninvertibleMatrixException Implementation ofsolve
andinverse
methods. This method contains the code ported from the JAMA package. Use a "left-looking", dot-product, Crout/Doolittle algorithm.This method does not checks the matrix size. It is caller's responsibility to ensure that the following hold:
- Parameters:
LU
- elements of theX
matrix to invert, including error terms.Y
- the desired result ofX
× U.eltY
- elements and error terms of theY
matrix, ornull
if not available.size
- the value ofX.getNumRow()
,X.getNumCol()
andY.getNumRow()
.innerSize
- the value ofY.getNumCol()
.- Throws:
NoninvertibleMatrixException
- if theX
matrix is not square or singular.
-