static void Main(string[] args) { //Create two matrices Matrix<int> mat1 = new Matrix<int>(3, 5); Matrix<int> mat2 = new Matrix<int>(3, 5); //Fill the matrices with numbers for (int i = 0; i < mat1.Rows; i++) { for (int j = 0; j < mat1.Cols; j++) { mat1.AddNumber(i + j, i, j); } } for (int i = 0; i < mat1.Rows; i++) { for (int j = 0; j < mat1.Cols; j++) { mat2[i, j] = i + j; } } //Print them Console.WriteLine(mat1.ToString()); Console.WriteLine(mat2.ToString()); //Use predefined operators and print the result Console.WriteLine((mat1 + mat2).ToString()); Console.WriteLine((mat1 - mat2).ToString()); //Console.WriteLine((mat2*mat2).ToString()); //For multiplication we need the row on the first matrix and col on the second matrix to be equal Console.WriteLine(mat1==mat2); }
static void Main() { //create instance of matixT Matrix<int> matrix1 = new Matrix<int>(3, 3); Matrix<int> matrix2 = new Matrix<int>(3, 3); //Fill in with numbers for (int i = 0; i < matrix1.Rows; i++) { for (int j = 0; j < matrix1.Cols; j++) { matrix1.AddNumber(i + j, i, j); } } for (int i = 0; i < matrix1.Rows; i++) { for (int j = 0; j < matrix1.Cols; j++) { matrix2[i, j] = i + j; } } //Print to view the starting point Console.WriteLine(matrix1.ToString()); Console.WriteLine(matrix2.ToString()); //test operators Console.WriteLine("operator + :"); Console.WriteLine((matrix1 + matrix2).ToString()); Console.WriteLine("operator - :"); Console.WriteLine((matrix1 - matrix2).ToString()); //check for equality Console.WriteLine(matrix1 == matrix2); }