19 lines
390 B
Org Mode
19 lines
390 B
Org Mode
|
x^{k+1} = D^{-1}(b - (L + U) x^k)
|
||
|
x^{k + 1} \rightarrow Ax^k
|
||
|
|
||
|
|
||
|
#+BEGIN_SRC c
|
||
|
loop while (err > tol && iter < maxiter) {
|
||
|
for (int i = 0; i < n; i++) {
|
||
|
sum = b[i];
|
||
|
for (int j = 0; j < i; j++) {
|
||
|
sum = sum - a[i][x] * x_0[i];
|
||
|
}
|
||
|
for (int j = i; j < n; j++) {
|
||
|
sum = sum + a[i][j] * x_0[j];
|
||
|
}
|
||
|
x_1[i] = sum / a[i][i];
|
||
|
}
|
||
|
}
|
||
|
#+END_SRC
|