From 40f07ad2436e9ac58976d1cd7bee26cee903fb25 Mon Sep 17 00:00:00 2001 From: syn Date: Sun, 16 Feb 2020 21:16:23 +0300 Subject: Third task --- libsolve.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'libsolve.py') 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: -- cgit v1.2.1-18-gbd029