20#ifndef CCGSL_MONTE_VEGAS_HPP
21#define CCGSL_MONTE_VEGAS_HPP
23#include<gsl/gsl_monte_vegas.h>
53 explicit state(
size_t const dim ){
56 try {
count =
new size_t; }
catch( std::bad_alloc& e ){
69 explicit state( gsl_monte_vegas_state* v ){
111#ifdef __GXX_EXPERIMENTAL_CXX0X__
117 std::swap(
count, v.count );
118 v.ccgsl_pointer =
nullptr;
126 state( std::move( v ) ).swap( *
this );
236#ifdef __GXX_EXPERIMENTAL_CXX0X__
345 double xu[],
size_t const dim,
size_t const calls,
347 return gsl_monte_vegas_integrate( f, xl, xu, dim, calls, r.
get(), state.get(),
362 template<
typename L,
typename U>
364 U& xu,
size_t const calls,
366 size_t const dim = xl.size();
367 if( dim != xu.size() )
368 GSL_ERROR(
"Mismatch in array lengths", GSL_EBADLEN );
369 if( dim != state.get()->dim )
370 GSL_ERROR(
"Array lengths must match dimension of state", GSL_EBADLEN );
371 return gsl_monte_vegas_integrate( f, xl.data(), xu.data(), dim, calls,
372 r.
get(), state.get(),
result, abserr ); }
387 template<
typename L,
typename U>
389 U& xu,
size_t const calls,
391 size_t const dim = xl.size();
392 if( dim != xu.size() )
393 GSL_ERROR(
"Mismatch in array lengths", GSL_EBADLEN );
395 GSL_ERROR(
"Array lengths must match dimension of state", GSL_EBADLEN );
396 return gsl_monte_vegas_integrate( &f, xl.data(), xu.data(), dim, calls,
Class that extends gsl_monte_function so that it can be constructed from arbitrary function objects.
Workspace for Monte Carlo integration using the VEGAS algorithm.
int get_stage() const
Get stage.
double get_alpha() const
Get alpha.
state(size_t const dim)
The default constructor creates a new state with n elements.
bool empty() const
Find if the state is empty.
state(gsl_monte_vegas_state *v)
Could construct from a gsl_monte_vegas_state.
bool operator!=(state const &v) const
Two state are different if their elements are not identical.
state & operator=(state const &v)
The assignment operator.
bool operator>=(state const &v) const
A container needs to define an ordering for sorting.
void swap(state &v)
Swap two state objects.
bool operator<=(state const &v) const
A container needs to define an ordering for sorting.
state()
The default constructor is only really useful for assigning to.
state(state &&v)
Move constructor.
state(state const &v)
The copy constructor.
gsl_monte_vegas_state * ccgsl_pointer
The shared pointer.
size_t use_count() const
Find how many state objects share this pointer.
void set_alpha(double const alpha)
Set alpha.
FILE * get_ostream() const
Get ostream.
void set_mode(int const mode)
Set mode.
double chisq() const
Get chi-squared value: this should be close to 1.
void set_verbose(int const verbose)
Set verbose.
size_t get_mode() const
Get mode.
bool operator<(state const &v) const
A container needs to define an ordering for sorting.
~state()
The destructor only deletes the pointers if count reaches zero.
int get_verbose() const
Get verbose.
bool operator==(state const &v) const
Two state are identically equal if their elements are identical.
void runval(double &result, double &sigma)
Returns the raw (unaveraged) values of the integral result and its error sigma from the most recent i...
void runval(double *result, double *sigma)
Returns the raw (unaveraged) values of the integral result and its error sigma from the most recent i...
void set_ostream(FILE *ostream)
Set ostream.
gsl_monte_vegas_state * get() const
Get the gsl_monte_vegas_state.
void set_stage(int const stage)
Set stage.
state & operator=(state &&v)
Move operator.
size_t * count
The shared reference count.
bool operator>(state const &v) const
A container needs to define an ordering for sorting.
void set_iterations(size_t const iterations)
Set iterations.
bool unique() const
Find if this is the only object sharing the gsl_monte_vegas_state.
size_t get_iterations() const
Get iterations.
gsl_rng * get() const
Get the gsl_rng.
int init(gsl::monte::vegas::state &state)
C++ version of gsl_monte_vegas_init().
int integrate(gsl::monte::function &f, L &xl, U &xu, size_t const calls, gsl::rng &r, state &state, double &result, double &abserr)
C++ version of gsl_monte_vegas_integrate().
gsl_sf_result result
Typedef for gsl_sf_result.
The gsl package creates an interface to the GNU Scientific Library for C++.