construct an Array - Maple Help

Array - construct an Array

 Calling Sequence Array(indfncs, dims, init, opts)

Parameters

 indfncs - (optional) procedure(s); indexing function(s) dims - (optional) range(s) of integers; dimension(s) init - (optional) Maple procedure, function, table, array, list, Array, set of equations, expression of type algebraic; initial values for the Array opts - (optional) equations of the form keyword = value; specifies additional properties of the Array

Description

 • 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.
 Dimension(s)
 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.
 Initializer
 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
 – table
 – 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).

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

Examples

 > $A:=\mathrm{Array}\left(\left[1,2,3\right]\right)$
 ${A}{:=}\left[\begin{array}{ccc}{1}& {2}& {3}\end{array}\right]$ (1)
 > $\mathrm{ArrayDims}\left(A\right)$
 ${1}{..}{3}$ (2)
 > $\mathrm{upperbound}\left(A\right)$
 ${3}$ (3)
 > $B:=\mathrm{Array}\left(2..3,-1..1,\left[\left[1,2,3\right],\left[4,5,6\right]\right]\right)$
 ${B}{:=}{\mathrm{Array}}{}\left({2}{..}{3}{,}{-}{1}{..}{1}{,}\left\{\left({2}{,}{-}{1}\right){=}{1}{,}\left({2}{,}{0}\right){=}{2}{,}\left({2}{,}{1}\right){=}{3}{,}\left({3}{,}{-}{1}\right){=}{4}{,}\left({3}{,}{0}\right){=}{5}{,}\left({3}{,}{1}\right){=}{6}\right\}\right)$ (4)
 > $\mathrm{ArrayNumDims}\left(B\right)$
 ${2}$ (5)
 > $\mathrm{ArrayNumElems}\left(B\right)$
 ${6}$ (6)
 > $C:=\mathrm{Array}\left({\mathrm{triangular}}_{\mathrm{upper}},1..3,1..4,\mathrm{fill}=1\right)$
 ${C}{:=}\left[\begin{array}{rrrr}{1}& {1}& {1}& {1}\\ {0}& {1}& {1}& {1}\\ {0}& {0}& {1}& {1}\end{array}\right]$ (7)
 > $F:=\mathrm{Array}\left(\mathrm{symmetric},1..3,1..3\right)$
 ${F}{:=}\left[\begin{array}{rrr}{0}& {0}& {0}\\ {0}& {0}& {0}\\ {0}& {0}& {0}\end{array}\right]$ (8)
 > ${F}_{1,1}:=1:$
 > ${F}_{1,2}:=2:$
 > ${F}_{1,3}:=3:$
 > $F$
 $\left[\begin{array}{rrr}{1}& {2}& {3}\\ {2}& {0}& {0}\\ {3}& {0}& {0}\end{array}\right]$ (9)
 > $G:=\mathrm{Array}\left(\left[1.2,1,4.78\right],\mathrm{datatype}={\mathrm{float}}_{8}\right)$
 ${G}{:=}\left[\begin{array}{ccc}{1.20000000000000}& {1.}& {4.78000000000000}\end{array}\right]$ (10)