I have a function in C that takes an array of complex floats and does calculations on them in-place.:
/* foo.c */
void foo(cmplx_float* array, int length) {...}
The complex float struct looks like this:
typedef struct cmplx_float {
float real;
float imag;
} cmplx_float ;
I need to call that function in python using ctypes. In Python I have an Numpy 1-D ndarray of complex64 elements.
I have also made a class derived from ctypes.Structure:
class c_float(Structure):
_fields_ = [('real', c_float),
('imag', c_float)]
I imagine that I might need another python class that implements an array of structs. Overall I'm just having problems with connecting the pieces together. What needs to be done to eventually call my function in Python basically something like this more or less:
some_ctype_array = SomeConversionCode(cmplx_numpy_array)
lib.foo(some_ctype_array, length)