GslFunctionFdfAdapter.hpp
Go to the documentation of this file.
1 #ifndef JULIAN_GSLFUNCTIONFDFADAPTER_HPP
2 #define JULIAN_GSLFUNCTIONFDFADAPTER_HPP
3 
4 #include <gsl/gsl_math.h>
5 
6 
7 namespace julian {
8 
22  template< typename F, typename dF >
23  class GslFunctionFdfAdapter : public gsl_function_fdf {
24  public:
25 
31  GslFunctionFdfAdapter(const F& kf, const dF& kdf) : f_(kf), df_(kdf) {
35  params=this;
36  }
37  private:
42  static double call_f(double x, void *params) {
43  return static_cast<GslFunctionFdfAdapter*>(params)->f_(x);
44  }
45 
50  static double call_df(double x, void *params) {
51  return static_cast<GslFunctionFdfAdapter*>(params)->df_(x);
52  }
53 
58  static void call_fdf(double x, void * params, double* f, double* df) {
59  (*f) = static_cast<GslFunctionFdfAdapter*>(params)->f_(x);
60  (*df) = static_cast<GslFunctionFdfAdapter*>(params)->df_(x);
61  }
62 
63  const F& f_;
64  const dF& df_;
65  };
66 }
67 #endif /* GSLFDFFUNCTIONADAPTER_HPP */
Class implements adapter for gsl_function_fdf.
Definition: GslFunctionFdfAdapter.hpp:23
Definition: cadHoliday.cpp:3
static double call_f(double x, void *params)
Method called by the GSL algorithm.
Definition: GslFunctionFdfAdapter.hpp:42
static double call_df(double x, void *params)
Method called by the GSL algorithm.
Definition: GslFunctionFdfAdapter.hpp:50
const F & f_
F must be a functor.
Definition: GslFunctionFdfAdapter.hpp:63
static void call_fdf(double x, void *params, double *f, double *df)
Method called by the GSL algorithm.
Definition: GslFunctionFdfAdapter.hpp:58
GslFunctionFdfAdapter(const F &kf, const dF &kdf)
Constructor.
Definition: GslFunctionFdfAdapter.hpp:31
const dF & df_
dF must be a functor. dF is derivative of F.
Definition: GslFunctionFdfAdapter.hpp:64