Beispiel #1
0
        public void performImplicitSingleStep(int x1, int x2, double eigenvalue)
        {
            if (!createBulgeSingleStep(x1, eigenvalue))
            {
                return;
            }

            // get rid of the bump
            if (Q != null)
            {
                QrHelperFunctions_DDRM.rank1UpdateMultR(Q, u.data, gamma, 0, x1, x1 + 2, _temp.data);
                if (checkOrthogonal && !MatrixFeatures_DDRM.isOrthogonal(Q, UtilEjml.TEST_F64))
                {
                    throw new InvalidOperationException("Bad");
                }
            }

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

            // perform simple steps
            for (int i = x1; i < x2 - 1; i++)
            {
                if (bulgeSingleStepQn(i) && Q != null)
                {
                    QrHelperFunctions_DDRM.rank1UpdateMultR(Q, u.data, gamma, 0, i + 1, i + 3, _temp.data);
                    if (checkOrthogonal && !MatrixFeatures_DDRM.isOrthogonal(Q, UtilEjml.TESTP_F64))
                    {
                        throw new InvalidOperationException("Bad");
                    }
                }

                if (printHumps)
                {
                    Console.WriteLine("i = " + i + " A = ");
                    A.print("%12.3e");
                }
            }

            if (checkHessenberg && !MatrixFeatures_DDRM.isUpperTriangle(A, 1, UtilEjml.TESTP_F64))
            {
                A.print("%12.3e");
                throw new InvalidOperationException("Bad matrix");
            }
        }
Beispiel #2
0
        private void performImplicitDoubleStep(int x1, int x2,
                                               double b11, double b21, double b31)
        {
            if (!bulgeDoubleStepQn(x1, b11, b21, b31, 0, false))
            {
                return;
            }

            // get rid of the bump
            if (Q != null)
            {
                QrHelperFunctions_DDRM.rank1UpdateMultR(Q, u.data, gamma, 0, x1, x1 + 3, _temp.data);
                if (checkOrthogonal && !MatrixFeatures_DDRM.isOrthogonal(Q, UtilEjml.TEST_F64))
                {
                    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.3e");
                Console.WriteLine("Pushing the hump off the matrix.");
            }

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

                if (printHumps)
                {
                    Console.WriteLine("i = " + i + " A = ");
                    A.print("%12.3e");
                }
            }
            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_DDRM.rank1UpdateMultR(Q, u.data, gamma, 0, x2 - 1, x2 + 1, _temp.data);
                if (checkOrthogonal && !MatrixFeatures_DDRM.isOrthogonal(Q, UtilEjml.TEST_F64))
                {
                    throw new InvalidOperationException("Bad");
                }
            }
            if (printHumps)
            {
                Console.WriteLine(" A = ");
                A.print("%12.3e");
            }
//        A.print("%12.3e");

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