pub fn integer_nullspace(m: &Matrix) -> Result<Vec<Matrix>, SymplexError>Expand description
A ℤ-basis of the integer kernel {x ∈ ℤⁿ : A·x = 0} of an m×n
integer matrix, as n×1 column vectors.
The basis has n − rank(A) vectors (empty for full column rank) and
generates every integer solution — unlike the rational
Matrix::nullspace, whose basis vectors may only span the kernel over
ℚ. Computed from the row Hermite normal form of [Aᵀ | I]: the rows
whose Aᵀ part vanishes are exactly a basis of the kernel lattice.
§Errors
SymplexError::InvalidArgument if any entry is not an integer literal.
§Examples
use symplex::prelude::*;
use symplex::normalforms::integer_nullspace;
let ctx = Context::new();
let a = matrix![ctx, [2, 4, 6]];
let basis = integer_nullspace(&a).unwrap();
assert_eq!(basis.len(), 2);
for k in &basis {
assert_eq!((&a * k).eval(), matrix![ctx, [0]]);
}
// Full column rank: trivial kernel.
assert!(integer_nullspace(&matrix![ctx, [1, 0], [0, 1], [1, 1]]).unwrap().is_empty());