Skip to content

Commit 05af705

Browse files
author
Release Manager
committed
gh-37208: Fix kernel basis computation for polynomial matrix in corner 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
2 parents 919eb9c + f503b52 commit 05af705

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/sage/matrix/matrix_polynomial_dense.pyx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3980,6 +3980,13 @@ cdef class Matrix_polynomial_dense(Matrix_generic_dense):
39803980
sage: Matrix(pR, 3, 2, [[x,0],[1,0],[x+1,0]]).minimal_kernel_basis()
39813981
[6 x 0]
39823982
[6 6 1]
3983+
3984+
TESTS:
3985+
3986+
We check that PR #37208 is fixed::
3987+
3988+
sage: Matrix(pR, 2, 0).minimal_kernel_basis().is_sparse()
3989+
False
39833990
"""
39843991
from sage.matrix.constructor import matrix
39853992

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

40034010
if n == 0: # early exit: kernel is identity
4004-
return matrix.identity(self.base_ring(), m, m)
4011+
return matrix.identity(self.base_ring(), m)
40054012

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

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

40424049
if m == 0: # early exit: kernel is identity
4043-
return matrix.identity(self.base_ring(), n, n)
4050+
return matrix.identity(self.base_ring(), n)
40444051

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

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

0 commit comments

Comments
 (0)