MAKE_ARRAY Function
Returns an array of specified type, dimensions, and initialization. It provides the ability to create an array dynamically whose characteristics are not known until run time.
enabled.
Usage
result = MAKE_ARRAY([dim1,... , dimn])
Input Parameters
dimi—(optional) The dimensions of the result. This may be any scalar expression with up to eight dimensions specified.
Returned Value
result—An array of specified type, dimensions, and initialization.
Keywords
Byte—If nonzero, sets the type of the result to BYTE.
Complex—If nonzero, sets the type of the result to COMPLEX.
Dcomplex—If nonzero, sets the type of the result to DCOMPLEX.
Dimension—A vector of 1 to 8 elements specifying the dimensions of the result.
Double—If nonzero, sets the type of the result to DOUBLE.
Float—If nonzero, sets the type of the result to FLOAT.
Index—The resulting array is initialized with each element set to the value of its one-dimensional index.
Int—If nonzero, sets the type of the result to INT.
I32—If nonzero, sets the type of the result to INT32.
Long—If nonzero, sets the type of the result to LONG.
Nozero—If nonzero, the resulting array is not initialized.
Size—A longword vector specifying the type and dimensions of the result. It consists of the following elements:
The first element is equal to the number of dimensions of
Value.
The next elements contain the size of each dimension.
The last two elements contain the type code and the number of elements in
Value, respectively. Valid type code values are listed below for the
Type keyword.
String—If nonzero, sets the type of the result to STRING.
Type—Sets the type of the result to be the type code entered:
1—BYTE
2—INT
3—LONG
4—FLOAT
5—DOUBLE
6—COMPLEX
7—STRING
12—DCOMPLEX
13—INT32
Value—Initializes each element of the resulting array with the given value. Can be of any scalar type, including structure types.
Discussion
The result type is taken from the Value keyword unless one of the other keywords that specify a type is also used. In that case, Value is coerced to be the type specified by this other keyword prior to initializing the resulting array.
note | The resulting type cannot be specified if Value is a structure. |
If Value is specified, all elements in the resulting array are set to Value. If Value is not specified, all elements are set to zero. If Index is specified, each element is set to its index. If Nozero is specified, the resulting array is not initialized.
Example
In this example, three different methods are used to create and initialize a 4-by-3 LONG array.
; The type of a is determined by the Size keyword.
a = MAKE_ARRAY(Size=[2, 4, 3, 3, 12], Value=5)
INFO, a
; PV-WAVE prints:
; A LONG = Array(4, 3)
PRINT, a
; PV-WAVE prints the following:
; 5 5 5 5
; 5 5 5 5
; 5 5 5 5
; The type of b is determined by the Type keyword.
b = MAKE_ARRAY(4, 3, Type=13, Value=5)
INFO, b
; PV-WAVE prints:
; B INT32 = Array(4, 3)
PRINT, b
; PV-WAVE prints the following:
; 5 5 5 5
; 5 5 5 5
; 5 5 5 5
; The type of c is determined by the Value keyword.
c = MAKE_ARRAY(4, 3, Value=5B)
INFO, c
; PV-WAVE prints:
; C BYTE = Array(4, 3)
PRINT, c
; PV-WAVE prints the following:
; 5 5 5 5
; 5 5 5 5
; 5 5 5 5
See Also
BINDGEN,
BYTARR,
CINDGEN,
COMPLEXARR,
DBLARR,
DCOMPLEXARR,
DCINDGEN,
DINDGEN,
FINDGEN,
FLTARR,
I32ARR,
I32INDGEN,
INDGEN,
INTARR,
LINDGEN,
LINSPACE,
LONARR,
SINDGEN,
SIZE,
STRARR