Commit
1 year ago
gh-37375: Speed up square matrix times vector over GF(2) When doing a matrix-times-vector multiplication over F_2, there is some inefficiency caused by calling `VectorSpace` to create a parent for the result. This becomes noticeable when repeatedly multiplying small matrices. When the dimensions are all the same, this can be improved by using the parent of the vector also as the parent for the result. Before: ``` sage: A = random_matrix(GF(2),10,10) sage: v0 = vector(random_matrix(GF(2),10,1)) sage: %timeit A*v0 2.26 µs ± 4.57 ns per loop (mean ± std. dev. of 7 runs, 100,000 loops each) ``` After: ``` sage: A = random_matrix(GF(2),10,10) sage: v0 = vector(random_matrix(GF(2),10,1)) sage: %timeit A*v0 981 ns ± 9.57 ns per loop (mean ± std. dev. of 7 runs, 1,000,000 loops each) ``` URL: https://github.com/sagemath/sage/pull/37375 Reported by: kedlaya Reviewer(s): Lorenz Panny
Author
Release Manager
Loading