List of usage examples for org.apache.commons.math3.linear RectangularCholeskyDecomposition RectangularCholeskyDecomposition
public RectangularCholeskyDecomposition(RealMatrix matrix) throws NonPositiveDefiniteMatrixException
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; }