Esempio n. 1
0
        public static TMatrix operator ~(TMatrix A)
        {
            int k_step;
            bool Stop = false;
            double phi_k;
            double phi_k1;

            TMatrix A_plus = new TMatrix();
            TMatrix F_k = new TMatrix();
            TMatrix F_k1 = new TMatrix();
            TMatrix I = new TMatrix();
            TMatrix AtA = new TMatrix();

            TMatrix M = new TMatrix(A.GetCols(), A.GetRows());

            AtA = !M * M;
            //C++ TO C# CONVERTER WARNING: The following line was determined to be a copy assignment (rather than a reference assignment) - this should be verified and a 'CopyFrom' method should be created if it does not yet exist:
            //ORIGINAL LINE: F_k = AtA;
            F_k.CopyFrom(AtA);
            F_k.Make_I();
            //C++ TO C# CONVERTER WARNING: The following line was determined to be a copy assignment (rather than a reference assignment) - this should be verified and a 'CopyFrom' method should be created if it does not yet exist:
            //ORIGINAL LINE: I = AtA;
            I.CopyFrom(AtA);
            I.Make_I();

            //C++ TO C# CONVERTER WARNING: The following line was determined to be a copy assignment (rather than a reference assignment) - this should be verified and a 'CopyFrom' method should be created if it does not yet exist:
            //ORIGINAL LINE: F_k = I;
            F_k.CopyFrom(I);
            phi_k = AtA.Trace();
            k_step = 2;

            for (; ; )
            {
                F_k1 = (phi_k * I) - (AtA * F_k);
                phi_k1 = (AtA * F_k1).Trace() / k_step;

                if (Math.Abs(phi_k1) == 0)
                    Stop = true;
                if (k_step > M.GetRows())
                    Stop = true;
                if (k_step > M.GetCols())
                    Stop = true;
                if (Stop == true)
                    break;

                //C++ TO C# CONVERTER WARNING: The following line was determined to be a copy assignment (rather than a reference assignment) - this should be verified and a 'CopyFrom' method should be created if it does not yet exist:
                //ORIGINAL LINE: F_k = F_k1;
                F_k.CopyFrom(F_k1);
                phi_k = phi_k1;
                k_step++;
            }

            TMatrix No_rang = new TMatrix(1, 1);
            No_rang.PutElm(0, 0, (double)10E+200);
            //C++ TO C# CONVERTER WARNING: The following line was determined to be a copy assignment (rather than a reference assignment) - this should be verified and a 'CopyFrom' method should be created if it does not yet exist:
            //ORIGINAL LINE: A_plus = No_rang;
            A_plus.CopyFrom(No_rang);
            if (phi_k == 0)
                return A_plus;
            A_plus = (1 / phi_k) * F_k * (!M);
            return A_plus;
        }
Esempio n. 2
0
 //---------------------------------------------------------------------------
 public static TMatrix operator -(TMatrix A, TMatrix B)
 {
     TMatrix M = new TMatrix();
     if (A.GetRows() == B.GetRows() && A.GetCols() == B.GetCols())
     {
         //C++ TO C# CONVERTER WARNING: The following line was determined to be a copy assignment (rather than a reference assignment) - this should be verified and a 'CopyFrom' method should be created if it does not yet exist:
         //ORIGINAL LINE: M = A;
         M.CopyFrom(A);
         for (int i = 0; i < M.GetRows(); i++)
             for (int j = 0; j < M.GetCols(); j++)
                 M.PutElm(i, j, A.GetElm(i, j) - B.GetElm(i, j));
     }
     else
         //throw E;
         throw new System.ApplicationException("попытка вычитани¤ матриц разного размера");
     return M;
 }