Search in sources :

Example 1 with CholeskyDecomposition

use of org.apache.commons.math3.linear.CholeskyDecomposition in project incubator-systemml by apache.

the class LibCommonsMath method computeCholesky.

/**
 * Function to compute Cholesky decomposition of the given input matrix.
 * The input must be a real symmetric positive-definite matrix.
 *
 * @param in commons-math3 Array2DRowRealMatrix
 * @return matrix block
 */
private static MatrixBlock computeCholesky(Array2DRowRealMatrix in) {
    if (!in.isSquare())
        throw new DMLRuntimeException("Input to cholesky() must be square matrix -- given: a " + in.getRowDimension() + "x" + in.getColumnDimension() + " matrix.");
    CholeskyDecomposition cholesky = new CholeskyDecomposition(in, 1e-14, CholeskyDecomposition.DEFAULT_ABSOLUTE_POSITIVITY_THRESHOLD);
    RealMatrix rmL = cholesky.getL();
    return DataConverter.convertToMatrixBlock(rmL.getData());
}
Also used : CholeskyDecomposition(org.apache.commons.math3.linear.CholeskyDecomposition) Array2DRowRealMatrix(org.apache.commons.math3.linear.Array2DRowRealMatrix) RealMatrix(org.apache.commons.math3.linear.RealMatrix) DMLRuntimeException(org.apache.sysml.runtime.DMLRuntimeException)

Aggregations

Array2DRowRealMatrix (org.apache.commons.math3.linear.Array2DRowRealMatrix)1 CholeskyDecomposition (org.apache.commons.math3.linear.CholeskyDecomposition)1 RealMatrix (org.apache.commons.math3.linear.RealMatrix)1 DMLRuntimeException (org.apache.sysml.runtime.DMLRuntimeException)1