> In the appended file I define (wrongly, it does not work) a function from
> line 33 to 36 to return the interpolated value and this should be use as
> required in line 41. But what about the params?

In this part of your example...

> auto foo::operator()(double x) -> double
> {
>     return gsl_spline_eval(spline.get(), x, acc.get());
> }
>
> auto function(double x, void* params) -> double
> {
>    return foo(x);
> }
>
> int main()
> {
>     gsl_function F;
>     F.function = &function;
> }

...you will need to invoke foo::operator() on an instance of class
foo.  Nothing GSL-specific here, just C++.  Does this even compile?

The idea should be something like

> auto function(double x, void* params) -> double
> {
>     return static_cast<foo*>(params)->operator()(x);
> }
>
> int main()
> {
>     foo bar(/*baz*, /*qux*/); // Your data here
>     gsl_function F;
>     F.function = &function;
>     F.params = &bar;
>     // Use gsl_function now
> }

where you make F.params a pointer to the instance of class foo that
you want to use, and then you cast in function function to retrieve
the foo instance you want prior to invoking operator() on it.  This
definitely does not compile.

Hope that helps,
Rhys

Reply via email to