20#ifndef CCGSL_MONTE_PLAIN_HPP
21#define CCGSL_MONTE_PLAIN_HPP
23#include<gsl/gsl_monte_plain.h>
53 explicit state(
size_t const dim ){
56 try {
count =
new size_t; }
catch( std::bad_alloc& e ){
69 explicit state( gsl_monte_plain_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__
262 double const xu[],
size_t const dim,
size_t const calls,
264 return gsl_monte_plain_integrate( f, xl, xu, dim, calls, r.
get(), state.get(),
279 template<
typename L,
typename U>
281 U
const& xu,
size_t const calls,
283 size_t const dim = xl.size();
284 if( dim != xu.size() )
285 GSL_ERROR(
"Mismatch in array lengths", GSL_EBADLEN );
286 if( dim != state.get()->dim )
287 GSL_ERROR(
"Array lengths must match dimension of state", GSL_EBADLEN );
288 return gsl_monte_plain_integrate( f, xl.data(), xu.data(), dim, calls,
289 r.
get(), state.get(),
result, abserr ); }
304 template<
typename L,
typename U>
306 U
const& xu,
size_t const calls,
308 size_t const dim = xl.size();
309 if( dim != xu.size() )
310 GSL_ERROR(
"Mismatch in array lengths", GSL_EBADLEN );
312 GSL_ERROR(
"Array lengths must match dimension of state", GSL_EBADLEN );
313 return gsl_monte_plain_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 plain Monte Carlo integration.
state(state const &v)
The copy constructor.
state()
The default constructor is only really useful for assigning to.
void swap(state &v)
Swap two state objects.
state(state &&v)
Move constructor.
state(size_t const dim)
The default constructor creates a new state with n elements.
bool operator!=(state const &v) const
Two state are different if their elements are not identical.
bool operator>=(state const &v) const
A container needs to define an ordering for sorting.
size_t use_count() const
Find how many state objects share this pointer.
bool unique() const
Find if this is the only object sharing the gsl_monte_plain_state.
state & operator=(state const &v)
The assignment operator.
gsl_monte_plain_state * ccgsl_pointer
The shared pointer.
size_t * count
The shared reference count.
bool operator==(state const &v) const
Two state are identically equal if their elements are identical.
state & operator=(state &&v)
Move operator.
bool operator>(state const &v) const
A container needs to define an ordering for sorting.
gsl_monte_plain_state * get() const
Get the gsl_monte_plain_state.
~state()
The destructor only deletes the pointers if count reaches zero.
state(gsl_monte_plain_state *v)
Could construct from a gsl_monte_plain_state.
bool empty() const
Find if the state is empty.
bool operator<(state const &v) const
A container needs to define an ordering for sorting.
bool operator<=(state const &v) const
A container needs to define an ordering for sorting.
gsl_rng * get() const
Get the gsl_rng.
int init(gsl::monte::plain::state &state)
C++ version of gsl_monte_plain_init().
int integrate(gsl::monte::function const &f, L const &xl, U const &xu, size_t const calls, gsl::rng &r, state &state, double &result, double &abserr)
C++ version of gsl_monte_plain_integrate().
gsl_sf_result result
Typedef for gsl_sf_result.
The gsl package creates an interface to the GNU Scientific Library for C++.