ArrayTools - Maple Programming Help

Home : Support : Online Help : Programming : Low-level Manipulation : Matrices, Vectors, and Arrays : ArrayTools : ArrayTools/NumElems

ArrayTools

 NumElems
 return the number of elements in an Array

 Calling Sequence NumElems(M) NumElems(M, i, j, ...)

Parameters

 M - Array i, j,... - Array indices

Description

 • The NumElems(M) function returns the number of elements in the array, M, or the number of elements in the subreference M(i,j).
 • NumElems does not perform bounds checking of the subreference index to assure that the index is valid.  Therefore, NumElems(M,5,5) will still return 1, the size of a subreference of the form M[5,5], even for a 2 x 2 array, M.
 • If fewer indices are specified than dimensions, as in NumElems(M,2..), the last dimension is considered to be the size of the product of all remaining dimensions.  Therefore, NumElems(M,..) can be used to find the number of elements in the whole array, which is equivalent to NumElems(M).
 • This function is part of the ArrayTools package, so it can be used in the short form NumElems(..) only after executing the command with(ArrayTools. However, it can always be accessed through the long form of the command by using ArrayTools[NumElems](..).

Examples

 > $\mathrm{with}\left(\mathrm{ArrayTools}\right):$
 > $M≔\mathrm{Matrix}\left(2,3\right)$
 ${M}{:=}\left[\begin{array}{rrr}{0}& {0}& {0}\\ {0}& {0}& {0}\end{array}\right]$ (1)
 > $\mathrm{NumElems}\left(M\right)$
 ${6}$ (2)
 > $\mathrm{NumElems}\left(M,\left[1,2\right],2\right)$
 ${2}$ (3)
 > $\mathrm{NumElems}\left(M,1,\left(\right)..\left(\right)\right)$
 ${3}$ (4)