I tried to use quadgk!()
, which is the in-place quadgk()
, but encountered problems. Simply put, quadgk!()
does not accpet Inf
or -Inf
in the domain boundary while it is not a problem with quadgk()
. The following is a MWE.
julia> using QuadGK, StatsFuns
julia> f(x) = normpdf(x)
f (generic function with 1 method)
julia> f!(y,x) = y .= f(x)
f! (generic function with 1 method)
julia> int_g = zeros(1)
1-element Vector{Float64}:
0.0
julia> # without `Inf` both are fine
julia> quadgk(f, 0.0, 1.0)
(0.341344746068543, 9.992007221626409e-16)
julia> quadgk!(f!, int_g, 0.0, 1.0)
([0.341344746068543], 9.992007221626409e-16)
julia> # with `Inf` problem arises
julia> quadgk(f, 0.0, Inf) # fine
(0.4999999999999999, 5.67681333382849e-9)
julia> quadgk!(f!, int_g, 0.0, Inf) # not work
ERROR: MethodError: objects of type QuadGK.InplaceIntegrand{typeof(f!), Vector{Float64}, Vector{Float64}} are not callable
Is it a bug or a design feature? If it is the former, could it be fixed? Thanks.