summaryrefslogtreecommitdiff
path: root/math/lgsFp.cpp
diff options
context:
space:
mode:
authorPaul Jungeblut <paul.jungeblut@gmail.com>2016-06-27 11:17:34 +0200
committerPaul Jungeblut <paul.jungeblut@gmail.com>2016-06-27 11:17:34 +0200
commit9e625b89bac7e8daaf583e215f3a0df3dc250bb2 (patch)
treeab295455fce73f726bd97a325a61d95aca77a508 /math/lgsFp.cpp
parent5bb1ac05882e0df43a2afe0c363e0f503f51c357 (diff)
Math section rebuild, merged convinience and sonstiges section.
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
+}