GslFunctionAdapter.hpp
Go to the documentation of this file.
1 #ifndef JULIAN_GSLFUNCTIONADAPTER_HPP
2 #define JULIAN_GSLFUNCTIONADAPTER_HPP
3 
4 #include <gsl/gsl_math.h>
5 
6 
7 namespace julian {
24  template< typename F >
25  class GslFunctionAdapter : public gsl_function {
26  public:
27 
32  GslFunctionAdapter(const F& functor) : functor_(functor) {
33  function = &GslFunctionAdapter::call;
34  params=this;
35  }
36  private:
39  static double call(double x, void *params) {
40  return static_cast<GslFunctionAdapter*>(params)->functor_(x);
41  }
42 
43  const F& functor_;
44  };
45 }
46 #endif
Definition: cadHoliday.cpp:3
static double call(double x, void *params)
Method called by the GSL algorithm.
Definition: GslFunctionAdapter.hpp:39
Class implements adapter for gsl_function.
Definition: GslFunctionAdapter.hpp:25
const F & functor_
F must be a functor. double operator()(double) will be used by GSL algorithm.
Definition: GslFunctionAdapter.hpp:43
GslFunctionAdapter(const F &functor)
Constructor.
Definition: GslFunctionAdapter.hpp:32