/** * <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); } }
/** * <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); } }
/** * <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); } }