pub fn lll(m: &Matrix, delta: (i64, i64)) -> Result<Matrix, SymplexError>Expand description
LLL-reduced basis of the lattice spanned by the rows of the integer
matrix A, with Lovász parameter δ = num/den (the standard choice
is (3, 4)). SymPy: Matrix.lll(delta).
The Gram–Schmidt data is exact (rational), so the result satisfies the
size condition |μ_ij| ≤ 1/2 and the Lovász condition
‖b*_k‖² ≥ (δ − μ²_{k,k−1})‖b*_{k−1}‖² exactly, and spans the same
lattice as A (same hermite_normal_form). See ZMatrix::lll
for the algorithm.
§Errors
SymplexError::InvalidArgument if any entry is not an integer
literal, δ is not in the open interval (1/4, 1), or the rows are
linearly dependent.
§Examples
use symplex::prelude::*;
use symplex::normalforms::{hermite_normal_form, lll};
let ctx = Context::new();
let b = matrix![ctx, [1, 1, 1], [-1, 0, 2], [3, 5, 6]];
let r = lll(&b, (3, 4)).unwrap();
// SymPy 1.14: Matrix([[1,1,1],[-1,0,2],[3,5,6]]).lll() == [[0,1,0],[1,0,1],[-1,0,2]]
assert_eq!(r, matrix![ctx, [0, 1, 0], [1, 0, 1], [-1, 0, 2]]);
assert_eq!(hermite_normal_form(&r).unwrap(), hermite_normal_form(&b).unwrap());