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.MatrixA immutable identity matrix without defined size.private static final intThe 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.Matrixclone()Returnsthissince this matrix is immutable.doublegetElement(int j, int i) Returns 1 for elements on the diagonal, 0 otherwise.intArbitrarily returns 0.intArbitrarily returns 0.(package private) static MatrixSISinverse(org.opengis.referencing.operation.Matrix X, boolean noChange) Computes the inverse of the given matrix.booleanReturnstruesince this matrix is the identity matrix.voidsetElement(int j, int i, double d) Unsupported operation since this matrix is immutable.private static MatrixSISsolve(double[] LU, org.opengis.referencing.operation.Matrix Y, double[] eltY, int size, int innerSize) Implementation ofsolveandinversemethods.(package private) static MatrixSISsolve(org.opengis.referencing.operation.Matrix X, org.opengis.referencing.operation.Matrix Y) SolvesX× U =Y.private static MatrixSISsolve(org.opengis.referencing.operation.Matrix X, org.opengis.referencing.operation.Matrix Y, double[] eltY, int size, int innerSize, boolean noChange) Implementation ofsolveandinversemethods, 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 theIDENTITYconstant only.
-
-
Method Details
-
isIdentity
public boolean isIdentity()Returnstruesince this matrix is the identity matrix.- Specified by:
isIdentityin 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:
getElementin interfaceorg.opengis.referencing.operation.Matrix
-
setElement
public void setElement(int j, int i, double d) Unsupported operation since this matrix is immutable.- Specified by:
setElementin interfaceorg.opengis.referencing.operation.Matrix
-
clone
public org.opengis.referencing.operation.Matrix clone()Returnsthissince this matrix is immutable. This method is defined because required byMatrixinterface. -
getNumRow
public int getNumRow()Arbitrarily returns 0. The actual value does not matter for the purpose ofSolver.- Specified by:
getNumRowin interfaceorg.opengis.referencing.operation.Matrix
-
getNumCol
public int getNumCol()Arbitrarily returns 0. The actual value does not matter for the purpose ofSolver.- Specified by:
getNumColin 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 theXmatrix.- Throws:
NoninvertibleMatrixException- if theXmatrix 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 theLUDecompositionclass of the JAMA matrix package.- Parameters:
X- the matrix to invert.Y- the desired result ofX× U.- Throws:
NoninvertibleMatrixException- if theXmatrix 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 ofsolveandinversemethods, 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 theYmatrix, ornullif not available.size- the value ofX.getNumRow(),X.getNumCol()andY.getNumRow().innerSize- the value ofY.getNumCol().noChange- iftrue, do not allow modifications to theXmatrix.- Throws:
NoninvertibleMatrixException- if theXmatrix 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 ofsolveandinversemethods. 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 theXmatrix to invert, including error terms.Y- the desired result ofX× U.eltY- elements and error terms of theYmatrix, ornullif not available.size- the value ofX.getNumRow(),X.getNumCol()andY.getNumRow().innerSize- the value ofY.getNumCol().- Throws:
NoninvertibleMatrixException- if theXmatrix is not square or singular.
-