![]() |
SuperSCS
1.3.2
|
Sparse matrix in C are formated in the compressed sparse column format.
Let \(A\in\mathbb{R}^{m\times n}\) be a sparse matrix with \(q\) nonzero elements.
The compressed sparse column, henceforth CSC, representation of \(A\) is the triplet \((a, I, J)\) where
Let us give a comprehensive example...
Consider the following sparse matrix
\begin{eqnarray*} A &=& \begin{bmatrix} 0.3\\ & 0.7\\ && 0.2\\ -0.5 & 0.9 \end{bmatrix} \end{eqnarray*}
We shall derive the CSC representation of \(A\).
We have \(m=4\), \(n=3\) and we count \(q=5\) nonzero elements.
Traversing \(A\) in column-major order, we have \(a = (0.3, -0.5, 0.7, 0.9, 0.2)\).
\(I\) is an array of length \(n+1=4\); it is constructed recursively as follows:
Note that the last element of \(I\) is the number of nonzero elements of the original matrix.
Lastly, \(J\) is constructed as follows:
In MATLAB, you may compute the CSC representation of a matrix A
as follows:
For convenience, SuperSCS implements the MATLAB function sparse_to_csc
with which you may convert a sparse matrix into its CSC format.
The function signature is:
Note that you first need to run make_scs
(see the installation page).
Here is an example of use:
This will return: