summaryrefslogtreecommitdiffstats
path: root/libsolve.py
diff options
context:
space:
mode:
authorsyn <isaqtm@gmail.com>2020-02-16 21:16:23 +0300
committersyn <isaqtm@gmail.com>2020-02-16 21:16:23 +0300
commit40f07ad2436e9ac58976d1cd7bee26cee903fb25 (patch)
tree66436365e8654f486ea67d57abf3eaee87529d00 /libsolve.py
parentfd78d0fd00e6b98ae8b9894db8be028575e205ac (diff)
downloadalg3-40f07ad2436e9ac58976d1cd7bee26cee903fb25.tar.gz
Third task
Diffstat (limited to 'libsolve.py')
-rw-r--r--libsolve.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/libsolve.py b/libsolve.py
index e9a0677..92f2b78 100644
--- a/libsolve.py
+++ b/libsolve.py
@@ -300,7 +300,7 @@ class Matrix:
parts.append(' & '.join(map(str, row.lst)))
return '\\begin{bmatrix}\n' + '\\\\\n'.join(parts) + '\n\\end{bmatrix}'
- def triangulate(self):
+ def triangulate(self, swap=False):
for i in range(self.shape[1]):
for j in range(i, self.shape[0]):
assert(self[j][i].deg() == 0)
@@ -315,6 +315,9 @@ class Matrix:
continue
coef = -Fraction(self[k][i].vec[0]) / Fraction(self[j][i].vec[0])
self[k] = self[k] + self[j] * coef
+
+ if swap:
+ self.make_U(j, i)
break
class Permutation: