Integrals.jl
Integrals.jl copied to clipboard
`transformation_if_inf` is not type stable
Updatingtransformation_if_inf is sufficient to make HCubatureJL() type stable. Other methods are still type unstable.
Do you have an MWE?
Since transformation_if_inf is kind of a f->g function. It's either going to be type unstable, or we need to introduce the extra overhead for every function call. We should add an argument like do_inf_transformation=Val{true}().
I don't recall what exactly I meant by "updating". Here is a MWE I just put together, I'm not sure if it captures the same problem I had in the OP.
using Quadrature , Distributions , Test
μ = [0.00 , 0.00]
Σ = [0.4 0.0 ; 0.00 0.4]
d = MvNormal(μ , Σ)
m(x , p) = pdf(d, x)
prob = QuadratureProblem{false}(m, [-Inf , -Inf] , [Inf , Inf])
sol = solve(prob,HCubatureJL(),reltol=1e-3,abstol=1e-3)
It's either going to be type unstable, or we need to introduce the extra overhead for every function call. We should add an argument like do_inf_transformation=Val{true}().
Could it not use a function barrier or something?
Not really, because it's a higher order function.
There must be something, we can chat about this at the summit.
I mean transformation_if_inf is kind of like a function barrier, and it's type unstable. The actual integration is type stable.
- Solving this doesn't seem to be sufficient to make
HCubatureJL()typestable. See https://github.com/JuliaMath/HCubature.jl/issues/42
I've addressed this issue in #241 by making sure with tests that all solves in the package are type-stable. I also deprecated do_inf_transformation and opted to transform all problems at solve time instead of init time. Note this does not guarantee type-groundedness, e.g. HCubatureJL is only type grounded when the limits of integration are vectors with static length.