Exemple #1
0
        /**
         * <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(DMatrixRMaj Q, double tol)
        {
            if (Q.numRows < Q.numCols)
            {
                throw new ArgumentException("The number of rows must be more than or equal to the number of columns");
            }

            DMatrixRMaj[] u = CommonOps_DDRM.columnsToVector(Q, null);

            for (int i = 0; i < u.Length; i++)
            {
                DMatrixRMaj a = u[i];

                for (int j = i + 1; j < u.Length; j++)
                {
                    double val = VectorVectorMult_DDRM.innerProd(a, u[j]);

                    if (!(Math.Abs(val) <= tol))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Exemple #2
0
        /**
         * <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 double computeEigenValue(DMatrixRMaj A, DMatrixRMaj eigenVector)
        {
            double bottom = VectorVectorMult_DDRM.innerProd(eigenVector, eigenVector);
            double top    = VectorVectorMult_DDRM.innerProdA(eigenVector, A, eigenVector);

            return(top / bottom);
        }
Exemple #3
0
        /// <summary>
        /// Computes the dot product (a.k.a. inner product) between this vector and vector 'v'.
        /// </summary>
        /// <param name="v">The second vector in the dot product.  Not modified.</param>
        public override double dot(SimpleMatrixD v)
        {
            if (!isVector())
            {
                throw new ArgumentException("'this' matrix is not a vector.");
            }
            else if (!v.isVector())
            {
                throw new ArgumentException("'v' matrix is not a vector.");
            }

            var vm = v.getMatrix();

            return(VectorVectorMult_DDRM.innerProd(mat, vm));
        }