20#ifndef CCGSL_MULTIROOT_FUNCTION_HPP
21#define CCGSL_MULTIROOT_FUNCTION_HPP
23#include<gsl/gsl_multiroots.h>
25#if __cplusplus <= 199711L
53 class function :
public gsl_multiroot_function {
74 virtual size_t size()
const = 0;
85 typedef int (*function_t)(gsl_vector
const*,
void*,gsl_vector*);
91 struct F :
public base_F {
98 xv.wrap_gsl_vector_without_ownership( 0 );
99 fv.wrap_gsl_vector_without_ownership( 0 );
110 static int fn( gsl_vector
const* x,
void* params, gsl_vector* fx ){
112 F<T>* ft =
reinterpret_cast<F<T>*
>( params );
113 ft->xv.ccgsl_pointer =
const_cast<gsl_vector*
>( x );
114 ft->fv.ccgsl_pointer = fx;
115 return ft->t.f( ft->xv, ft->fv ); }
133 class Fn :
public base_F {
141 xv.wrap_gsl_vector_without_ownership( 0 );
142 fv.wrap_gsl_vector_without_ownership( 0 );
147 function_t
function(){
return &fn; }
166 static int fn( gsl_vector
const* x,
void* params, gsl_vector* fx ){
168 Fn* ft =
reinterpret_cast<Fn*
>( params );
169 ft->xv.ccgsl_pointer =
const_cast<gsl_vector*
>( x );
170 ft->fv.ccgsl_pointer = fx;
171 return ft->f( ft->xv, ft->fv ); }
287 function( T& t ){ function_constructor<T>( *
this, t ); }
296 func =
new function::Fn( f,
n );
338#ifdef __GXX_EXPERIMENTAL_CXX0X__
346 std::swap( params, v.params );
347 std::swap(
count, v.count );
356 std::swap(
func, v.func );
359 std::swap( params, v.params );
360 std::swap(
count, v.count );
388 f.func =
new function::F<T>( t );
389 f.f = &function::F<T>::fn;
393 f.count =
new size_t;
403 f.func = v.func; f.count = v.count; f.f = v.f; f.n = v.n;
404 f.params = v.params;
if( f.count != 0 ) ++*f.count;
413 f.f = v.f; f.n = v.n; f.params = v.params; }
Class that extends gsl_multiroot_function so that it can be constructed from arbitrary function objec...
function & operator=(function &&v)
Move operator.
function(function &&v)
Move constructor.
function(gsl_multiroot_function &v)
Could construct from a gsl_multiroot_function.
friend void function_constructor(function &, T &)
base_F * func
This gives something for params to point to.
~function()
The destructor unshares any shared resource.
function & operator=(function const &v)
The assignment operator.
function(int(*const f)(gsl::vector const &, gsl::vector &), size_t n)
Construct from a function with no parameters (but with n function values and arguments).
function(T &t)
Construct from an object that implements gsl::multiroot::function::Concept.
function(function const &v)
The copy constructor.
size_t * count
The shared reference count: used for copying this.
function()
The default constructor is only really useful for assigning to.
This class handles vector objects as shared handles.
void function_constructor(function &, T &)
function make_function(T &t)
Make a gsl::multiroot::function from a function object that implements gsl::multiroot::function::Conc...
size_t n(workspace const &w)
C++ version of gsl_rstat_n().
double F(double phi, double k, mode_t mode)
C++ version of gsl_sf_ellint_F().
The gsl package creates an interface to the GNU Scientific Library for C++.
This is an empty abstract base class.
virtual int f(gsl::vector const &x, gsl::vector &f)=0
The function.
virtual size_t size() const =0
This function should return the number of elements of x and f in f().