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

Speed up square matrix times vector over GF(2) #37375

Merged
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
25 changes: 19 additions & 6 deletions src/sage/matrix/matrix_mod2_dense.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -595,14 +595,27 @@ cdef class Matrix_mod2_dense(matrix_dense.Matrix_dense): # dense or sparse
sage: v = vector(GF(2), 0)
sage: m * v
(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)

Add a test involving a nonsquare matrix::

sage: A = random_matrix(GF(2),10^4,10^3)
sage: v0 = random_matrix(GF(2),10^3,1)
sage: v1 = v0.column(0)
sage: r0 = A*v0
sage: r1 = A*v1
sage: r0.column(0) == r1
True
"""
cdef mzd_t *tmp
global VectorSpace
if VectorSpace is None:
from sage.modules.free_module import VectorSpace
VS = VectorSpace(self._base_ring, self._nrows)
if not isinstance(v, Vector_mod2_dense):
v = VS(v)
if self._nrows == self._ncols and isinstance(v, Vector_mod2_dense):
VS = v.parent()
else:
global VectorSpace
if VectorSpace is None:
from sage.modules.free_module import VectorSpace
VS = VectorSpace(self._base_ring, self._nrows)
if not isinstance(v, Vector_mod2_dense):
v = VS(v)
if self.ncols() != v.degree():
raise ArithmeticError("number of columns of matrix must equal degree of vector")

Expand Down
Loading