15 #ifndef BORNAGAIN_BASE_UTILS_INTEGRATORMCMISER_H
16 #define BORNAGAIN_BASE_UTILS_INTEGRATORMCMISER_H
18 #include <gsl/gsl_monte_miser.h>
22 template <
class T>
using miser_integrand = double (T::*)(
double*, size_t,
void*)
const;
39 const T* m_object_pointer;
49 double integrate(
double* min_array,
double* max_array,
void* params,
size_t nbr_points);
53 static double StaticCallBack(
double* d_array,
size_t dim,
void* v)
57 return (p_cb->m_object_pointer->*mf)(d_array, dim, p_cb->m_data);
62 gsl_monte_miser_state* m_gsl_workspace;
63 gsl_rng* m_random_gen;
87 : mp_object(p_object), m_member_function(p_member_function),
88 m_dim(dim), m_gsl_workspace{nullptr}
90 m_gsl_workspace = gsl_monte_miser_alloc(m_dim);
92 const gsl_rng_type* random_type;
94 random_type = gsl_rng_default;
95 m_random_gen = gsl_rng_alloc(random_type);
100 gsl_monte_miser_free(m_gsl_workspace);
101 gsl_rng_free(m_random_gen);
110 gsl_monte_function f;
111 f.f = StaticCallBack;
115 double result, error;
116 gsl_monte_miser_integrate(&f, min_array, max_array, m_dim, nbr_points, m_random_gen,
117 m_gsl_workspace, &result, &error);
double(T::*)(double *, size_t, void *) const miser_integrand
Alias template for member function with signature double f(double)
std::unique_ptr< IntegratorMCMiser< T > > P_integrator_miser
Alias template for handle to a miser integrator.
Template class to use Monte Carlo MISER integration of class member functions.
double integrate(double *min_array, double *max_array, void *params, size_t nbr_points)
perform the actual integration over the ranges [min_array, max_array]
IntegratorMCMiser(const T *p_object, miser_integrand< T > p_member_function, size_t dim)
to integrate p_member_function, which must belong to p_object
structure holding the object and possible extra parameters