def voronoi_cell(self, radius=None): """ Compute the Voronoi cell of a lattice, returning a Polyhedron. INPUT: - ``radius`` -- (default: automatic determination) radius of ball containing considered vertices OUTPUT: The Voronoi cell as a Polyhedron instance. The result is cached so that subsequent calls to this function return instantly. EXAMPLES:: sage: from sage.modules.free_module_integer import IntegerLattice sage: L = IntegerLattice([[1, 0], [0, 1]]) sage: V = L.voronoi_cell() sage: V.Vrepresentation() (A vertex at (1/2, -1/2), A vertex at (1/2, 1/2), A vertex at (-1/2, 1/2), A vertex at (-1/2, -1/2)) The volume of the Voronoi cell is the square root of the discriminant of the lattice:: sage: L = IntegerLattice(Matrix(ZZ, 4, 4, [[0,0,1,-1],[1,-1,2,1],[-6,0,3,3,],[-6,-24,-6,-5]])); L Free module of degree 4 and rank 4 over Integer Ring User basis matrix: [ 0 0 1 -1] [ 1 -1 2 1] [ -6 0 3 3] [ -6 -24 -6 -5] sage: V = L.voronoi_cell() # long time sage: V.volume() # long time 678 sage: sqrt(L.discriminant()) 678 Lattices not having full dimension are handled as well:: sage: L = IntegerLattice([[2, 0, 0], [0, 2, 0]]) sage: V = L.voronoi_cell() sage: V.Hrepresentation() (An inequality (-1, 0, 0) x + 1 >= 0, An inequality (0, -1, 0) x + 1 >= 0, An inequality (1, 0, 0) x + 1 >= 0, An inequality (0, 1, 0) x + 1 >= 0) ALGORITHM: Uses parts of the algorithm from [Vit1996]_. REFERENCES: .. [Vit1996] \E. Viterbo, E. Biglieri. *Computing the Voronoi Cell of a Lattice: The Diamond-Cutting Algorithm*. IEEE Transactions on Information Theory, 1996. """ if not self._basis_is_LLL_reduced: self.LLL() B = self.reduced_basis from diamond_cutting import calculate_voronoi_cell return calculate_voronoi_cell(B, radius=radius)
def voronoi_cell(self, radius=None): """ Compute the Voronoi cell of a lattice, returning a Polyhedron. INPUT: - ``radius`` -- (default: automatic determination) radius of ball containing considered vertices OUTPUT: The Voronoi cell as a Polyhedron instance. The result is cached so that subsequent calls to this function return instantly. EXAMPLES:: sage: from sage.modules.free_module_integer import IntegerLattice sage: L = IntegerLattice([[1, 0], [0, 1]]) sage: V = L.voronoi_cell() sage: V.Vrepresentation() (A vertex at (1/2, -1/2), A vertex at (1/2, 1/2), A vertex at (-1/2, 1/2), A vertex at (-1/2, -1/2)) The volume of the Voronoi cell is the square root of the discriminant of the lattice:: sage: L = IntegerLattice(Matrix(ZZ, 4, 4, [[0,0,1,-1],[1,-1,2,1],[-6,0,3,3,],[-6,-24,-6,-5]])); L Free module of degree 4 and rank 4 over Integer Ring User basis matrix: [ 0 0 1 -1] [ 1 -1 2 1] [ -6 0 3 3] [ -6 -24 -6 -5] sage: V = L.voronoi_cell() # long time sage: V.volume() # long time 678 sage: sqrt(L.discriminant()) 678 Lattices not having full dimension are handled as well:: sage: L = IntegerLattice([[2, 0, 0], [0, 2, 0]]) sage: V = L.voronoi_cell() sage: V.Hrepresentation() (An inequality (-1, 0, 0) x + 1 >= 0, An inequality (0, -1, 0) x + 1 >= 0, An inequality (1, 0, 0) x + 1 >= 0, An inequality (0, 1, 0) x + 1 >= 0) ALGORITHM: Uses parts of the algorithm from [Vit1996]_. REFERENCES: .. [Vit1996] E. Viterbo, E. Biglieri. *Computing the Voronoi Cell of a Lattice: The Diamond-Cutting Algorithm*. IEEE Transactions on Information Theory, 1996. """ if not self._basis_is_LLL_reduced: self.LLL() B = self.reduced_basis from diamond_cutting import calculate_voronoi_cell return calculate_voronoi_cell(B, radius=radius)
def voronoi_cell(self, radius=None): """ Compute the Voronoi cell of a lattice, returning a Polyhedron. INPUT: - ``radius`` -- radius of ball containing considered vertices (default: automatic determination). OUTPUT: The Voronoi cell as a Polyhedron instance. The result is cached so that subsequent calls to this function return instantly. EXAMPLES:: sage: L = Lattice([[1, 0], [0, 1]]) sage: V = L.voronoi_cell() sage: V.Vrepresentation() (A vertex at (1/2, -1/2), A vertex at (1/2, 1/2), A vertex at (-1/2, 1/2), A vertex at (-1/2, -1/2)) The volume of the Voronoi cell is the square root of the discriminant of the lattice:: sage: L = random_lattice(4); L ZZ-lattice of degree 4 and rank 4 Inner product matrix: [ 2 1 0 -1] [ 1 7 3 1] [ 0 3 54 3] [ -1 1 3 673] Basis matrix: [ 0 0 1 -1] [ 1 -1 2 1] [ -6 0 3 3] [ -6 -24 -6 -5] sage: V = L.voronoi_cell() sage: V.convex_volume() 678.0 sage: sqrt(L.discriminant()) 678 Lattices not having full dimension are handled as well:: sage: L = Lattice([[2, 0, 0], [0, 2, 0]]) sage: V = L.voronoi_cell() sage: V.Hrepresentation() (An inequality (-1, 0, 0) x + 1 >= 0, An inequality (0, -1, 0) x + 1 >= 0, An inequality (1, 0, 0) x + 1 >= 0, An inequality (0, 1, 0) x + 1 >= 0) "Over-dimensional" lattices are reduced first:: sage: L = Lattice([[1, 0], [2, 0], [0, 2]]) sage: L.voronoi_cell().Vrepresentation() (A vertex at (1/2, -1), A vertex at (1/2, 1), A vertex at (-1/2, 1), A vertex at (-1/2, -1)) ALGORITHM: Uses parts of the algorithm from [Vit1996]. REFERENCES: .. [Vit1996] E. Viterbo, E. Biglieri. Computing the Voronoi Cell of a Lattice: The Diamond-Cutting Algorithm. IEEE Transactions on Information Theory, 1996. """ if self.__voronoi_cell is None: basis_matrix = self.reduced_embedded_basis_matrix() self.__voronoi_cell = calculate_voronoi_cell(basis_matrix, radius=radius) return self.__voronoi_cell