JuliaMath / HCubature.jl

pure-Julia multidimensional h-adaptive integration
Other
153 stars 25 forks source link

hcubature not type stable #42

Closed sharanry closed 2 years ago

sharanry commented 2 years ago

Related: https://github.com/SciML/Integrals.jl/issues/65

using HCubature, Distributions, Test

μ = [0.00 , 0.00]
Σ = [0.4 0.0 ; 0.00 0.4]
d = MvNormal(μ , Σ)
f = (x) -> pdf(d, x)
lb, ub = [-1 , -1] , [1 , 1]
@inferred hcubature(f, lb, ub;
            maxevals=typemax(Int))
ERROR: return type Tuple{Float64, Float64} does not match inferred return type Tuple{Any, Any}
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:33
 [2] top-level scope
   @ REPL[7]:1
sharanry commented 2 years ago

Calling with StaticArrays is sufficient to make the function call type stable.

stevengj commented 2 years ago

Yes, or a tuple should work too.

Converting from a generic Array to an SVector cannot be type-stable because the length is not part of the type.