Lattice algorithm#

hsnf.lattice.equivalent(lattice1: numpy.ndarray[Any, numpy.dtype[numpy.int64]], lattice2: numpy.ndarray[Any, numpy.dtype[numpy.int64]], row_wise: bool = True) bool[source]#

Return if and only if given two lattices are equivalent. Assume both lattices are full rank.

Two lattices are equivalent if and only if they have the same Hermite normal forms.

Parameters
  • lattice1 (array, (n, n)) – If row_wise=True, lattice1[i, :] is the i-th basis vector of the lattice. Otherwise lattice1[:, i] is.

  • lattice2 (array, (n, n)) – If row_wise=True, lattice2[i, :] is the i-th basis vector of the lattice Otherwise lattice2[:, i] is.

  • row_wise – If true, basis vectors are aligned in row wise, otherwise in column wise.

hsnf.lattice.compute_union(lattice1: numpy.ndarray[Any, numpy.dtype[numpy.int64]], lattice2: numpy.ndarray[Any, numpy.dtype[numpy.int64]], row_wise: bool = True)[source]#

Return the smallest lattice containing both lattice1 and lattice2

The union of two lattices with basis vectors \(\mathbf{A}\) and \(\mathbf{B}\) is computed by a Hermite normal form of the concatenated matrices \([\mathbf{A} | \mathbf{B}]\).

Parameters
  • lattice1 (array, (n, n)) – If row_wise=True, lattice1[i, :] is the i-th basis vector of the lattice. Otherwise lattice1[:, i] is.

  • lattice2 (array, (n, n)) – If row_wise=True, lattice2[i, :] is the i-th basis vector of the lattice Otherwise lattice2[:, i] is.

  • row_wise – If true, basis vectors are aligned in row wise, otherwise in column wise.

hsnf.lattice.compute_dual(lattice, row_wise: bool = True)[source]#

Return basis of a dual lattice.

For lattice \(L\), its dual lattice is

\[\tilde{L} = \{ \mathbf{x} \in \mathrm{Span}_{\mathbb{R}}(L) \mid \langle \mathbf{x}, \mathbf{y} \rangle = 0 \, (\forall \mathbf{y} \in L) \}\]
Parameters
  • lattice (array, (n, n)) – If row_wise=True, lattice[i, :] is the i-th basis vector of the lattice. Otherwise lattice[:, i] is.

  • row_wise – If true, basis vectors are aligned in row wise, otherwise in column wise.

hsnf.lattice.compute_intersection(lattice1: numpy.ndarray[Any, numpy.dtype[numpy.int64]], lattice2: numpy.ndarray[Any, numpy.dtype[numpy.int64]], row_wise: bool = True)[source]#

Return intersection lattice of lattice1 and lattice2.

Let a dual of lattice \(L\) be \(\tilde{L}\). The dual of intersection of lattices \(L\) and \(L'\) is a union of dual lattices of \(L\) and \(L'\):

\[\widetilde{ L \cap L' } = \tilde{L} \cup \tilde{L'}\]
Parameters
  • lattice1 (array, (n, n)) – If row_wise=True, lattice1[i, :] is the i-th basis vector of the lattice. Otherwise lattice1[:, i] is.

  • lattice2 (array, (n, n)) – If row_wise=True, lattice2[i, :] is the i-th basis vector of the lattice Otherwise lattice2[:, i] is.

  • row_wise – If true, basis vectors are aligned in row wise, otherwise in column wise.