IDL

MAKE_ARRAY

MAKE_ARRAY

The MAKE_ARRAY function enables you to dynamically create an array whose characteristics are not known until run time.

Examples


To create a 3-element by 4-element integer array with each element set to the value 5, enter:

M = MAKE_ARRAY(3, 4, /INTEGER, VALUE = 5)

Syntax


Result = MAKE_ARRAY ( [D1[, ..., D8]], DIMENSION=vector, INCREMENT=value, /INDEX, /NOZERO, SIZE=vector, START=value, TYPE=type_code, VALUE=value, /BOOLEAN, /BYTE, /COMPLEX, /DCOMPLEX, /DOUBLE, /FLOAT, /INTEGER, /L64, /LONG, /OBJ, /PTR, /STRING, /UINT, /UL64, /ULONG )

Return Value


Returns an array of the specified type, dimensions, and initialization.

Arguments


Di

Either an array or a series of scalar expressions specifying the dimensions of the result. If a single argument is specified, it can be either a scalar expression or an array of up to eight elements. If multiple arguments are specified, they must all be scalar expressions. Up to eight dimensions can be specified. If the dimension arguments are not integer values, IDL will convert them to integer values before creating the new array.

The Di arguments are optional if the dimensions of the result are specified using the DIMENSION keyword. Note that you should supply either the Di arguments or a value for the DIMENSION keyword, but not both.

Keywords


BOOLEAN

Set this keyword to create a boolean array.

BYTE

Set this keyword to create a byte array.

COMPLEX

Set this keyword to create a complex, single-precision, floating-point array.

DCOMPLEX

Set this keyword to create a complex, double-precision, floating-point array.

DIMENSION

An array of up to eight scalar elements, specifying the dimensions of the result. Note that you should supply either the Di arguments or a value for the DIMENSION keyword, but not both.

DOUBLE

Set this keyword to create a double-precision, floating-point array.

FLOAT

Set this keyword to create a single-precision, floating-point array.

INCREMENT

Set this keyword to a double-precision number giving the spacing between values in the array. The default is 1. Setting this keyword is equivalent to multiplying each array element by this value and then converting to the result type. This keyword is only applied if INDEX is set. This keyword is ignored for arrays of boolean, objects, or pointers.

INDEX

Set this keyword to initialize the array with each element set to the value of its one-dimensional subscript. This keyword cannot be used with arrays of boolean, objects, or pointers.

INTEGER

Set this keyword to create an integer array.

L64

Set this keyword to create a 64-bit integer array.

LONG

Set this keyword to create a longword integer array.

NOZERO

Set this keyword to prevent the initialization of the array. Normally, each element of the resulting array is set to zero.

Note: This keyword is ignored for arrays of boolean, strings, objects, or pointers. Arrays of these types will always be initialized to zero.

OBJ

Set this keyword to create an object reference array.

PTR

Set this keyword to create a pointer array.

SIZE

A size vector specifying the type and dimensions of the result. The format of a size vector is given in the description of the SIZE function.

START

Set this keyword to a double-precision number giving the value of the first element in the array when the array is initialized by index. The default is 0. Setting this keyword is equivalent to adding a constant offset to each element (after first multiplying by INCREMENT if necessary) and then converting to the result type. This keyword is only applied if INDEX is set. This keyword is ignored for arrays of boolean, objects, or pointers.

STRING

Set this keyword to create a string array.

TYPE

The type code to set the type of the result.

Type Code

Type Name

Data Type

0

UNDEFINED

Undefined

1

BYTE

Byte

2

INT

Integer

3

LONG

Longword integer

4

FLOAT

Floating point

5

DOUBLE

Double-precision floating

6

COMPLEX

Complex floating

7

STRING

String

8

STRUCT

Structure

9

DCOMPLEX

Double-precision complex

10

POINTER

Pointer

11

OBJREF

Object reference

12

UINT

Unsigned Integer

13

ULONG

Unsigned Longword Integer

14

LONG64

64-bit Integer

15

ULONG64

Unsigned 64-bit Integer

Note: All type code values except for TYPE=8 (structures) are valid. To create an array of structures, use the REPLICATE function.

UINT

Set this keyword to create an unsigned integer array.

UL64

Set this keyword to create an unsigned 64-bit integer array.

ULONG

Set this keyword to create an unsigned longword integer array.

VALUE

The value to initialize each element of the resulting array. VALUE can be a scalar of any type including structure types. The result type is taken from VALUE unless one of the other keywords that specify a type is also set. In that case, VALUE is converted to the type specified by the other keyword prior to initializing the resulting array.

Thread Pool Keywords

This routine is written to make use of IDL’s thread pool, which can increase execution speed on systems with multiple CPUs. The values stored in the !CPU system variable control whether IDL uses the thread pool for a given computation. In addition, you can use the thread pool keywords TPOOL_MAX_ELTS, TPOOL_MIN_ELTS, and TPOOL_NOTHREAD to override the defaults established by !CPU for a single invocation of this routine. See Thread Pool Keywords for details.

Version History


4.0

Introduced

8.2.1 Added START keyword
8.3 Added INCREMENT keyword
8.4 Added BOOLEAN keyword

See Also


BOOLARR, BYTARR, COMPLEXARR, DBLARR, DCOMPLEXARR, FLTARR, INTARR, LON64ARR, LONARR, REPLICATE, STRARR, UINTARR, ULON64ARR, ULONARR

Notes


This page has no user notes yet. Be the first one!


This information is not subject to the controls of the International Traffic in Arms Regulations (ITAR) or the Export Administration Regulations (EAR). However, it may be restricted from transfer to various embargoed countries under U.S. laws and regulations.
© 2014 Exelis Visual Information Solutions