summaryrefslogtreecommitdiff
path: root/math/gauss.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'math/gauss.cpp')
-rw-r--r--math/gauss.cpp8
1 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;