El domingo, 21 de diciembre de 2014 11:11:50 UTC-6, Sheehan Olver escribió:
>
> Hi,
>
> Any tips for optimizing the code below? Here, Q1 and Q2 are
> Vector{Float64} and a and b are Float64. It seems to be taking an
> unusually long time, and it seems likely there exists a BLAS command that
> will do better, though I couldn't see an appropriate one.
>
> Sheehan
>
>
>
>
> function applygivens!(Q1,Qk,a,b)
> for j=1:length(Q1)
> @inbounds Q1[j],Qk[j]=a*Q1[j]+b*Qk[j],-b*Q1[j]+a*Qk[j]
>
Might it be extracting the entries of the array twice? (I can't say that I
have much understanding of the output of `code_llvm`...)
Maybe it would help to stick these in temporary variables before doing the
calculation:
@inbounds c, d = Q1[j], Qk[j]
@inbounds Q1[j], Qk[j] = a*c+b*d, -b*c+a*d
David.
> end
> end
>