+ *

This method delegates the work to {@code inverse().multiply(matrix)} in order to leverage + * the special handling done by {@code inverse()} for non-square matrices.

+ */ + @Override + public MatrixSIS solve(final Matrix matrix) throws MismatchedMatrixSizeException, NoninvertibleMatrixException { + MatrixSIS result = inverse(); + if (!matrix.isIdentity()) { + result = result.multiply(matrix); + } + return result; + } + + /** + * {@inheritDoc} + * + *

This method performs a special check for non-square matrices in an attempt to invert them anyway. + * If this matrix has more columns than rows, then this method can invert that matrix if and only if + * some columns contain only 0 elements. In such case, the dimensions corresponding to those columns are + * considered independent of all other dimensions. This happen typically with the dimension of z + * and t ordinate values.

+ * + *

Example: in a conversion from (x₁,y₁,z,t) to (x₂,y₂), if the (x,y) dimensions are independent + * of z and t dimensions, then we do not need those (z,t) dimensions for calculating the inverse of (x₁,y₁) + * to (x₂,y₂). We can omit the (z,t) dimensions in order to have a square matrix, perform the inversion, + * then insert NaN in place of the omitted dimensions. In the matrix below, we can see that (x,y) are + * independent of (z,t) because the 3th and 4th columns contains only 0 elements: