9#include <gsl/gsl_errno.h>
10#include <gsl/gsl_fft_halfcomplex.h>
11#include <gsl/gsl_fft_real.h>
12#include <gsl/gsl_spline.h>
24 void operator()(gsl_fft_real_wavetable *p) { gsl_fft_real_wavetable_free(p); }
25 void operator()(gsl_fft_real_workspace *p) { gsl_fft_real_workspace_free(p); }
26 void operator()(gsl_fft_halfcomplex_wavetable *p) { gsl_fft_halfcomplex_wavetable_free(p); }
29using real_wt_uptr = std::unique_ptr<gsl_fft_real_wavetable, GSLFree>;
30using real_ws_uptr = std::unique_ptr<gsl_fft_real_workspace, GSLFree>;
31using hc_wt_uptr = std::unique_ptr<gsl_fft_halfcomplex_wavetable, GSLFree>;
45 void operator()(gsl_spline *spline) { gsl_spline_free(spline); }
46 void operator()(gsl_interp_accel *acc) { gsl_interp_accel_free(acc); }
49using accel_uptr = std::unique_ptr<gsl_interp_accel, GSLFree>;
55 throw std::runtime_error(
"Failed to allocate a GSL interpolation accelerator");
60template <
typename X,
typename Y>
62 std::size_t N =
x.size();
64 throw std::runtime_error(
Strings::strmakef(
"x and y lengths for spline don't match: %zu vs %zu", N,
y.size()));
67 throw std::runtime_error(
"A spline requires non-empty vectors");
71 throw std::runtime_error(
Strings::strmakef(
"Failed to allocate a GSL spline with %zu points", N));
73 int status = gsl_spline_init(spline.get(),
x.data(),
y.data(), N);
74 if (status != GSL_SUCCESS) {
75 throw std::runtime_error(
"Failed to initialize GSL spline: " + std::string(gsl_strerror(status)));
81 std::size_t N =
x.size();
83 throw std::runtime_error(
MANTID_KERNEL_DLL std::string strmakef(char const *const fmt,...)
This is the constructor that std::string needed to have.
real_wt_uptr make_gsl_real_wavetable(std::size_t dn)
std::unique_ptr< gsl_fft_halfcomplex_wavetable, GSLFree > hc_wt_uptr
std::unique_ptr< gsl_fft_real_workspace, GSLFree > real_ws_uptr
hc_wt_uptr make_gsl_hc_wavetable(std::size_t dn)
real_ws_uptr make_gsl_real_workspace(std::size_t dn)
std::unique_ptr< gsl_fft_real_wavetable, GSLFree > real_wt_uptr
std::unique_ptr< gsl_interp_accel, GSLFree > accel_uptr
spline_uptr make_cubic_spline(std::span< X const > x, std::span< Y const > y)
constexpr unsigned int MIN_CSPLINE_POINTS
Minimum number of points needed to fit a cubic spline in GSL.
spline_uptr make_spline(std::span< X const > x, std::span< Y const > y, gsl_interp_type const *type)
accel_uptr make_interp_accel()
std::unique_ptr< gsl_spline, GSLFree > spline_uptr
Functor to free GSL objects in a unique pointer.
void operator()(gsl_fft_real_workspace *p)
void operator()(gsl_fft_halfcomplex_wavetable *p)
void operator()(gsl_fft_real_wavetable *p)
Functor to free a GSL objects in a unique pointer.
void operator()(gsl_spline *spline)
void operator()(gsl_interp_accel *acc)