reduce_basis

Function reduce_basis 

Source
pub(crate) fn reduce_basis(
    rows: [[f64; 3]; 3],
    dim: usize,
) -> Option<[[[i64; 3]; 3]; 2]>
Expand description

Unimodular integer transforms [U, W] with W = U^{-T}: the rows U a of the leading dim rows a are a reduced basis of the same lattice, and W b are their reciprocal rows when b are those of a.

A row is reduced when neither adding a multiple of another row nor, in three dimensions, adding the sum or difference of the two others shortens it by more than a relative 1e-8. Only such strict decreases are applied and rows are never permuted, so a reduced basis (for example a hexagonal one, whose ties do not count) is kept. Returns None for a reduced basis, or when the reduction would need coefficients beyond 2^20, which leaves the given basis in use.