Пример #1
0
 public static Vector LU(Matrix A, Vector b)
 {
     double sum;
     LU lu = new LU(A);
     Matrix Rez = lu.L_U;
     Vector B_i = lu.M * b;
     Vector X = new Vector(A.ColumnCount);
     for (int i = A.ColumnCount - 1; i >= 0; i--)
     {
         if (i == A.ColumnCount - 1)
         {
             X[i] = B_i[i] / Rez[i, i];
         }
         else
         {
             sum = 0;
             for (int j = i; j < A.ColumnCount; j++)
             {
                 sum += Rez[i, j] * X[j];
             }
             X[i] = (B_i[i] - sum) / Rez[i, i];
         }
     }
     return X;
 }
Пример #2
0
 public static double Determinant(Matrix val)
 {
     LU lu = new LU(val);
     double R = 1;
     Matrix temp = new Matrix(lu.L_U);
     for (int i = 0; i < temp.RowCount; i++)
     {
         R *= temp[i, i];
     }
     return Math.Round(R, 2) * Math.Pow(-1, lu.number_of_permutations);
 }