Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap GSL.jl in extension #213

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft

Wrap GSL.jl in extension #213

wants to merge 3 commits into from

Conversation

lxvm
Copy link
Collaborator

@lxvm lxvm commented Dec 29, 2023

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

  • Appropriate tests were added
  • 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 lxvm changed the title Wrap GSL.jl Wrap GSL.jl in extension Dec 29, 2023
GSLIntegration(routine; kws...)

One-dimensional quadrature of Float64-valued function using `routine` from GSL with
additional arguments. For example `using Integrals, GSL; GSLIntegration(integration_cquad; wssize=100)`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably document the available functions. How many are there?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are quite a few, since the GSL includes a rewrite of quadpack. I'll put a full list below and I hope that most of them can be wrapped metaprogramatically

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

integration_cquad
integration_fixed
integration_glfixed
integration_qag
integration_qagi
integration_qagil
integration_qagiu
integration_qagp
integration_qags
integration_qawc
integration_qawf
integration_qawo
integration_qaws
integration_qcheb
integration_qk
integration_qk15
integration_qk21
integration_qk31
integration_qk41
integration_qk51
integration_qk61
integration_qng
integration_romberg

@ChrisRackauckas
Copy link
Member

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

@lxvm
Copy link
Collaborator Author

lxvm commented Dec 31, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants