I want to write a structure containing all the functions (including GSL functions) and parameters for solving an ODE system. From the main function, I only want to call an update function defined in the struct to advance the system by one time-step. When I try this however, I get the error:
Line 27, ERROR: cannot convert ‘ODE::funcS’ from type ‘int (ODE::)(double, const double*, double*, void*)’ to type ‘int (*)(double, const double*, double*, void*)’ Below is a minimal code. \
Here is a minimal version of my code:
#include <iostream>
#include <gsl/gsl_errno.h>
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_odeiv.h>
struct ODE
{
void update(double dt)
{
// code to advance ODE solution by one time-step dt
}
int
funcS (double t, const double y[], double f[],
void *params)
{
return GSL_SUCCESS;
}
double mu = 10;
gsl_odeiv_system sysS;
void
initializeSys()
{
sysS.function = funcS; //Line 27
}
};
int
func (double t, const double y[], double f[],
void *params)
{
return GSL_SUCCESS;
}
int main()
{
// GIVES ERROR
ODE mySys;
mySys.update(0.01);
// WORKS
double mu = 10;
gsl_odeiv_system sys;
sys.function = func;
return 0;
}