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

Matrix-vector product with a transposed/adjoint BandedMatrix is slow #280

Open
jishnub opened this issue Nov 16, 2022 · 0 comments
Open

Comments

@jishnub
Copy link
Member

jishnub commented Nov 16, 2022

julia> B = BandedMatrix(1=>Float64.(1:7))
8×8 BandedMatrix{Float64} with bandwidths (-1, 1):
     1.0                        
         2.0                    
             3.0                
                 4.0            
                     5.0        
                         6.0    
                             7.0
                               

julia> v = Float64[i for i in axes(B,2)];

julia> @btime transpose($B) * $v;  # uses gbmv
  989.600 ns (3 allocations: 304 bytes)

julia> @btime transpose(transpose(v) * $B);  # uses default_blasmul!
  254.820 ns (3 allocations: 160 bytes)

julia> @btime $B' * v;
  1.014 μs (2 allocations: 144 bytes)

julia> @btime ($v' * $B)';
  191.123 ns (1 allocation: 128 bytes)

Edit: This behavior seems to switch at larger sizes, so I'm not sure if there's a universal fix

julia> B = BandedMatrix(rand(100, 100));

julia> v = Float64[i for i in axes(B,2)];

julia> @btime $B' * v;
  1.755 μs (2 allocations: 912 bytes)

julia> @btime ($v' * $B)';
  4.973 μs (1 allocation: 896 bytes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant