ccgsl 2.7.2
C++wrappersforGnuScientificLibrary
gsl::monte::function Class Reference

Class that extends gsl_monte_function so that it can be constructed from arbitrary function objects. More...

#include <monte.hpp>

Inheritance diagram for gsl::monte::function:
Inheritance graph
Collaboration diagram for gsl::monte::function:
Collaboration graph

Public Member Functions

 function ()
 The default constructor is only really useful for assigning to. More...
 
 function (double(*const f)(gsl::vector const &), size_t const dim)
 Construct from a function. More...
 
template<typename T >
 function (T &c, double(T::*f)(gsl::vector const &), size_t const dim)
 Construct from a function object and a suitable member function. More...
 
 function (function const &v)
 The copy constructor. More...
 
functionoperator= (function const &v)
 The assignment operator. More...
 
 function (function &&v)
 Move constructor. More...
 
functionoperator= (function &&v)
 Move operator. More...
 
 ~function ()
 The destructor unshares any shared resource. More...
 

Static Private Member Functions

static double fn (double *x, size_t dim, void *params)
 This is the function that gsl_monte_function points to if function is constructed from a function object. More...
 

Private Attributes

base_F * base_f
 
size_t * count
 The shared reference count. More...
 

Detailed Description

Class that extends gsl_monte_function so that it can be constructed from arbitrary function objects.

The arbitrary function object dould be a object of a class containing a member function whose argument and return values are doubles. The member function may be declared const.

To construct an object of this class from a function object t of class T, use, for example,

gsl::monte::function f( t, dim, &T::operator() )
Class that extends gsl_monte_function so that it can be constructed from arbitrary function objects.
Definition: monte.hpp:59

where T::operator is a member function whose single argument is a double. To assign, use, for example,

f = monte::make_function( t, dim, &T::operator() )
function make_function(T &c, double(T::*f)(gsl::vector const &), size_t const dim)
Make a gsl::monte::function from a function object and a suitable member function.
Definition: monte.hpp:4407

There are multiple forms of the function constructor and make_function(). These should allow you to construct a function object from any reasonable function object and quite a lot of unreasonable ones too. If f is an object of class gsl_monte_function, it is always possible to pass &f to a gsl function that requires a gsl_monte_function* argument.

This class is designed for flexibility rather than efficient copying. So if objects are to be copied frequently, consider using shared pointers or the like.

The class extends gsl_monte_function. If constructed from a function object, gsl_monte_function::params is always the function object and gsl_monte_function::function calls the member function using params to obtain an object to call the member function from.

Definition at line 59 of file monte.hpp.

Constructor & Destructor Documentation

◆ function() [1/5]

gsl::monte::function::function ( )
inline

The default constructor is only really useful for assigning to.

Definition at line 3366 of file monte.hpp.

References base_f, and count.

◆ function() [2/5]

gsl::monte::function::function ( double(*)(gsl::vector const &)  f,
size_t const  dim 
)
inlineexplicit

Construct from a function.

Parameters
fThe function.
dimThe number of parameters of the function.

Definition at line 3378 of file monte.hpp.

References base_f, and count.

◆ function() [3/5]

template<typename T >
gsl::monte::function::function ( T &  c,
double(T::*)(gsl::vector const &)  f,
size_t const  dim 
)
inline

Construct from a function object and a suitable member function.

Parameters
cThe function object.
fThe member function.
dimThe number of parameters of the function.

Definition at line 3557 of file monte.hpp.

References base_f, and count.

◆ function() [4/5]

gsl::monte::function::function ( function const &  v)
inline

The copy constructor.

This shares base_f.

Parameters
vThe function to copy.

Definition at line 4323 of file monte.hpp.

References count.

◆ function() [5/5]

gsl::monte::function::function ( function &&  v)
inline

Move constructor.

Parameters
vThe function to move.

Definition at line 4354 of file monte.hpp.

References count.

◆ ~function()

gsl::monte::function::~function ( )
inline

The destructor unshares any shared resource.

Definition at line 4378 of file monte.hpp.

References base_f, and count.

Member Function Documentation

◆ fn()

static double gsl::monte::function::fn ( double *  x,
size_t  dim,
void *  params 
)
inlinestaticprivate

This is the function that gsl_monte_function points to if function is constructed from a function object.

Parameters
xA double.
dimThe number of function arguments.
paramsThe parameters, which are always set to be a pointer to the function object.
Returns
the function object function evaluated at x.

Definition at line 4395 of file monte.hpp.

References gsl::sf::mathieu::b().

◆ operator=() [1/2]

function & gsl::monte::function::operator= ( function &&  v)
inline

Move operator.

Parameters
vThe function to move.
Returns
A reference to base_f in this.

Definition at line 4366 of file monte.hpp.

References base_f, and count.

◆ operator=() [2/2]

function & gsl::monte::function::operator= ( function const &  v)
inline

The assignment operator.

This makes a shared copy.

Parameters
vThe function to copy

Definition at line 4334 of file monte.hpp.

References base_f, and count.

Member Data Documentation

◆ base_f

base_F* gsl::monte::function::base_f
private

Definition at line 3357 of file monte.hpp.

Referenced by function(), operator=(), and ~function().

◆ count

size_t* gsl::monte::function::count
private

The shared reference count.

Definition at line 3361 of file monte.hpp.

Referenced by function(), operator=(), and ~function().


The documentation for this class was generated from the following file: