示例#1
0
        private void performImplicitDoubleStep(int x1, int x2,
                                               float b11, float b21, float b31)
        {
            if (!bulgeDoubleStepQn(x1, b11, b21, b31, 0, false))
            {
                return;
            }

            // get rid of the bump
            if (Q != null)
            {
                QrHelperFunctions_FDRM.rank1UpdateMultR(Q, u.data, gamma, 0, x1, x1 + 3, _temp.data);
                if (checkOrthogonal && !MatrixFeatures_FDRM.isOrthogonal(Q, UtilEjml.TEST_F32))
                {
                    u.print();

                    Q.print();
                    throw new InvalidOperationException("Bad");
                }
            }

            if (printHumps)
            {
                Console.WriteLine("Applied first Q matrix, it should be humped now. A = ");
                A.print("%12.3fe");
                Console.WriteLine("Pushing the hump off the matrix.");
            }

            // perform float steps
            for (int i = x1; i < x2 - 2; i++)
            {
                if (bulgeDoubleStepQn(i) && Q != null)
                {
                    QrHelperFunctions_FDRM.rank1UpdateMultR(Q, u.data, gamma, 0, i + 1, i + 4, _temp.data);
                    if (checkOrthogonal && !MatrixFeatures_FDRM.isOrthogonal(Q, UtilEjml.TEST_F32))
                    {
                        throw new InvalidOperationException("Bad");
                    }
                }

                if (printHumps)
                {
                    Console.WriteLine("i = " + i + " A = ");
                    A.print("%12.3fe");
                }
            }
            if (printHumps)
            {
                Console.WriteLine("removing last bump");
            }
            // the last one has to be a single step
            if (x2 - 2 >= 0 && bulgeSingleStepQn(x2 - 2) && Q != null)
            {
                QrHelperFunctions_FDRM.rank1UpdateMultR(Q, u.data, gamma, 0, x2 - 1, x2 + 1, _temp.data);
                if (checkOrthogonal && !MatrixFeatures_FDRM.isOrthogonal(Q, UtilEjml.TEST_F32))
                {
                    throw new InvalidOperationException("Bad");
                }
            }
            if (printHumps)
            {
                Console.WriteLine(" A = ");
                A.print("%12.3fe");
            }
//        A.print("%12.3fe");

            if (checkHessenberg && !MatrixFeatures_FDRM.isUpperTriangle(A, 1, UtilEjml.TEST_F32))
            {
                A.print("%12.3fe");
                throw new InvalidOperationException("Bad matrix");
            }
        }