Пример #1
0
        static double[] Gauss(Eq equat)
        {
            double[,] m = new double[equat.n, equat.n];
            for (int i = 0; i < equat.n; i++)
            {
                for (int j = 0; j < equat.n; j++)
                {
                    m[i, j] = equat.matr[i, j];
                }
            }
            double d = Eq.Det(m);

            if (d != 0)
            {
                equat.Diag();
                for (int i = equat.n - 1; i >= 0; i--)
                {
                    double sum = 0;
                    for (int j = equat.n - 1; j > i; j--)
                    {
                        sum += equat.x[j] * equat.matr[i, j];
                    }
                    equat.x[i] = (equat.b[i] - sum) / equat.matr[i, i];
                }
            }
            return(equat.x);
        }
Пример #2
0
        public bool IsPO()
        {
            bool isPO = true;

            for (int i = 1; i <= n; i++)
            {
                double[,] temp = new double[i, i];
                for (int j = 0; j < i; j++)
                {
                    for (int k = 0; k < i; k++)
                    {
                        temp[j, k] = matr[j, k];
                    }
                }
                double det = Eq.Det(temp);
                if (det > 0)
                {
                    continue;
                }
                else
                {
                    isPO = false;
                    break;
                }
            }
            return(isPO);
        }