/** * Computes the inverse of the given matrix. * <p> * By default, the inverse of the matrix is computed using the QR-decomposition, * unless a more efficient method can be determined for the input matrix. * <p> * Note: this method will use a singularity threshold of 0, * use {@link #inverse(RealMatrix, double)} if a different threshold is needed. * * @param matrix Matrix whose inverse shall be computed * @return the inverse of {@code matrix} * @throws NullArgumentException if {@code matrix} is {@code null} * @throws SingularMatrixException if m is singular * @throws NonSquareMatrixException if matrix is not square * @since 3.3 */ public static RealMatrix inverse(RealMatrix matrix) throws NullArgumentException, SingularMatrixException, NonSquareMatrixException { return inverse(matrix, 0); }
protected double[][] evaluate(double[][] d1) throws EvaluationException { if (d1.length != d1[0].length) { throw new EvaluationException(ErrorEval.VALUE_INVALID); } Array2DRowRealMatrix temp = new Array2DRowRealMatrix(d1); return MatrixUtils.inverse(temp).getData(); } };
/** * Computes the inverse of the given matrix. * <p> * By default, the inverse of the matrix is computed using the QR-decomposition, * unless a more efficient method can be determined for the input matrix. * <p> * Note: this method will use a singularity threshold of 0, * use {@link #inverse(RealMatrix, double)} if a different threshold is needed. * * @param matrix Matrix whose inverse shall be computed * @return the inverse of {@code matrix} * @throws NullArgumentException if {@code matrix} is {@code null} * @throws SingularMatrixException if m is singular * @throws NonSquareMatrixException if matrix is not square * @since 3.3 */ public static RealMatrix inverse(RealMatrix matrix) throws NullArgumentException, SingularMatrixException, NonSquareMatrixException { return inverse(matrix, 0); }
/** * Computes the inverse of the given matrix. * <p> * By default, the inverse of the matrix is computed using the QR-decomposition, * unless a more efficient method can be determined for the input matrix. * <p> * Note: this method will use a singularity threshold of 0, * use {@link #inverse(RealMatrix, double)} if a different threshold is needed. * * @param matrix Matrix whose inverse shall be computed * @return the inverse of {@code matrix} * @throws NullArgumentException if {@code matrix} is {@code null} * @throws SingularMatrixException if m is singular * @throws NonSquareMatrixException if matrix is not square * @since 3.3 */ public static RealMatrix inverse(RealMatrix matrix) throws NullArgumentException, SingularMatrixException, NonSquareMatrixException { return inverse(matrix, 0); }
protected double[][] evaluate(double[][] d1) throws EvaluationException { if (d1.length != d1[0].length) { throw new EvaluationException(ErrorEval.VALUE_INVALID); } Array2DRowRealMatrix temp = new Array2DRowRealMatrix(d1); return MatrixUtils.inverse(temp).getData(); } };