Example #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.getNumElements());

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

            return(Q);
        }
Example #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.getNumElements());

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

            return(Q);
        }