Study Vault Search notes, aliases and full text
Graph
ConceptDBISAI-written · not yet proofread

Sparse Matrix

Also Sparse Matrices

A sparse matrix is a matrix with mostly zero entries, stored as the list of its non-zero entries as (value, row index, column index) triples instead of all m × n entries.

Know these firstVector Space Model

Typical case: a term-document matrix in the Vector Space Model, where ∣V∣|V| is large but each document contains only a small fraction of the vocabulary, so storing all entries is infeasible.

Properties#

  • Space: O(nnz)O(\text{nnz}) for nnz\text{nnz} non-zero entries, instead of O(m⋅n)O(m \cdot n) for the dense matrix.
  • Storage orders:
    • row-major: sorted by row index first; the entries of one row are consecutive.
    • column-major: sorted by column index first; the entries of one column are consecutive.
  • PyTorch: torch.sparse_coo_tensor(indices, values) builds a sparse matrix from a 2×nnz2 \times \text{nnz} index tensor (rows, columns) and the values; “coo” stands for “coordinates”. Internally the non-zero values are always stored in row-major order. A sparse tensor can be multiplied with a dense tensor, so q⊤Aq^\top A works directly on the sparse AA.

Example#

Sources#

Search

Type In
↑ ↓ move ↵ open ⇥ next section Ctrl↵ results page Prefix # to search text only