public static boolean isEquals( BlockMatrix64F A , BlockMatrix64F B ) { if( A.blockLength != B.blockLength ) return false; return MatrixFeatures.isEquals(A,B); }
/** * 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( DenseMatrix64F cov ) { if( !MatrixFeatures.isDiagonalPositive(cov) ) return 1; if( !MatrixFeatures.isSymmetric(cov,TOL) ) return 2; if( !MatrixFeatures.isPositiveSemidefinite(cov) ) return 3; return 0; }
public static void checkSquare(DenseMatrix64F m) { if (!MatrixFeatures.isSquare(m)) throw new RuntimeException("Matrix is not square: " + m); }
@Override public void process() { DenseMatrix64F a = ((VariableMatrix)A).matrix; DenseMatrix64F b = ((VariableMatrix)B).matrix; if( !MatrixFeatures.isVector(a) || !MatrixFeatures.isVector(b)) throw new RuntimeException("Both inputs to dot() must be vectors"); output.value = VectorVectorMult.innerProd(a,b); } };
/** * Checks to see if any of the elements in this matrix are either NaN or infinite. * * @return True of an element is NaN or infinite. False otherwise. */ public boolean hasUncountable() { return MatrixFeatures.hasUncountable(mat); }
if( checkOrthogonal && !MatrixFeatures.isOrthogonal(Q,1e-8) ) throw new RuntimeException("Bad"); if( bulgeSingleStepQn(i) && Q != null ) { QrHelperFunctions_D64.rank1UpdateMultR(Q, u.data, gamma, 0, i + 1, i + 3, _temp.data); if( checkOrthogonal && !MatrixFeatures.isOrthogonal(Q,1e-8) ) throw new RuntimeException("Bad"); if( checkHessenberg && !MatrixFeatures.isUpperTriangle(A,1,1e-12)) { A.print("%12.3e"); throw new RuntimeException("Bad matrix");
/** * Checks to see if matrix 'a' is the same as this matrix within the specified * tolerance. * * @param a The matrix it is being compared against. * @param tol How similar they must be to be equals. * @return If they are equal within tolerance of each other. */ public boolean isIdentical(T a, double tol) { return MatrixFeatures.isIdentical(mat,a.getMatrix(),tol); }
private void checkForNaN(DenseMatrix64F matrix) { if (doChecks) { if ((matrix != null) && MatrixFeatures.hasNaN(matrix)) { throw new RuntimeException("Matrix contains NaN: " + matrix); } } }
public static void checkPositiveSemiDefinite(DenseMatrix64F m) { if (!MatrixFeatures.isPositiveSemidefinite(m)) throw new RuntimeException("Matrix is not positive semidefinite: " + m); }
private boolean isNullspaceComponentZero(DenseMatrix64F matrixToTest, DenseMatrix64F nullspace) { DenseMatrix64F nullspaceCheck = new DenseMatrix64F(nullspace.getNumCols(), matrixToTest.getNumCols()); CommonOps.multTransA(nullspace, matrixToTest, nullspaceCheck); boolean nullspaceComponentZero = MatrixFeatures.isConstantVal(nullspaceCheck, 0.0, 1e-7); return nullspaceComponentZero; } }
/** * 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 boolean isValidFast( DenseMatrix64F cov ) { return MatrixFeatures.isDiagonalPositive(cov); }
/** * <p></p> * Computes the dot product or inner product between two vectors. If the two vectors are columns vectors * then it is defined as:<br> * {@code dot(a,b) = a<sup>T</sup> * b}<br> * If the vectors are column or row or both is ignored by this function. * </p> * @param a Vector * @param b Vector * @return Dot product of the two vectors */ public static double dot( D1Matrix64F a , D1Matrix64F b ) { if( !MatrixFeatures.isVector(a) || !MatrixFeatures.isVector(b)) throw new RuntimeException("Both inputs must be vectors"); return VectorVectorMult.innerProd(a,b); }
/** * Checks to see if any of the elements in this matrix are either NaN or infinite. * * @return True of an element is NaN or infinite. False otherwise. */ public boolean hasUncountable() { return MatrixFeatures.hasUncountable(mat); }
if( checkOrthogonal && !MatrixFeatures.isOrthogonal(Q,1e-8) ) throw new RuntimeException("Bad"); if( bulgeSingleStepQn(i) && Q != null ) { QrHelperFunctions.rank1UpdateMultR(Q,u.data,gamma,0,i+1,i+3,_temp.data); if( checkOrthogonal && !MatrixFeatures.isOrthogonal(Q,1e-8) ) throw new RuntimeException("Bad"); if( checkHessenberg && !MatrixFeatures.isUpperTriangle(A,1,1e-12)) { A.print("%12.3e"); throw new RuntimeException("Bad matrix");
/** * Checks to see if matrix 'a' is the same as this matrix within the specified * tolerance. * * @param a The matrix it is being compared against. * @param tol How similar they must be to be equals. * @return If they are equal within tolerance of each other. */ public boolean isIdentical(T a, double tol) { return MatrixFeatures.isIdentical(mat,a.getMatrix(),tol); }
private void checkForNaN(DenseMatrix64F matrix) { if (doChecks) { if ((matrix != null) && MatrixFeatures.hasNaN(matrix)) { throw new RuntimeException("Matrix contains NaN: " + matrix); } } }
public static void checkPositiveSemiDefinite(DenseMatrix64F m) { if (!MatrixFeatures.isPositiveSemidefinite(m)) throw new RuntimeException("Matrix is not positive semidefinite: " + m); }
public boolean areConstraintsEnforcedSuccesfully(DenseMatrix64F x, DenseMatrix64F j, DenseMatrix64F p, double epsilon) { // This check is only valid if you use an 'exact' solver, not if you're using the damped least squares 'pseudoinverse' if (j.getNumRows() > 0) { check.reshape(p.getNumRows(), 1); CommonOps.mult(j, x, check); CommonOps.subtractEquals(check, p); return MatrixFeatures.isConstantVal(check, 0.0, epsilon); } return true; } }
/** * 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 boolean isValidFast( DenseMatrix64F cov ) { return MatrixFeatures.isDiagonalPositive(cov); }
public static boolean isEquals( BlockMatrix64F A , BlockMatrix64F B ) { if( A.blockLength != B.blockLength ) return false; return MatrixFeatures.isEquals(A,B); }