The SIZE function returns size and type information for its argument if no keywords are set. If a keyword is set, SIZE returns the specified quantity.
Result = SIZE( Expression [, /L64] [, /DIMENSIONS | , /FILE_LUN | , /N_DIMENSIONS | , /N_ELEMENTS | , /STRUCTURE | , /TNAME | , /TYPE] )
The returned vector is always of integer type. The first element is equal to the number of dimensions of Expression. This value is zero if Expression is scalar or undefined. The next elements contain the size of each dimension, one element per dimension (none if Expression is scalar or undefined). After the dimension sizes, the last two elements contain the type code (zero if undefined) and the number of elements in Expression, respectively. The type codes are listed below.
The following table lists the IDL type codes and type names returned by the SIZE function:
The expression for which size information is requested.
With the exception of L64, the following keywords determine the return value of the SIZE function and are mutually exclusive - specify at most one of the following.
Set this keyword to return the dimensions of Expression. If Expression is scalar, the result is a scalar containing a 0. For arrays, the result is an array containing the array dimensions. The result is a 32-bit integer when possible, and 64-bit integer if the number of elements in Expression requires it. Set L64 to force 64-bit integers to be returned in all cases.If Expression is undefined, IDL reports eight dimensions.
Set this keyword to return the file unit to which Expression is associated, if it is an IDL file variable, as created with the ASSOC function. If Expression is not a file variable, 0 is returned (0 is not a valid file unit for ASSOC).
By default, the result of SIZE is 32-bit integer when possible, and 64-bit integer if the number of elements in Expression requires it. Set L64 to force 64-bit integers to be returned in all cases. In addition to affecting the default result, L64 also affects the output from the DIMENSIONS, N_ELEMENTS, and STRUCTURE keywords.
| Note |
Set this keyword to return the number of dimension in Expression, if it is an array. If Expression is scalar or undefined, 0 is returned.
Set this keyword to return the number of data elements in Expression. Setting this keyword is equivalent to using the N_ELEMENTS function. The result will be 32-bit integer when possible, and 64-bit integer if the number of elements in Expression requires it. Set L64 to force 64-bit integers to be returned in all cases. If Expression is undefined, 0 is returned.
Set this keyword to return all available information about Expression in a structure.
| Note |
The following are descriptions of the fields in the returned structure:
Set this keyword to return the IDL type of Expression as a string. See IDL Type Codes and Names for details.
Set this keyword to return the IDL type code for Expression. See IDL Type Codes and Names for details. For an example illustrating how to determine the type code of an expression, see Determining the Size/Type of an Array.
Print the size information for a 10 by 20 floating-point array by entering:
PRINT, SIZE(FINDGEN(10, 20))
IDL prints:
2 10 20 4 200
This IDL output indicates the array has 2 dimensions, equal to 10 and 20, a type code of 4, and 200 elements total.
Similarly, to print only the number of dimensions of the same array:
PRINT, SIZE(FINDGEN(10, 20), /N_DIMENSIONS)
IDL prints:
2
Introduced: Original