/* * IFD-R.c: solving the ideal-free distribution for a generalised functional * response with exponential interference function * * * Created by Adriaan Dokter * last modified: Apr-2015 * */ #include #include #include #include #include #include #include #include #define MAX(a,b) (((a)>(b))?(a):(b)) struct f_params { int size; float *areas; float *ks; float *FRs; int Nbirds; float p0; }; /********************************************************************/ /* Prototypes of local functions: */ /********************************************************************/ double f_ifd (double x, void *params); void IFDgsl(float *FRs,float *areas,int *Nbirds,float *kk,float *frandom,int *Ndata, float *distrib,float *maxw, double *logival, int *maxiter, int *type); /********************************************************************/ /* local functions */ /********************************************************************/ double f_ifd (double x, void *params){ struct f_params *p = (struct f_params *) params; double output = 0; int i; int size = p->size; float *areas = p->areas; float *ks = p->ks; float *FRs = p->FRs; int Nbirds = p->Nbirds; float p0 = p->p0; output=-Nbirds; for (i=0; i0){ FRs0[i]=FRs[i]; } else { FRs0[i]=0; nFRs0++; } } /* if all gain rates zero or negative, distribute all birds randomly */ if (nFRs0==imax) { for (i=0; ilogival[0]){ for (i=0; i