Немного доработать метод по нахождению определителя квадратной матрицы - C#
Формулировка задачи:
Добрый день, есть класс, помогите пожалуйста дописать метод по нахождению определителя квадратной матрицы н-ого порядка
Листинг программы
- class matrix
- {
- int n;
- int[,] arr;
- public void enter();
- public void output();
- public void addmat(matrix temp);
- public void multimat(matrix tmp);
- public void transpon();
- public int determ()
- {
- int det = 0;
- if (n == 1)
- {
- det = arr[0, 0];
- }
- else if (n == 2)
- {
- det = arr[0, 0] * arr[1, 1] - arr[0, 1] * arr[1, 0];
- }
- else
- {
- int[,] matr = new int[n - 1, n - 1];
- for (int i = 0; i < n; ++i)
- {
- for (int j = 0; j < n - 1; ++j) // чего-то нашел тут на форуме, но в компиляторе краснота
- {
- if (j < i)
- matr[j] = arr[j];
- else
- matr[j] = arr[j + 1];
- }
- det += Math.Pow((double)-1, (i + j)) * determ(matr, n - 1, n - 1) * b[i, n - 1];
- }
- }
- return det;
- }
- }
Помогите прошу!
Решение задачи: «Немного доработать метод по нахождению определителя квадратной матрицы»
textual
Листинг программы
- class Matrix
- {
- private double[,] _matrix;
- public Matrix() { }
- public Matrix(double[,] matrix)
- {
- _matrix = matrix;
- }
- public static Matrix operator +(Matrix first, Matrix second)
- {
- if (first._matrix.GetLength(0) != second._matrix.GetLength(0)) throw new ArgumentException();
- if (first._matrix.GetLength(1) != second._matrix.GetLength(1)) throw new ArgumentException();
- int n = first._matrix.GetLength(0);
- int m = first._matrix.GetLength(1);
- Matrix newMatrix = new Matrix();
- for (int i = 0; i < n; i++)
- {
- for (int j = 0; j < m; j++)
- {
- newMatrix._matrix[i, j] = first._matrix[i, j] + second._matrix[i, j];
- }
- }
- return newMatrix;
- }
- }
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д