Skip to content

Commit

Permalink
gh-37208: Fix kernel basis computation for polynomial matrix in corne…
Browse files Browse the repository at this point in the history
…r case

    
For univariate polynomial matrices, either with zero columns (or zero
rows if `row_wise=False`), or which are zero, the computed minimal
kernel basis was of the sparse type (due to a mistake in using the
identity method). This is fixed.

- [x] The title is concise, informative, and self-explanatory.
- [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.
- [ ] I have updated the documentation accordingly.

### ⌛ Dependencies

PR #37201  modified a test in the same file
`matrix_polynomial_dense.pyx`
    
URL: #37208
Reported by: Vincent Neiger
Reviewer(s): Vincent Neiger, Xavier Caruso
  • Loading branch information
Release Manager committed Feb 1, 2024
2 parents 919eb9c + f503b52 commit 05af705
Showing 1 changed file with 11 additions and 4 deletions.
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)

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

0 comments on commit 05af705

Please sign in to comment.