Integrals.jl icon indicating copy to clipboard operation
Integrals.jl copied to clipboard

Wrap GSL.jl in extension

Open lxvm opened this issue 2 years ago • 2 comments

Hi,

I was interested in wrapping some of the GSL integration routines, which are unfortunately limited to 1d integration of scalar, real-valued functions. The main motivation is that the GSL has routines that claim to integrate singular functions and have robust adaptivity, which are helpful to have available for benchmarking algorithms and integrating certain functions. Part of the challenge of writing this extension, for me, is that GSL.jl is a low-level wrapper of the C library and I don't have much experience with memory management. It would be incredibly helpful for the reviewer to inspect the memory management, including the use of finalizers in init_cacheval and the call to Base.unsafe_convert when constructing a runtime closure. Is there anything missing, such as calls to GC.@preserve (see here)?

Below, I mention a few additional todos below and an example of the usage is here

using GSL, Integrals
prob = IntegralProblem((x,p) -> sin(p*x), 0.0, 1.0, 1.0)
alg = GSLIntegration(integration_cquad; wssize=100)
solve(prob, alg)

Checklist

  • [x] Appropriate tests were added
  • [x] Any code changes were done in a way that does not break public API
  • [ ] All documentation related to code changes were updated
  • [ ] The new code follows the contributor guidelines, in particular the SciML Style Guide and COLPRAC.
  • [ ] Any new documentation only uses public API
  • [ ] Finish wrapping the remaining routines
  • [ ] Provide useful defaults for routine parameters, including allocation sizes (e.g. wssize)

Additional context

Add any other context about the problem here.

lxvm avatar Dec 29 '23 17:12 lxvm

This is looking good. Indeed it'll be interesting to see those robust methods on some example.

ChrisRackauckas avatar Dec 30 '23 10:12 ChrisRackauckas

While I wrap the other routines, there might be some upstream changes that facilitate the usage of GSL (see https://github.com/JuliaMath/GSL.jl/pull/130)

lxvm avatar Dec 31 '23 16:12 lxvm