/** * <p> * Given matrix A and an eigen vector of A, compute the corresponding eigen value. This is * the Rayleigh quotient.<br> * <br> * x<sup>T</sup>Ax / x<sup>T</sup>x * </p> * * * @param A Matrix. Not modified. * @param eigenVector An eigen vector of A. Not modified. * @return The corresponding eigen value. */ public static float computeEigenValue(FMatrixRMaj A, FMatrixRMaj eigenVector) { float bottom = VectorVectorMult_FDRM.innerProd(eigenVector, eigenVector); float top = VectorVectorMult_FDRM.innerProdA(eigenVector, A, eigenVector); return(top / bottom); }
/** * <p> * Checks to see if a matrix is orthogonal or isometric. * </p> * * @param Q The matrix being tested. Not modified. * @param tol Tolerance. * @return True if it passes the test. */ public static bool isOrthogonal(FMatrixRMaj Q, float tol) { if (Q.numRows < Q.numCols) { throw new ArgumentException("The number of rows must be more than or equal to the number of columns"); } FMatrixRMaj[] u = CommonOps_FDRM.columnsToVector(Q, null); for (int i = 0; i < u.Length; i++) { FMatrixRMaj a = u[i]; for (int j = i + 1; j < u.Length; j++) { float val = VectorVectorMult_FDRM.innerProd(a, u[j]); if (!(Math.Abs(val) <= tol)) { return(false); } } } return(true); }