Skip to content

Commit fa83177

Browse files
author
Release Manager
committed
gh-40497: Actually avoid hermite_form in solve_right if possible I tried to speed this up in #40276 , but there was some error in logic which makes it fail. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [ ] The title is concise and informative. - [ ] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - #12345: short description why this is a dependency --> <!-- - #34567: ... --> URL: #40497 Reported by: user202729 Reviewer(s): user202729
2 parents 8497e52 + 7715d90 commit fa83177

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/sage/matrix/matrix2.pyx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,6 @@ cdef class Matrix(Matrix1):
901901
sage: v = matrix.identity(QQ, 500).solve_right(vector(QQ, [1]*500), extend=False) # <1s
902902
sage: matrix.identity(QQ, 500).hermite_form() # not tested (slow)
903903
sage: v = (matrix.identity(ZZ, 500)*2).solve_right(vector(ZZ, [2]*500), extend=False) # <1s
904-
sage: matrix.identity(ZZ, 500).hermite_form() # not tested (slow)
905904
sage: m = matrix.identity(ZZ, 250).stack(matrix.identity(ZZ, 250))*2
906905
sage: v = m.solve_right(vector(ZZ, [2]*500), extend=False) # <1s
907906
sage: m._solve_right_hermite_form(matrix(ZZ, [[2]]*500)) # not tested (slow)
@@ -974,10 +973,11 @@ cdef class Matrix(Matrix1):
974973
if P not in _Fields and not extend:
975974
if self.rank() == self.ncols():
976975
# hermite_form is slow, avoid if possible
976+
F = P.fraction_field()
977977
if self.is_square():
978-
X = self._solve_right_nonsingular_square(C, check_rank=False)
978+
X = self.change_ring(F)._solve_right_nonsingular_square(C.change_ring(F), check_rank=False)
979979
else:
980-
X = self._solve_right_general(C)
980+
X = self.change_ring(F)._solve_right_general(C.change_ring(F))
981981
try:
982982
X = X.change_ring(P)
983983
except TypeError:

0 commit comments

Comments
 (0)