I am working with some legacy C code, which is quite convoluted. Here is what I have:
In the header file is declared:
int derivs(double,const double *,double *,void *);
then in the .c file with the same name is another declaration:
int derivs(double,const double *,double *,void *);
then the function is defined (in the same file):
int derivs(double t, const double y[], double dydN[], void * params)
{
int i;
if(y[2]>=1.0)
{
for(i=0;i<NEQS;i++)
{
dydN[i] = 0.0;
}
}
else
{
if(y[2] > VERYSMALLNUM)/*Here for numerical issues in
sqrt()*/
{
dydN[0]= - sqrt(y[2]/FOURPI); //d phi/ d N eq. (17)
}
else
{
dydN[0] = 0.0;
}
dydN[1] = y[1]*y[2]; // dH / dN = eps * H
dydN[2] = y[2]*(y[3]+2.0*y[2]); // d epsilon / dN
dydN[3] = 2.0*y[4]-5.0*y[2]*y[3]-12.0*y[2]*y[2];
for(i=4;i<NEQS-1;i++)
{
dydN[i] = (0.5*(i-3)*y[3]+(i-4)*y[2])*y[i]+y[i+1];
}
dydN[NEQS-1] = (0.5*(NEQS-4)*y[3]+(NEQS-5)*y[2])*y[NEQS-1];
}
return GSL_SUCCESS;
}
and then in another function in the same file is the following line:
z=int_de(y,Nstart,Nend,&kount,kmax,yp,xp,NEQS,derivs);
i.e., derivs is called by name only, without any arguments. The function int_de is declared as follows:
int int_de (gsl_vector *y, double N, double Nend, int *kount, int kmax,
gsl_matrix *ypp, gsl_vector *xpp, int NEQS, int (*derivs)(double,const
double *, double *,void *))
My question is how does the use of derivs
in int_de
work? It is called without any of its arguments.