Returning complex data from C code
Mike Page
Mike at Page-One.Waitrose.com
Mon Mar 1 14:52:34 CET 2010
Hello,
I have written an external DLL in C code that works fine for real data. I
want to extend it for complex data, but the data types specified in the call
function seem to be limited to 'i', 'r', 'd' and 'c' - no complex type.
I can get the complex input data in the C code, by just extending the array
indexing. The imaginary data is stored in a block the same size as the real
and immediately after it. But I can't return a complex array result. Even
if I set the array to a correctly sized complex array before calling my
function (so I have enough space allocated for a complex result), the
returned value is real, even though I have written data to its imaginary
part.
I guess the call function sets the data type flag to real before returning
the array. Is there any way around this? I could return the real and
imaginary separately and then combine them in Scilab, but I am using the C
code because I want it to be efficient.
I can publish the code here if it helps.
Thanks for any advice.
Mike.
More information about the users
mailing list