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

Fix kernel basis computation for polynomial matrix in corner case #37208

Merged
merged 5 commits into from
Feb 2, 2024
Merged
Changes from 1 commit
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
15 changes: 11 additions & 4 deletions src/sage/matrix/matrix_polynomial_dense.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3980,6 +3980,13 @@ cdef class Matrix_polynomial_dense(Matrix_generic_dense):
sage: Matrix(pR, 3, 2, [[x,0],[1,0],[x+1,0]]).minimal_kernel_basis()
[6 x 0]
[6 6 1]

TESTS:

We check that PR #37208 is fixed::

sage: Matrix(pR, 2, 0).minimal_kernel_basis().is_sparse()
False
"""
from sage.matrix.constructor import matrix

Expand All @@ -4001,11 +4008,11 @@ cdef class Matrix_polynomial_dense(Matrix_generic_dense):
return matrix(self.base_ring(), 0, m)

if n == 0: # early exit: kernel is identity
return matrix.identity(self.base_ring(), m, m)
return matrix.identity(self.base_ring(), m)
vneiger marked this conversation as resolved.
Show resolved Hide resolved

d = self.degree() # well defined since m > 0 and n > 0
if d == -1: # matrix is zero: kernel is identity
return matrix.identity(self.base_ring(), m, m)
return matrix.identity(self.base_ring(), m)

# degree bounds on the kernel basis
degree_bound = min(m,n)*d+max(shifts)
Expand Down Expand Up @@ -4040,11 +4047,11 @@ cdef class Matrix_polynomial_dense(Matrix_generic_dense):
return matrix(self.base_ring(), n, 0)

if m == 0: # early exit: kernel is identity
return matrix.identity(self.base_ring(), n, n)
return matrix.identity(self.base_ring(), n)

d = self.degree() # well defined since m > 0 and n > 0
if d == -1: # matrix is zero
return matrix.identity(self.base_ring(), n, n)
return matrix.identity(self.base_ring(), n)

# degree bounds on the kernel basis
degree_bound = min(m,n)*d+max(shifts)
Expand Down
Loading