def __init__(self, base_ring, cartan_type, level, twisted): """ Initialize ``self``. EXAMPLES:: sage: Q = QSystem(QQ, ['A',2]) sage: TestSuite(Q).run() sage: Q = QSystem(QQ, ['E',6,2], twisted=True) sage: TestSuite(Q).run() """ self._cartan_type = cartan_type self._level = level self._twisted = twisted indices = tuple(itertools.product(cartan_type.index_set(), [1])) basis = IndexedFreeAbelianMonoid(indices, prefix='Q', bracket=False) # This is used to do the reductions if self._twisted: self._cm = cartan_type.classical().cartan_matrix() else: self._cm = cartan_type.cartan_matrix() self._Irev = {ind: pos for pos,ind in enumerate(self._cm.index_set())} self._poly = PolynomialRing(ZZ, ['q'+str(i) for i in self._cm.index_set()]) category = Algebras(base_ring).Commutative().WithBasis() CombinatorialFreeModule.__init__(self, base_ring, basis, prefix='Q', category=category)
def __init__(self, root_system, base_ring, extended): """ TESTS:: sage: R = RootSystem(['A',4]) sage: from sage.combinat.root_system.weight_space import WeightSpace sage: Q = WeightSpace(R, QQ); Q Weight space over the Rational Field of the Root system of type ['A', 4] sage: TestSuite(Q).run() sage: WeightSpace(R, QQ, extended = True) Traceback (most recent call last): ... AssertionError: extended weight lattices are only implemented for affine root systems """ basis_keys = root_system.index_set() self._extended = extended if extended: assert root_system.cartan_type().is_affine(), "extended weight lattices are only implemented for affine root systems" basis_keys = tuple(basis_keys) + ("delta",) self.root_system = root_system CombinatorialFreeModule.__init__(self, base_ring, basis_keys, prefix = "Lambdacheck" if root_system.dual_side else "Lambda", latex_prefix = "\\Lambda^\\vee" if root_system.dual_side else "\\Lambda", category = WeightLatticeRealizations(base_ring)) if root_system.cartan_type().is_affine() and not extended: # For an affine type, register the quotient map from the # extended weight lattice/space to the weight lattice/space domain = root_system.weight_space(base_ring, extended=True) domain.module_morphism(self.fundamental_weight, codomain = self ).register_as_coercion()
def __init__(self, I, prefix='R'): """ Initialize ``self``. TESTS:: sage: P = posets.BooleanLattice(3) sage: R = P.incidence_algebra(QQ).reduced_subalgebra() sage: TestSuite(R).run() # long time """ self._ambient = I EC = {} P = self._ambient._poset if not P.is_finite(): raise NotImplementedError("only implemented for finite posets") for i in self._ambient.basis().keys(): S = P.subposet(P.interval(*i)) added = False for k in EC: if S._hasse_diagram.is_isomorphic(k._hasse_diagram): EC[k].append(i) added = True break if not added: EC[S] = [i] self._equiv_classes = map(sorted, EC.values()) self._equiv_classes = {cls[0]: cls for cls in self._equiv_classes} cat = Algebras(I.base_ring()).FiniteDimensional().WithBasis() CombinatorialFreeModule.__init__(self, I.base_ring(), sorted(self._equiv_classes.keys()), prefix=prefix, category=cat)
def __init__(self, base_ring, cell_complex, cohomology=False, cat=None): """ Initialize ``self``. EXAMPLES:: sage: RP2 = simplicial_complexes.ProjectivePlane() sage: H = RP2.homology_with_basis(QQ) sage: TestSuite(H).run() sage: H = RP2.homology_with_basis(GF(2)) sage: TestSuite(H).run() sage: H = RP2.cohomology_ring(GF(2)) sage: TestSuite(H).run() sage: H = RP2.cohomology_ring(GF(5)) sage: TestSuite(H).run() sage: H = simplicial_complexes.ComplexProjectivePlane().cohomology_ring() sage: TestSuite(H).run() """ # phi is the associated chain contraction. # M is the homology chain complex. phi, M = cell_complex.algebraic_topological_model(base_ring) if cohomology: phi = phi.dual() # We only need the rank of M in each degree, and since # we're working over a field, we don't need to dualize M # if working with cohomology. cat = Modules(base_ring).WithBasis().Graded().or_subcategory(cat) self._contraction = phi self._complex = cell_complex self._cohomology = cohomology self._graded_indices = {deg: range(M.free_module_rank(deg)) for deg in range(cell_complex.dimension()+1)} indices = [(deg, i) for deg in self._graded_indices for i in self._graded_indices[deg]] CombinatorialFreeModule.__init__(self, base_ring, indices, category=cat)
def __init__(self, NCSymD): """ EXAMPLES:: sage: w = SymmetricFunctionsNonCommutingVariables(QQ).dual().w() sage: TestSuite(w).run() """ def lt_set_part(A, B): A = sorted(map(sorted, A)) B = sorted(map(sorted, B)) for i in range(len(A)): if A[i] > B[i]: return 1 elif A[i] < B[i]: return -1 return 0 CombinatorialFreeModule.__init__( self, NCSymD.base_ring(), SetPartitions(), prefix="w", bracket=False, monomial_cmp=lt_set_part, category=NCSymDualBases(NCSymD), )
def __init__(self, group, base_ring=IntegerRing()): r""" See :class:`GroupAlgebra` for full documentation. EXAMPLES:: sage: GroupAlgebra(GL(3, GF(7))) Group algebra of group "General Linear Group of degree 3 over Finite Field of size 7" over base ring Integer Ring """ from sage.groups.group import Group from sage.groups.old import Group as OldGroup if not base_ring.is_commutative(): raise NotImplementedError("Base ring must be commutative") if not isinstance(group, (Group, OldGroup)): raise TypeError('"%s" is not a group' % group) self._group = group CombinatorialFreeModule.__init__(self, base_ring, group, prefix='', bracket=False, category=HopfAlgebrasWithBasis(base_ring)) if not base_ring.has_coerce_map_from(group) : ## some matrix groups assume that coercion is only valid to ## other matrix groups. This is a workaround ## call _element_constructor_ to coerce group elements #try : self._populate_coercion_lists_(coerce_list=[base_ring, group]) #except TypeError : # self._populate_coercion_lists_( coerce_list = [base_ring] ) else : self._populate_coercion_lists_(coerce_list=[base_ring])
def __init__(self, R, n, names): """ The free algebra on `n` generators over a base ring. EXAMPLES:: sage: F.<x,y,z> = FreeAlgebra(QQ, 3); F # indirect doctet Free Algebra on 3 generators (x, y, z) over Rational Field TEST: Note that the following is *not* the recommended way to create a free algebra:: sage: from sage.algebras.free_algebra import FreeAlgebra_generic sage: FreeAlgebra_generic(ZZ, 3, 'abc') Free Algebra on 3 generators (a, b, c) over Integer Ring """ if R not in Rings(): raise TypeError("Argument R must be a ring.") self.__ngens = n indices = FreeMonoid(n, names=names) cat = AlgebrasWithBasis(R) CombinatorialFreeModule.__init__(self, R, indices, prefix='F', category=cat) self._assign_names(indices.variable_names())
def __init__(self, cell_complex, degree, cells=None, base_ring=None): """ EXAMPLES:: sage: T = cubical_complexes.Torus() sage: T.n_chains(2, QQ, cochains=True) Free module generated by {[1,1] x [0,1] x [1,1] x [0,1], [0,0] x [0,1] x [0,1] x [1,1], [0,0] x [0,1] x [1,1] x [0,1], [0,0] x [0,1] x [0,0] x [0,1], [0,1] x [1,1] x [0,1] x [0,0], [0,1] x [0,0] x [0,0] x [0,1], [1,1] x [0,1] x [0,1] x [0,0], [0,1] x [1,1] x [0,0] x [0,1], [0,0] x [0,1] x [0,1] x [0,0], [0,1] x [0,0] x [0,1] x [0,0], [0,1] x [0,0] x [1,1] x [0,1], [0,1] x [1,1] x [1,1] x [0,1], [0,1] x [0,0] x [0,1] x [1,1], [1,1] x [0,1] x [0,0] x [0,1], [1,1] x [0,1] x [0,1] x [1,1], [0,1] x [1,1] x [0,1] x [1,1]} over Rational Field sage: T.n_chains(2).dimension() 16 TESTS:: sage: T.n_chains(2, cochains=True).base_ring() Integer Ring sage: T.n_chains(8, cochains=True).dimension() 0 sage: T.n_chains(-3, cochains=True).dimension() 0 """ if base_ring is None: base_ring = ZZ CellComplexReference.__init__(self, cell_complex, degree, cells=cells) CombinatorialFreeModule.__init__( self, base_ring, self._cells, prefix='\\chi', bracket=['_', ''] )
def __init__(self, abstract, prefix, modules, index_set=None): """ INPUT: - ``abstract`` -- the abstract character ring - ``prefix`` -- a string (e.g. "S", "P") - ``modules`` -- a string (e.g. "simple", "projective indecomposable") - ``index_set`` -- a list (or iterable) the indexing set for the basis By default, the index set is given by the index set for the simple modules. EXAMPLES:: sage: G = HTrivialMonoids().Finite().example().character_ring(QQ) """ self._abstract = abstract self._modules = modules if index_set is None: index_set = abstract.base().simple_modules_index_set() CombinatorialFreeModule.__init__(self, abstract.base_ring(), index_set, prefix = prefix, category = (abstract.character_ring_category().Realizations(), abstract.Realizations()))
def __init__(self, QSym): r""" The dual immaculate basis of the non-commutative symmetric functions. This basis first appears in Berg, Bergeron, Saliola, Serrano and Zabrocki's " A lift of the Schur and Hall-Littlewood bases to non-commutative symmetric functions". EXAMPLES :: sage: QSym = QuasiSymmetricFunctions(QQ) sage: dI = QSym.dI() sage: dI([1,3,2])*dI([1]) # long time (6s on sage.math, 2013) dI[1, 1, 3, 2] + dI[2, 3, 2] sage: dI([1,3])*dI([1,1]) dI[1, 1, 1, 3] + dI[1, 1, 4] + dI[1, 2, 3] - dI[1, 3, 2] - dI[1, 4, 1] - dI[1, 5] + dI[2, 3, 1] + dI[2, 4] sage: dI([3,1])*dI([2,1]) # long time (7s on sage.math, 2013) dI[1, 1, 5] - dI[1, 4, 1, 1] - dI[1, 4, 2] - 2*dI[1, 5, 1] - dI[1, 6] - dI[2, 4, 1] - dI[2, 5] - dI[3, 1, 3] + dI[3, 2, 1, 1] + dI[3, 2, 2] + dI[3, 3, 1] + dI[4, 1, 1, 1] + 2*dI[4, 2, 1] + dI[4, 3] + dI[5, 1, 1] + dI[5, 2] sage: F = QSym.F() sage: dI(F[1,3,1]) -dI[1, 1, 1, 2] + dI[1, 1, 2, 1] - dI[1, 2, 2] + dI[1, 3, 1] sage: F(dI(F([2,1,3]))) F[2, 1, 3] """ CombinatorialFreeModule.__init__(self, QSym.base_ring(), Compositions(), prefix='dI', bracket=False, category=QSym.Bases())
def __init__(self, A): r""" Initialize ``self``. EXAMPLES:: sage: S = SymmetricGroupAlgebra(QQ, 3) sage: C = S.cellular_basis() sage: TestSuite(C).run() """ self._algebra = A I = [(la, s, t) for la in A.cell_poset() for s in A.cell_module_indices(la) for t in A.cell_module_indices(la)] # TODO: Use instead A.category().Realizations() so # operations are defined by coercion? cat = Algebras(A.category().base_ring()).FiniteDimensional().WithBasis().Cellular() CombinatorialFreeModule.__init__(self, A.base_ring(), I, prefix='C', bracket=False, category=cat) # Register coercions if A._to_cellular_element is not NotImplemented: to_cellular = A.module_morphism(A._to_cellular_element, codomain=self, category=cat) if A._from_cellular_index is NotImplemented: from_cellular = ~to_cellular else: from_cellular = self.module_morphism(A._from_cellular_index, codomain=A, category=cat) if A._to_cellular_element is NotImplemented: to_cellular = ~from_cellular to_cellular.register_as_coercion() from_cellular.register_as_coercion()
def __init__(self, basis, ambient, unitriangular, category): r""" Initialization. TESTS:: sage: from sage.modules.with_basis.subquotient import SubmoduleWithBasis sage: X = CombinatorialFreeModule(QQ, range(3), prefix="x"); x = X.basis() sage: ybas = (x[0]-x[1], x[1]-x[2]) sage: Y = SubmoduleWithBasis(ybas, X) sage: Y.print_options(prefix='y') sage: Y.basis().list() [y[0], y[1]] sage: [ y.lift() for y in Y.basis() ] [x[0] - x[1], x[1] - x[2]] sage: TestSuite(Y).run() """ import operator ring = ambient.base_ring() CombinatorialFreeModule.__init__(self, ring, basis.keys(), category=category.Subobjects()) self._ambient = ambient self._basis = basis self._unitriangular = unitriangular self.lift_on_basis = self._basis.__getitem__
def __init__(self, base_ring, n, variable_name, filtration): r""" Initialize ``self``. EXAMPLES:: sage: Y = Yangian(QQ, 4, filtration='loop') sage: TestSuite(Y).run(skip="_test_antipode") # Not implemented sage: Y = Yangian(QQ, 4, filtration='natural') sage: G = Y.algebra_generators() sage: elts = [Y.one(), G[1,2,2], G[1,1,4], G[3,3,1], G[1,2,1]*G[2,1,4]] sage: TestSuite(Y).run(elements=elts) # long time """ self._n = n self._filtration = filtration category = HopfAlgebrasWithBasis(base_ring).Filtered() if filtration == 'natural': category = category.Connected() self._index_set = tuple(range(1,n+1)) # The keys for the basis are tuples (l, i, j) indices = GeneratorIndexingSet(self._index_set) # We note that the generators are non-commutative, but we always sort # them, so they are, in effect, indexed by the free abelian monoid basis_keys = IndexedFreeAbelianMonoid(indices, bracket=False, prefix=variable_name) CombinatorialFreeModule.__init__(self, base_ring, basis_keys, sorting_key=Yangian._term_key, prefix=variable_name, category=category)
def __init__(self, M, prefix='I'): """ Initialize ``self``. TESTS:: sage: L = posets.BooleanLattice(4) sage: M = L.moebius_algebra(QQ) sage: TestSuite(M.I()).run() """ self._basis_name = "idempotent" CombinatorialFreeModule.__init__(self, M.base_ring(), tuple(M._lattice), prefix=prefix, category=MoebiusAlgebraBases(M)) ## Change of basis: E = M.E() self.module_morphism(self._to_natural_basis, codomain=E, category=self.category(), triangular='lower', unitriangular=True ).register_as_coercion() E.module_morphism(E._to_idempotent_basis, codomain=self, category=self.category(), triangular='lower', unitriangular=True ).register_as_coercion()
def __init__(self, R, names=None): """ Initialize ``self``. TESTS:: sage: A = algebras.FreeDendriform(QQ, '@'); A Free Dendriform algebra on one generator ['@'] over Rational Field sage: TestSuite(A).run() sage: F = algebras.FreeDendriform(QQ, 'xy') sage: TestSuite(F).run() # long time """ if names.cardinality() == 1: Trees = BinaryTrees() key = BinaryTree._sort_key else: Trees = LabelledBinaryTrees() key = LabelledBinaryTree._sort_key # Here one would need LabelledBinaryTrees(names) # so that one can restrict the labels to some fixed set self._alphabet = names cat = Algebras(R).WithBasis().Graded() CombinatorialFreeModule.__init__(self, R, Trees, latex_prefix="", sorting_key=key, category=cat)
def __init__(self, R, names=None): """ Initialize ``self``. TESTS:: sage: A = algebras.FreePreLie(QQ, '@'); A Free PreLie algebra on one generator ['@'] over Rational Field sage: TestSuite(A).run() sage: F = algebras.FreePreLie(QQ, 'xy') sage: TestSuite(F).run() # long time sage: F = algebras.FreePreLie(QQ, ZZ) sage: elts = F.some_elements()[:-1] # Skip the last element sage: TestSuite(F).run(some_elements=elts) # long time """ if names.cardinality() == 1: Trees = RootedTrees() else: Trees = LabelledRootedTrees() # Here one would need LabelledRootedTrees(names) # so that one can restrict the labels to some fixed set self._alphabet = names cat = MagmaticAlgebras(R).WithBasis().Graded() CombinatorialFreeModule.__init__(self, R, Trees, latex_prefix="", category=cat)
def __init__(self, g, basis_key, prefix, **kwds): """ Initialize ``self``. TESTS:: sage: L = lie_algebras.sl(QQ, 2) sage: PBW = L.pbw_basis() sage: E,F,H = PBW.algebra_generators() sage: TestSuite(PBW).run(elements=[E, F, H]) sage: TestSuite(PBW).run(elements=[E, F, H, E*F + H]) # long time """ if basis_key is not None: self._basis_key = basis_key else: self._basis_key_inverse = None R = g.base_ring() self._g = g monomials = IndexedFreeAbelianMonoid(g.basis().keys(), prefix, sorting_key=self._monoid_key, **kwds) CombinatorialFreeModule.__init__(self, R, monomials, prefix='', bracket=False, latex_bracket=False, sorting_key=self._monomial_key, category=Algebras(R).WithBasis().Filtered())
def __init__(self, root_system, base_ring, index_set=None): """ EXAMPLES:: sage: e = RootSystem(['A',3]).ambient_lattice() sage: s = e.simple_reflections() sage: L = RootSystem(['A',3]).coroot_lattice() sage: e.has_coerce_map_from(L) True sage: e(L.simple_root(1)) (1, -1, 0, 0) """ self.root_system = root_system if index_set is None: index_set = tuple(range(0, self.dimension())) CombinatorialFreeModule.__init__(self, base_ring, index_set, prefix='e', category = WeightLatticeRealizations(base_ring)) coroot_lattice = self.root_system.coroot_lattice() coroot_lattice.module_morphism(self.simple_coroot, codomain=self).register_as_coercion() # FIXME: here for backward compatibility; # Should we use dimension everywhere? self.n = self.dimension() ct = root_system.cartan_type() if ct.is_irreducible() and ct.type() == 'E': self._v0 = self([0,0,0,0,0, 0,1, 1]) self._v1 = self([0,0,0,0,0,-2,1,-1])
def __init__(self, R, names=None): """ Initialize ``self``. TESTS:: sage: A = algebras.FreePreLie(QQ, '@'); A Free PreLie algebra on one generator ['@'] over Rational Field sage: TestSuite(A).run() sage: A = algebras.FreePreLie(QQ, None); A Free PreLie algebra on one generator ['o'] over Rational Field sage: F = algebras.FreePreLie(QQ, 'xy') sage: TestSuite(F).run() # long time """ if names is None: Trees = RootedTrees() key = RootedTree.sort_key self._alphabet = Alphabet(['o']) else: Trees = LabelledRootedTrees() key = LabelledRootedTree.sort_key self._alphabet = names # Here one would need LabelledRootedTrees(names) # so that one can restrict the labels to some fixed set cat = MagmaticAlgebras(R).WithBasis().Graded() & LieAlgebras(R).WithBasis().Graded() CombinatorialFreeModule.__init__(self, R, Trees, latex_prefix="", sorting_key=key, category=cat)
def __init__(self, M, prefix='KL'): """ Initialize ``self``. TESTS:: sage: L = posets.BooleanLattice(4) sage: M = L.quantum_moebius_algebra() sage: TestSuite(M.KL()).run() # long time """ self._basis_name = "Kazhdan-Lusztig" CombinatorialFreeModule.__init__(self, M.base_ring(), tuple(M._lattice), prefix=prefix, category=MoebiusAlgebraBases(M)) ## Change of basis: E = M.E() phi = self.module_morphism(self._to_natural_basis, codomain=E, category=self.category(), triangular='lower', unitriangular=True, key=M._lattice._element_to_vertex) phi.register_as_coercion() (~phi).register_as_coercion()
def __init__(self, submodule, category): r""" Initialize this quotient of a module with basis by a submodule. TESTS:: sage: from sage.modules.with_basis.subquotient import QuotientModuleWithBasis sage: X = CombinatorialFreeModule(QQ, range(3), prefix="x"); x = X.basis() sage: I = X.submodule( (x[0]-x[1], x[1]-x[2]) ) sage: Y = QuotientModuleWithBasis(I) sage: Y.print_options(prefix='y') sage: Y Free module generated by {2} over Rational Field sage: Y.category() Join of Category of finite dimensional modules with basis over Rational Field and Category of vector spaces with basis over Rational Field and Category of quotients of sets sage: Y.basis().list() [y[2]] sage: TestSuite(Y).run() """ self._submodule = submodule self._ambient = submodule.ambient() embedding = submodule.lift indices = embedding.cokernel_basis_indices() CombinatorialFreeModule.__init__(self, submodule.base_ring(), indices, category=category)
def __init__(self, R, M, ordering=None): """ Initialize ``self``. EXAMPLES:: sage: M = matroids.Wheel(3) sage: OS = M.orlik_solomon_algebra(QQ) sage: TestSuite(OS).run() We check on the matroid associated to the graph with 3 vertices and 2 edges between each vertex:: sage: G = Graph([[1,2],[1,2],[2,3],[2,3],[1,3],[1,3]], multiedges=True) sage: M = Matroid(G) sage: OS = M.orlik_solomon_algebra(QQ) sage: elts = OS.some_elements() + list(OS.algebra_generators()) sage: TestSuite(OS).run(elements=elts) """ self._M = M self._sorting = {x:i for i,x in enumerate(ordering)} # set up the dictionary of broken circuits self._broken_circuits = dict() for c in self._M.circuits(): L = sorted(c, key=lambda x: self._sorting[x]) self._broken_circuits[frozenset(L[1:])] = L[0] cat = Algebras(R).FiniteDimensional().WithBasis().Graded() CombinatorialFreeModule.__init__(self, R, M.no_broken_circuits_sets(ordering), prefix='OS', bracket='{', sorting_key=self._sort_key, category=cat)
def __init__(self, kBoundedRing): r""" TESTS:: sage: Sym = SymmetricFunctions(QQ) sage: from sage.combinat.sf.new_kschur import kHomogeneous sage: KB = Sym.kBoundedSubspace(3,t=1) sage: kHomogeneous(KB) 3-bounded Symmetric Functions over Rational Field with t=1 in the 3-bounded homogeneous basis """ CombinatorialFreeModule.__init__(self, kBoundedRing.base_ring(), kBoundedRing.indices(), category= KBoundedSubspaceBases(kBoundedRing, kBoundedRing.t), prefix='h%d'%kBoundedRing.k) self._kBoundedRing = kBoundedRing self.k = kBoundedRing.k h = self.realization_of().ambient().homogeneous() self.lift = self._module_morphism(lambda x: h[x], codomain=h, triangular='lower', unitriangular=True, inverse_on_support=lambda p:p if p.get_part(0) <= self.k else None) self.ambient = ConstantFunction(h) self.lift.register_as_coercion() self.retract = SetMorphism(Hom(h, self, SetsWithPartialMaps()), self.lift.preimage) self.register_conversion(self.retract)
def __init__(self, alg, prefix="D"): r""" Initialize ``self``. EXAMPLES:: sage: TestSuite(DescentAlgebra(QQ, 4).D()).run() """ self._prefix = prefix self._basis_name = "standard" p_set = subsets(range(1, alg._n)) CombinatorialFreeModule.__init__(self, alg.base_ring(), map(tuple, p_set), category=DescentAlgebraBases(alg), bracket="", prefix=prefix) # Change of basis: B = alg.B() self.module_morphism(self.to_B_basis, codomain=B, category=self.category() ).register_as_coercion() B.module_morphism(B.to_D_basis, codomain=self, category=self.category() ).register_as_coercion() # Coercion to symmetric group algebra SGA = SymmetricGroupAlgebra(alg.base_ring(), alg._n) self.module_morphism(self.to_symmetric_group_algebra, codomain=SGA, category=Algebras(alg.base_ring()) ).register_as_coercion()
def __init__(self, root_system, base_ring): r""" EXAMPLES:: sage: R = RootSystem(["A",3,1]) sage: R.cartan_type().AmbientSpace <class 'sage.combinat.root_system.type_affine.AmbientSpace'> sage: e = R.ambient_space(); e Ambient space of the Root system of type ['A', 3, 1] sage: TestSuite(R.ambient_space()).run() sage: L = RootSystem(['A',3]).coroot_lattice() sage: e.has_coerce_map_from(L) True sage: e(L.simple_root(1)) e[0] - e[1] """ self.root_system = root_system classical = root_system.cartan_type().classical().root_system().ambient_space(base_ring) basis_keys = tuple(classical.basis().keys()) + ("delta","deltacheck") CombinatorialFreeModule.__init__(self, base_ring, basis_keys, prefix = "e", latex_prefix = "e", category = WeightLatticeRealizations(base_ring)) self._weight_space = self.root_system.weight_space(base_ring=base_ring,extended=True) self.classical().module_morphism(self.monomial, codomain=self).register_as_coercion() # Duplicated from ambient_space.AmbientSpace coroot_lattice = self.root_system.coroot_lattice() coroot_lattice.module_morphism(self.simple_coroot, codomain=self).register_as_coercion()
def __init__(self, A, category=None): """ Initialize ``self``. EXAMPLES:: sage: A = Algebras(QQ).WithBasis().Filtered().example() sage: grA = A.graded_algebra() sage: TestSuite(grA).run(elements=[prod(grA.algebra_generators())]) """ if A not in ModulesWithBasis(A.base_ring().category()).Filtered(): raise ValueError("the base algebra must be filtered and with basis") self._A = A base_ring = A.base_ring() base_one = base_ring.one() category = A.category().Graded().or_subcategory(category) try: opts = copy(A.print_options()) if not opts['prefix'] and not opts['bracket']: opts['bracket'] = '(' opts['prefix'] = opts['prefix'] + 'bar' except AttributeError: opts = {'prefix': 'Abar'} CombinatorialFreeModule.__init__(self, base_ring, A.basis().keys(), category=category, **opts) # Setup the conversion back phi = self.module_morphism(diagonal=lambda x: base_one, codomain=A) self._A.register_conversion(phi)
def __init__(self, alg, graded=True): r""" Initialize ``self``. EXAMPLES:: sage: G = algebras.FSym(QQ).G() sage: TestSuite(G).run() # long time Checks for the antipode:: sage: FSym = algebras.FSym(QQ) sage: G = FSym.G() sage: for b in G.basis(degree=3): ....: print("%s : %s" % (b, b.antipode())) G[123] : -G[1|2|3] G[13|2] : -G[13|2] G[12|3] : -G[12|3] G[1|2|3] : -G[123] sage: F = FSym.dual().F() sage: for b in F.basis(degree=3): ....: print("%s : %s" % (b, b.antipode())) F[123] : -F[1|2|3] F[13|2] : -F[13|2] F[12|3] : -F[12|3] F[1|2|3] : -F[123] """ CombinatorialFreeModule.__init__(self, alg.base_ring(), StandardTableaux(), category=FSymBases(alg), bracket="", prefix=self._prefix)
def __init__(self, R, gens): """ EXAMPLES:: sage: L = LieAlgebras(QQ).WithBasis().example() sage: TestSuite(L).run() """ cat = LieAlgebras(R).WithBasis() CombinatorialFreeModule.__init__(self, R, gens, category=cat)
def __init__(self, base_ring): """ EXAMPLES:: sage: H = GradedHopfAlgebrasWithBasis(QQ).Connected().example() sage: TestSuite(H).run() """ CombinatorialFreeModule.__init__(self, base_ring, NonNegativeIntegers(), category=GradedHopfAlgebrasWithBasis(base_ring).Connected())
def __init__(self, base_ring): """ EXAMPLES:: sage: A = GradedModulesWithBasis(QQ).example(); A An example of a graded module with basis: the free module on partitions over Rational Field sage: TestSuite(A).run() """ CombinatorialFreeModule.__init__(self, base_ring, Partitions(), category=GradedModulesWithBasis(base_ring))
def __init__(self, alg, prefix="B"): r""" Initialize ``self``. EXAMPLES:: sage: TestSuite(DescentAlgebra(QQ, 4).B()).run() """ self._prefix = prefix self._basis_name = "subset" CombinatorialFreeModule.__init__(self, alg.base_ring(), Compositions(alg._n), category=DescentAlgebraBases(alg), bracket="", prefix=prefix) S = NonCommutativeSymmetricFunctions(alg.base_ring()).Complete() self.module_morphism(self.to_nsym, codomain=S, category=Algebras(alg.base_ring()) ).register_as_coercion()
def __init__(self, base_ring): r""" EXAMPLES:: sage: A = FiniteDimensionalAlgebrasWithBasis(QQ).example(); A An example of a finite dimensional algebra with basis: the path algebra of the Kronecker quiver (containing the arrows a:x->y and b:x->y) over Rational Field sage: TestSuite(A).run() """ basis_keys = ['x', 'y', 'a', 'b'] self._nonzero_products = { 'xx':'x', 'xa':'a', 'xb':'b', 'yy':'y', 'ay':'a', 'by':'b' } CombinatorialFreeModule.__init__( self, base_ring, basis_keys, category=FiniteDimensionalAlgebrasWithBasis(base_ring))
def __init__(self, base_ring, q, prefix='H'): """ Initialize ``self``. EXAMPLES:: sage: R.<q> = ZZ[] sage: H = HallAlgebra(R, q) sage: TestSuite(H).run() sage: R = PolynomialRing(ZZ, 'q').fraction_field() sage: q = R.gen() sage: H = HallAlgebra(R, q) sage: TestSuite(H).run() # long time sage: R.<q> = LaurentPolynomialRing(ZZ) sage: H = HallAlgebra(R, q) sage: TestSuite(H).run() # long time """ self._q = q try: q_inverse = q**-1 if not q_inverse in base_ring: hopf_structure = False else: hopf_structure = True except Exception: hopf_structure = False if hopf_structure: category = HopfAlgebrasWithBasis(base_ring) else: category = AlgebrasWithBasis(base_ring) CombinatorialFreeModule.__init__(self, base_ring, Partitions(), prefix=prefix, bracket=False, sorting_key=cmp_to_key(transpose_cmp), category=category) # Coercions I = self.monomial_basis() M = I.module_morphism(I._to_natural_on_basis, codomain=self, triangular='upper', unitriangular=True, inverse_on_support=lambda x: x.conjugate(), invertible=True) M.register_as_coercion() (~M).register_as_coercion()
def __init__(self, R, indices, **kwds): """ Initialize ``self``. EXAMPLES:: sage: L = LieAlgebras(QQ).WithBasis().example() sage: UEA = L.universal_enveloping_algebra() sage: TestSuite(UEA).run() """ if 'category' not in kwds: kwds['category'] = Algebras(R).WithBasis() if 'prefix' not in kwds: kwds['prefix'] = 'P' # This is a workaround until IndexedFree(Abelian)Monoid elements compare properly kwds['sorting_key'] = lambda x: x.to_word_list() kwds['sorting_reverse'] = True M = IndexedFreeAbelianMonoid(indices, bracket='') CombinatorialFreeModule.__init__(self, R, M, **kwds)
def __init__(self, V, c, h): """ Initialize ``self``. EXAMPLES:: sage: L = lie_algebras.VirasoroAlgebra(QQ) sage: M = L.verma_module(3, 1/2) sage: TestSuite(M).run() """ self._c = c self._h = h self._V = V from sage.combinat.partition import _Partitions indices = _Partitions.map(VermaModule._partition_to_neg_tuple) CombinatorialFreeModule.__init__(self, V.base_ring(), indices, prefix='v')
def __init__(self, R, P, prefix='I'): """ Initialize ``self``. TESTS:: sage: P = posets.BooleanLattice(4) sage: I = P.incidence_algebra(QQ) sage: TestSuite(I).run() # long time """ cat = Algebras(R).WithBasis() if P in FiniteEnumeratedSets(): cat = cat.FiniteDimensional() self._poset = P CombinatorialFreeModule.__init__(self, R, map(tuple, P.intervals()), prefix=prefix, category=cat)
def __init__(self, cell_complex, degree, cells=None, base_ring=None): """ EXAMPLES:: sage: T = cubical_complexes.Torus() sage: C = T.n_chains(2, QQ) sage: C.dimension() 16 sage: sorted(C.gens()) [[0,0] x [0,1] x [0,0] x [0,1], [0,0] x [0,1] x [0,1] x [0,0], [0,0] x [0,1] x [0,1] x [1,1], [0,0] x [0,1] x [1,1] x [0,1], [0,1] x [0,0] x [0,0] x [0,1], [0,1] x [0,0] x [0,1] x [0,0], [0,1] x [0,0] x [0,1] x [1,1], [0,1] x [0,0] x [1,1] x [0,1], [0,1] x [1,1] x [0,0] x [0,1], [0,1] x [1,1] x [0,1] x [0,0], [0,1] x [1,1] x [0,1] x [1,1], [0,1] x [1,1] x [1,1] x [0,1], [1,1] x [0,1] x [0,0] x [0,1], [1,1] x [0,1] x [0,1] x [0,0], [1,1] x [0,1] x [0,1] x [1,1], [1,1] x [0,1] x [1,1] x [0,1]] TESTS:: sage: T.n_chains(2, cochains=True).base_ring() Integer Ring sage: T.n_chains(8, cochains=True).dimension() 0 sage: T.n_chains(-3, cochains=True).dimension() 0 """ if base_ring is None: base_ring = ZZ CellComplexReference.__init__(self, cell_complex, degree, cells=cells) CombinatorialFreeModule.__init__(self, base_ring, self._cells, prefix='\\chi', bracket=['_', ''])
def __init__(self, R, n, r): """ Initialize ``self``. TESTS:: sage: S = SchurAlgebra(ZZ, 2, 2) sage: TestSuite(S).run() :: sage: SchurAlgebra(ZZ, -2, 2) Traceback (most recent call last): ... ValueError: n (=-2) must be a positive integer sage: SchurAlgebra(ZZ, 2, -2) Traceback (most recent call last): ... ValueError: r (=-2) must be a non-negative integer sage: SchurAlgebra('niet', 2, 2) Traceback (most recent call last): ... ValueError: R (=niet) must be a commutative ring """ if n not in ZZ or n <= 0: raise ValueError("n (={}) must be a positive integer".format(n)) if r not in ZZ or r < 0: raise ValueError( "r (={}) must be a non-negative integer".format(r)) if not R in Rings.Commutative(): raise ValueError("R (={}) must be a commutative ring".format(R)) self._n = n self._r = r CombinatorialFreeModule.__init__( self, R, schur_representative_indices(n, r), prefix='S', bracket=False, category=AlgebrasWithBasis(R).FiniteDimensional())
def __init__(self, n_cells, base_ring=None, cochains=False): """ EXAMPLES:: sage: T = cubical_complexes.Torus() sage: T.n_chains(2, QQ) Free module generated by {[1,1] x [0,1] x [1,1] x [0,1], [0,0] x [0,1] x [0,1] x [1,1], [0,0] x [0,1] x [1,1] x [0,1], [0,0] x [0,1] x [0,0] x [0,1], [0,1] x [1,1] x [0,1] x [0,0], [0,1] x [0,0] x [0,0] x [0,1], [1,1] x [0,1] x [0,1] x [0,0], [0,1] x [1,1] x [0,0] x [0,1], [0,0] x [0,1] x [0,1] x [0,0], [0,1] x [0,0] x [0,1] x [0,0], [0,1] x [0,0] x [1,1] x [0,1], [0,1] x [1,1] x [1,1] x [0,1], [0,1] x [0,0] x [0,1] x [1,1], [1,1] x [0,1] x [0,0] x [0,1], [1,1] x [0,1] x [0,1] x [1,1], [0,1] x [1,1] x [0,1] x [1,1]} over Rational Field sage: T.n_chains(2).dimension() 16 TESTS:: sage: T.n_chains(2).base_ring() Integer Ring sage: T.n_chains(8).dimension() 0 sage: T.n_chains(-3).dimension() 0 """ if base_ring is None: base_ring = ZZ self._cochains = cochains if cochains: CombinatorialFreeModule.__init__(self, base_ring, n_cells, prefix='\\chi', bracket=['_', '']) else: CombinatorialFreeModule.__init__(self, base_ring, n_cells, prefix='', bracket=False)
def __init__(self, NCSymD): """ EXAMPLES:: sage: w = SymmetricFunctionsNonCommutingVariables(QQ).dual().w() sage: TestSuite(w).run() """ def lt_set_part(A, B): A = sorted(map(sorted, A)) B = sorted(map(sorted, B)) for i in range(len(A)): if A[i] > B[i]: return 1 elif A[i] < B[i]: return -1 return 0 CombinatorialFreeModule.__init__(self, NCSymD.base_ring(), SetPartitions(), prefix='w', bracket=False, monomial_cmp=lt_set_part, category=NCSymDualBases(NCSymD))
def __init__(self, R, q): r""" Initialize ``self``. EXAMPLES:: sage: AW = algebras.AskeyWilson(QQ) sage: TestSuite(AW).run() # long time """ self._q = q cat = Algebras(Rings().Commutative()).WithBasis() indices = cartesian_product([NonNegativeIntegers()] * 6) CombinatorialFreeModule.__init__(self, R, indices, prefix='AW', sorting_key=_basis_key, sorting_reverse=True, category=cat) self._assign_names('A,B,C,a,b,g')
def __init__(self, R, n, names): """ Initialize ``self``. EXAMPLES:: sage: Z.<x,y,z> = algebras.FreeZinbiel(QQ) sage: TestSuite(Z).run() """ if R not in Rings: raise TypeError("argument R must be a ring") indices = Words(Alphabet(n, names=names)) cat = MagmaticAlgebras(R).WithBasis() self._n = n CombinatorialFreeModule.__init__(self, R, indices, prefix='Z', category=cat) self._assign_names(names)
def __init__(self, gp_indices, n, q, bar, R, category, indices_key=None): """ Initialize ``self``. TESTS:: sage: O = algebras.QuantumMatrixCoordinate(3, 2) sage: TestSuite(O).run() """ self._n = n self._q = q if bar is None: def bar(x): return x.subs(q=~self._q) self._bar = bar if indices_key is None: indices = IndexedFreeAbelianMonoid(gp_indices) else: indices = IndexedFreeAbelianMonoid(gp_indices, sorting_key=indices_key) CombinatorialFreeModule.__init__(self, R, indices, category=category)
def __init__(self, kBoundedRing): r""" TESTS:: sage: from sage.combinat.sf.new_kschur import K_kSchur sage: kB = SymmetricFunctions(QQ).kBoundedSubspace(3,1) sage: g = K_kSchur(kB) sage: g 3-bounded Symmetric Functions over Rational Field with t=1 in the K-3-Schur basis sage: g[2,1]*g[1] -2*Kks3[2, 1] + Kks3[2, 1, 1] + Kks3[2, 2] sage: g([]) Kks3[] sage: TestSuite(g).run() # long time (11s on sage.math, 2013) sage: h = SymmetricFunctions(QQ).h() sage: g(h[1,1]) -Kks3[1] + Kks3[1, 1] + Kks3[2] """ CombinatorialFreeModule.__init__(self, kBoundedRing.base_ring(), kBoundedRing.indices(), category= KBoundedSubspaceBases(kBoundedRing, kBoundedRing.base_ring().one()), prefix='Kks%d'%kBoundedRing.k) self._kBoundedRing = kBoundedRing self.k = kBoundedRing.k s = self.realization_of().ambient().schur() self.ambient = ConstantFunction(s) kh = self.realization_of().khomogeneous() g_to_kh = self.module_morphism(self._g_to_kh_on_basis,codomain=kh) g_to_kh.register_as_coercion() kh_to_g = kh.module_morphism(self._kh_to_g_on_basis, codomain=self) kh_to_g.register_as_coercion() h = self.realization_of().ambient().h() lift = self._module_morphism(self.lift, triangular='lower', unitriangular=True, codomain=h) lift.register_as_coercion() retract = h._module_morphism(self.retract, codomain=self) #retract = SetMorphism(Hom(h, self, SetsWithPartialMaps()), lift.preimage) self.register_conversion(retract)
def __init__(self, root_system, base_ring): r""" EXAMPLES:: sage: R = RootSystem(["A",3,1]) sage: R.cartan_type().AmbientSpace <class 'sage.combinat.root_system.type_affine.AmbientSpace'> sage: e = R.ambient_space(); e Ambient space of the Root system of type ['A', 3, 1] sage: TestSuite(R.ambient_space()).run() sage: L = RootSystem(['A',3]).coroot_lattice() sage: e.has_coerce_map_from(L) True sage: e(L.simple_root(1)) e[0] - e[1] """ self.root_system = root_system classical = root_system.cartan_type().classical().root_system( ).ambient_space(base_ring) basis_keys = tuple(classical.basis().keys()) + ("delta", "deltacheck") def sortkey(x): return (1 if isinstance(x, str) else 0, x) CombinatorialFreeModule.__init__( self, base_ring, basis_keys, prefix="e", latex_prefix="e", sorting_key=sortkey, category=WeightLatticeRealizations(base_ring)) self._weight_space = self.root_system.weight_space(base_ring=base_ring, extended=True) self.classical().module_morphism(self.monomial, codomain=self).register_as_coercion() # Duplicated from ambient_space.AmbientSpace coroot_lattice = self.root_system.coroot_lattice() coroot_lattice.module_morphism(self.simple_coroot, codomain=self).register_as_coercion()
def __init__(self, base_ring, q, prefix='I'): """ Initialize ``self``. EXAMPLES:: sage: R.<q> = ZZ[] sage: I = HallAlgebra(R, q).monomial_basis() sage: TestSuite(I).run() sage: R = PolynomialRing(ZZ, 'q').fraction_field() sage: q = R.gen() sage: I = HallAlgebra(R, q).monomial_basis() sage: TestSuite(I).run() sage: R.<q> = LaurentPolynomialRing(ZZ) sage: I = HallAlgebra(R, q).monomial_basis() sage: TestSuite(I).run() """ self._q = q try: q_inverse = q**-1 if not q_inverse in base_ring: hopf_structure = False else: hopf_structure = True except Exception: hopf_structure = False if hopf_structure: category = HopfAlgebrasWithBasis(base_ring) else: category = AlgebrasWithBasis(base_ring) CombinatorialFreeModule.__init__(self, base_ring, Partitions(), prefix=prefix, bracket=False, category=category) # Coercions if hopf_structure: e = SymmetricFunctions(base_ring).e() f = lambda la: q ** sum(-((r * (r - 1)) // 2) for r in la) M = self.module_morphism(diagonal=f, codomain=e) M.register_as_coercion() (~M).register_as_coercion()
def __init__(self, base_ring=QQ['t'], prefix='S'): r""" Initialize ``self``. EXAMPLES:: sage: S = ShiftingOperatorAlgebra(QQ['t']) sage: TestSuite(S).run() """ indices = ShiftingSequenceSpace() cat = Algebras(base_ring).WithBasis() CombinatorialFreeModule.__init__(self, base_ring, indices, prefix=prefix, bracket=False, category=cat) # Setup default conversions sym = SymmetricFunctions(base_ring) self._sym_h = sym.h() self._sym_s = sym.s() self._sym_h.register_conversion(self.module_morphism(self._supp_to_h, codomain=self._sym_h)) self._sym_s.register_conversion(self.module_morphism(self._supp_to_s, codomain=self._sym_s))
def __init__(self, d, n, q, R): """ Initialize ``self``. EXAMPLES:: sage: Y = algebras.YokonumaHecke(5, 3) sage: elts = Y.some_elements() + list(Y.algebra_generators()) sage: TestSuite(Y).run(elements=elts) """ self._d = d self._n = n self._q = q self._Pn = Permutations(n) import itertools C = itertools.product(*([range(d)]*n)) indices = list( itertools.product(C, self._Pn)) cat = Algebras(R).WithBasis() CombinatorialFreeModule.__init__(self, R, indices, prefix='Y', category=cat) self._assign_names(self.algebra_generators().keys())
def __init__(self, k, q1, q2, q3, base_ring, prefix): r""" Initialize ``self``. TESTS:: sage: R.<q,r,s> = ZZ[] sage: B4 = algebras.Blob(4, q, r, s) sage: TestSuite(B4).run() sage: B3 = algebras.Blob(3, q, r, s) sage: B = list(B3.basis()) sage: TestSuite(B3).run(elements=B) # long time """ self._q1 = q1 self._q2 = q2 self._q3 = q3 diagrams = BlobDiagrams(k) cat = Algebras(base_ring.category()).FiniteDimensional().WithBasis() CombinatorialFreeModule.__init__(self, base_ring, diagrams, category=cat, prefix=prefix, bracket=False)
def __init__(self, base_ring, n, level, variable_name, filtration): """ Initialize ``self``. EXAMPLES:: sage: Y = Yangian(QQ, 4, 3) sage: TestSuite(Y).run(skip="_test_antipode") """ self._level = level self._n = n self._filtration = filtration category = HopfAlgebrasWithBasis(base_ring)#.Filtered() # TODO - once implemented self._index_set = tuple(range(1,n+1)) # The keys for the basis are tuples (l, i, j) indices = GeneratorIndexingSet(self._index_set, level) # We note that the generators are non-commutative, but we always sort # them, so they are, in effect, indexed by the free abelian monoid basis_keys = IndexedFreeAbelianMonoid(indices, bracket=False, prefix=variable_name) CombinatorialFreeModule.__init__(self, base_ring, basis_keys, prefix=variable_name, category=category)
def __init__(self, W, q1, q2, base_ring, prefix): """ EXAMPLES:: sage: R.<q1,q2>=QQ[] sage: H = IwahoriHeckeAlgebraT("A2",q1,q2,base_ring=Frac(R),prefix="t"); H The Iwahori Hecke Algebra of Type A2 in q1,q2 over Fraction Field of Multivariate Polynomial Ring in q1, q2 over Rational Field and prefix t sage: TestSuite(H).run() """ self._cartan_type = W.cartan_type() self._prefix = prefix self._index_set = W.index_set() self._q1 = base_ring(q1) self._q2 = base_ring(q2) if W.is_finite(): category = FiniteDimensionalAlgebrasWithBasis(base_ring) else: category = AlgebrasWithBasis(base_ring) CombinatorialFreeModule.__init__(self, base_ring, W, category=category)
def __init__(self, base_ring, cell_complex, cohomology=False, cat=None): """ Initialize ``self``. EXAMPLES:: sage: RP2 = simplicial_complexes.ProjectivePlane() sage: H = RP2.homology_with_basis(QQ) sage: TestSuite(H).run() sage: H = RP2.homology_with_basis(GF(2)) sage: TestSuite(H).run() sage: H = RP2.cohomology_ring(GF(2)) sage: TestSuite(H).run() sage: H = RP2.cohomology_ring(GF(5)) sage: TestSuite(H).run() sage: H = simplicial_complexes.ComplexProjectivePlane().cohomology_ring() sage: TestSuite(H).run() """ # phi is the associated chain contraction. # M is the homology chain complex. phi, M = cell_complex.algebraic_topological_model(base_ring) if cohomology: phi = phi.dual() # We only need the rank of M in each degree, and since # we're working over a field, we don't need to dualize M # if working with cohomology. cat = Modules(base_ring).WithBasis().Graded().or_subcategory(cat) self._contraction = phi self._complex = cell_complex self._cohomology = cohomology self._graded_indices = { deg: range(M.free_module_rank(deg)) for deg in range(cell_complex.dimension() + 1) } indices = [(deg, i) for deg in self._graded_indices for i in self._graded_indices[deg]] CombinatorialFreeModule.__init__(self, base_ring, indices, category=cat)
def __init__(self, M, prefix='I'): """ Initialize ``self``. TESTS:: sage: L = posets.BooleanLattice(4) sage: M = L.moebius_algebra(QQ) sage: TestSuite(M.I()).run() Check that the transition maps can be pickled:: sage: L = posets.BooleanLattice(4) sage: M = L.moebius_algebra(QQ) sage: E = M.E() sage: I = M.I() sage: phi = E.coerce_map_from(I) sage: loads(dumps(phi)) Generic morphism: ... """ self._basis_name = "idempotent" CombinatorialFreeModule.__init__(self, M.base_ring(), tuple(M._lattice), prefix=prefix, category=MoebiusAlgebraBases(M)) ## Change of basis: E = M.E() self.module_morphism(self._to_natural_basis, codomain=E, category=self.category(), triangular='lower', unitriangular=True, key=M._lattice._element_to_vertex ).register_as_coercion() E.module_morphism(E._to_idempotent_basis, codomain=self, category=self.category(), triangular='lower', unitriangular=True, key=M._lattice._element_to_vertex ).register_as_coercion()
def __init__(self, R, n, names, prefix): """ Initialize ``self``. EXAMPLES:: sage: Z.<x,y,z> = algebras.FreeZinbiel(QQ) sage: TestSuite(Z).run() sage: Z = algebras.FreeZinbiel(QQ, ZZ) sage: G = Z.algebra_generators() sage: TestSuite(Z).run(elements=[Z.an_element(), G[1], G[1]*G[2]*G[0]]) TESTS:: sage: Z.<x,y,z> = algebras.FreeZinbiel(5) Traceback (most recent call last): ... TypeError: argument R must be a ring sage: algebras.FreeZinbiel(QQ, ['x', 'y'], prefix='f') Free Zinbiel algebra on generators (f[x], f[y]) over Rational Field """ if R not in Rings(): raise TypeError("argument R must be a ring") if names is None: indices = Words(Alphabet(n), infinite=False) self._n = None else: indices = Words(Alphabet(n, names=names), infinite=False) self._n = n cat = MagmaticAlgebras(R).WithBasis().Graded() CombinatorialFreeModule.__init__(self, R, indices, prefix=prefix, category=cat) if self._n is not None: self._assign_names(names)
def __init__(self, root_system, base_ring): """ EXAMPLES:: sage: e = RootSystem(['A',3]).ambient_lattice() sage: s = e.simple_reflections() """ self.root_system = root_system CombinatorialFreeModule.__init__(self, base_ring, range(0, self.dimension()), element_class=AmbientSpaceElement, prefix='e') # FIXME: here for backward compatibility; # Should we use dimension everywhere? self.n = self.dimension() ct = root_system.cartan_type() if ct.is_irreducible() and ct.type() == 'E': self._v0 = self([0, 0, 0, 0, 0, 0, 1, 1]) self._v1 = self([0, 0, 0, 0, 0, -2, 1, -1])
def __init__(self, root_system, base_ring, extended): """ TESTS:: sage: R = RootSystem(['A',4]) sage: from sage.combinat.root_system.weight_space import WeightSpace sage: Q = WeightSpace(R, QQ); Q Weight space over the Rational Field of the Root system of type ['A', 4] sage: TestSuite(Q).run() sage: WeightSpace(R, QQ, extended = True) Traceback (most recent call last): ... ValueError: extended weight lattices are only implemented for affine root systems """ basis_keys = root_system.index_set() self._extended = extended if extended: if not root_system.cartan_type().is_affine(): raise ValueError("extended weight lattices are only" " implemented for affine root systems") basis_keys = tuple(basis_keys) + ("delta", ) self.root_system = root_system CombinatorialFreeModule.__init__( self, base_ring, basis_keys, prefix="Lambdacheck" if root_system.dual_side else "Lambda", latex_prefix="\\Lambda^\\vee" if root_system.dual_side else "\\Lambda", category=WeightLatticeRealizations(base_ring)) if root_system.cartan_type().is_affine() and not extended: # For an affine type, register the quotient map from the # extended weight lattice/space to the weight lattice/space domain = root_system.weight_space(base_ring, extended=True) domain.module_morphism(self.fundamental_weight, codomain=self).register_as_coercion()
def __init__(self, R, cartan_matrix, wt, prefix): """ Initialize ``self``. """ self._cartan_matrix = cartan_matrix self._weight = wt self._d = sum(wt) # Reduced words #red_words = Family(Permutations(self._d), lambda p: tuple(p.reduced_word())) red_words = FiniteEnumeratedSet([tuple(p.reduced_word()) for p in Permutations(self._d)]) red_words.rename("reduced words of S_{}".format(self._d)) # The monomials M = FreeAbelianMonoid(self._d, names=['x%s'%i for i in range(1, self._d+1)]) # Idempotents (i.e. the colors of the strands) index_set = self._cartan_matrix.index_set() P = Permutations(sum([[index_set[i]]*v for i,v in enumerate(wt)],[])) I = cartesian_product([red_words, M, P]) CombinatorialFreeModule.__init__(self, R, I, prefix=prefix, monomial_key=KLRAlgebra._monomial_key, category=Algebras(R).WithBasis().Graded())
def __init__(self, M, prefix='T', category=None, **options): r""" Initialize ``self``. EXAMPLES:: sage: C = CombinatorialFreeModule(QQ, ['a','b','c']) sage: TA = TensorAlgebra(C) sage: TestSuite(TA).run() sage: m = SymmetricFunctions(QQ).m() sage: Tm = TensorAlgebra(m) sage: TestSuite(Tm).run() """ self._base_module = M R = M.base_ring() category = GradedHopfAlgebrasWithBasis(R.category()).or_subcategory(category) CombinatorialFreeModule.__init__(self, R, IndexedFreeMonoid(M.indices()), prefix=prefix, category=category, **options) # the following is not the best option, but it's better than nothing. self._print_options['tensor_symbol'] = options.get('tensor_symbol', tensor.symbol)
def __init__(self, n, R=ZZ, prefix='a'): """ Initiates the affine nilTemperley Lieb algebra over the ring `R`. EXAMPLES:: sage: A = AffineNilTemperleyLiebTypeA(3, prefix="a"); A The affine nilTemperley Lieb algebra A3 over the ring Integer Ring sage: TestSuite(A).run() sage: A = AffineNilTemperleyLiebTypeA(3, QQ); A The affine nilTemperley Lieb algebra A3 over the ring Rational Field """ if not isinstance(R, Ring): raise TypeError("Argument R must be a ring.") self._cartan_type = CartanType(['A', n - 1, 1]) self._n = n W = WeylGroup(self._cartan_type) self._prefix = prefix self._index_set = W.index_set() self._base_ring = R category = AlgebrasWithBasis(R) CombinatorialFreeModule.__init__(self, R, W, category=category)
def __init__(self, base_ring, cartan_type, level): """ Initialize ``self``. EXAMPLES:: sage: Q = QSystem(QQ, ['A',2]) sage: TestSuite(Q).run() """ self._cartan_type = cartan_type self._level = level indices = tuple(itertools.product(cartan_type.index_set(), [1])) basis = IndexedFreeAbelianMonoid(indices, prefix='Q', bracket=False) # This is used to do the reductions self._poly = PolynomialRing( ZZ, ['q' + str(i) for i in cartan_type.index_set()]) category = Algebras(base_ring).Commutative().WithBasis() CombinatorialFreeModule.__init__(self, base_ring, basis, prefix='Q', category=category)