Skip to content

Commit d531017

Browse files
committed
Fix incorrect parent reuse in matrix-vector multiplication over GF(2)
1 parent d617df4 commit d531017

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/sage/matrix/matrix_mod2_dense.pyx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,9 +677,25 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse
677677
sage: r1 = A*v1
678678
sage: r0.column(0) == r1
679679
True
680+
681+
Check that :issue:`40167` is fixed::
682+
683+
sage: M = matrix(GF(2), [[1,1],[0,1]])
684+
sage: v = vector(GF(2), [0, 1])
685+
sage: V = span([v]) # one-dimensional subspace of GF(2)^2
686+
sage: image_basis = [M * b for b in V.basis()]
687+
sage: image = span(image_basis)
688+
sage: image_basis[0] in image.basis()
689+
True
680690
"""
681691
cdef mzd_t *tmp
682-
if self._nrows == self._ncols and isinstance(v, Vector_mod2_dense):
692+
if (
693+
self._nrows == self._ncols and
694+
isinstance(v, Vector_mod2_dense) and
695+
v.parent().is_full() and
696+
v.parent().degree() == self._nrows and
697+
v.parent().base_ring() is self._base_ring
698+
):
683699
VS = v.parent()
684700
else:
685701
global VectorSpace

0 commit comments

Comments
 (0)