Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Import a sparse matrix from the SuiteSparse matrix collection
| ResourceFunction["SuiteSparseMatrix"][spec] imports the specified sparse matrix from the SuiteSparse matrix collection. | |
| ResourceFunction["SuiteSparseMatrix"][spec,prop] retrieves the meta information property prop of the specified matrix. | |
| ResourceFunction["SuiteSparseMatrix"][cprop] gives the meta information property cprop of the collection. | |
| ResourceFunction["SuiteSparseMatrix"][] gives a list {{"name1","group1"},…} for all matrices in the collection. | |
| ResourceFunction["SuiteSparseMatrix"][session,…] uses the specified running ExternalSessionObject. | 
| "name" | matrix name | 
| {"name","group"} | name and group | 
| id | integer ID | 
| "ID" | matrix ID | 
| "Name" | name | 
| "Group" | group | 
| "Kind" | short desription | 
| {"prop1",…} | list of properties | 
| "MetaInformation" | available meta information | 
| All | meta information and the SparseArray value | 
| All | a catalog of available matrices | 
| "ContentDate" | release date of the collection | 
| "ContentLength" | the number of matrices | 
| "StatisticsURL" | the default URL of the statistics file | 
Get a SuiteSparse matrix by name:
| In[1]:= | ![ssm = ResourceFunction["SuiteSparseMatrix"]["ash85"]](https://www.wolframcloud.com/obj/resourcesystem/images/dcf/dcfba042-d58c-4762-ba6a-2c298953dfab/1d5e29f06b5c3eac.png) | 
| Out[1]= |  | 
| In[2]:= | ![MatrixPlot[ssm]](https://www.wolframcloud.com/obj/resourcesystem/images/dcf/dcfba042-d58c-4762-ba6a-2c298953dfab/604227068559b669.png) | 
| Out[2]= |  | 
Compute the matrix trace:
| In[3]:= | ![Tr[ssm]](https://www.wolframcloud.com/obj/resourcesystem/images/dcf/dcfba042-d58c-4762-ba6a-2c298953dfab/784a891ab43bd178.png) | 
| Out[3]= |  | 
Import a matrix by its name:
| In[4]:= | ![ResourceFunction["SuiteSparseMatrix"]["ash85"]](https://www.wolframcloud.com/obj/resourcesystem/images/dcf/dcfba042-d58c-4762-ba6a-2c298953dfab/27aa7be55a77ec0b.png) | 
| Out[4]= |  | 
By the name and group:
| In[5]:= | ![ResourceFunction["SuiteSparseMatrix"][{"ash85", "HB"}]](https://www.wolframcloud.com/obj/resourcesystem/images/dcf/dcfba042-d58c-4762-ba6a-2c298953dfab/3be105ca0acf5bdd.png) | 
| Out[5]= |  | 
By ID:
| In[6]:= | ![ResourceFunction["SuiteSparseMatrix"][11]](https://www.wolframcloud.com/obj/resourcesystem/images/dcf/dcfba042-d58c-4762-ba6a-2c298953dfab/081ad3591f9c1f10.png) | 
| Out[6]= |  | 
A list of available {"name","group"} pairs:
| In[7]:= | ![ResourceFunction["SuiteSparseMatrix"][]](https://www.wolframcloud.com/obj/resourcesystem/images/dcf/dcfba042-d58c-4762-ba6a-2c298953dfab/5b57071dc8d8105d.png) | 
| Out[7]= |  | 
Meta information:
| In[8]:= | ![ResourceFunction["SuiteSparseMatrix"]["ash85", "MetaInformation"]](https://www.wolframcloud.com/obj/resourcesystem/images/dcf/dcfba042-d58c-4762-ba6a-2c298953dfab/3c1c1674d42f45e5.png) | 
| Out[8]= |  | 
| In[9]:= | ![ResourceFunction["SuiteSparseMatrix"][11, "MetaInformation"]](https://www.wolframcloud.com/obj/resourcesystem/images/dcf/dcfba042-d58c-4762-ba6a-2c298953dfab/1ec61d4a39c38747.png) | 
| Out[9]= |  | 
Specified property:
| In[10]:= | ![ResourceFunction["SuiteSparseMatrix"]["ash85", "Kind"]](https://www.wolframcloud.com/obj/resourcesystem/images/dcf/dcfba042-d58c-4762-ba6a-2c298953dfab/5989146a4e43f9aa.png) | 
| Out[10]= |  | 
Several properties:
| In[11]:= | ![ResourceFunction["SuiteSparseMatrix"][11, {"Name", "Group"}]](https://www.wolframcloud.com/obj/resourcesystem/images/dcf/dcfba042-d58c-4762-ba6a-2c298953dfab/0140496866344ea4.png) | 
| Out[11]= |  | 
All available properties:
| In[12]:= | ![ResourceFunction["SuiteSparseMatrix"]["ash85", All]](https://www.wolframcloud.com/obj/resourcesystem/images/dcf/dcfba042-d58c-4762-ba6a-2c298953dfab/4ec23e524784a30d.png) | 
| Out[12]= |  | 
| In[13]:= | ![ResourceFunction["SuiteSparseMatrix"][11, All]](https://www.wolframcloud.com/obj/resourcesystem/images/dcf/dcfba042-d58c-4762-ba6a-2c298953dfab/0d861762acba588e.png) | 
| Out[13]= |  | 
Use a specified Python session:
| In[14]:= | ![session = StartExternalSession["Python"]](https://www.wolframcloud.com/obj/resourcesystem/images/dcf/dcfba042-d58c-4762-ba6a-2c298953dfab/26b23600029b40ec.png) | 
| Out[14]= |  | 
| In[15]:= | ![ResourceFunction["SuiteSparseMatrix"][session, 11]](https://www.wolframcloud.com/obj/resourcesystem/images/dcf/dcfba042-d58c-4762-ba6a-2c298953dfab/6fe82c3aaaaac0b3.png) | 
| Out[15]= |  | 
Close the session:
| In[16]:= | ![DeleteObject[session]](https://www.wolframcloud.com/obj/resourcesystem/images/dcf/dcfba042-d58c-4762-ba6a-2c298953dfab/1040f7e19efd9907.png) | 
Obtain a graph representation of a large sparse matrix:
| In[17]:= | ![m = ResourceFunction["SuiteSparseMatrix"]["diag"]](https://www.wolframcloud.com/obj/resourcesystem/images/dcf/dcfba042-d58c-4762-ba6a-2c298953dfab/36ccdcf39b5f78c2.png) | 
| Out[17]= |  | 
| In[18]:= | ![GraphPlot[%]](https://www.wolframcloud.com/obj/resourcesystem/images/dcf/dcfba042-d58c-4762-ba6a-2c298953dfab/4c5b14d71c6e2c74.png) | 
| Out[18]= |  | 
3D visualization:
| In[19]:= | ![ResourceFunction["SuiteSparseMatrix"]["3elt"]](https://www.wolframcloud.com/obj/resourcesystem/images/dcf/dcfba042-d58c-4762-ba6a-2c298953dfab/59892485efb5e86a.png) | 
| Out[19]= |  | 
| In[20]:= | ![GraphPlot3D[%]](https://www.wolframcloud.com/obj/resourcesystem/images/dcf/dcfba042-d58c-4762-ba6a-2c298953dfab/018d051da4f7cd18.png) | 
| Out[20]= |  | 
The total number of available sparse matrices currently available in the SuiteSparse matrix collection:
| In[21]:= | ![ResourceFunction["SuiteSparseMatrix"]["ContentLength"]](https://www.wolframcloud.com/obj/resourcesystem/images/dcf/dcfba042-d58c-4762-ba6a-2c298953dfab/036e6bbb55023916.png) | 
| Out[21]= |  | 
The latest update date of the content:
| In[22]:= | ![ResourceFunction["SuiteSparseMatrix"]["ContentDate"]](https://www.wolframcloud.com/obj/resourcesystem/images/dcf/dcfba042-d58c-4762-ba6a-2c298953dfab/4019e7f5e5c802eb.png) | 
| Out[22]= |  | 
A catalog of available matrices:
| In[23]:= | ![ResourceFunction["SuiteSparseMatrix"][All] // Dataset](https://www.wolframcloud.com/obj/resourcesystem/images/dcf/dcfba042-d58c-4762-ba6a-2c298953dfab/3eca58aa66aaa130.png) | 
| Out[24]= |  | 
Some of these matrices are also available in ExampleData:
| In[25]:= | ![ExampleData[{"Matrix", "1138BUS"}]](https://www.wolframcloud.com/obj/resourcesystem/images/dcf/dcfba042-d58c-4762-ba6a-2c298953dfab/6970702b591d6ccf.png) | 
| Out[25]= |  | 
The resource function ProbNumObject returns the sparse matrix given its name and group:
| In[26]:= | ![session = StartExternalSession["Python"]](https://www.wolframcloud.com/obj/resourcesystem/images/dcf/dcfba042-d58c-4762-ba6a-2c298953dfab/577ab5acff263175.png) | 
| Out[26]= |  | 
| In[27]:= | ![p = ResourceFunction["ProbNumObject"][session]](https://www.wolframcloud.com/obj/resourcesystem/images/dcf/dcfba042-d58c-4762-ba6a-2c298953dfab/534d5a9043acae78.png) | 
| Out[27]= |  | 
| In[28]:= | ![p["SuiteSparseMatrix"["bcspwr01", "HB"]]](https://www.wolframcloud.com/obj/resourcesystem/images/dcf/dcfba042-d58c-4762-ba6a-2c298953dfab/32cf7179a2436de1.png) | 
| Out[28]= |  | 
Convert to SparseArray:
| In[29]:= | ![Normal[%]](https://www.wolframcloud.com/obj/resourcesystem/images/dcf/dcfba042-d58c-4762-ba6a-2c298953dfab/06d89e3bbfa69fce.png) | 
| Out[29]= |  | 
Obtain the same matrix with SuiteSparseMatrix:
| In[30]:= | ![ResourceFunction["SuiteSparseMatrix"][session, {"bcspwr01", "HB"}]](https://www.wolframcloud.com/obj/resourcesystem/images/dcf/dcfba042-d58c-4762-ba6a-2c298953dfab/2d627d09f68278f5.png) | 
| Out[30]= |  | 
| In[31]:= | ![SameQ[%, %%]](https://www.wolframcloud.com/obj/resourcesystem/images/dcf/dcfba042-d58c-4762-ba6a-2c298953dfab/08fcbe3eba334eac.png) | 
| Out[31]= |  | 
| In[32]:= | ![DeleteObject[session]](https://www.wolframcloud.com/obj/resourcesystem/images/dcf/dcfba042-d58c-4762-ba6a-2c298953dfab/38a11f120217272f.png) | 
SuiteSparseMatrix["name"] fails if the same name exists in several groups:
| In[33]:= | ![ResourceFunction["SuiteSparseMatrix"]["barth"]](https://www.wolframcloud.com/obj/resourcesystem/images/dcf/dcfba042-d58c-4762-ba6a-2c298953dfab/43b882f25f69288f.png) | 
| Out[33]= |  | 
Specify the group to retrieve the matrix:
| In[34]:= | ![ResourceFunction["SuiteSparseMatrix"][{"barth", "Nasa"}]](https://www.wolframcloud.com/obj/resourcesystem/images/dcf/dcfba042-d58c-4762-ba6a-2c298953dfab/624efcb55592b256.png) | 
| Out[34]= |  | 
Visualize the first few matrices from the SuiteSparse collection:
| In[35]:= | ![session = StartExternalSession["Python"]](https://www.wolframcloud.com/obj/resourcesystem/images/dcf/dcfba042-d58c-4762-ba6a-2c298953dfab/3036805d1ccd854c.png) | 
| Out[35]= |  | 
| In[36]:= | ![data = Table[
  ResourceFunction["SuiteSparseMatrix"][session, i, All], {i, 5}]](https://www.wolframcloud.com/obj/resourcesystem/images/dcf/dcfba042-d58c-4762-ba6a-2c298953dfab/6dc14c6229dea00e.png) | 
| Out[37]= |  | 
| In[38]:= | ![Dataset[data /. sp_SparseArray :> MatrixPlot[sp]]](https://www.wolframcloud.com/obj/resourcesystem/images/dcf/dcfba042-d58c-4762-ba6a-2c298953dfab/2c130a793b96e93f.png) | 
| Out[38]= |  | 
| In[39]:= | ![DeleteObject[session]](https://www.wolframcloud.com/obj/resourcesystem/images/dcf/dcfba042-d58c-4762-ba6a-2c298953dfab/094bd9afc7f9fc6a.png) | 
This work is licensed under a Creative Commons Attribution 4.0 International License