summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Jungeblut <paul.jungeblut@gmail.com>2016-10-09 01:00:17 +0200
committerPaul Jungeblut <paul.jungeblut@gmail.com>2016-10-09 01:00:17 +0200
commit6f40d2ea416d3fb8f58e1d0993f5d581e8a330c7 (patch)
treefd475b6a3f40c30d39ce41a14bce85a3037ec0fa
parentfc360bc7cf96765febb2bf8222a2e7b0731adf7d (diff)
Little fix in gauss code.
-rw-r--r--math/gauss.cpp8
-rw-r--r--tcr.pdfbin257593 -> 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;
diff --git a/tcr.pdf b/tcr.pdf
index fbc1fe5..9d598f7 100644
--- a/tcr.pdf
+++ b/tcr.pdf
Binary files differ