diff options
| author | Gloria Mundi <gloria@gloria-mundi.eu> | 2025-06-07 19:42:50 +0200 |
|---|---|---|
| committer | Gloria Mundi <gloria@gloria-mundi.eu> | 2025-06-07 19:42:50 +0200 |
| commit | f8f53c2f9e63f0ac89b67dc4d413ec9a76415a73 (patch) | |
| tree | 7210642adde99db427b3da70c0f3f41355eb71f4 /content/math | |
| parent | e65975ec92509abbf0078673b7a8495bfc47a245 (diff) | |
adapt Tutte matching to new Gauss, and remove some global variables
Diffstat (limited to 'content/math')
| -rw-r--r-- | content/math/lgsFp.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/content/math/lgsFp.cpp b/content/math/lgsFp.cpp index 4c12477..5028782 100644 --- a/content/math/lgsFp.cpp +++ b/content/math/lgsFp.cpp @@ -1,6 +1,7 @@ -vector<int> pivots; // ith pivot is in ith row -void gauss(int n, int m) { - for (int r = 0, c = 0; c < m; c++) { +vector<int> gauss(vector<vector<ll>> &mat) { + int n = ssize(mat), m = ssize(mat[0]); + vector<int> pivots; // ith pivot is in ith row + for (int r = 0, c = 0; r < n && c < m; c++) { for (int i = r; i < n; i++) { if (mat[i][c] != 0){ swap(mat[r], mat[i]); @@ -16,5 +17,7 @@ void gauss(int n, int m) { mat[i][j] = (mat[i][j] - f*mat[r][j] % mod + mod) % mod; }} pivots.push_back(c); - if (++r == n) break; -}} // no solution if pivots.back() == m-1 + r++; + } + return pivots; // no solution if pivots.back() == m-1 +} |
