MATLAB Application Program Interface Reference | Help Desk |
mxIsComplex
Inquire if anmxArray
is complex
integer*4 function mxIsComplex(pm) integer*4 pmpm 1 if complex, 0 otherwise. Use
mxIsComplex
to determine whether or not an imaginary part is allocated for an mxArray
. The imaginary pointer pi
is 0 if an mxArray
is purely real and does not have any imaginary data. If an mxArray
is complex, pi
points to an array of numbers.
When a MEX-file is called, MATLAB automatically examines all the input (right-hand side) arrays. If any input array is complex, then MATLAB automatically allocates memory to hold imaginary data for all other input arrays. For example, suppose a user passes three input variables (apricot
, banana
, and carambola
) to a MEX-file named Jest
:
>> apricot = 7; >> banana = sqrt(-5:5); >> carambola = magic(2); >> Jest(apricot, banana, carambola);
banana
is complex. Therefore, even though array apricot
is purely real, MATLAB automatically allocates space (one element) to hold an imaginary value of apricot
. MATLAB also automatically allocates space (four elements) to hold the nonexistent imaginary values of carambola
.
In other words, MATLAB forces every input array to be real or every input array to be complex.
mxIsNumeric