StructArrays.jl icon indicating copy to clipboard operation
StructArrays.jl copied to clipboard

Forward complex matrix multiplication to components

Open jishnub opened this issue 2 years ago • 1 comments

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).

jishnub avatar Jan 19 '24 11:01 jishnub

Seems pretty straightforward and uncontroversial, I guess...

aplavin avatar Mar 08 '24 21:03 aplavin