Expand description
Integer lattices and algorithms.
Structs§
- Affine
Lattice - A lattice that is offset from the origin by a vector. Mathematicians would call this a lattice coset.
- Lattice
- A “lattice”, i.e. the span of a set of vectors.
This can never be empty because it always contains the zero vector even if
Lattice::basis
has zero rows. The matrix always stores the ambient dimension (the number of columns) even if there are zero rows.
Traits§
- Working
Type - Lattice algorithms are possibly internally working with a different ring. These rings need to implement this.
- Working
Type For - This trait facilitates the conversion between the ring of the lattice and the ring used internally.
Functions§
- cvp_
nearest_ plane - Approximates the CVP using Babai’s nearest plane algorithm.
The return value is a pair of the vector and the vector of coefficients
of that vector if
compute_coefficients
is true. Otherwise the second element of the pair is an empty vector. - cvp_
planes - Solves the CVP exactly.
- cvp_
rounding - Approximates the CVP using Babai’s rounding technique. The returns value is a vector of the coefficients of the linear combination of the basis vectors, so if you want the actual point, you still have to matrix multiply with the basis matrix. In practice, it is a good idea to reduce the basis (e.g. using LLL) so that the approximation is good.
- gram_
schmidt - Gram-Schmidt of the rows of the matrix
a
. The rows will span the same subspace as the original rows, even if they are not linearly independent. The rows of the result are not normalized. Callgram_schmidt_orthonormal
if you want that. - gram_
schmidt_ orthonormal - Gram-Schmidt of the rows of the matrix
a
. The rows of the result are normalized. Callgram_schmidt
if you don’t want that. This functions requires that the rows are linearly independent (unlikegram_schmidt
). - lll
- Performs LLL basis reduction using rational numbers.
- rq_
decomposition - Computes the RQ-decomposition (row QR-decomposition) of a matrix.
Returns a lower triangular matrix
R
and an orthogonal matrixQ
, such thatR * Q = A
. - size_
reduce - Size reduce the basis. This essentially is Gram-Schmidt but rounding the coefficients to integers.