Wolfram ResearchPRODUCTSPURCHASEFOR USERSCOMPANYOUR SITES
THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.

ArrayRules

SparseArray can accept a list of rules to form a sparse array. These rules hold the indices and values of nonzero elements. In the following example, the element at position {2,1} has the value 5. ArrayRules generates the rules for a sparse array.

In[1]:= 

Out[1]=

ArrayRules returns the rules that represent the sparse array. It returns a rule of blank patterns {_,_} to show the default value.

In[2]:= 

Out[2]=

When a scalar is added to the sparse array, the default value is changed. For example, here the default value is 5.

In[3]:= 

Out[3]=

ArrayRules can take a second argument, which is the default value shown on output. Here, a default rule with value 5 is used. Because there is only one element with this value, the list of rules is much longer.

In[4]:= 

Out[4]=

ArrayRules is a useful way to get information about a sparse array such as the non-default elements or the default value. This example shows how to get the indices of the non-default elements.

In[5]:= 

Out[5]=


Any questions about topics on this page? Click here to get an individual response.Buy NowFree TrialMore Information



 © 2009 Wolfram Research, Inc.  Terms of Use  Privacy Policy |
Sign up for our newsletter: