Skip to content

Commit fde1956

Browse files
author
Release Manager
committed
gh-40302: Fixed small typo in p-adic Smith form <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes #12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes #12345". --> There is a small typo in a loop bound, which causes `_matrix_smith_form()` to throw whenever given a nonsquare matrix with parameters `integral=False, exact=False`. For example ```sage sage: A = Zp(5) sage: matrix(A,[1,1]).smith_form(transformation=False, integral=False, exact=False) ``` should compute `[1 + O(5^20) O(5^20)]` but throws an IndexError instead. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [ ] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [x] I have updated the documentation and checked the documentation preview. <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - #12345: short description why this is a dependency --> <!-- - #34567: ... --> URL: #40302 Reported by: Eddie Nguyen Reviewer(s): Dima Pasechnik, Frédéric Chapoton
2 parents d03ee30 + 4036647 commit fde1956

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/sage/rings/padics/local_generic.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,6 +1304,10 @@ def _matrix_smith_form(self, M, transformation, integral, exact):
13041304
sage: M.smith_form(transformation=False, exact=False) # indirect doctest
13051305
[O(5^10) O(5^10)]
13061306
[O(5^10) O(5^10)]
1307+
1308+
sage: A = Zp(5)
1309+
sage: matrix(A,[1,1]).smith_form(transformation=False, integral=False, exact=False)
1310+
[1 + O(5^20) O(5^20)]
13071311
"""
13081312
from sage.rings.infinity import infinity
13091313
from .precision_error import PrecisionError
@@ -1460,8 +1464,8 @@ def _matrix_smith_form(self, M, transformation, integral, exact):
14601464
if exact:
14611465
smith[i,i] = self(1)
14621466
else:
1463-
for j in range(n):
1464-
smith[i,j] = smith[i,j] >> v
1467+
for j in range(m):
1468+
smith[i,j] >>= v
14651469
if transformation:
14661470
for i in range(n):
14671471
for j in range(n):

0 commit comments

Comments
 (0)