You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# element functionfunctionele{T,Q}(x::Vector{T},y::Vector{Q})
return x*dot(x,y)
endele_closure{T}(x::Vector{T}) =ele(x,y);
x =rand(4); y =rand(4); ntimes =10e5;
Why is this slower
cache =ForwardDiffCache()
kout =zeros(4,4)
k =copy(kout)
g =zeros(4)
tic()
for i =1:ntimes
k, allres = ForwardDiff.jacobian!(kout,ele_closure,x,ForwardDiff.AllResults,cache=cache)
value!(g,allres)
endtoc()
elapsed time:4.254816853 seconds
than this?
tic()
# residualfor i =1:ntimes
g =ele(x,y)
end
cache =ForwardDiffCache()
for i =1:ntimes
kfunc = ForwardDiff.jacobian(ele_closure,x,cache=cache)
endtoc()
elapsed time:3.654483469 seconds