How to create a sparse CSCMatrix using Spark?

Viewed 912

The documentation of Spark, for creating a pyspark.ml.linalg.SparseMatrix says:

Column-major sparse matrix. The entry values are stored in Compressed
Sparse Column (CSC) format. For example, the following matrix

   1.0 0.0 4.0 
   0.0 3.0 5.0
   2.0 0.0 6.0   

is stored as values: [1.0, 2.0, 3.0, 4.0, 5.0, 6.0], 
rowIndices=[0, 2, 1, 0, 1, 2], 
colPointers=[0, 2, 3, 6]

Can you explain how do we derive the colPointers? It says that they represent the index corresponding to the start of a new column, but still I cannot wrap my head around it.

1 Answers
Related