Numerical Linear Algebra

sparse matrix methods

A matrix is sparse when the overwhelming majority of its entries are zero — think of a million-by-million matrix with only a handful of nonzeros per row, the kind that arises from discretized PDEs, networks, and graphs. Storing all those zeros, or doing arithmetic with them, would be absurd. Sparse matrix methods are the storage formats and algorithms that touch only the nonzeros, turning an impossible problem into a routine one.

The first idea is representation. Instead of a full n-by-n array, you store only the nonzero values and their locations. Common formats include coordinate list (COO: triples of row, column, value), compressed sparse row (CSR: values plus column indices plus row pointers), and compressed sparse column (CSC). A matrix-vector product then costs O(nnz), proportional to the number of nonzeros, not to n^2 — often a colossal saving.

The second idea is preserving sparsity through computation. Here direct methods hit a wall: factoring a sparse matrix creates fill-in, zeros that turn nonzero in the L and U factors, sometimes catastrophically. Sparse direct solvers fight this by reordering rows and columns (minimum-degree, nested-dissection orderings) to minimize fill before factoring. Even so, fill-in can exhaust memory on the largest problems.

This is exactly why iterative Krylov methods dominate at scale. Conjugate gradient and GMRES need only matrix-vector products, which respect sparsity perfectly and never create fill-in, so their memory stays at O(nnz) throughout. Combined with a sparse preconditioner, they solve systems with millions or billions of unknowns that no direct method could ever factor. Sparsity is the structural reason the iterative philosophy wins in large-scale scientific computing.

CSR: values[], col_index[], row_ptr[]; matvec cost = O(nnz), not O(n^2)

Compressed sparse row stores only nonzeros and their positions, so a matrix-vector product scales with the number of nonzeros.

Sparsity is not just few nonzeros but a useful pattern of them. A banded or block-structured sparse matrix factors with little fill; a sparse matrix with nonzeros scattered randomly can fill in almost completely. Reordering to expose good structure is half the battle for sparse direct solvers.

Also called
sparse linear algebra