Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add one check for matrix index #149

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion cypari2/gen.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1522,14 +1522,17 @@ cdef class Gen(Gen_base):
if typ(self.g) != t_MAT:
raise TypeError("cannot index PARI type %s by tuple" % typ(self.g))

if len(n) != 2:
raise ValueError("matrix index must be [row, column]")

i, j = n

if i < 0 or i >= glength(gel(self.g, 1)):
raise IndexError("row i(=%s) must be between 0 and %s" % (i, self.nrows()-1))
if j < 0 or j >= glength(self.g):
raise IndexError("column j(=%s) must be between 0 and %s" % (j, self.ncols()-1))

self.cache((i,j), x)
self.cache((i, j), x)
xt = x.ref_target()
set_gcoeff(self.g, i+1, j+1, xt)
return
Expand Down
Loading