From 6f40d2ea416d3fb8f58e1d0993f5d581e8a330c7 Mon Sep 17 00:00:00 2001 From: Paul Jungeblut Date: Sun, 9 Oct 2016 01:00:17 +0200 Subject: Little fix in gauss code. --- math/gauss.cpp | 8 ++++++-- 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 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; diff --git a/tcr.pdf b/tcr.pdf index fbc1fe5..9d598f7 100644 Binary files a/tcr.pdf and b/tcr.pdf differ -- cgit v1.2.3