public static void Main(string[] args) { double[,] mat = new double[5, 5]; for (int c = 0; c < 5; c++) { for (int c1 = 0; c1 < 5; c1++) { Console.Write($"Enter the element [{c},{c1}] = "); mat [c, c1] = double.Parse(Console.ReadLine()); } } for (int c = 0; c < 5; c++) { for (int c1 = 0; c1 < 5; c1++) { Console.Write($"\t{mat[c,c1]}"); } Console.WriteLine(""); } Matrix theMat = new Matrix(mat, 5, 5); theMat.GaussJordan(); Console.WriteLine("After guass elimination = "); MatrixOutput.Print(theMat); } // END MAIN
public void Print() { int expType = theExpression.getExpType(); if (expType == 1) { Console.WriteLine($"{theExpression.getTag()} = "); MatrixOutput.Print(theExpression.getMatrix()); } else if (expType == 2) { Console.WriteLine($"{theExpression.getTag()} = {theExpression.getNumber().getNumber()}"); } }
MatrixOutput IService.MatrixSum(MatrixInput Input) { MatrixT <int> A = new MatrixT <int>(new int[Input.matrix1[0].Length, Input.matrix1[1].Length]); MatrixT <int> B = new MatrixT <int>(new int[Input.matrix2[0].Length, Input.matrix2[1].Length]); for (int i = 0; i < Input.matrix1[0].Length; i++) { for (int j = 0; j < Input.matrix1[1].Length; j++) { A[i, j] = Input.matrix1[i][j]; } } for (int i = 0; i < Input.matrix2[0].Length; i++) { for (int j = 0; j < Input.matrix2[1].Length; j++) { B[i, j] = Input.matrix2[i][j]; } } MatrixT <int> MatResult = A + B; MatrixOutput result = new MatrixOutput(); result.matrixResult = new int[Input.matrix1[0].Length][]; for (int i = 0; i < Input.matrix1[1].Length; i++) { result.matrixResult[i] = new int[Input.matrix1[0].Length]; } int[][] ansArr = new int[Input.matrix1[0].Length][]; for (int i = 0; i < Input.matrix1[1].Length; i++) { ansArr[i] = new int[Input.matrix1[0].Length]; } for (int i = 0; i < Input.matrix1[0].Length; i++) { for (int j = 0; j < Input.matrix1[1].Length; j++) { ansArr[i][j] = MatResult[i, j]; } } result.matrixResult = ansArr; return(result); }
static void Main(string[] args) { MatrixInput input = new MatrixInput(); input.matrix1 = new int[2][]; for (int i = 0; i < 2; i++) { input.matrix1[i] = new int[2]; } input.matrix2 = new int[2][]; for (int i = 0; i < 2; i++) { input.matrix2[i] = new int[2]; } for (int i = 0; i < input.matrix1[0].Length; i++) { for (int j = 0; j < input.matrix1[0].Length; j++) { input.matrix1[i][j] = 1; input.matrix2[i][j] = 2; } } ServiceClient client = new ServiceClient(); MatrixOutput output = client.MatrixMul(input); Console.WriteLine("Исходные матрицы:"); for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { Console.Write(input.matrix1[i][j]); } Console.WriteLine(); } for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { Console.Write(input.matrix2[i][j]); } Console.WriteLine(); } Console.WriteLine("Ответ:"); int[][] otv = output.matrixResult; for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { Console.Write(otv[i][j]); } Console.WriteLine(); } Console.ReadKey(); }