Import and Export of Sparse MatricesMathematica provides a number of different tools for I/O. You can save your data in a file so that you or a colleague can continue to work with it in Mathematica later. For this you might want to use some of the expression I/O functions; these are discussed in the section Expression Input and Output. If you want to work with matrices from a source external to Mathematica using specific data formats, the functions Import and Export are useful. The Import function supports a variety of different formats, some of which are relevant to sparse matrices. There are two formats that are specific to sparse matrices and are supported in Mathematica: Harwell-Boeing and Matrix Market. This example imports the matrix in the file dwg961b.cua using the Harwell-Boeing format. In[1]:=  |
Out[1]=
|
The result is a 961 961 matrix of numbers with 10591 nonzero elements. In[2]:=  |
Out[2]=
|
You can confirm the dimensions of the matrix. In[3]:=  |
Out[3]=
|
If the matrix is multiplied with itself, the result may not be as sparse as before. In[4]:=  |
Out[4]=
|
Many examples of matrices in Harwell-Boeing and Matrix Market formats can be found at http://math.nist.gov/MatrixMarket/index.html.
|