9 {
11
12 std::cout << "Matrix size: ";
14
15
21 }
22
23
24 std::cout << std::endl << "Enter value of the matrix: " << std::endl;
27 std::cin >>
28 mat[i][j];
29 }
30 }
31
32
33 for (step = 0; step <
mat_size - 1; step++) {
34 for (i = step; i <
mat_size - 1; i++) {
35 double a = (mat[i + 1][step] / mat[step][step]);
36
38 mat[i + 1][j] = mat[i + 1][j] - (a * mat[step][j]);
39 }
40 }
41
42 std::cout << std::endl
43 << "Matrix using Gaussian Elimination method: " << std::endl;
46 x[i][j] = mat[i][j];
47 std::cout << mat[i][j] << " ";
48 }
49 std::cout << std::endl;
50 }
51 std::cout << std::endl
52 << "Value of the Gaussian Elimination method: " << std::endl;
53 for (i =
mat_size - 1; i >= 0; i--) {
56 x[i][j] = x[j][j] * x[i][j];
58 }
59 if (x[i][i] == 0)
60 x[i][i] = 0;
61 else
63
64 std::cout << "x" << i << "= " << x[i][i] << std::endl;
65 }
66
68 delete[] mat[i];
70 delete[] x[i];
71 }
72 delete[] mat;
73 delete[] x;
74
75 return 0;
76}
T sum(const std::vector< std::valarray< T > > &A)