Question

I'm working with the code on the GSL examples page to try to solve a system of four differential equations. I've been wrestling with passing five parameters to the ODE system, and have arrived at one final (I hope!) compile-time error. A snippet follows, giving me the error

114:57: error: invalid conversion from ‘int (*)(double, const double*, 
double*, double**, void*)’ to ‘int (*)(double, const double*, double*, 
double*, void*)’ [-fpermissive]

which corresponds to the line starting with gsl_odeiv2_system:

int main()
{
  double t = 0.0;
  double y[4] = { 0.0, 0.0, 1.0, 1.0 };
  int i, s;

  struct pendula_params * info;
  info->m2 = 1.0;
  info->m1 = 1.0;
  info->l1 = 1.0;
  info->l2 = 1.0;
  info->g  = 1.0;

  gsl_odeiv2_system sys = { pendula, jacobian, 4, &info };

  gsl_odeiv2_driver *d =
    gsl_odeiv2_driver_alloc_y_new (&sys, gsl_odeiv2_step_msadams,
                                   1e-3, 1e-8, 1e-8);

Any thoughts on what might be going on?

Many thanks,

Mark C.

Was it helpful?

Solution

You can see what the error is by comparing the two function types that appear in the error message.

The gsl_odeiv2_system structure expects the jacobian member to be a pointer to a function that takes a double* as the fourth parameter. But your jacobian function takes a double** as the fourth parameter, which makes it incompatible.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top