/** * Performs a variety of tests to see if the provided matrix is a valid * covariance matrix. * * @return 0 = is valid 1 = failed positive diagonal, 2 = failed on symmetry, 2 = failed on positive definite */ public static int isValid(FMatrixRMaj cov) { if (!MatrixFeatures_FDRM.isDiagonalPositive(cov)) { return(1); } if (!MatrixFeatures_FDRM.isSymmetric(cov, TOL)) { return(2); } if (!MatrixFeatures_FDRM.isPositiveSemidefinite(cov)) { return(3); } return(0); }
/** * This is a fairly light weight check to see of a covariance matrix is valid. * It checks to see if the diagonal elements are all positive, which they should be * if it is valid. Not all invalid covariance matrices will be caught by this method. * * @return true if valid and false if invalid */ public static bool isValidFast(FMatrixRMaj cov) { return(MatrixFeatures_FDRM.isDiagonalPositive(cov)); }