Example usage for org.apache.commons.math3.linear RectangularCholeskyDecomposition RectangularCholeskyDecomposition

List of usage examples for org.apache.commons.math3.linear RectangularCholeskyDecomposition RectangularCholeskyDecomposition

Introduction

In this page you can find the example usage for org.apache.commons.math3.linear RectangularCholeskyDecomposition RectangularCholeskyDecomposition.

Prototype

public RectangularCholeskyDecomposition(RealMatrix matrix) throws NonPositiveDefiniteMatrixException 

Source Link

Document

Decompose a symmetric positive semidefinite matrix.

Usage

From source file:edu.cmu.tetrad.util.MatrixUtils1.java

/**
 * Return true if the given matrix is symmetric positive definite--that is,
 * if it would make a valid covariance matrix.
 *//*from ww  w .  j av a 2s.  c  om*/
@SuppressWarnings({ "BooleanMethodIsAlwaysInverted" })
public static boolean isPositiveDefinite(TetradMatrix matrix) {
    //        DoubleMatrix2D _matrix = new DenseDoubleMatrix2D(matrix.toArray());
    //        System.out.println(MatrixUtils.toString(new CholeskyDecomposition(_matrix).getL().toArray()));
    //        return new CholeskyDecomposition(_matrix).isSymmetricPositiveDefinite();

    try {
        new RectangularCholeskyDecomposition(matrix.getRealMatrix());
    } catch (NonPositiveDefiniteMatrixException e) {
        return false;
    }

    return true;
}