/** * <p> * Computes a metric which measures the the quality of an eigen value decomposition. If a * value is returned that is close to or smaller than 1e-15 then it is within machine precision. * </p> * <p> * EVD quality is defined as:<br> * <br> * Quality = ||A*V - V*D|| / ||A*V||. * </p> * * @param orig The original matrix. Not modified. * @param eig EVD of the original matrix. Not modified. * @return The quality of the decomposition. */ public static double quality( DenseMatrix64F orig , EigenDecomposition<DenseMatrix64F> eig ) { SimpleMatrix A = SimpleMatrix.wrap(orig); SimpleMatrix V = SimpleMatrix.wrap(EigenOps.createMatrixV(eig)); SimpleMatrix D = SimpleMatrix.wrap(EigenOps.createMatrixD(eig)); SimpleMatrix L = A.mult(V); SimpleMatrix R = V.mult(D); SimpleMatrix diff = L.minus(R); double top = diff.normF(); double bottom = L.normF(); double error = top/bottom; return error; }
/** * <p> * Computes a metric which measures the the quality of an eigen value decomposition. If a * value is returned that is close to or smaller than 1e-15 then it is within machine precision. * </p> * <p> * EVD quality is defined as:<br> * <br> * Quality = ||A*V - V*D|| / ||A*V||. * </p> * * @param orig The original matrix. Not modified. * @param eig EVD of the original matrix. Not modified. * @return The quality of the decomposition. */ public static double quality( DenseMatrix64F orig , EigenDecomposition<DenseMatrix64F> eig ) { SimpleMatrix A = SimpleMatrix.wrap(orig); SimpleMatrix V = SimpleMatrix.wrap(EigenOps.createMatrixV(eig)); SimpleMatrix D = SimpleMatrix.wrap(EigenOps.createMatrixD(eig)); SimpleMatrix L = A.mult(V); SimpleMatrix R = V.mult(D); SimpleMatrix diff = L.minus(R); double top = diff.normF(); double bottom = L.normF(); double error = top/bottom; return error; }
DenseMatrix64F V = EigenOps.createMatrixV(eig); DenseMatrix64F D = EigenOps.createMatrixD(eig);