MapInstead of using listability you can use Map to apply a function to every element in a matrix. In[1]:=  |
Map will apply the function fun to every element in the matrix. In[2]:=  |
Out[2]=
|
You can see the matrix that the sparse array represents. Note that because the function f did not have any definition, it is just kept wrapped around every element. In[3]:=  |
Out[3]//MatrixForm=
|
Here, a function that squares its argument and divides the result by 5 is applied to every element in the matrix. In[4]:=  |
Out[4]=
|
In[5]:=  |
Out[5]//MatrixForm=
|
When Map applies a function to a sparse array, it only operates on the elements that are actually stored (including the default element). More information on Mathematica programming can be found in The Mathematica Book.
|