I created a C-library with a number of functions that I can call from python using ctypes. I've got my head around some of the simpler ones but I'm stumped by how I pass the right arguments to the following function:
foo(double *, double *, void(*f1)(double *, double *, double, struct sys *),
void(*f2)(double *, double *, double, struct sys *), struct sys *, double *,
double, double, int, int, gsl_rng *)
My starting point is setting the .argtypes
for the function. I've got the double arrays sorted with POINTER(100*c_double)
etc.
However, I am stuck on how to pass the function pointers. I have a number of functions (of the form of f1 and f2), which reside in the same library as foo
that I would like to pass as arguments to foo
.
I think I've managed pass the struct sys* pointer ok by using the following code:
class sys(Structure):
_fields_ = [("alpha", c_double),
("sigma", c_double)]
and then using POINTER(sys)
as the argtype
there. Finally, the gsl_rng
is a typical random number generator from the GNU Scientific Library; I don't know where to start here.
Can anybody shine some light on the complicated ctypes?