-
Notifications
You must be signed in to change notification settings - Fork 43
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
Add mutating versions of functions that reuse external storage for sigma points and weights #110
Comments
We would be happy to accept a PR for this. |
👍 I'll try to find time to implement this feature and return to you if I need help. |
@dlfivefifty I started to implement this feature for
It should be
Notice different P.S. fixed tests do pass |
Updated Gauss-Laguerre looks some-what like this: I also added more place for external storage re-usage and as a result we save some allocations: function test()
dummy = 0.0
for n in 1:1000
x, w = gausslaguerre(n)
dummy += sum(w)
end
return dummy
end # master
julia> @btime test()
762.632 ms (54755 allocations: 12.85 MiB)
999.9999999999991
# after update
julia> @btime test()
744.996 ms (53507 allocations: 12.60 MiB) It is also interesting to see how much do we safe with in-place versions: function test_reuse(x, w)
dummy = 0.0
for n in 1:1000
x, w = FastGaussQuadrature.gausslaguerre!(x, w, n)
dummy += sum(view(w, 1:n))
end
return dummy
end julia> @btime test_reuse(s[1], s[2]) setup=(s=(Vector{Float64}(undef, 1000), Vector{Float64}(undef, 1000)))
743.897 ms (51507 allocations: 4.69 MiB) # third of the original allocations
999.9999999999991 I'm not sure where do this remaining allocations come from. Probably there are some other places that I overlooked. It looks that saved extra allocations do not contribute much in the overall performance, but it may affect performance in larger programs with a lot of GC pressure I suppose. |
The code is mostly a Matlab port so there’s a lot of room food improvement |
Hey! Thanks for this amazing package. Would it be possible to add mutating version of all functions that would support and reuse external storage for sigma points and weights instead of allocating a new one each time, e.g:
Usually it is a good practice in Julia to have such functions, e.g. we have
map!
,filter!
etc.The benefit of this would be improved performance in cases where you need continuously recompute sigma points and weights for different
alpha
parameter for example (forgausslaguerre
). Non-mutating versions would be simply:The text was updated successfully, but these errors were encountered: