Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

""" 

Lattice Euclidean Group Elements 

 

The classes here are used to return particular isomorphisms of 

:class:`PPL lattice 

polytopes<sage.geometry.polyhedron.ppl_lattice_polytope.LatticePolytope_PPL_class>`. 

""" 

######################################################################## 

# Copyright (C) 2012 Volker Braun <vbraun.name@gmail.com> 

# 

# Distributed under the terms of the GNU General Public License (GPL) 

# 

# http://www.gnu.org/licenses/ 

######################################################################## 

 

from sage.structure.sage_object import SageObject 

from sage.rings.integer_ring import ZZ 

from sage.modules.all import vector 

from sage.matrix.constructor import matrix 

 

 

######################################################################## 

class LatticePolytopeError(Exception): 

""" 

Base class for errors from lattice polytopes 

""" 

pass 

 

 

######################################################################## 

class LatticePolytopesNotIsomorphicError(LatticePolytopeError): 

""" 

Raised when two lattice polytopes are not isomorphic. 

""" 

pass 

 

 

######################################################################## 

class LatticePolytopeNoEmbeddingError(LatticePolytopeError): 

""" 

Raised when no embedding of the desired kind can be found. 

""" 

pass 

 

 

######################################################################## 

class LatticeEuclideanGroupElement(SageObject): 

 

def __init__(self, A, b): 

""" 

An element of the lattice Euclidean group. 

 

Note that this is just intended as a container for results from 

LatticePolytope_PPL. There is no group-theoretic functionality to 

speak of. 

 

EXAMPLES:: 

 

sage: from sage.geometry.polyhedron.ppl_lattice_polytope import LatticePolytope_PPL, C_Polyhedron 

sage: from sage.geometry.polyhedron.lattice_euclidean_group_element import LatticeEuclideanGroupElement 

sage: M = LatticeEuclideanGroupElement([[1,2],[2,3],[-1,2]], [1,2,3]) 

sage: M 

The map A*x+b with A= 

[ 1 2] 

[ 2 3] 

[-1 2] 

b = 

(1, 2, 3) 

sage: M._A 

[ 1 2] 

[ 2 3] 

[-1 2] 

sage: M._b 

(1, 2, 3) 

sage: M(vector([0,0])) 

(1, 2, 3) 

sage: M(LatticePolytope_PPL((0,0),(1,0),(0,1))) 

A 2-dimensional lattice polytope in ZZ^3 with 3 vertices 

sage: _.vertices() 

((1, 2, 3), (2, 4, 2), (3, 5, 5)) 

""" 

self._A = matrix(ZZ, A) 

self._b = vector(ZZ, b) 

assert self._A.nrows() == self._b.degree() 

 

def __call__(self, x): 

""" 

Return the image of ``x`` 

 

INPUT: 

 

- ``x`` -- a vector or lattice polytope. 

 

EXAMPLES:: 

 

sage: from sage.geometry.polyhedron.ppl_lattice_polytope import LatticePolytope_PPL, C_Polyhedron 

sage: from sage.geometry.polyhedron.lattice_euclidean_group_element import LatticeEuclideanGroupElement 

sage: M = LatticeEuclideanGroupElement([[1,2],[2,3],[-1,2]], [1,2,3]) 

sage: M(vector(ZZ, [11,13])) 

(38, 63, 18) 

sage: M(LatticePolytope_PPL((0,0),(1,0),(0,1))) 

A 2-dimensional lattice polytope in ZZ^3 with 3 vertices 

""" 

from sage.geometry.polyhedron.ppl_lattice_polytope import ( 

LatticePolytope_PPL, LatticePolytope_PPL_class) 

if isinstance(x, LatticePolytope_PPL_class): 

if x.is_empty(): 

from sage.libs.ppl import C_Polyhedron 

return LatticePolytope_PPL(C_Polyhedron(self._b.degree(), 

'empty')) 

return LatticePolytope_PPL(*[self(v) for v in x.vertices()]) 

pass 

v = self._A*x+self._b 

v.set_immutable() 

 

return v 

 

def _repr_(self): 

r""" 

Return a string representation 

 

EXAMPLES:: 

 

sage: from sage.geometry.polyhedron.lattice_euclidean_group_element import LatticeEuclideanGroupElement 

sage: M = LatticeEuclideanGroupElement([[1,2],[2,3],[-1,2]], [1,2,3]) 

sage: M._repr_() 

'The map A*x+b with A=\n[ 1 2]\n[ 2 3]\n[-1 2]\nb = \n(1, 2, 3)' 

""" 

s = 'The map A*x+b with A=\n'+str(self._A) 

s += '\nb = \n'+str(self._b) 

return s 

 

def domain_dim(self): 

""" 

Return the dimension of the domain lattice 

 

EXAMPLES:: 

 

sage: from sage.geometry.polyhedron.lattice_euclidean_group_element import LatticeEuclideanGroupElement 

sage: M = LatticeEuclideanGroupElement([[1,2],[2,3],[-1,2]], [1,2,3]) 

sage: M 

The map A*x+b with A= 

[ 1 2] 

[ 2 3] 

[-1 2] 

b = 

(1, 2, 3) 

sage: M.domain_dim() 

2 

""" 

return self._A.ncols() 

 

def codomain_dim(self): 

""" 

Return the dimension of the codomain lattice 

 

EXAMPLES:: 

 

sage: from sage.geometry.polyhedron.lattice_euclidean_group_element import LatticeEuclideanGroupElement 

sage: M = LatticeEuclideanGroupElement([[1,2],[2,3],[-1,2]], [1,2,3]) 

sage: M 

The map A*x+b with A= 

[ 1 2] 

[ 2 3] 

[-1 2] 

b = 

(1, 2, 3) 

sage: M.codomain_dim() 

3 

 

Note that this is not the same as the rank. In fact, the 

codomain dimension depends only on the matrix shape, and not 

on the rank of the linear mapping:: 

 

sage: zero_map = LatticeEuclideanGroupElement([[0,0],[0,0],[0,0]], [0,0,0]) 

sage: zero_map.codomain_dim() 

3 

""" 

return self._A.nrows()