Trac #40167: Fix incorrect parent reuse in matrix-vector multiplication over GF(2) #40176
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #40167. This PR fixes a bug in
Matrix_mod2_dense._matrix_times_vector_
revealed in #40167, where the parent of the resulting vector was incorrectly reused from the input vector.The regression was introduced in PR #37375, which added an optimization to speed up matrix-vector multiplication when the matrix is square and matches the vector dimension. However, it failed to account for edge cases where the input vector's parent is not the full ambient vector space—for example, when working with subspaces. In this case, we can no longer assume that the ambient space is the vector's ambient space.
In such cases, reusing the parent leads to incorrect coercion or a result vector with an invalid parent space. This patch introduces an explicit check: if the vector's parent is the full space
GF(2)^n
, it is reused; otherwise, a default parent is constructed to ensure correctness.Example (correct behavior restored)
📝 Checklist
⌛ Dependencies