Calling three argument dot with a Symmetric view of a sparse matrix is very slow.
Example:
using LinearAlgebra, SparseArrays, BenchmarkTools
A = sprandn(1000,1000,0.1)
A = A+A' #symmetric
B = Symmetric(triu(A))
x = randn(1000)
The quadratic form x'*B*x is about 100x slower using dot, although fine when computed directly. The same operation is about the same either way using A.
julia> @btime ($x'*$A*$x);
173.777 μs (1 allocation: 7.94 KiB)
julia> @btime ($x'*$B*$x);
97.280 μs (1 allocation: 7.94 KiB)
julia> @btime dot($x,$A,$x);
174.176 μs (0 allocations: 0 bytes)
julia> @btime dot($x,$B,$x);
9.559 ms (0 allocations: 0 bytes)
The final case above ends up appears to be falling back on the general symmetric dot implementation here.
This might be related to #23.
Calling three argument
dotwith a Symmetric view of a sparse matrix is very slow.Example:
The quadratic form
x'*B*xis about 100x slower usingdot, although fine when computed directly. The same operation is about the same either way usingA.The final case above ends up appears to be falling back on the general symmetric
dotimplementation here.This might be related to #23.