예제 #1
0
        /**
         * <p>
         * Computes the householder vector that is used to create reflector for the column.
         * The results are stored in the original matrix.
         * </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 computeHouseHolderCol(int blockLength, DSubmatrixD1 Y,
                                                 double[] gamma, int i)
        {
            double max = BlockHouseHolder_DDRB.findMaxCol(blockLength, Y, i);

            if (max == 0.0)
            {
                return(false);
            }
            else
            {
                // computes tau and normalizes u by max
                double tau = computeTauAndDivideCol(blockLength, Y, i, max);

                // divide u by u_0
                double u_0 = Y.get(i, i) + tau;
                divideElementsCol(blockLength, Y, i, u_0);

                gamma[Y.col0 + i] = u_0 / tau;
                tau *= max;

                // after the reflector is applied the column would be all zeros but be -tau in the first element
                Y.set(i, i, -tau);
            }
            return(true);
        }
예제 #2
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, DSubmatrixD1 Y,
                                                 double[] gamma, int i)
        {
            double max = BlockHouseHolder_DDRB.findMaxRow(blockLength, Y, i, i + 1);

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

                // divide u by u_0
                double u_0 = Y.get(i, i + 1) + tau;
                VectorOps_DDRB.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);
        }