diff options
| author | Paul Jungeblut <paul.jungeblut@gmail.com> | 2016-10-09 01:00:17 +0200 |
|---|---|---|
| committer | Paul Jungeblut <paul.jungeblut@gmail.com> | 2016-10-09 01:00:17 +0200 |
| commit | 6f40d2ea416d3fb8f58e1d0993f5d581e8a330c7 (patch) | |
| tree | fd475b6a3f40c30d39ce41a14bce85a3037ec0fa | |
| parent | fc360bc7cf96765febb2bf8222a2e7b0731adf7d (diff) | |
Little fix in gauss code.
| -rw-r--r-- | math/gauss.cpp | 8 | ||||
| -rw-r--r-- | tcr.pdf | bin | 257593 -> 257807 bytes |
2 files changed, 6 insertions, 2 deletions
diff --git a/math/gauss.cpp b/math/gauss.cpp index 5faaa90..b8e43d4 100644 --- a/math/gauss.cpp +++ b/math/gauss.cpp @@ -18,14 +18,18 @@ void takeAll(int n, int line) { }}} int gauss(int n) { // Gibt zurück, ob das System (eindeutig) lösbar ist. + vector<bool> done(n, false); for (int i = 0; i < n; i++) { int swappee = i; // Sucht Pivotzeile für bessere Stabilität. - for (int j = i + 1; j < n; j++) + for (int j = 0; j < n; j++) { + if (done[j]) continue; if (abs(mat[j][i]) > abs(mat[i][i])) swappee = j; + } swapLines(n, i, swappee); if (abs(mat[i][i]) > EPSILON) { normalLine(n, i); - takeAll(n, i); + takeAll(n, i); + done[i] = true; }} // Ab jetzt nur noch checks bzgl. Eindeutigkeit/Existenz der Lösung. for (int i = 0; i < n; i++) { bool allZero = true; Binary files differ |
