construct an Array - Maple Help

Online Help

All Products    Maple    MapleSim

Home : Support : Online Help : Programming : Data Types : Rtables, Arrays, Matrices, and Vectors : Data Types : Array

Array - construct an Array

Calling Sequence

Array(indfncs, dims, init, opts)




(optional) procedure(s); indexing function(s)



(optional) range(s) of integers; dimension(s)



(optional) Maple procedure, function, table, array, list, Array, set of equations, expression of type algebraic; initial values for the Array



(optional) equations of the form keyword = value; specifies additional properties of the Array



The Array(..) function is the constructor for the Array data structure. Arrays  are implemented as rtables and are distinct from other Maple objects such as arrays, tables, Matrices, and Vectors.  Note that Array supersedes the deprecated array.


Each of the parameters in the calling sequence is optional. If no parameters are provided, an empty 0-dimensional Array is returned.


If dims and init are not specified, or if only a scalar value is specified for init, a 0-dimensional Array containing a single element is constructed.


The following sections describe permissible values for each parameter if it is included in the calling sequence.


Indexing Function(s)


Indexing functions are used to index into an Array to retrieve or store a value. An Array has zero or more indexing functions, which are specified by name when the Array is constructed. The name of an indexing functions is always of the form "index/indfnc". When specifying an indexing function indfnc in the calling sequence, only the indfnc part of the name is specified.


Note:  If the initializer (see below) is an existing Array, the indexing functions are not inherited.


The indexing function can be built-in or user-defined. For more information regarding indexing functions, see ArrayIndFns.




The number of dimensions of an Array can range from 0 to 63. Each of the dimensions dims in the calling sequence must be specified as a range of integers.




The init parameter specifies the initial values of the Array in one of the following formats.


list of values (in the case of a multi-dimensional Array, nested lists are used)


existing Array, Matrix, or Vector




set of equations of the form (indices) = value


initializer function (procedure)


scalar value


If the initial values are specified as a list of values or an existing Array, Matrix or Vector, the number of dimensions of the initial values must match the bounds (if they were specified).


If the initial values are specified as a procedure, table, or set of equations, the dimensions must be specified, and the indices of the initializers must fit within those dimensions.


If a procedure is specified, that function is called for each member of a set of indices, determined by the indexing function. The function must return a value for the specified element of the Array.


Each initial value can be any Maple expression, but this expression must be able to be evaluated to a value of the datatype of the Array (see Options below). For hardware floating-point Arrays, this must be a hardware floating-point number, or one of the special expressions representing undefined or +-infinity. For hardware integer Arrays, the expressions must be able to be evaluated to a machine integer. Failure to evaluate to the datatype will generate an error.


The list form of initializer for a two or more dimensional Array is specified in row-major order unless the transpose option (see below) is specified.


If the bounds are determined from the list form of the initializer, then the bounds of each dimension are determined from the first object in that dimension. For example, for a 2-dimensional Array, the number of rows is determined by the number of sub-lists in the main list. The number of columns is determined by the number of elements in the first sub-list, and so on for higher dimensioned Arrays. If transpose is specified, then dimension determination starts with the last dimension (i.e. the number of columns is determined by the number of sub-lists in the main list, and so on).


If there are too few initializer values for a dimension, the remainder of that dimension is filled with an appropriate default for the type of Array (either an appropriate zero, the value specified by the fill option (see below), or a value determined by the indexing functions). If there are too many initializer values, an exception is raised.


A 0-dimensional Array can be initialized by specifying a literal value (i.e. a 0-level nesting of lists). For example, Array(2) creates a 0-dimensional Array containing the single element, 2. This form can only be used if the value is of a type that cannot be confused with one of the other forms of initializer. If it is desired to initialize a 0-dimensional Array with a more complex type, the fill option should be used (e.g. Array(fill=[2, 3]) would create a 0-dimensional Array containing the single value [2, 3]).


An Array with scalar storage (see Options below) is initialized in the usual way. Any form of initializer works, although the most efficient method would be a set which contains one equation, or by using the fill parameter.


After creation, it is possible to change the entries and some of the properties of the Array.  See Array assignment and Array options for more information.


For additional information on accessing elements or groups of elements of a Array, see Array indexing.


Only small Arrays are displayed inline in Maple. A small Array is defined as a 1- or 2-dimensional object whose dimension(s) are in the range 1..25 (TTY version of Maple) or the range 1..10 (GUI version of Maple). Any Array whose dimension(s) are larger than this size is displayed by using a placeholder. For information on how to view the contents of a placeholder, see structuredview.


You can display larger Arrays inline by using the interface(rtablesize=value) command, where value is an integer that represents the upper bound of the dimension range.


To change the environment so that Maple always displays rtables inline, include the interface(rtablesize=infinity) command in a Maple initialization file (see maple).


For more information, see interface.

Thread Safety


The Array command is thread-safe as of Maple 15.


For more information on thread safety, see index/threadsafe.



































See Also

Array assignment, Array dimensions, Array elements, Array indexing, Array indexing functions, Array number of dimensions, Array number of elements, Array options, error, interface, list, maple, Matrix, procedure, rtable, set, setattribute, structuredview, table, type/algebraic, upperbound, Vector, verify/Array

Download Help Document

Was this information helpful?

Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam