summaryrefslogtreecommitdiff
path: root/math/lgsFp.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'math/lgsFp.cpp')
-rw-r--r--math/lgsFp.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/math/lgsFp.cpp b/math/lgsFp.cpp
index e42e4ab..439e5b7 100644
--- a/math/lgsFp.cpp
+++ b/math/lgsFp.cpp
@@ -1,15 +1,16 @@
-void normalLine(ll n, ll line, ll p) { //normalisiert Zeile line
- ll factor = multInv(mat[line][line], p); //Implementierung von oben
+// Laufzeit: O(n^3)
+void normalLine(ll n, ll line, ll p) { // Normalisiert Zeile line.
+ ll factor = multInv(mat[line][line], p); // Implementierung von oben.
for (ll i = 0; i <= n; i++) {
mat[line][i] *= factor;
mat[line][i] %= p;
}
}
-void takeAll(ll n, ll line, ll p) { //zieht Vielfaches von line von allen anderen Zeilen ab
+void takeAll(ll n, ll line, ll p) { // Zieht Vielfaches von line von allen anderen Zeilen ab.
for (ll i = 0; i < n; i++) {
if (i == line) continue;
- ll diff = mat[i][line]; //abziehen
+ ll diff = mat[i][line];
for (ll j = 0; j <= n; j++) {
mat[i][j] -= (diff * mat[line][j]) % p;
while (mat[i][j] < 0) {
@@ -19,9 +20,9 @@ void takeAll(ll n, ll line, ll p) { //zieht Vielfaches von line von allen andere
}
}
-void gauss(ll n, ll p) { //n x n+1-Matrix, Koerper F_p
+void gauss(ll n, ll p) { // nx(n+1)-Matrix, Koerper F_p.
for (ll line = 0; line < n; line++) {
normalLine(n, line, p);
takeAll(n, line, p);
}
-} \ No newline at end of file
+}