ArrayRules

ArrayRules[SparseArray[]]

gives the rules {pos1val1,pos2val2,} specifying elements in a sparse array.

ArrayRules[list]

gives rules for SparseArray[list].

Details

  • The last element of ArrayRules[s] is always {_,_,}->def, where def is the default value for unspecified elements in the sparse array. »
  • ArrayRules[list,val] takes the default value to be val. »
  • ArrayRules[list] assumes a default value of 0. »

Examples

open allclose all

Basic Examples  (1)

Get the explicit elements in a SparseArray:

In[1]:=
Click for copyable input
Out[1]=
In[2]:=
Click for copyable input
Out[2]=

These rules are sufficient to efficiently construct an identical SparseArray:

In[3]:=
Click for copyable input
Out[3]=
In[4]:=
Click for copyable input
Out[4]=

Scope  (2)

Applications  (4)

Properties & Relations  (2)

See Also

SparseArray  Position  Normal  Keys  Values

Tutorials

Introduced in 2003
(5.0)