sparse - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Data Types : Tables, lists, and sets : indexing functions : indexfcn/sparse

sparse

The Sparse Indexing Function

 

Calling Sequence

Description

Examples

Compatibility

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 := table(sparse,[A=a]):

T[A];

a

(1)

T[B];

0

(2)

a := array(sparse,1..2):

a[1];

0

(3)

a[j];

aj

(4)

T := table(sparse=undefined,{1=1,2=2}):

T[1];

1

(5)

T[100];

undefined

(6)

Compatibility

• 

The sparse indexing function was updated in Maple 2019.

• 

The sparse=XXX option was updated in Maple 2019.

See Also

indexfcn

sparse