array - Maple Help

array

create an array

 Calling Sequence array( indexfcn, bounds, list) array( a)

Parameters

 indexfcn - (optional) indexing function bounds - (optional) sequence of ranges list - (optional) list of initial values a - (optional) array

Description

 • Important: The array command has been deprecated. Use the superseding command Array instead.
 • An array is a specialization of a table, with zero or more specified dimensions, where each dimension is an integer range. The result of executing the array function is to create an array. For example, V := array(1..10)  creates a one dimensional array of length 10 but with no explicit entries. The command A := array(1..m, 1..n) (where m and n evaluate to positive integers) creates a two dimensional array with m rows and n columns.
 • All parameters to the array function are optional and may appear in any order, but at least one bound and list must appear. The bounds parameter is a sequence of integer ranges which must appear consecutively.  If the bounds are not specified then they are deduced from the list of initial values.
 • The indexfcn can be a procedure or a name specifying how indexing is to be performed - see indexfcn for more information. The built-in indexing functions are symmetric, antisymmetric, sparse, diagonal, and identity. If indexfcn is not specified, then ordinary'' indexing is used.
 • The list of initial values may be a list of equations (cf. tables), or a list of values (one-dimensional), or a nested list of lists (row-by-row).
 • The map function can be used to apply a function to each entry of an array. For example, map (simplify, A) simplifies each entry of the array A.
 • Arrays have special evaluation rules (like procedures) so that if the name A has been assigned an array then A evaluates to the name A and eval(A) yields the actual array structure.
 • The op function extracts the operands of an array structure. op(1, eval(A)) yields indexfcn, if one is specified.  If no indexfcn has been specified,  it returns nothing. op(2, eval(A)) yields bounds; and op(3, eval(A)) yields entries, where entries is a list of equations corresponding to the explicit entries in the array (cf. entries).
 • When the array constructor is called with a single argument, a, whose value is an existing array, a copy of a is returned. Since arrays are mutable objects, and assignment in Maple is by-reference, making a copy of an array to work with is useful when you do not want to modify the original array.

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

Examples

Important: The array command has been deprecated. Use the superseding command Array instead.

 > $v≔\mathrm{array}\left(1..4\right):$
 > $\mathbf{for}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}i\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{to}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}3\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{do}\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{2.0em}{0.0ex}}v\left[i\right]≔{i}^{2}\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\mathbf{end}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{do}:$$\mathrm{print}\left(v\right)$
 $\left[\begin{array}{cccc}{1}& {4}& {9}& {{\mathrm{?}}}_{{4}}\end{array}\right]$ (1)
 > $v\left[2\right]$
 ${4}$ (2)

Trying to refer to something out of bounds returns an error:

 > $v\left[0\right]$
 > $A≔\mathrm{array}\left(1..2,1..2\right):$
 > $A\left[1,2\right]≔x:$
 > $A\left[1,1\right]$
 ${{A}}_{{1}{,}{1}}$ (3)
 > $A\left[1,2\right]$
 ${x}$ (4)
 > $\mathrm{print}\left(A\right)$
 $\left[\begin{array}{cc}{{\mathrm{?}}}_{{1}{,}{1}}& {x}\\ {{\mathrm{?}}}_{{2}{,}{1}}& {{\mathrm{?}}}_{{2}{,}{2}}\end{array}\right]$ (5)
 > $A≔\mathrm{array}\left(\mathrm{symmetric},1..2,1..2,\left[\left[1,x\right],\left[x,{x}^{2}\right]\right]\right):$
 > $\mathrm{op}\left(1,\mathrm{eval}\left(A\right)\right)$
 ${\mathrm{symmetric}}$ (6)
 > $\mathrm{op}\left(2,\mathrm{eval}\left(A\right)\right)$
 ${1}{..}{2}{,}{1}{..}{2}$ (7)
 > $\mathrm{op}\left(3,\mathrm{eval}\left(A\right)\right)$
 $\left[\left({1}{,}{2}\right){=}{x}{,}\left({1}{,}{1}\right){=}{1}{,}\left({2}{,}{2}\right){=}{{x}}^{{2}}\right]$ (8)
 > $\mathrm{map}\left(\mathrm{diff},A,x\right)$
 $\left[\begin{array}{cc}{0}& {1}\\ {1}& {2}{}{x}\end{array}\right]$ (9)