I am writing a test program to evaluate a function written in MATLAB and converted to C code by the MATLAB Coder. This function takes complex inputs, and I'd like to use CFFI to cast this data from a python array, and then call the function.
The function works fine if I change the generated code to accept an array of real values and an array of imaginary values, and then combine them, but I'd like to pass the input data as one parameter.
lib = 'path/to/somedll.dll'
C = ffi.dlopen(lib)
some_function = C.some_function
ffi=cffi.FFI()
ffi.cdef("typedef float real32_T;")
ffi.cdef("""typedef struct {
real32_T re, im;
} creal32_T;""")
ffi.cdef("some_function(const creal32_T inputdata[10], ...);")
inputdata = ffi.new("const creal32_T [10]")
# What I would like to do:
for i in range(0, 10):
inputdata[i] = ffi.cast("creal_32T", data_in[i])
some_function(inputdata, ...)