44 | | [An inequality (-1, 0) x + 1 >= 0, An inequality (0, -1) x + 1 >= 0, An inequality (0, 1) x + 1 >= 0, An inequality (1, 0) x + 1 >= 0, An inequality (1, 1) x + 1 >= 0] |
| 53 | [An inequality (-1, 0) x + 1 >= 0, |
| 54 | An inequality (0, -1) x + 1 >= 0, |
| 55 | An inequality (0, 1) x + 1 >= 0, |
| 56 | An inequality (1, 0) x + 1 >= 0, |
| 57 | An inequality (1, 1) x + 1 >= 0] |
64 | | [[-3/2, 0, -1/2], [-3/2, 0, 3/2], [-3/2, 1, -3/2], [-3/2, 2, -3/2], [-3/2, 2, 3/2], [-1/2, -1, -1/2], [-1/2, 0, -3/2], [1/2, -2, 1/2], [1/2, -2, 3/2], [3/2, -2, 1/2], [3/2, -2, 3/2], [3/2, 0, -3/2], [3/2, 2, -3/2], [3/2, 2, 3/2]] |
| 78 | [A vertex at (-3/2, 0, -1/2), A vertex at (-3/2, 0, 3/2), |
| 79 | A vertex at (-3/2, 1, -3/2), A vertex at (-3/2, 2, -3/2), |
| 80 | A vertex at (-3/2, 2, 3/2), A vertex at (-1/2, -1, -1/2), |
| 81 | A vertex at (-1/2, 0, -3/2), A vertex at (1/2, -2, 1/2), |
| 82 | A vertex at (1/2, -2, 3/2), A vertex at (3/2, -2, 1/2), |
| 83 | A vertex at (3/2, -2, 3/2), A vertex at (3/2, 0, -3/2), |
| 84 | A vertex at (3/2, 2, -3/2), A vertex at (3/2, 2, 3/2)] |
| 85 | |
66 | | [[-3, 0, 0], [-3, 0, 3], [-3, 2, -2], [-3, 4, -3], [-3, 5, -3], [-3, 5, 3], [-2, 1, -2], [-2, 3, -3], [-1, -2, 0], [-1, -1, -1], [1, -4, 1], [1, -3, 0], [2, -5, 2], [2, -5, 3], [3, -5, 2], [3, -5, 3], [3, -3, 0], [3, 3, -3], [3, 5, -3], [3, 5, 3]] |
| 87 | [A vertex at (-3, 0, 0), A vertex at (-3, 0, 3), |
| 88 | A vertex at (-3, 2, -2), A vertex at (-3, 4, -3), |
| 89 | A vertex at (-3, 5, -3), A vertex at (-3, 5, 3), |
| 90 | A vertex at (-2, 1, -2), A vertex at (-2, 3, -3), |
| 91 | A vertex at (-1, -2, 0), A vertex at (-1, -1, -1), |
| 92 | A vertex at (1, -4, 1), A vertex at (1, -3, 0), |
| 93 | A vertex at (2, -5, 2), A vertex at (2, -5, 3), |
| 94 | A vertex at (3, -5, 2), A vertex at (3, -5, 3), |
| 95 | A vertex at (3, -3, 0), A vertex at (3, 3, -3), |
| 96 | A vertex at (3, 5, -3), A vertex at (3, 5, 3)] |
85 | | """ |
86 | | self._cartan_type = CartanType( cartan_type ) |
87 | | assert self._cartan_type.is_finite() |
88 | | root_space = self._cartan_type.root_system().root_space() |
89 | | # TODO: generalize this as a method of root lattice realization |
90 | | rhocheck = sum( beta.associated_coroot() for beta in root_space.positive_roots() )/2 |
91 | | I = root_space.index_set() |
92 | | inequalities = [] |
93 | | for orbit in root_space.almost_positive_roots_decomposition(): |
94 | | c = rhocheck.coefficient(orbit[0].leading_support()) |
95 | | for beta in orbit: |
96 | | inequalities.append( [c] + [ beta.coefficient(i) for i in I ] ) |
97 | | Polyhedron_QQ_ppl.__init__(self, len(I), None, [inequalities,[]]) |
98 | | # check that there are non non trivial facets |
99 | | assert self.n_facets() == len(inequalities) |
| 113 | |
| 114 | |
| 115 | |
| 116 | class Associahedron_class(Polyhedron_QQ_ppl): |
| 117 | r""" |
| 118 | The Python class of an associahedron |
| 119 | |
| 120 | You should use the :func:`Associahedron` convenience function to |
| 121 | construct associahedra from the cartan type. |
| 122 | |
| 123 | TESTS:: |
| 124 | |
| 125 | sage: Asso = Associahedron(['A',2]); Asso |
| 126 | Generalized associahedron of type ['A', 2] with 5 vertices |
| 127 | sage: TestSuite(Asso).run() |
| 128 | """ |
| 170 | |
| 171 | |
| 172 | |
| 173 | |
| 174 | |
| 175 | |
| 176 | class Associahedra(Polyhedra_QQ_ppl): |
| 177 | """ |
| 178 | Parent of Associahedra of specified dimension |
| 179 | |
| 180 | EXAMPLES:: |
| 181 | |
| 182 | sage: from sage.combinat.root_system.associahedron import Associahedra |
| 183 | sage: parent = Associahedra(QQ,2); parent |
| 184 | Polyhedra in QQ^2 |
| 185 | sage: type(parent) |
| 186 | <class 'sage.combinat.root_system.associahedron.Associahedra_with_category'> |
| 187 | sage: parent(['A',2]) |
| 188 | Generalized associahedron of type ['A', 2] with 5 vertices |
| 189 | |
| 190 | Importantly, the parent knows the dimension of the ambient |
| 191 | space. If you try to construct an associahedron of a different |
| 192 | dimension, a ``ValueError`` is raised:: |
| 193 | |
| 194 | sage: parent(['A',3]) |
| 195 | Traceback (most recent call last): |
| 196 | ... |
| 197 | ValueError: V-representation data requires a list of length ambient_dim |
| 198 | """ |
| 199 | Element = Associahedron_class |
| 200 | |
| 201 | def _element_constructor_(self, cartan_type, **kwds): |
| 202 | """ |
| 203 | The element constructor. |
| 204 | |
| 205 | This method is called internally when we try to convert |
| 206 | something into an element. In this case, the only thing that |
| 207 | can be converted into an associahedron is the Cartan type. |
| 208 | |
| 209 | EXAMPLES:: |
| 210 | |
| 211 | sage: from sage.combinat.root_system.associahedron import Associahedra |
| 212 | sage: parent = Associahedra(QQ,2) |
| 213 | sage: parent(['A',2]) |
| 214 | Generalized associahedron of type ['A', 2] with 5 vertices |
| 215 | sage: parent._element_constructor_(['A',2]) |
| 216 | Generalized associahedron of type ['A', 2] with 5 vertices |
| 217 | """ |
| 218 | cartan_type = CartanType( cartan_type ) |
| 219 | assert cartan_type.is_finite() |
| 220 | root_space = cartan_type.root_system().root_space() |
| 221 | # TODO: generalize this as a method of root lattice realization |
| 222 | rhocheck = sum( beta.associated_coroot() for beta in root_space.positive_roots() )/2 |
| 223 | I = root_space.index_set() |
| 224 | inequalities = [] |
| 225 | for orbit in root_space.almost_positive_roots_decomposition(): |
| 226 | c = rhocheck.coefficient(orbit[0].leading_support()) |
| 227 | for beta in orbit: |
| 228 | inequalities.append( [c] + [ beta.coefficient(i) for i in I ] ) |
| 229 | associahedron = super(Associahedra, self)._element_constructor_(None, [inequalities,[]]) |
| 230 | associahedron._cartan_type = cartan_type |
| 231 | return associahedron |
| 232 | |
| 233 | |