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 i1 = 0; i1 < b.GetWidth(); i1++) { for (int i2 = 0; i2 < b.GetWidth(); i2++) { array1[i, i1] += a[i, i2] * b[i2, i1]; } } } MyMatrix resMass = new MyMatrix(array1); return(resMass); }
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("Impossible. Matrixes not the same!"); } 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 operator +(MyMatrix first, MyMatrix second) { return(MyMatrix.Sum(first, second)); }
public MyMatrix GetTransponedCopy() { MyMatrix result = new MyMatrix(GetTransponedArray()); return(result); }
public MyMatrix(MyMatrix newMatrix) { MyMatrix _matrix = newMatrix; }
public static MyMatrix operator *(MyMatrix a, MyMatrix b) { return(MyMatrix.multiply(a, b)); }
public MyMatrix(MyMatrix mtx) { matrix = (double[, ])mtx.matrix.Clone(); }