Drop GSL dependency - #26
Closed
krystophny wants to merge 1 commit into
Closed
Conversation
Replace GSL calls with libneo math kit routines and in-tree code: - mephit_pert.f90: gsl_sf_bessel_In_array -> neo_bessel_i::bessel_in_array - hyper1F1.c: gsl_integration_qag -> mephit_integrate_gk (libneo Gauss-Kronrod 21), gsl_sum_levin_u -> in-tree levin_u_sum (Weniger 1989) - mephit_fem.c: gsl_integration_glfixed -> mephit_gauss_legendre (libneo Golub-Welsch) - mephit_util.c, mephit_run.c: drop gsl_errno_msg and the GSL error handler; quadrature errors surface as QUADPACK return codes - math_c_api.f90, mephit_math.h: bind(C) shims exporting the libneo quadrature to the C sources - CMakeLists.txt: drop find_package(GSL), link LIBNEO::math, locate FFTW directly instead of relying on libneo's parent-scope leakage - SetupCODE.cmake: drop fgsl-1.6.0 pickup Requires libneo with the math kit (itpplasma/libneo#290).
This was referenced Jun 10, 2026
Member
Author
|
Superseded by #28, which migrates MEPHIT onto fortnum (the single numerical core) instead of the libneo math-kit. #28 has a verified-green full build and numerical-equivalence checks for the Bessel, 1F1 quadrature, Levin acceleration, and Gauss-Legendre paths. Leaving this open for a human to close. |
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Removes the GSL/FGSL dependency. Replacements come from the libneo math kit
(itpplasma/libneo#290) plus a short in-tree Levin-u summation. All replacement
code is clean-room, implemented from published algorithms.
Resolves #24.
Changes
src/mephit_pert.f90: thebind(C)interface togsl_sf_bessel_In_arrayis replaced by
neo_bessel_i::bessel_in_array. Forpol_mode = 0theI_{m-1}value now comes from the symmetryI_{-n} = I_ninstead of anout-of-range GSL call.
src/math_c_api.f90,src/mephit_math.h(new):bind(C)shimsmephit_integrate_gk(libneo Gauss-Kronrod 21, QUADPACK QAG semantics) andmephit_gauss_legendre(libneo Golub-Welsch nodes/weights). No modulestate; the C callback and its context pointer pass through a wrapper local
to each call, so the shims stay thread-safe.
src/hyper1F1.c:gsl_integration_qagcalls go throughmephit_integrate_gk;gsl_sum_levin_uis replaced by an in-treelevin_u_sum, a 45-line Levin u-transformation after Weniger, Comput.Phys. Rep. 10 (1989) 189, eqs. (7.2-8) and (7.3-5).
src/mephit_fem.c:gsl_integration_glfixedis replaced bymephit_gauss_legendre.src/mephit_util.c,src/mephit_util.h,src/mephit_run.c:gsl_errno_msgand the GSL error handler installation are removed;quadrature errors surface as QUADPACK return codes.
CMakeLists.txt:find_package(GSL REQUIRED)andGSL::gslremoved,LIBNEO::mathlinked,src/math_c_api.f90added. FFTW is now locateddirectly; the libneo math-kit branch no longer leaks FFTW variables into
the parent scope.
cmake/SetupCODE.cmake: fgsl-1.6.0 pickup removed.Depends on itpplasma/libneo#290 for the
LIBNEO::mathtarget; draft untilthat merges into libneo
main.Verification
Built on macOS (Homebrew gfortran 15, Accelerate LAPACK) against the libneo
math-kitbranch.Before, GSL was a hard requirement and
libmephitlinked it:After, the full build succeeds without GSL and no binary links it:
The repo has no ctest suite covering the touched paths, so a standalone
harness compares old GSL-backed code against the new implementations. The
old
hyper1F1.c(frommain, linked against Homebrew GSL 2.8) is compiledwith prefixed symbols next to the new
libmephit; GSL is the oracle forGauss-Legendre nodes/weights and the Bessel array, matching the libneo
oracle-test pattern (GSL linked only in the test harness, never in shipped
targets). Representative arguments: 25 complex
(b, z)pairs for thehypergeometric routines, quadrature orders 1 to 12, Bessel orders 1 to 16
at six arguments between 1e-3 and 20.
All differences are at least two orders below the 1e-12 target. The cases
where
hypergeometric1f1_quaddiverges (integrand singular for the givenb) produce identical signed infinities before and after.Not verified here: a full MEPHIT run (needs FreeFem++ and run data, not
available on this machine) and the Python tests under
test/(need acompleted run).