ArrayRules

ArrayRules[SparseArray[]]
gives the rules {pos1val1,pos2val2,} specifying elements in a sparse array.

ArrayRules[list]
gives rules for SparseArray[list].

DetailsDetails

  • 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. »

ExamplesExamplesopen allclose all

Basic Examples  (1)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]=
Introduced in 2003
(5.0)
Translate this page: