-
Notifications
You must be signed in to change notification settings - Fork 3
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
more efficient realdot for arrays #6
Comments
I did not include it due to the discussion and benchmarks mentioned in JuliaLang/LinearAlgebra.jl#436. However, I guess it would be good to benchmark it again since it's a quite old issue. |
I just tried a couple of options, the function realdot1(a::AbstractVector{Complex{T}}, b::AbstractVector{Complex{S}}) where {T,S}
axes(a,1) == axes(b,1) || throw(DimensionMismatch())
s = zero(T) * zero(S)
@simd for i in axes(a,1)
@inbounds ai, bi = a[i], b[i]
s = muladd(real(ai), real(bi), s)
s = muladd(imag(ai), imag(bi), s)
end
return s
end |
For big arrays, it is memory-bound and not compute-bound, which is probably why they all become about the same. |
Right now you use
real(LinearAlgebra.dot(x, y))
, which does twice as much work as necessary for complex arrays.You could do e.g.
and similar…
Or you could just write out the loop (two
muladd
calls per complex entry, with@simd
), since BLAS doesn't have much of an advantage for this type of operation.The text was updated successfully, but these errors were encountered: