private boolean correctionNearZero() { if (NormOps.normP2(spatialError) < tolerance) { return true; } return false; }
@Override public void process() { output.value= NormOps.normF(((VariableMatrix)A).matrix); } };
/** * <p> * The condition number of a matrix is used to measure the sensitivity of the linear * system <b>Ax=b</b>. A value near one indicates that it is a well conditioned matrix.<br> * <br> * κ<sub>p</sub> = ||A||<sub>p</sub>||A<sup>-1</sup>||<sub>p</sub> * </p> * <p> * If the matrix is not square then the condition of either A<sup>T</sup>A or AA<sup>T</sup> is computed. * <p> * @param A The matrix. * @param p p-norm * @return The condition number. */ public static double conditionP( DenseMatrix64F A , double p ) { if( p == 2 ) { return conditionP2(A); } else if( A.numRows == A.numCols ){ // square matrices are the typical case DenseMatrix64F A_inv = new DenseMatrix64F(A.numRows,A.numCols); if( !CommonOps.invert(A,A_inv) ) throw new IllegalArgumentException("A can't be inverted."); return normP(A,p) * normP(A_inv,p); } else { DenseMatrix64F pinv = new DenseMatrix64F(A.numCols,A.numRows); CommonOps.pinv(A,pinv); return normP(A,p) * normP(pinv,p); } }
/** * Computes either the vector p-norm or the induced matrix p-norm depending on A * being a vector or a matrix respectively. * * @param A Vector or matrix whose norm is to be computed. * @param p The p value of the p-norm. * @return The computed norm. */ public static double normP( DenseMatrix64F A , double p ) { if( p == 1 ) { return normP1(A); } else if( p == 2 ) { return normP2(A); } else if( Double.isInfinite(p)) { return normPInf(A); } if( MatrixFeatures.isVector(A) ) { return elementP(A,p); } else { throw new IllegalArgumentException("Doesn't support induced norms yet."); } }
/** * An unsafe but faster version of {@link #normP} that calls routines which are faster * but more prone to overflow/underflow problems. * * @param A Vector or matrix whose norm is to be computed. * @param p The p value of the p-norm. * @return The computed norm. */ public static double fastNormP( DenseMatrix64F A , double p ) { if( p == 1 ) { return normP1(A); } else if( p == 2 ) { return fastNormP2(A); } else if( Double.isInfinite(p)) { return normPInf(A); } if( MatrixFeatures.isVector(A) ) { return fastElementP(A,p); } else { throw new IllegalArgumentException("Doesn't support induced norms yet."); } }
NormOps.normalizeF(u[0]); double val = NormOps.normF(r); if( val == 0 || Double.isNaN(val) || Double.isInfinite(val)) throw new RuntimeException("Failed sanity check");
/** * This method computes the eigen vector with the largest eigen value by using the * direct power method. This technique is the easiest to implement, but the slowest to converge. * Works only if all the eigenvalues are real. * * @param A The matrix. Not modified. * @return If it converged or not. */ public boolean computeDirect( DenseMatrix64F A ) { initPower(A); boolean converged = false; for( int i = 0; i < maxIterations && !converged; i++ ) { // q0.print(); CommonOps.mult(A,q0,q1); double s = NormOps.normPInf(q1); CommonOps.divide(q1,s,q2); converged = checkConverged(A); } return converged; }
double threshold = NormOps.normPInf(A)*UtilEjml.EPS; NormOps.normalizeF(b); double error = NormOps.normPInf(x);
/** * <p> * The condition p = 2 number of a matrix is used to measure the sensitivity of the linear * system <b>Ax=b</b>. A value near one indicates that it is a well conditioned matrix. * </p> * * @see NormOps#conditionP2(DenseMatrix64F) * * @return The condition number. */ public double conditionP2() { return NormOps.conditionP2(mat); }
CommonOps.subtract(solution, x, solution); System.out.println("File"+qpsFileName); double norm=NormOps.normP1(solution); System.out.println("diffNormToMatlabAnswer="+ norm);
/** * Computes either the vector p-norm or the induced matrix p-norm depending on A * being a vector or a matrix respectively. * * @param A Vector or matrix whose norm is to be computed. * @param p The p value of the p-norm. * @return The computed norm. */ public static double normP( DenseMatrix64F A , double p ) { if( p == 1 ) { return normP1(A); } else if( p == 2 ) { return normP2(A); } else if( Double.isInfinite(p)) { return normPInf(A); } if( MatrixFeatures.isVector(A) ) { return elementP(A,p); } else { throw new IllegalArgumentException("Doesn't support induced norms yet."); } }
/** * An unsafe but faster version of {@link #normP} that calls routines which are faster * but more prone to overflow/underflow problems. * * @param A Vector or matrix whose norm is to be computed. * @param p The p value of the p-norm. * @return The computed norm. */ public static double fastNormP( DenseMatrix64F A , double p ) { if( p == 1 ) { return normP1(A); } else if( p == 2 ) { return fastNormP2(A); } else if( Double.isInfinite(p)) { return normPInf(A); } if( MatrixFeatures.isVector(A) ) { return fastElementP(A,p); } else { throw new IllegalArgumentException("Doesn't support induced norms yet."); } }
NormOps.normalizeF(u[0]); double val = NormOps.normF(r); if( val == 0 || Double.isNaN(val) || Double.isInfinite(val)) throw new RuntimeException("Failed sanity check");
/** * This method computes the eigen vector with the largest eigen value by using the * direct power method. This technique is the easiest to implement, but the slowest to converge. * Works only if all the eigenvalues are real. * * @param A The matrix. Not modified. * @return If it converged or not. */ public boolean computeDirect( DenseMatrix64F A ) { initPower(A); boolean converged = false; for( int i = 0; i < maxIterations && !converged; i++ ) { // q0.print(); CommonOps.mult(A,q0,q1); double s = NormOps.normPInf(q1); CommonOps.divide(s,q1,q2); converged = checkConverged(A); } return converged; }
double threshold = NormOps.normPInf(A)*UtilEjml.EPS; NormOps.normalizeF(b); double error = NormOps.normPInf(x);
/** * <p> * The condition p = 2 number of a matrix is used to measure the sensitivity of the linear * system <b>Ax=b</b>. A value near one indicates that it is a well conditioned matrix. * </p> * * @see NormOps#conditionP2(DenseMatrix64F) * * @return The condition number. */ public double conditionP2() { return NormOps.conditionP2(mat); }
private boolean correctionNearZero() { if (NormOps.normP2(spatialError) < tolerance) { return true; } return false; }