def subcrystal(self, index_set=None, generators=None, max_depth=float("inf"), direction="both"): r""" Construct the subcrystal from ``generators`` using `e_i` and `f_i` for all `i` in ``index_set``. INPUT: - ``index_set`` -- (Default: ``None``) The index set; if ``None`` then use the index set of the crystal - ``generators`` -- (Default: ``None``) The list of generators; if ``None`` then use the module generators of the crystal - ``max_depth`` -- (Default: infinity) The maximum depth to build - ``direction`` -- (Default: ``'both'``) The direction to build the subcrystal. It can be one of the following: - ``'both'`` - Using both `e_i` and `f_i` - ``'upper'`` - Using `e_i` - ``'lower'`` - Using `f_i` EXAMPLES:: sage: C = crystals.KirillovReshetikhin(['A',3,1], 1, 2) sage: S = list(C.subcrystal(index_set=[1,2])); S [[[1, 1]], [[1, 2]], [[1, 3]], [[2, 2]], [[2, 3]], [[3, 3]]] sage: C.cardinality() 10 sage: len(S) 6 sage: list(C.subcrystal(index_set=[1,3], generators=[C(1,4)])) [[[1, 4]], [[2, 4]], [[1, 3]], [[2, 3]]] sage: list(C.subcrystal(index_set=[1,3], generators=[C(1,4)], max_depth=1)) [[[1, 4]], [[2, 4]], [[1, 3]]] sage: list(C.subcrystal(index_set=[1,3], generators=[C(1,4)], direction='upper')) [[[1, 4]], [[1, 3]]] sage: list(C.subcrystal(index_set=[1,3], generators=[C(1,4)], direction='lower')) [[[1, 4]], [[2, 4]]] """ if index_set is None: index_set = self.index_set() if generators is None: generators = self.module_generators from sage.combinat.backtrack import TransitiveIdealGraded if direction == 'both': return TransitiveIdealGraded(lambda x: [x.f(i) for i in index_set] + [x.e(i) for i in index_set], generators, max_depth) if direction == 'upper': return TransitiveIdealGraded(lambda x: [x.e(i) for i in index_set], generators, max_depth) if direction == 'lower': return TransitiveIdealGraded(lambda x: [x.f(i) for i in index_set], generators, max_depth) raise ValueError("direction must be either 'both', 'upper', or 'lower'")
def __iter__(self, index_set=None, max_depth = float("inf")): """ Returns the iterator of ``self``. INPUT: - ``index_set`` -- (Default: ``None``) The index set; if ``None`` then use the index set of the crystal - ``max_depth`` -- (Default: infinity) The maximum depth to build EXAMPLES:: sage: C = CrystalOfLSPaths(['A',2,1],[0,1,0]) sage: [p for p in C.__iter__(max_depth=3)] [(Lambda[1],), (Lambda[0] - Lambda[1] + Lambda[2],), (2*Lambda[0] - Lambda[2],), (-Lambda[0] + 2*Lambda[2] - delta,), (1/2*Lambda[0] + Lambda[1] - Lambda[2] - 1/2*delta, -1/2*Lambda[0] + Lambda[2] - 1/2*delta), (-Lambda[0] + Lambda[1] + 1/2*Lambda[2] - delta, Lambda[0] - 1/2*Lambda[2])] sage: [p for p in C.__iter__(index_set=[0, 1], max_depth=3)] [(Lambda[1],), (Lambda[0] - Lambda[1] + Lambda[2],), (-Lambda[0] + 2*Lambda[2] - delta,)] """ if index_set is None: index_set = self.index_set() from sage.combinat.backtrack import TransitiveIdealGraded return TransitiveIdealGraded(lambda x: [x.f(i) for i in index_set], self.module_generators, max_depth).__iter__()
def __iter__(self, index_set=None, max_depth=float('inf')): """ Return an iterator over the elements of ``self``. INPUT: - ``index_set`` -- (Default: ``None``) The index set; if ``None`` then use the index set of the crystal - ``max_depth`` -- (Default: infinity) The maximum depth to build The iteration order is not specified except that, if ``max_depth`` is finite, then the iteration goes depth by depth. EXAMPLES:: sage: C = crystals.LSPaths(['A',2,1],[-1,0,1]) sage: C.__iter__.__module__ 'sage.categories.crystals' sage: g = C.__iter__() sage: g.next() (-Lambda[0] + Lambda[2],) sage: g.next() (Lambda[0] - Lambda[1] + delta,) sage: g.next() (Lambda[1] - Lambda[2] + delta,) sage: g.next() (-Lambda[0] + Lambda[2] + delta,) sage: g.next() (Lambda[1] - Lambda[2],) sage: sorted(C.__iter__(index_set=[1,2]), key=str) [(-Lambda[0] + Lambda[2],), (Lambda[0] - Lambda[1],), (Lambda[1] - Lambda[2],)] sage: sorted(C.__iter__(max_depth=1), key=str) [(-Lambda[0] + Lambda[2],), (Lambda[0] - Lambda[1] + delta,), (Lambda[1] - Lambda[2],)] """ if index_set is None: index_set = self.index_set() if max_depth < float('inf'): from sage.combinat.backtrack import TransitiveIdealGraded return TransitiveIdealGraded(lambda x: [x.f(i) for i in index_set] + [x.e(i) for i in index_set], self.module_generators, max_depth).__iter__() from sage.combinat.backtrack import TransitiveIdeal return TransitiveIdeal(lambda x: [x.f(i) for i in index_set] + [x.e(i) for i in index_set], self.module_generators).__iter__()
def __iter__(self, index_set=None, max_depth=float('inf')): """ Returns the iterator of ``self``. INPUT: - ``index_set`` -- (Default: ``None``) The index set; if ``None`` then use the index set of the crystal - ``max_depth`` -- (Default: infinity) The maximum depth to build EXAMPLES:: sage: C = CrystalOfLSPaths(['A',2,1],[-1,0,1]) sage: C.__iter__.__module__ 'sage.categories.crystals' sage: g = C.__iter__() sage: g.next() (-Lambda[0] + Lambda[2],) sage: g.next() (Lambda[0] - Lambda[1] + delta,) sage: g.next() (Lambda[1] - Lambda[2] + delta,) sage: g.next() (Lambda[1] - Lambda[2],) sage: g.next() (Lambda[0] - Lambda[1],) sage: h = C.__iter__(index_set=[1,2]) sage: h.next() (-Lambda[0] + Lambda[2],) sage: h.next() (Lambda[1] - Lambda[2],) sage: h.next() (Lambda[0] - Lambda[1],) sage: h.next() Traceback (most recent call last): ... StopIteration sage: g = C.__iter__(max_depth=1) sage: g.next() (-Lambda[0] + Lambda[2],) sage: g.next() (Lambda[1] - Lambda[2],) sage: g.next() (Lambda[0] - Lambda[1] + delta,) sage: h.next() Traceback (most recent call last): ... StopIteration """ if index_set is None: index_set = self.index_set() if max_depth < float('inf'): from sage.combinat.backtrack import TransitiveIdealGraded return TransitiveIdealGraded(lambda x: [x.f(i) for i in index_set] + [x.e(i) for i in index_set], self.module_generators, max_depth).__iter__() from sage.combinat.backtrack import TransitiveIdeal return TransitiveIdeal(lambda x: [x.f(i) for i in index_set] + [x.e(i) for i in index_set], self.module_generators).__iter__()