Ejemplo 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 CMatrixRMaj createReflector(CMatrixRMaj u, float gamma)
        {
            if (!MatrixFeatures_CDRM.isVector(u))
            {
                throw new ArgumentException("u must be a vector");
            }

            CMatrixRMaj Q = CommonOps_CDRM.identity(u.getNumElements());

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

            return(Q);
        }
Ejemplo 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 CMatrixRMaj createReflector(CMatrixRMaj u)
        {
            if (!MatrixFeatures_CDRM.isVector(u))
            {
                throw new ArgumentException("u must be a vector");
            }

            float norm  = NormOps_CDRM.normF(u);
            float gamma = -2.0f / (norm * norm);

            CMatrixRMaj Q = CommonOps_CDRM.identity(u.getNumElements());

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

            return(Q);
        }