StructArrays.jl
StructArrays.jl copied to clipboard
Forward complex matrix multiplication to components
Start implementing #223 This PR forwards the matrix multiplication to the components, which may lead to a substantial speed-up if the components are BLAS-compatible matrices.
On master
julia> using StructArrays, LinearAlgebra, BenchmarkTools
julia> A = StructArray{ComplexF64}((rand(1000,1000), rand(1000,1000)));
julia> @btime $A * $A;
1.543 s (12 allocations: 15.29 MiB)
This PR
julia> @btime $A * $A;
58.998 ms (6 allocations: 15.26 MiB)
I've added a method for matrix * vector as well. This is actually marginally slower for BLAS-compatible cases. However, this may be substantially more efficient if the components have fast matrix * vector methods defined (e.g. sparse matrices).
Seems pretty straightforward and uncontroversial, I guess...