Custom Functions > Function Definitions > MathcadArrayAllocate
MathcadArrayAllocate
This function allocates memory for a COMPLEXARRAY of cols columns and rows rows. It sets the hReal, hImag, rows and cols members of the argument array.
BOOL MathcadArrayAllocate(array, rows, cols, allocateReal,
allocateImaginary)
COMPLEXARRAY* const array;
unsigned int rows;
unsigned int cols;
BOOL allocateReal;
BOOL allocateImaginary;
Parameter
Description
array
Pointer to the COMPLEXARRAY structure that is to be filled with the information about an array.
The COMPLEXARRAY structure has the following form:
typedef struct tagCOMPLEXARRAY {
unsigned int rows;
unsigned int cols;
double **hReal;
double **hImag;

} COMPLEXARRAY;
rows
Row dimension of the array that is being allocated. After a successful allocation, the rows member of the argument array is set to the value of rows.
cols
Column dimension of the array that is being allocated. After a successful allocation, the cols member of the argument array is set to the value of cols.
allocateReal
Boolean flag indicating whether a memory block should be allocated to store the real part of the array. If allocateReal is FALSE, the function does not allocate storage for the real part of the array and sets the hReal member to NULL.
allocateImag
Boolean flag indicating whether a memory block should be allocated to store the imaginary part of the array. If allocateImag is FALSE, the function does not allocate storage for the imaginary part of the array and sets the hImag member to NULL.
Return Value
Returns TRUE if the allocation is successful, FALSE otherwise.
Additional Information
hReal and hImag members of the argument array are allocated as a 2-dimensional array of the range [0 .. cols – 1][0 .. rows – 1].
To allocate memory for scalars, use MathcadAllocate.
To free memory, use MathcadArrayFree.
Was this helpful?