Dense, Sparse, and Matrix-Free Operators
Dense storage retains every matrix entry; sparse storage records selected entries and their positions; a matrix-free operator computes its action without assembling the full matrix. The best choice depends on what a solver needs to do. A sparse Hamiltonian can still lead to dense factors, dense eigenvectors, or an unaffordable Krylov basis.
Required background. Array representations fixes the basis, dtype, and operator action.
Storage and arithmetic costs
Section titled “Storage and arithmetic costs”For an matrix with stored entries, dense storage costs , while a compressed sparse row representation stores values, column indices, and row pointers. Matrix-vector multiplication costs or respectively. Constants matter: sparse multiplication must load indices and often accesses vector elements irregularly, whereas dense kernels reuse data efficiently.
For complex binary64 values, the value array alone uses bytes in a dense matrix. At , that is GB in decimal units. A tridiagonal matrix with approximately entries instead needs about MB of values, plus indices and row pointers. Storing its three diagonals directly is more economical still.
A sparse format is not an instruction to discard small entries. Structural zeros come from the model or discretization; thresholding nonzero entries introduces a new approximation. If is the discarded Hermitian part, eigenvalue shifts are bounded in absolute value by , but a componentwise threshold alone does not supply this norm bound independently of dimension.
A finite-difference operator without a matrix
Section titled “A finite-difference operator without a matrix”For a grid function with interior values and zero Dirichlet endpoint values, define
with and . Each output uses only the input at that grid point and its two neighbors. Three shifted vector operations apply in work without storing indices. This is a matrix-free stencil. Assemble the same matrix for a small and compare its action on a complex vector before using the stencil in a large sparse eigensolver.
For , , and , the result is
This hand calculation catches periodic wraparound introduced accidentally by a cyclic array shift. Boundary entries must be handled explicitly.
Solver costs beyond the Hamiltonian
Section titled “Solver costs beyond the Hamiltonian”If only a few extremal eigenpairs are needed, Krylov methods may avoid dense diagonalization. Yet storing trial vectors costs and orthogonalization costs can become substantial. Asking for all eigenvectors ultimately requires output storage even when is sparse.
Interior eigenvalues often motivate shift-invert actions . A sparse factorization can create many additional nonzero entries, called fill-in. Its memory demand depends on ordering and graph structure, not just the original nonzero count. Alternatively, iterative inner solves add another tolerance and preconditioning problem.
The exponential is generally dense even if is sparse. To evolve one vector, use an exponential action rather than constructing the full propagator. Similarly, a sparse pure-state vector can quickly become dense under time evolution; sparsity is a property of both the representation and the state at the relevant time.
Choosing an implementation
Section titled “Choosing an implementation”Use dense storage for small problems, broad spectral information, and reference calculations where simplicity aids verification. Use structured diagonals for fixed-bandwidth stencils, general sparse formats for irregular connectivity, and matrix-free actions when structure makes assembly wasteful. Benchmark the whole calculation, including assembly, format conversion, factorization, and output.
Coordinate-format assembly permits repeated contributions to an entry. Ensure duplicates are summed before reasoning about nonzero counts or comparing a matrix with its adjoint. A matrix-free implementation must expose the correct adjoint action if the solver requests it; for non-Hermitian problems, reusing the forward action is incorrect.
Changing storage should preserve the mathematical problem. Compare actions and residuals on small cases before comparing timings. Faster execution of a differently truncated Hamiltonian is not a storage-only improvement.
Exercises
Section titled “Exercises”A calculation stores 80 complex vectors of length . How much memory do those vectors require, ignoring allocator overhead?
Solution
bytes, or GB in decimal units. This can exceed the storage of a sparse local Hamiltonian, so the Krylov dimension matters to memory planning.
Why can setting each entry smaller than to zero fail to limit the operator error to ?
Solution
Many discarded entries can act coherently. For example, a matrix whose every entry is has spectral norm . An entrywise threshold controls individual entries, not their collective operator action.
References
Section titled “References”- Bai, Z., J. Demmel, J. Dongarra, A. Ruhe, and H. van der Vorst, eds., Templates for the Solution of Algebraic Eigenvalue Problems, SIAM, 2000, Sparse Matrix Storage Formats — storage schemes and matrix-vector operations.
- Saad, Y., Numerical Methods for Large Eigenvalue Problems, revised ed., SIAM, 2011 — sparse and matrix-free spectral algorithms and their memory requirements.