JuliaMath / HCubature.jl

pure-Julia multidimensional h-adaptive integration
Other
148 stars 23 forks source link

Add integrand function type parameter #45

Closed jwscook closed 1 year ago

jwscook commented 1 year ago

Related to and supplants #44, this makes the change hcubature(f, a, b ... to hcubature(f::F, a, b... where F. The same benchmark as the other PR on the same machine is

julia> using HCubature, BenchmarkTools

julia> @benchmark hcubature(x -> cos(x[1])*cos(x[2]), [0,0], [1,1])
BenchmarkTools.Trial: 10000 samples with 1 evaluation.
 Range (min … max):  11.121 μs …  8.734 ms  ┊ GC (min … max): 0.00% … 99.38%
 Time  (median):     11.484 μs              ┊ GC (median):    0.00%
 Time  (mean ± σ):   12.554 μs ± 87.231 μs  ┊ GC (mean ± σ):  6.91% ±  0.99%

     ▄▇▆▆██▆▃▁                                                 
  ▁▄▇█████████▇▆▅▄▄▃▃▃▂▂▂▂▂▂▂▁▁▁▁▁▁▁▁▁▁▁▁▂▂▂▂▂▂▂▂▂▂▂▂▁▁▁▁▁▁▁▁ ▃
  11.1 μs         Histogram: frequency by time        13.6 μs <

 Memory estimate: 4.12 KiB, allocs estimate: 27.
jwscook commented 1 year ago

Out of interest, merging #44 into this made the performance worse.

jwscook commented 1 year ago

Is there anything else that needs to be done to this PR?

stevengj commented 1 year ago

LGTM, thanks!

jwscook commented 1 year ago

No problem! Happy to help 😃