static void gauss_solver int rightSide Length for int for int double v

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
static void gauss_solver()
{
int n = rightSide.Length;
for(int i = 0; i < n; ++i)
for (int j = i + 1; j < n; ++j)
{
double value = equationMatrix[i, i];
double koeff = equationMatrix[j, i] / value;
for (int c = 0; c < n; ++c)
equationMatrix[j, c] -= koeff * equationMatrix[i, c];
rightSide[j] -= koeff * rightSide[i];
}
for (int i = n - 1; i >= 0; --i)
for (int j = i - 1; j >= 0; --j)
{
double value = equationMatrix[i, i];
double koeff = equationMatrix[j, i] / value;
for (int c = 0; c < n; ++c)
equationMatrix[j, c] -= koeff * equationMatrix[i, c];
rightSide[j] -= koeff * rightSide[i];
}
for (int i = 0; i < n; ++i)
{
approxKoeff[i] = rightSide[i] / equationMatrix[i, i];
}
}