public static MatrixList TransposeMatrix(MatrixList matrix) { int[,] newMatrix = new int[matrix.Lenght, matrix.Count]; for (int i = 0; i < newMatrix.GetLength(0); i++) { for (int j = 0; j < newMatrix.GetLength(1); j++) { newMatrix[i, j] = matrix.Elem(j, i); } } return(GetMatrix(newMatrix)); }
public static MatrixList SumMatrix(MatrixList matrix1, MatrixList matrix2) { if (matrix1.Count != matrix2.Count || matrix1.Lenght != matrix2.Lenght) { return(null); } int[,] sumMatrix = new int[matrix1.Count, matrix1.Lenght]; for (int i = 0; i < sumMatrix.GetLength(0); i++) { for (int j = 0; j < sumMatrix.GetLength(1); j++) { sumMatrix[i, j] = matrix1.Elem(i, j) + matrix2.Elem(i, j); } } return(GetMatrix(sumMatrix)); }
public static MatrixList MultiplicationMatrix(MatrixList matrix1, MatrixList matrix2) { if (matrix1.Lenght != matrix2.Count) { return(null); } int[,] MultiplicationMatrix = new int[matrix1.Count, matrix2.Lenght]; for (int i = 0; i < MultiplicationMatrix.GetLength(0); i++) { for (int j = 0; j < MultiplicationMatrix.GetLength(1); j++) { MultiplicationMatrix[i, j] = 0; for (int k = 0; k < matrix1.Lenght; k++) { MultiplicationMatrix[i, j] += matrix1.Elem(i, k) * matrix2.Elem(k, j); } } } return(GetMatrix(MultiplicationMatrix)); }