Esempio n. 1
0
        /**
         * <p>
         * Creates a reflector from the provided vector and gamma.<br>
         * <br>
         * Q = I - &gamma; u u<sup>H</sup><br>
         * </p>
         *
         * @param u A vector.  Not modified.
         * @param gamma To produce a reflector gamma needs to be equal to 2/||u||.
         * @return An orthogonal reflector.
         */
        public static ZMatrixRMaj createReflector(ZMatrixRMaj u, double gamma)
        {
            if (!MatrixFeatures_ZDRM.isVector(u))
            {
                throw new ArgumentException("u must be a vector");
            }

            ZMatrixRMaj Q = CommonOps_ZDRM.identity(u.NumElements);

            CommonOps_ZDRM.multAddTransB(-gamma, 0, u, u, Q);

            return(Q);
        }
Esempio n. 2
0
        /**
         * <p>
         * Creates a reflector from the provided vector.<br>
         * <br>
         * Q = I - &gamma; u u<sup>T</sup><br>
         * &gamma; = 2/||u||<sup>2</sup>
         * </p>
         *
         * @param u A vector. Not modified.
         * @return An orthogonal reflector.
         */
        public static ZMatrixRMaj createReflector(ZMatrixRMaj u)
        {
            if (!MatrixFeatures_ZDRM.isVector(u))
            {
                throw new ArgumentException("u must be a vector");
            }

            double norm  = NormOps_ZDRM.normF(u);
            double gamma = -2.0 / (norm * norm);

            ZMatrixRMaj Q = CommonOps_ZDRM.identity(u.NumElements);

            CommonOps_ZDRM.multAddTransB(gamma, 0, u, u, Q);

            return(Q);
        }
Esempio n. 3
0
 public static ZMatrixRMaj checkIdentity(ZMatrixRMaj A, int numRows, int numCols)
 {
     if (A == null)
     {
         return(CommonOps_ZDRM.identity(numRows, numCols));
     }
     else if (numRows != A.numRows || numCols != A.numCols)
     {
         throw new ArgumentException("Input is not " + numRows + " x " + numCols + " matrix");
     }
     else
     {
         CommonOps_ZDRM.setIdentity(A);
     }
     return(A);
 }