It is necessary to solve SLAU by iterative method. All methods are already available, you just need to apply them correctly in the program file

Console.WriteLine("Есть матрица А"); double[,] A = { { 2, 1 }, { 1, -2 } }; Matrix.dispMartix(A); Console.WriteLine("и eё вектор решений"); double[] B = { 3, 1 }; Matrix.dispVec(B); Console.WriteLine(); double[] C; C = SLAU.solveByInv(A,B); Matrix.dispVec(C); double tor=10; double[] C1; C1 = SLAU.iteration(A,B,tor); Matrix.dispVec(C1); 

Methods themselves

 public static double[] solveByInv(double[,] A, double[] b) { double[] res = new double[b.GetLength(0)]; res = Matrix.multMatToVec(Matrix.invertMatrix(A), b); return res; } public static double findMaxDiff(double[] V1, double[] V2) { double[] diff = Matrix.addVecToVec(V1, Matrix.multVecToNumb(V2, -1)); double res = Math.Abs(diff[0]); for (int i = 0; i < diff.GetLength(0) - 1; i++) { if (Math.Abs(diff[i + 1]) >= diff[i]) { res = Math.Abs(diff[i + 1]); } } return res; } public static double[] iteration(double[,] c, double[] b, double eps) { double[] result = new double[c.GetLength(0)]; double[] previousRes = new double[result.GetLength(0)]; double normC = 0; for (int row = 0; row < c.GetLength(0); row++) { for (int col = 0; col < c.GetLength(1); col++) { normC += Math.Pow(c[row, col], 2); } } normC = Math.Sqrt(normC); if (normC > 1) { Console.WriteLine("Есть решение"); } else { Console.WriteLine("Решений нет"); } for (int i = 0; i < previousRes.GetLength(0); i++) { previousRes[i] = 0; } double max = -1; // итерац. проц Xi+1=Cxi+b do { max = -1; result = Matrix.addVecToVec(Matrix.multMatToVec(c, previousRes), b); max = SLAU.findMaxDiff(result, previousRes); for (int i = 0; i < result.GetLength(0); i++) { previousRes[i] = result[i]; } } while (max > eps); return result; } 

How to apply them correctly? Also already written a bunch of other methods for working with matrices.

Closed due to the fact that the essence of the question is not clear to the participants of Dmitriy Simushev , Kromster , aleksandr barakin , fori1ton , αλεχολυτ 19 Oct '16 at 19:23 .

Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • Well, duck, you already have an example of calling the method is `C1 = SLAU.iteration (A, B, tor);` - Alex.B
  • Understand the theory of SLAES, then understand C #, then you will understand what parameters are passed to the methods, call the methods with the correct parameters. Get the solution entered SLAU - Alex.B
  • one
    If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky

1 answer 1

An example of how to call a method. Before this, do not forget to connect the class SLAU, which is described in "your code".

 double[] C1; double[,] A1; double [] B; double eps = 12; double[,] A = { { 8, 5 }, { 5, -9 } }; Matrix.dispMartix(A); double[] B = { 6, 2 }; Matrix.dispVec(B); C1= SLAU.iteration(A,B,eps);