COMPLEXARRAY Structure

Array and vector values in custom Mathcad functions are passed as COMPLEXARRAY structures, as defined in mcadincl.h. The COMPLEXARRAY structure has four members:

When Mathcad sends an array to a UserEFI using the COMPLEXARRAY structure, it actually passes two arrays: one for the real part and one for the complex part. If no element of an array has an imaginary part, Array->hImag is equal to NULL. If all elements are purely imaginary, Array->hReal is equal to NULL.

There are provisions made for matrices that contain non-numeric values, such as Mathcad string variables. Every entry in these arrays contains either a valid scalar number or a NaN. Mathcad marks non-scalar entries using two distinct NaNs. One NaN is just a bit sequence indicating an unusable numeric value. The other NaN indicates that the value stored in that location is not a number, but is a string or a function.

Mathcad stores the values of any non-numeric matrix entries in a separate data structure that is not available to the UserEFI, so it is not possible for the UserEFI to determine the actual value of the string or function stored. Mathcad versions 11 and earlier stored an address for the contents of non-numeric entries in the array passed to the UserEFI. In Mathcad 12 and higher, however, only the NaN marker that the element is not numeric is available, so it is not possible to recover the contents of a string or function entry in an array through the UserEFI interface. Strings may be passed individually using the MCSTRING type.

If the result of your function is a COMPLEXARRAY structure, allocate memory for the complex array using the MathcadArrayAllocate function.