How to define a pointer to an array of complex numbers ?
이전 댓글 표시
I have created an array of 10 complex numbers and initialized all elements to (1.0 +1.0i). I would like to define a pointer to the array "complex_array" inorder to pass that as an input argument to a c function. The function in the shared library has "_Complex float * v" as the argument type, which has been converted to "s_C_float_complexPtr" by the matlab loadlibrary(). Can this be achieved using libpointer() ? If yes, what is the type of the pointer ? Or is there any other way ?
array = zeros(1, 10, 'single');
complex_array = complex(complex(array, single(1.0)) + single(1.0));
dataptr = libpointer('s_C_float_complexPtr', complex_array);
calllib('lib','cmplx_mean_removal', dataptr, 10);
The above code throws the following error,
A structure is required.
Error in libpointer (line 21)
ptr=lib.pointer(varargin{:});
Note:
- Here is the content of ‘complex_array’ when I print it,
complex_array =
1×10 single row vector
Columns 1 through 8
1.0000 + 1.0000i 1.0000 + 1.0000i 1.0000 + 1.0000i 1.0000 + 1.0000i 1.0000 + 1.0000i 1.0000 + 1.0000i 1.0000 + 1.0000i 1.0000 + 1.0000i
Columns 9 through 10
1.0000 + 1.0000i 1.0000 + 1.0000i
2. Here is the signature of the c function, (uses standard complex notation from “complex.h”)
void cmplx_mean_removal( _Complex float * v, uint32_t len);
Would appreciate any inputs. Thank you.
댓글 수: 1
Jerome Almon
2023년 12월 4일
편집: Jerome Almon
2023년 12월 4일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Dates and Time에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!