sparse - Maple Help

sparse

The Sparse Indexing Function

 Calling Sequence table(sparse, ...) table(sparse=XXX, ...) array(sparse, ...)

Description

 • The sparse indexing function is used to create a table or an array with a sparse representation, meaning that only nonzero elements are stored in the underlying data structure.
 • The sparse indexing function specifies that unassigned entries of a table or an array have the value 0. For example, array(sparse, 1..2, 1..2) is a zero matrix.
 • If T is a table and j is an unevaluated name, then T[j] returns unevaluated. However, if j evaluates to an integer, then T[j] returns either the value of T[j] or 0 if T[j] has no assigned value.
 • A default value other than zero can be used when constructing a sparse table.  The command, table(sparse=XXX), creates a table filled with XXXs at each entry.  This option is only available for tables.
 • Note: The command array has been superseded by Array.

Examples

 > $T≔\mathrm{table}\left(\mathrm{sparse},\left[A=a\right]\right):$
 > $T\left[A\right]$
 ${a}$ (1)
 > $T\left[B\right]$
 ${0}$ (2)
 > $a≔\mathrm{array}\left(\mathrm{sparse},1..2\right):$
 > $a\left[1\right]$
 ${0}$ (3)
 > $a\left[j\right]$
 ${{a}}_{{j}}$ (4)
 > $T≔\mathrm{table}\left(\mathrm{sparse}=\mathrm{undefined},\left\{1=1,2=2\right\}\right):$
 > $T\left[1\right]$
 ${1}$ (5)
 > $T\left[100\right]$
 ${\mathrm{undefined}}$ (6)

Compatibility

 • The sparse indexing function was updated in Maple 2019.
 • The sparse=XXX option was updated in Maple 2019.