Skip to content

E2: Randomized Numerical Linear Algebra (RandNLA)

Module: sci_form::experimental::rand_nlaFeature flag: experimental-randnla


Overview

Replaces the O(N3) EHT diagonalization with the Randomized Nyström Approximation, reducing cost to O(N2) or O(NlogN) for sparse matrices. This enables EHT calculations on systems of thousands of atoms where full diagonalization is impractical.


Theory

Nyström Approximation

Given a symmetric matrix SRN×N:

  1. Sketch: Generate ΩRN×k with Gaussian entries N(0,1/k)
  2. Project: Compute Y=SΩ via sparse-dense multiplication
  3. Reconstruct: SY(ΩTY)1YT

The rank parameter k=min(N,50+logN) controls accuracy vs. speed.

Randomized S1/2

Via randomized SVD: SUΣVT, then S1/2UΣ1/2UT with truncated singular values.

Randomized Diagonalization

The transformed Hamiltonian H~=S1/2HS1/2 is diagonalized using sketch + Rayleigh-Ritz refinement, extracting only the nocc/2 occupied eigenvectors.


API

rust
use sci_form::experimental::rand_nla::*;

// Nyström approximation
let config = NystromConfig { rank: 50, seed: 42 };
let approx = nystrom_approximate(&matrix, &config);

// Randomized SVD
let rsvd = randomized_svd(&matrix, rank, seed);

// Randomized S^{-1/2}
let s_inv_sqrt = randomized_inverse_sqrt(&overlap, rank, seed);

// Full randomized EHT pipeline
let result = rand_eht_calculate(&elements, &coords, &config);
// result.homo_energy, result.gap, result.rand_nla_error

Error Control

The module includes automatic error estimation:

error=HCSCEFSCEF

If the error exceeds 0.1%, the module falls back to exact diagonalization and reports in the rand_nla_error field.


Tests

bash
cargo test --features experimental-randnla --test regression -- test_randnla

Covers: sketch matrix statistics, Nyström reconstruction error, randomized SVD accuracy, and EHT eigenvalue comparison against exact diagonalization for benzene and naphthalene.

Released under the MIT License.