I decided to port some of my Python functions to C, mostly following this simple tutorial. Problem is that my C function returns a complex float, and there's no corresponding type in ctypes's documentation. This is is a problem I couldn't solve myself with my limited knowledge on cross-language coding and C, even extended by Google.
My C function works like this:
#include <tgmath.h>
float _Complex integrand(float _Complex theta1, double r, double z){
//[code] }
So, based on the tutorial, the corresponding Python wrapper (probably) should be something like this:
complextype = '??????'
_integr = ctypes.CDLL('libintegrand.so')
_integr.integrand.argtypes = (complextype, ctypes.c_double, ctypes.c_double)
def integrand(theta1, r, z):
global _integr
result = _integr.integrand(complextype(theta1), ctypes.c_double(r), ctypes.c_double(z))
return float(result)
But what should this type be? How should I do this?
If the fact that the function also has a complex argument makes it significantly more complicated, please ignore the complex argument.
global _integrstatement is unnecessary and the oykd probably cause an experienced Python programmer to assume this function will mutate global state when it does not