Randomized numerical linear algebra
Module: sci_form::rand_nla (core since 2026-11-08; F93 validated) Feature flag: none — beta-randnla and experimental-randnla are compatibility aliases; sci_form::beta::rand_nla re-exports the core module.
Validation and limits
| Question | Answer |
|---|---|
| Compared with | exact symmetric eigensolver (NumPy/SciPy) |
| Measured separation | rank-N/4 3.8e-4 with power iterations; N=600, k=160, 9.6e-4, ~80 ms vs ~143 ms |
| Confidence region | near-identity or gapped EHT, k ≥ N/4, lowest four states |
| Main limitation | the full-spectrum path still relies on the exact fallback; clustered spectra degrade |
The raw rows and the exact tolerances are in the full validation matrix.
Overview
Replaces the
Theory
Nyström Approximation
Given a symmetric matrix
- Sketch: Generate
with Gaussian entries. - Project: Compute
via sparse-dense multiplication - Reconstruct:
and , with .
The rank parameter
Randomized
Via randomized SVD:
Randomized Diagonalization
The transformed Hamiltonian N > 500, solve_eht_randnla_lowrank replaces the full
API
The low-level interface works on the Hamiltonian and overlap matrices:
use nalgebra::DMatrix;
use sci_form::rand_nla::{
solve_eht_randnla, solve_eht_randnla_lowrank, RandNlaConfig,
};
let h: DMatrix<f64> = /* EHT Hamiltonian, eV */;
let s: DMatrix<f64> = /* overlap matrix */;
let config = RandNlaConfig {
sketch_size: Some(50), // k; None = 50 + ceil(log2 N)
seed: 42,
max_error: 1e-3,
fallback_enabled: true,
power_iterations: 2,
};
// Full randomized generalized eigensolver (all N eigenpairs).
let (energies, c, info) = solve_eht_randnla(&h, &s, &config);
// N > 500 path: only the lowest `n_eigen` states, no N×N diagonalization.
let low = solve_eht_randnla_lowrank(&h, &s, &config, 4);
// low.eigenvalues, low.eigenvectors, low.infoThe convenience wrapper that assembles the EHT matrices is eht::solve_eht_randnla(elements, positions, k, config), which returns (EhtResult, RandNlaInfo) — the usual EHT result plus rank/residual/fallback metadata. k is the optional Wolfsberg–Helmholtz constant (None = default).
The Nyström building block is public as NystromApprox::from_matrix_with_power_iterations(&s, &sketch, q) with GaussianSketch::new(&mut rng, n, k).
Error Control
The module includes automatic error estimation:
If the error exceeds 0.1%, the module falls back to exact diagonalization and reports in the rand_nla_error field.
Validation (F93, 2026-10-14)
External gate tests/beta_randnla_validation.rs vs scripts/validation/oracle_randnla.py (numpy/scipy, overlap spectra): single-shot rank-N/4 ~0.13, near-identity regime 3.9e-3 with fallback OFF, default config exact incl. exercised fallback at N=96.
Subspace iterations (2026-11-07): NystromApprox::from_matrix_with_power_iterations and RandNlaConfig::power_iterations add re-orthonormalised power iterations. With 384 iterations the same rank-N/4 sketches reach 3.8e-4 (F93a-bis), so the <1e-3 accuracy criterion is met for the fixture.
EHT backend (2026-11-07): eht::solve_eht_randnla assembles the EHT Hamiltonian/overlap exactly as solve_eht and routes the generalized eigenproblem through the randomized solver, returning the usual EhtResult plus the rank/residual/fallback metadata.
N>500 path (2026-11-08): solve_eht_randnla_lowrank uses Nyström for S^{-1/2} and a reorthogonalized Lanczos iteration on a randomized start, so it never forms or diagonalizes the full N × N transformed Hamiltonian. Measured on N = 600, k = 160: the four lowest states have 9.6e-4 relative error and the call takes ~80 ms versus ~143 ms for the exact symmetric diagonalization. The module is core; the full-spectrum path still uses the exact fallback, and that limitation is recorded in the validation report.
Tests
cargo test --test experimental_gates -- test_randnla8 integration tests (tests/experimental/test_randnla.rs) covering: sketch matrix statistics, Nyström reconstruction error, randomized SVD accuracy, and EHT eigenvalue comparison against exact diagonalization for benzene and naphthalene.
These tests live in the experimental_gates target — see Overview for the full command matrix.