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(Nlog⁡N) 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 S∈RN×N:

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

The rank parameter k=min(N,50+⌈log⁡N⌉) controls accuracy vs. speed.

Randomized S−1/2 ​

Via randomized SVD: S≈UΣVT, then S−1/2≈UΣ−1/2UT with truncated singular values.

Randomized Diagonalization ​

The transformed Hamiltonian H~=S−1/2HS−1/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=∥HC−SCE∥F∥SCE∥F

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.