-
-
Notifications
You must be signed in to change notification settings - Fork 37
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
Handle units consistently in handle_infinites #96
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #96 +/- ##
==========================================
+ Coverage 98.21% 98.27% +0.06%
==========================================
Files 6 6
Lines 615 637 +22
==========================================
+ Hits 604 626 +22
Misses 11 11 ☔ View full report in Codecov by Sentry. |
return workfunc(f, s, identity) | ||
I, E = workfunc(BatchIntegrand((y, t) -> begin resize!(f.x, length(t)); | ||
f.f!(y, f.x .= u .* t); end, f.y, f.x, f.t, f.max_batch), | ||
map(x -> x/oneunit(x), s), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pays the cost of a division for every integrand evaluation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, that is just for the segments.
@stevengj this pr is now updated to pass unitless limits to
benchmark for this prjulia> using BenchmarkTools
julia> using QuadGK
julia> @benchmark quadgk(x -> x, 0, 1) # zero-cost integrand, no subdivisions
BenchmarkTools.Trial: 10000 samples with 993 evaluations.
Range (min … max): 35.383 ns … 107.806 ns ┊ GC (min … max): 0.00% … 0.00%
Time (median): 35.839 ns ┊ GC (median): 0.00%
Time (mean ± σ): 36.505 ns ± 4.703 ns ┊ GC (mean ± σ): 0.00% ± 0.00%
█▄
██▃▃▂▂▂▂▂▂▁▂▂▂▁▂▁▂▁▁▁▁▁▁▂▁▁▂▁▁▂▂▁▁▂▂▂▂▁▁▂▂▂▂▂▂▂▂▂▂▂▁▂▂▂▁▁▁▂▂ ▂
35.4 ns Histogram: frequency by time 63.2 ns <
Memory estimate: 0 bytes, allocs estimate: 0.
julia> @benchmark quadgk(x -> sin(100x), 0, 1) # low-cost integrand with subdivisions
BenchmarkTools.Trial: 10000 samples with 1 evaluation.
Range (min … max): 11.611 μs … 55.500 μs ┊ GC (min … max): 0.00% … 0.00%
Time (median): 11.965 μs ┊ GC (median): 0.00%
Time (mean ± σ): 12.100 μs ± 1.526 μs ┊ GC (mean ± σ): 0.00% ± 0.00%
▃█▇█▅▄▂▁
▂▂▂▂▂▂▂▁▂▁▁▂▁▁▁▂▁▂▂▃▅█████████▇▆▆▅▄▄▃▃▃▃▃▃▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂ ▃
11.6 μs Histogram: frequency by time 12.4 μs <
Memory estimate: 1.69 KiB, allocs estimate: 3. benchmark on masterjulia> using BenchmarkTools
julia> using QuadGK
julia> @benchmark quadgk(x -> x, 0, 1) # zero-cost integrand, no subdivisions
BenchmarkTools.Trial: 10000 samples with 992 evaluations.
Range (min … max): 33.998 ns … 402.374 ns ┊ GC (min … max): 0.00% … 0.00%
Time (median): 35.007 ns ┊ GC (median): 0.00%
Time (mean ± σ): 36.006 ns ± 7.741 ns ┊ GC (mean ± σ): 0.00% ± 0.00%
▃█
██▃▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▁
34 ns Histogram: frequency by time 70.1 ns <
Memory estimate: 0 bytes, allocs estimate: 0.
julia> @benchmark quadgk(x -> sin(100x), 0, 1) # low-cost integrand with subdivisions
BenchmarkTools.Trial: 10000 samples with 1 evaluation.
Range (min … max): 11.362 μs … 57.351 μs ┊ GC (min … max): 0.00% … 0.00%
Time (median): 11.762 μs ┊ GC (median): 0.00%
Time (mean ± σ): 12.303 μs ± 1.512 μs ┊ GC (mean ± σ): 0.00% ± 0.00%
█▄
▇▅▂██▃▂▂▂▂▁▁▁▂▃▄▃▃▇▆▃▃▂▂▂▂▂▂▂▂▂▂▂▂▂▂▁▂▁▂▁▂▂▂▂▂▂▂▂▁▂▂▁▁▂▁▁▁▂ ▃
11.4 μs Histogram: frequency by time 17 μs <
Memory estimate: 1.69 KiB, allocs estimate: 3. I think this is ready and could be a patch release |
# in-place function f!(y, x) that takes an array of x values and outputs an array of results in-place | ||
f!::F | ||
y::Ty | ||
x::Tx | ||
t::T |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not great that we pay the price of having an additional point array here …
Fixes #95
This pr changes
handle_infinities
to always pass limits with units todo_quadgk
so that the samesegbuf
can be used with finite and infinite limits.It also adds some tests to check this works for inplace and batched integrands.
Unfortunately, the endpoints of the segments in a segbuf don't correspond to the intervals used in the original domain when using the infinity transformation. However, changing that would be a lot more involved than what is needed for this pr.