# Support for Compressed Sparse Column sparse matrix representation

Is there native support for Compressed Sparse Column (CSC) format for sparse matrices, like importing and manipulating them?

• Why exactly are you focused on CSC and not CSR?
– user21
Commented May 11, 2012 at 8:24
• I am working on/modifying a code which has adopted CSC format - dats y Commented May 14, 2012 at 10:05

The first Google hit for "compressed sparse column" is this page, which explains that it's also called the Harwell-Boeing format. If this is what you need, this format is supported by Mathematica.

Mathematica has, I think, very efficient SparseArray functionality. SarseArrays are supported by a wide variety of functions, e.g LinearSolve, Eigensystem... The SparseArray is stored in CSR (Look for the SparseArray entry). If you are interested here is a description of the internals. For the Import/Export you could either make use of the HarwellBoeing format (as pointed out by Szabolcs) or make use of the positions and values and then create the SparseArray using:

positions = {{1, 1}, {2, 2}, {3, 3}, {1, 3}};
values = {1, 2, 3, 4};
sa = SparseArray[positions -> values]


To extract positions and values from SparseArrays use:

sa["NonzeroPositions"]
(*{{1, 1}, {1, 3}, {2, 2}, {3, 3}}*)
sa["NonzeroValues"]
(*{1, 4, 2, 3}*)


Here is a link where examples of efficient use of SparseArrays was discussed and it shows the addition of values into the same position. But there are many more cases where SparseArrays are useful. In fact, I think, they are quite underestimated.
You can evaluate $ImportFormats or $ExportFormats for a simple list of formats available.