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

Map

Instead 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.


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: