Yes—there are several C++-centric libraries (or coherent “bundles” of libraries) that give you roughly the same numerical breadth as GNU GSL but with modern, idiomatic C++ APIs.
There isn’t a single, monolithic “drop-in C++ GSL,” but by mixing one or two of the libraries below you can cover every GSL module while keeping a clean C++-style interface.
───────────────────────────────────────────────────────────────────────────────
- One-stop (almost) “scientific toolkits”
───────────────────────────────────────────────────────────────────────────────
Library | What it gives you (C++ style) | Notes
------------------|----------------------------------------------------------|-----------------------------------------------------
Eigen | Dense + sparse linear algebra, decompositions, geometry | Header-only, expression templates, BLAS-level speed. No random, ODE, etc.
Armadillo | Matlab-like API, dense + sparse LA, stats, random, FFT | Thin wrapper over LAPACK/BLAS (+ optionally FFTW, ARPACK, SuperLU).
Blaze | High-performance tensors/vectors/matrices, automatic AVX | Focuses on linear algebra; plug-ins for LAPACK/BLAS, FFTW.
xtensor | N-dim “NumPy-like” arrays, broadcasting, FFT (xtensor-fft)| Good match if you want tensor arithmetic and Python interop (xtensor-python).
Vc / std::simd | Explicit SIMD vector class for element-wise math | Complements linear-algebra libs for low-level kernels.
All four give you C++11-20-friendly APIs (RAII, templates, move semantics, etc.) and will replace the GSL BLAS/LAPACK wrappers, statistics helpers, and basic FFTs.
───────────────────────────────────────────────────────────────────────────────
2. Filling the remaining GSL gaps module-by-module
───────────────────────────────────────────────────────────────────────────────
| GSL Module | Modern C++ replacement (header-only when ❑) |
|---|
| Random numbers | (StdLib), PCG ❑, Boost.Random ❑ |
| Special functions | Boost.Math ❑ (Bessel, elliptic, airy, …) |
| Quadrature / Integration | Boost.Math Quadrature ❑ (Gauss-Kronrod, tanh-sinh) |
| Interpolation / Spline | Boost.Math Interpolators ❑, Eigen::Spline (unsupported) |
| ODE solvers | Boost.Numeric.Odeint ❑ (explicit/implicit, stiff, controlled) |
| FFT (1-D, N-D) | FFTW++, KISS FFT, xtensor-fft, mkl::fft (if MKL OK) |
| Optimization / NL solve | ceres-solver, dlib::optimization, cpp-optlib ❑ |
| Statistics / Accumulators | Boost.Accumulators ❑, Boost.Math Stats ❑ |
| Automatic differentiation | autodiff-v2, Adept, Stan Math |
| Sparse direct/iterative solve | SuiteSparse (C API but C++ wrappers in Eigen, Blaze), Spectra ❑ for large eigenproblems |
| Monte-Carlo / Quasi-random | Boost.Random ❑, ompt-random or PCG ❑ |
───────────────────────────────────────────────────────────────────────────────
3. “Batteries-included” bundles
───────────────────────────────────────────────────────────────────────────────
• SciCpp (https://github.com/SciCpp/sci): early-stage attempt at a single C++20 scientific umbrella—still incomplete but converging.
• HighFive + xtensor + Eigen is a popular “mini-stack” in HPC codes (HDF5 I/O, arrays, LA).
• KokkosKernels targets performance-portable BLAS, sparse, graph kernels (C++17, GPU ready).
───────────────────────────────────────────────────────────────────────────────
4. Decision tree
───────────────────────────────────────────────────────────────────────────────
Need → Good pick
────────────────────────────┼──────────────────────────────────────────────────
“Mostly matrices/vectors” → Eigen (or Armadillo if you like Matlab style)
“NumPy-like tensors” → xtensor (+ xtensor-fft)
“High-end performance” → Blaze or Eigen + OpenBLAS/MKL/oneMKL backend
“Lots of ODE / integrals” → Eigen/Armadillo + Boost.Numeric.Odeint + Boost.Math
“Single header RNG & stats” → PCG + Boost.Math Stats
“Sparse stuff” → Eigen’s sparse module + SuiteSparse back-end
───────────────────────────────────────────────────────────────────────────────
5. Example: replacing three GSL calls in modern C++
───────────────────────────────────────────────────────────────────────────────
// GSL style (C)
gsl_rng *r = gsl_rng_alloc(gsl_rng_mt19937);
double x = gsl_cdf_gamma_Qinv(p, k, theta);
gsl_interp_accel *acc = gsl_interp_accel_alloc();
gsl_spline *spline = gsl_spline_alloc(gsl_interp_steffen, n);
gsl_spline_init(spline, xdata, ydata, n);
double y = gsl_spline_eval(spline, xquery, acc);
Modern C++ alternative (header-only, no raw pointers):
#include <random>
#include <boost/math/distributions/gamma.hpp>
#include <boost/math/interpolators/steffen.hpp>
// 1. RNG (PCG or just <random>)
std::mt19937_64 eng(std::random_device{}());
std::normal_distribution<double> normal;
double sample = normal(eng);
// 2. Gamma quantile
double x = boost::math::quantile(
boost::math::gamma_distribution<double>(k, theta), p);
// 3. Steffen spline
auto spline = boost::math::interpolators::steffen(xdata, ydata);
double y = spline(xquery);
No manual allocation, RAII ensures cleanup, template types deduced, and pure headers mean no linking hassle.
───────────────────────────────────────────────────────────────────────────────
6. Bottom line
───────────────────────────────────────────────────────────────────────────────
• There isn’t a single “GNU GSL-for-C++” project, but the combo of
- Eigen/Armadillo/xtensor/Blaze for arrays & LA,
- Boost (Math, Random, Odeint, Accumulators) for numerics, and
- FFTW++ / SuiteSparse / PCG et al. for the remaining gaps
gives you everything GSL offers while keeping a clean, idiomatic, header-only (if desired) modern C++ style.
• If you truly need a one-file dependency list, pick Eigen + selected Boost components; that pair covers ~80 % of the everyday GSL workload with zero C-style APIs.