1

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, ...)

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.