ccgsl  2.7.0
C++wrappersforGnuScientificLibrary
gsl::multimin::function Class Reference

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

#include <multimin_function.hpp>

Inheritance diagram for gsl::multimin::function:
Inheritance graph
Collaboration diagram for gsl::multimin::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 n)
 Construct from a function. More...
 
 function (double(*const f)(gsl::vector const volatile &), size_t const n)
 Construct from a function. More...
 
template<typename T >
 function (T &c, double(T::*f)(gsl::vector const &), size_t const n)
 Construct from a function object and a suitable member function. More...
 
template<typename T >
 function (T &c, double(T::*f)(gsl::vector const volatile &), size_t const n)
 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 (gsl_vector const *x, void *params)
 This is the function that gsl_multimin_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_multimin_function so that it can be constructed from arbitrary function objects.

The arbitrary function object could 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::multimin::function f( t, &T::operator() )
Class that extends gsl_multimin_function so that it can be constructed from arbitrary function object...

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

f = multimin::make_function( t, &T::operator() )
function make_function(T &c, double(T::*f)(gsl::vector const &), size_t const n)
Make a gsl::multimin::function from a function object and a suitable member function.

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_multimin_function, it is always possible to pass &f to a gsl function that requires a gsl_multimin_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. Moving is defined for C++11.

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

Definition at line 64 of file multimin_function.hpp.

Constructor & Destructor Documentation

◆ function() [1/7]

gsl::multimin::function::function ( )
inline

The default constructor is only really useful for assigning to.

Definition at line 3059 of file multimin_function.hpp.

References base_f, count, and gsl::rstat::n().

◆ function() [2/7]

gsl::multimin::function::function ( double(*)(gsl::vector const &)  f,
size_t const  n 
)
inlineexplicit

Construct from a function.

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

Definition at line 3071 of file multimin_function.hpp.

References base_f, count, fn(), and gsl::rstat::n().

◆ function() [3/7]

gsl::multimin::function::function ( double(*)(gsl::vector const volatile &)  f,
size_t const  n 
)
inlineexplicit

Construct from a function.

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

Definition at line 3087 of file multimin_function.hpp.

References base_f, count, fn(), and gsl::rstat::n().

◆ function() [4/7]

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

Construct from a function object and a suitable member function.

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

Definition at line 3272 of file multimin_function.hpp.

References base_f, count, fn(), and gsl::rstat::n().

◆ function() [5/7]

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

Construct from a function object and a suitable member function.

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

Definition at line 3289 of file multimin_function.hpp.

References base_f, count, fn(), and gsl::rstat::n().

◆ function() [6/7]

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

The copy constructor.

This shares base_f.

Parameters
vThe function to copy.

Definition at line 4134 of file multimin_function.hpp.

References count, and gsl::rstat::n().

◆ function() [7/7]

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

Move constructor.

Parameters
vThe function to move.

Definition at line 4165 of file multimin_function.hpp.

References count, and gsl::rstat::n().

◆ ~function()

gsl::multimin::function::~function ( )
inline

The destructor unshares any shared resource.

Definition at line 4189 of file multimin_function.hpp.

References base_f, and count.

Member Function Documentation

◆ fn()

static double gsl::multimin::function::fn ( gsl_vector const *  x,
void *  params 
)
inlinestaticprivate

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

Parameters
xA double.
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 4205 of file multimin_function.hpp.

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

Referenced by function().

◆ operator=() [1/2]

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

Move operator.

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

Definition at line 4177 of file multimin_function.hpp.

References base_f, count, and gsl::rstat::n().

◆ operator=() [2/2]

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

The assignment operator.

This makes a shared copy.

Parameters
vThe function to copy

Definition at line 4145 of file multimin_function.hpp.

References base_f, count, and gsl::rstat::n().

Member Data Documentation

◆ base_f

base_F* gsl::multimin::function::base_f
private

Definition at line 3050 of file multimin_function.hpp.

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

◆ count

size_t* gsl::multimin::function::count
private

The shared reference count.

Definition at line 3054 of file multimin_function.hpp.

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


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