lizfcm/notes/Nov-27.org

21 lines
406 B
Org Mode
Raw Permalink Normal View History

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];
}
err = 0.0;
}
#+END_SRC