public static MyMatrix Sum(MyMatrix first, MyMatrix second) { double[,] array1 = new double[first.GetHeight(), first.GetWidth()]; if (first.GetHeight() != second.GetHeight() || first.GetWidth() != second.GetWidth()) { Console.WriteLine("Матрицы не одинаковые. Невозможно применить сложение"); } else { for (int i = 0; i < first.GetHeight(); i++) { for (int j = 0; j < first.GetWidth(); j++) { array1[i, j] = first[i, j] + second[i, j]; } } } MyMatrix resMass = new MyMatrix(array1); return(resMass); }
public static MyMatrix multiply(MyMatrix a, MyMatrix b) { double[,] array1 = new double[a.GetHeight(), b.GetWidth()]; for (int i = 0; i < a.GetWidth(); i++) { for (int j = 0; j < b.GetWidth(); j++) { for (int k = 0; k < b.GetWidth(); k++) { array1[i, j] += a[i, k] * b[k, j]; } } } MyMatrix resMass = new MyMatrix(array1); return(resMass); }