Graph
Compressed Sparse Column

🧮Compressed Sparse Column

NEW

Also known as: CSC, Compressed Column Storage

A sparse matrix storage format that stores nonzero elements grouped by column using value, row index, and column pointer arrays.

DESCRIPTION

Compressed Sparse Column (CSC) stores sparse matrices by compressing columns. It maintains three arrays: nonzero values, row indices for each value, and a column pointer array indicating where each column’s data begins. CSC supports efficient column slicing and operations like solving triangular systems. It’s widely used in numerical linear algebra, optimization, and scientific computing. Libraries like SciPy and SuiteSparse implement CSC with optimized kernels. Choice between CSC and CSR depends on access patterns and algorithm requirements. Conversions between formats are typically provided in sparse libraries.

ALTERNATIVE DEFINITIONS

SciPy

A csc_matrix is a sparse matrix in Compressed Sparse Column format.

Concise library definition identifying the format.

Source

Wikipedia

In compressed sparse column (CSC) format, a matrix is represented by values, row indices, and column pointer arrays that store nonzero entries column by column.

Describes the three-array representation and column-wise storage.

Source

Sparse Matrix COO Format SciPy NumPy Matrix-Vector Multiplication Block Sparse Graph Adjacency Matrix Linear Algebra FEM Matrices

COMPETING TERMS

Compressed Sparse Row

KNOWLEDGE AREAS

Mathematics Data Science AI Platform & Tooling

TARGET AUDIENCE

Data Scientist AI Engineer MLOps Engineer Software Developer

EXTERNAL SOURCES

TOP QUESTIONS

What is Compressed Sparse Column (CSC) format?

CSC stores nonzeros column by column using values, row indices, and column pointers. It’s efficient for column slicing and certain linear solves.

Category: Concepts

When should I use CSC instead of CSR?

Use CSC for column-based operations and factorizations; choose CSR for row-based operations like row slicing and many SpMV patterns.

Category: Advice

What are the three arrays in CSC?

They are data (values), indices (row indices), and indptr (column pointers). They compactly represent nonzero structure per column.

Category: Concepts

How does CSC affect performance of SpMV?

SpMV performance depends on access patterns and cache locality. CSC can be excellent when multiplying by a vector where column traversal is natural.

Category: Performance

How do I convert between CSC and CSR?

Sparse libraries like SciPy provide methods (e.g., .tocsr(), .tocsc()) that reindex nonzeros and pointer arrays accordingly.

Category: Tools

What are common pitfalls with CSC?

Incorrect index types, unsorted indices, and duplicate entries degrade performance. Normalize structure and types before heavy computations.

Category: Mistakes

Is CSC suitable for dynamic insertion of elements?

Frequent insertions are costly; use COO for assembly and then convert to CSC for computation.

Category: Advice

How does CSC interact with factorization algorithms?

Many direct solvers expect or produce CSC for efficient column-oriented factorizations like Cholesky.

Category: Concepts

Does CSC help memory usage?

Yes, by storing only nonzeros and compact indices. Savings grow with sparsity.

Category: Benefits