JuliaMath / QuadGK.jl

adaptive 1d numerical Gauss–Kronrod integration in Julia
MIT License
268 stars 37 forks source link

Inplace method not callable with Inf #50

Closed dominikkiese closed 1 year ago

dominikkiese commented 3 years ago

Hi,

wanted to know if this is the expected behavior. When doing

function f!(b, x)
   b[1] = exp(-x^2)
   b[2] = exp(-x^2)
   return nothing 
end

buf = zeros(Float64, 2); quadgk!(f!, buf, 0.0, Inf)

I get ERROR: MethodError: objects of type QuadGK.InplaceIntegrand{typeof(f!),Array{Float64,1},Array{Float64,1}} are not callable. For finite upper bounds though everything seems to work. In my use case however, I need to compute integrals for which the upper bound is Inf, and I do not a priori know if and when I can truncate the integral for some large upper bound.

stevengj commented 3 years ago

Sounds like a bug.

In the meantime, you can just implement the same coordinate transformation (which QuadGK does internally) yourself: image

dominikkiese commented 3 years ago

Sure, that is what we used for now. I think however, that it would be more convenient to have it in the package. Are you planning to fix this in the near future? Otherwise I'll try to make a PR when I find the time.

stevengj commented 3 years ago

I haven't had time to work on this, so a PR would be welcome.