Esempio n. 1
0
        /**
         * <p>
         * Computes the householder vector from the specified row
         * </p>
         *
         * <p>
         * The householder vector 'u' is computed as follows:<br>
         * <br>
         * u(1) = 1 <br>
         * u(i) = x(i)/(&tau; + x(1))<br>
         * </p>
         *
         * The first element is implicitly assumed to be one and not written.
         *
         * @return If there was any problems or not. true = no problem.
         */
        public static bool computeHouseHolderRow(int blockLength, FSubmatrixD1 Y,
                                                 float[] gamma, int i)
        {
            float max = BlockHouseHolder_FDRB.findMaxRow(blockLength, Y, i, i + 1);

            if (max == 0.0f)
            {
                return(false);
            }
            else
            {
                // computes tau and normalizes u by max
                float tau = computeTauAndDivideRow(blockLength, Y, i, i + 1, max);

                // divide u by u_0
                float u_0 = Y.get(i, i + 1) + tau;
                VectorOps_FDRB.div_row(blockLength, Y, i, u_0, Y, i, i + 1, Y.col1 - Y.col0);

                gamma[Y.row0 + i] = u_0 / tau;

                // after the reflector is applied the column would be all zeros but be -tau in the first element
                Y.set(i, i + 1, -tau * max);
            }
            return(true);
        }