Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question
Why exactly are you focused on CSC and not CSR? – user21 May 11 '12 at 8:24
I am working on/modifying a code which has adopted CSC format - dats y – my account_ram May 14 '12 at 10:05
up vote 5 down vote accepted

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.

share|improve this answer
Thanks Szabolics – my account_ram May 14 '12 at 10:16

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:

(*{{1, 1}, {1, 3}, {2, 2}, {3, 3}}*)
(*{1, 4, 2, 3}*)

and then export those. "Properties" has more info.

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.

share|improve this answer
+1. I was not aware of all these Mathgroup discussions. Another possibly relevant link in this context:… – Leonid Shifrin May 11 '12 at 9:00

You can view the full list of supported formats. You can also view the list of formats by category.

You can evaluate $ImportFormats or $ExportFormats for a simple list of formats available.

share|improve this answer
Have checked it - nothing useful there – my account_ram May 11 '12 at 6:06
@myaccount_ram then perhaps the answer is: "No." – Mr.Wizard May 11 '12 at 6:22
Szabolcs's answer solves it .. Thanks – my account_ram May 14 '12 at 10:17

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.