1 function [d,x,r,v]=csparse(a)
2 % convert matrix from ij to column sparse format
4 % a matlab sparse matrix
6 % d vector [number of rows; number of columns; number of nonzeros]
11 % row indices for column j are r(x(j):x(j+1)-1)
12 % values for column j are v(x(j):x(j+1)-1)
15 % make sure r c v are all columns
20 [tmp,index]=sort(m*c+r);