def __init__(self, R, base, scalar, prefix, name, leading_coeff=None): """ EXAMPLES:: sage: from sage.combinat.sf.sfa import zee sage: from sage.combinat.sf.orthotriang import SymmetricFunctionAlgebra_orthotriang sage: m = SFAMonomial(QQ) sage: s = SymmetricFunctionAlgebra_orthotriang(QQ, m, zee, 's', 'Schur functions') TESTS:: sage: TestSuite(s).run(elements = [s[1,1]+2*s[2], s[1]+3*s[1,1]]) sage: TestSuite(s).run(skip = ["_test_associativity", "_test_prod"]) # long time (7s on sage.math, 2011) Note: ``s.an_element()`` is of degree 4; so we skip ``_test_associativity`` and ``_test_prod`` which involve (currently?) expensive calculations up to degree 12. """ self._sf_base = base self._scalar = scalar self._prefix = prefix self._name = name self._leading_coeff = leading_coeff sfa.SymmetricFunctionAlgebra_generic.__init__(self, R) self._self_to_base_cache = {} self._base_to_self_cache = {} self.register_coercion(SetMorphism(Hom(base, self), self._base_to_self)) base.register_coercion(SetMorphism(Hom(self, base), self._self_to_base))
def __init__(self, ambient, category): self._ambient = ambient Parent.__init__(self, category=category.IsomorphicObjects()) # Bricolage self._remove_from_coerce_cache(ambient) phi = SetMorphism(Hom(ambient, self, category), self.retract) phi.register_as_coercion()
def __init__(self, R, t=None): """ TESTS:: sage: HallLittlewoodP(QQ) Hall-Littlewood polynomials in the P basis over Fraction Field of Univariate Polynomial Ring in t over Rational Field sage: HallLittlewoodP(QQ,t=2) Hall-Littlewood polynomials in the P basis with t=2 over Rational Field """ if t is None: R = R['t'].fraction_field() self.t = R.gen() elif t not in R: raise ValueError, "t (=%s) must be in R (=%s)" % (t, R) else: self.t = R(t) self._name += " with t=%s" % self.t sfa.SymmetricFunctionAlgebra_generic.__init__(self, R) # print self, self._s # This coercion is broken: HLP = HallLittlewoodP(QQ); HLP(HLP._s[1]) # Bases defined by orthotriangularity should inherit from some # common category BasesByOrthotriangularity (shared with Jack, HL, orthotriang, Mcdo) if hasattr(self, "_s_cache"): self._s = sfa.SFASchur(R) # temporary until Hom(GradedHopfAlgebrasWithBasis work better) category = sage.categories.all.ModulesWithBasis(self.base_ring()) self.register_coercion( SetMorphism(Hom(self._s, self, category), self._s_to_self)) self._s.register_coercion( SetMorphism(Hom(self, self._s, category), self._self_to_s))
def __init__(self, R): """ EXAMPLES:: sage: Z = ZonalPolynomials(QQ) sage: P = Z._P; P Jack polynomials in the P basis with t=2 over Rational Field sage: Z(P[2,1] + 2*P[3,1]) Z[2, 1] + 2*Z[3, 1] sage: P(Z[2,1] + 2*Z[3,1]) JackP[2, 1] + 2*JackP[3, 1] TESTS:: sage: TestSuite(Z).run(elements = [Z[1], Z[1,1]]) sage: TestSuite(Z).run(skip = ["_test_associativity", "_test_prod"]) # long time (7s on sage.math, 2011) Note: ``Z.an_element()`` is of degree 4; so we skip the ``_test_associativity`` and ``_test_prod`` which involve (currently?) expensive calculations up to degree 12. """ JackPolynomials_p.__init__(self, R, t=R(2)) self._name = "Zonal polynomials" self._prefix = "Z" category = sage.categories.all.ModulesWithBasis(self.base_ring()) self._P = JackPolynomialsP(self.base_ring(), t=R(2)) self.register_coercion( SetMorphism(Hom(self._P, self, category), self.sum_of_terms)) self._P.register_coercion( SetMorphism(Hom(self, self._P, category), self._P.sum_of_terms))
def __init__(self, R, t=None): """ EXAMPLES:: sage: JackPolynomialsJ(QQ).base_ring() Fraction Field of Univariate Polynomial Ring in t over Rational Field sage: JackPolynomialsJ(QQ, t=2).base_ring() Rational Field """ if t is None: R = R['t'].fraction_field() self.t = R.gen() elif t not in R: raise ValueError, "t (=%s) must be in R (=%s)" % (t, R) else: self.t = R(t) if str(t) != 't': self._name += " with t=%s" % self.t sfa.SymmetricFunctionAlgebra_generic.__init__(self, R) # Bases defined by orthotriangularity should inherit from some # common category BasesByOrthotriangularity (shared with Jack, HL, orthotriang, Mcdo) if hasattr(self, "_m_cache"): # temporary until Hom(GradedHopfAlgebrasWithBasis work better) category = sage.categories.all.ModulesWithBasis(R) self._m = sfa.SFAMonomial(self.base_ring()) self.register_coercion( SetMorphism(Hom(self._m, self, category), self._m_to_self)) self._m.register_coercion( SetMorphism(Hom(self, self._m, category), self._self_to_m))
def __init__(self, R, level, t=None): """ EXAMPLES:: sage: from sage.combinat.sf.llt import * sage: LLT_spin(QQ, 3) LLT polynomials in the HSp basis at level 3 over Fraction Field of Univariate Polynomial Ring in t over Rational Field sage: LLT_spin(QQ, 3, t=2) LLT polynomials in the HSp basis at level 3 with t=2 over Rational Field """ if t is None: R = R['t'].fraction_field() self.t = R.gen() elif t not in R: raise ValueError, "t (=%s) must be in R (=%s)" % (t, R) else: self.t = R(t) self._name += " with t=%s" % self.t self._level = level sfa.SymmetricFunctionAlgebra_generic.__init__(self, R) # temporary until Hom(GradedHopfAlgebrasWithBasis work better) category = sage.categories.all.ModulesWithBasis(R) self._m = sfa.SFAMonomial(self.base_ring()) self.register_coercion( SetMorphism(Hom(self._m, self, category), self._m_to_self)) self._m.register_coercion( SetMorphism(Hom(self, self._m, category), self._self_to_m))
def __init__(self, Sym, base, scalar, prefix, basis_name, leading_coeff=None): """ Initialization of the symmetric function algebra defined via orthotriangular rules. INPUT: - ``self`` -- a basis determined by an orthotriangular definition - ``Sym`` -- ring of symmetric functions - ``base`` -- an instance of a basis of the ring of symmetric functions (e.g. the Schur functions) - ``scalar`` -- a function ``zee`` on partitions. The function ``zee`` determines the scalar product on the power sum basis with normalization `<p_\mu, p_\mu> = zee(mu)`. - ``prefix`` -- the prefix used to display the basis - ``basis_name`` -- the name used for the basis EXAMPLES:: sage: from sage.combinat.sf.sfa import zee sage: from sage.combinat.sf.orthotriang import SymmetricFunctionAlgebra_orthotriang sage: Sym = SymmetricFunctions(QQ) sage: m = Sym.m() sage: s = SymmetricFunctionAlgebra_orthotriang(Sym, m, zee, 's', 'Schur'); s Symmetric Functions over Rational Field in the Schur basis TESTS:: sage: TestSuite(s).run(elements = [s[1,1]+2*s[2], s[1]+3*s[1,1]]) sage: TestSuite(s).run(skip = ["_test_associativity", "_test_prod"]) # long time (7s on sage.math, 2011) Note: ``s.an_element()`` is of degree 4; so we skip ``_test_associativity`` and ``_test_prod`` which involve (currently?) expensive calculations up to degree 12. """ self._sym = Sym self._sf_base = base self._scalar = scalar self._leading_coeff = leading_coeff sfa.SymmetricFunctionAlgebra_generic.__init__(self, Sym, prefix=prefix, basis_name=basis_name) self._self_to_base_cache = {} self._base_to_self_cache = {} self.register_coercion(SetMorphism(Hom(base, self), self._base_to_self)) base.register_coercion(SetMorphism(Hom(self, base), self._self_to_base))
def __init__(self, R, q=None, t=None): """ EXAMPLES:: sage: MacdonaldPolynomialsP(QQ) Macdonald polynomials in the P basis over Fraction Field of Multivariate Polynomial Ring in q, t over Rational Field sage: MacdonaldPolynomialsP(QQ,t=2) Macdonald polynomials in the P basis with t=2 over Fraction Field of Univariate Polynomial Ring in q over Rational Field sage: MacdonaldPolynomialsP(QQ,q=2) Macdonald polynomials in the P basis with q=2 over Fraction Field of Univariate Polynomial Ring in t over Rational Field sage: MacdonaldPolynomialsP(QQ,q=2,t=2) Macdonald polynomials in the P basis with q=2 and t=2 over Rational Field """ #Neither q nor t are specified if t is None and q is None: R = R['q,t'].fraction_field() self.q, self.t = R.gens() elif t is not None and q is None: if t not in R: raise ValueError, "t (=%s) must be in R (=%s)" % (t, R) self.t = R(t) self._name += " with t=%s" % self.t R = R['q'].fraction_field() self.q = R.gen() elif t is None and q is not None: if q not in R: raise ValueError, "q (=%s) must be in R (=%s)" % (q, R) self.q = R(q) self._name += " with q=%s" % self.q R = R['t'].fraction_field() self.t = R.gen() else: if t not in R or q not in R: raise ValueError self.q = R(q) self.t = R(t) self._name += " with q=%s and t=%s" % (self.q, self.t) sfa.SymmetricFunctionAlgebra_generic.__init__(self, R) # Bases defined by orthotriangularity should inherit from some # common category BasesByOrthotriangularity (shared with Jack, HL, orthotriang, Mcdo) if hasattr(self, "_s_cache"): self._s = sfa.SFASchur(R) # temporary until Hom(GradedHopfAlgebrasWithBasis work better) category = sage.categories.all.ModulesWithBasis(self.base_ring()) self.register_coercion( SetMorphism(Hom(self._s, self, category), self._s_to_self)) self._s.register_coercion( SetMorphism(Hom(self, self._s, category), self._self_to_s))
def __init__(self, R, k, t=None): """ EXAMPLES:: sage: kSchurFunctions(QQ, 3).base_ring() doctest:1: DeprecationWarning: Deprecation warning: Please use SymmetricFunctions(QQ).kschur() instead! See http://trac.sagemath.org/5457 for details. Univariate Polynomial Ring in t over Rational Field sage: kSchurFunctions(QQ, 3, t=1).base_ring() Rational Field sage: ks3 = kSchurFunctions(QQ, 3) sage: ks3 == loads(dumps(ks3)) True """ self.k = k self._name = "k-Schur Functions at level %s" % k self._prefix = "ks%s" % k self._element_class = kSchurFunctions_t.Element if t is None: R = R['t'] self.t = R.gen() elif t not in R: raise ValueError, "t (=%s) must be in R (=%s)" % (t, R) else: self.t = R(t) if str(t) != 't': self._name += " with t=%s" % self.t self._s_to_self_cache = s_to_k_cache.get(k, {}) self._self_to_s_cache = k_to_s_cache.get(k, {}) # This is an abuse, since kschur functions do not form a basis of Sym from sage.combinat.sf.sf import SymmetricFunctions Sym = SymmetricFunctions(R) sfa.SymmetricFunctionAlgebra_generic.__init__(self, Sym) # so we need to take some counter measures self._basis_keys = sage.combinat.partition.Partitions(max_part=k) # The following line is just a temporary workaround to keep # the repr of those k-schur as they were before #13404; since # they are deprecated, there is no need to bother about them. self.rename(self._name + " over %s" % self.base_ring()) self._s = Sym.s() # temporary until Hom(GradedHopfAlgebrasWithBasis work better) category = sage.categories.all.ModulesWithBasis(self.base_ring()) # This really should be a conversion, not a coercion (it can fail) self.register_coercion( SetMorphism(Hom(self._s, self, category), self._s_to_self)) self._s.register_coercion( SetMorphism(Hom(self, self._s, category), self._self_to_s))
def __init__(self, Sym, other_basis, bname, pfix): r""" Initialize the basis and register coercions. The coercions are set up between the ``other_basis``. INPUT: - ``Sym`` -- an instance of the symmetric function algebra - ``other_basis`` -- a basis of Sym - ``bname`` -- the name for this basis (convention: ends in "character") - ``pfix`` -- a prefix to use for the basis EXAMPLES:: sage: Sym = SymmetricFunctions(QQ) sage: ht = SymmetricFunctions(QQ).ht(); ht Symmetric Functions over Rational Field in the induced trivial character basis sage: st = SymmetricFunctions(QQ).st(); st Symmetric Functions over Rational Field in the irreducible symmetric group character basis sage: TestSuite(ht).run() """ SFA_generic.__init__(self, Sym, basis_name=bname, prefix=pfix, graded=False) self._other = other_basis self.module_morphism(self._self_to_other_on_basis, codomain=self._other).register_as_coercion() self.register_coercion( SetMorphism(Hom(self._other, self), self._other_to_self))
def representation(self, s): """ Return the representation of `s` as a linear morphism acting on ``self`` INPUT: - `s` -- an element of the semigroup acting on ``self`` EXAMPLES:: sage: S = AperiodicMonoids().Finite().example(5); S sage: A = S.simple_module(3) sage: pi = S.monoid_generators() sage: pi Finite family {1: 11345, 2: 12245, 3: 12335, 4: 12344, -1: 22345, -4: 12355, -3: 12445, -2: 13345} sage: phi = A.representation(pi[1]) Generic endomorphism of A quotient of Free module generated by {33444, 33334, 33344, 34444} endowed with an action of The finite H-trivial monoid of order preserving maps on {1, .., 5} over Rational Field sage: phi(A.an_element()) 2*B[11144] + 2*B[11444] + 3*B[11114] sage: phi.matrix() [1 0 0 0] [0 0 0 0] [0 0 1 0] [0 1 0 1] """ from sage.categories.homset import End import functools return SetMorphism( End(self, Modules(self.base_ring()).WithBasis().FiniteDimensional()), functools.partial(self.action, s))
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 _coerce_map_from_(self, S): """ Return ``True`` if a coercion from ``S`` exists. EXAMPLES:: sage: L = LazyLaurentSeriesRing(GF(2), 'z') sage: L.has_coerce_map_from(ZZ) True sage: L.has_coerce_map_from(GF(2)) True """ if self.base_ring().has_coerce_map_from(S): return True if isinstance(S, (PolynomialRing_general, LaurentPolynomialRing_generic)) and S.ngens() == 1: def make_series_from(poly): op = LazyLaurentSeriesOperator_polynomial(self, poly) a = poly.valuation() c = (self.base_ring().zero(), poly.degree() + 1) return self.element_class(self, coefficient=op, valuation=a, constant=c) return SetMorphism(Hom(S, self, Sets()), make_series_from) return False
def _apply_functor_to_morphism(self, f): r""" Lift a homomorphism of rings to the corresponding homomorphism of the group algebras of ``self.group()``. INPUT: - ``f`` - a morphism of rings. OUTPUT: A morphism of group algebras. EXAMPLES:: sage: G = SymmetricGroup(3) sage: A = GroupAlgebra(G, ZZ) sage: h = sage.categories.morphism.SetMorphism(Hom(ZZ, GF(5), Rings()), lambda x: GF(5)(x)) sage: hh = A.construction()[0](h) sage: hh(A.0 + 5 * A.1) (1,2,3) """ codomain = self(f.codomain()) return SetMorphism( Hom(self(f.domain()), codomain, Rings()), lambda x: sum( codomain(g) * f(c) for (g, c) in six.iteritems(dict(x))))
def __init__(self, Sym, pfix): r""" Initialize the basis and register coercions. The coercions are set up between the ``other_basis`` INPUT: - ``Sym`` -- an instance of the symmetric function algebra - ``pfix`` -- a prefix to use for the basis EXAMPLES:: sage: Sym = SymmetricFunctions(QQ) sage: ht = SymmetricFunctions(QQ).ht(); ht Symmetric Functions over Rational Field in the induced trivial symmetric group character basis sage: st = SymmetricFunctions(QQ).st(); st Symmetric Functions over Rational Field in the irreducible symmetric group character basis """ SFA_generic.__init__( self, Sym, basis_name="irreducible symmetric group character", prefix=pfix, graded=False) self._other = Sym.Schur() self._p = Sym.powersum() self.module_morphism(self._self_to_power_on_basis, codomain=Sym.powersum()).register_as_coercion() self.register_coercion( SetMorphism(Hom(self._other, self), self._other_to_self))
def __init__(self, root_system, base_ring): """ EXAMPLES:: sage: P = RootSystem(['A',4]).root_space() sage: s = P.simple_reflections() """ from sage.categories.morphism import SetMorphism from sage.categories.homset import Hom from sage.categories.sets_with_partial_maps import SetsWithPartialMaps self.root_system = root_system CombinatorialFreeModule.__init__( self, base_ring, root_system.index_set(), prefix="alphacheck" if root_system.dual_side else "alpha", latex_prefix="\\alpha^\\vee" if root_system.dual_side else "\\alpha", category=RootLatticeRealizations(base_ring)) if base_ring is not ZZ: # Register the partial conversion back from ``self`` to the root lattice # See :meth:`_to_root_lattice` for tests root_lattice = self.root_system.root_lattice() SetMorphism(Hom(self, root_lattice, SetsWithPartialMaps()), self._to_root_lattice).register_as_conversion()
def module_morphism(self, *, function, category=None, codomain, **keywords): r""" Construct a module morphism from ``self`` to ``codomain``. Let ``self`` be a module `X` over a ring `R`. This constructs a morphism `f: X \to Y`. INPUT: - ``self`` -- a parent `X` in ``Modules(R)``. - ``function`` -- a function `f` from `X` to `Y` - ``codomain`` -- the codomain `Y` of the morphism (default: ``f.codomain()`` if it's defined; otherwise it must be specified) - ``category`` -- a category or ``None`` (default: ``None``) EXAMPLES:: sage: V = FiniteRankFreeModule(QQ, 2) sage: e = V.basis('e'); e Basis (e_0,e_1) on the 2-dimensional vector space over the Rational Field sage: neg = V.module_morphism(function=operator.neg, codomain=V); neg Generic endomorphism of 2-dimensional vector space over the Rational Field sage: neg(e[0]) Element -e_0 of the 2-dimensional vector space over the Rational Field """ # Make sure that we only create a module morphism, even if # domain and codomain have more structure if category is None: category = Modules(self.base_ring()) return SetMorphism(Hom(self, codomain, category), function)
def _apply_functor_to_morphism(self, f): r""" Lift a homomorphism of rings to the corresponding homomorphism of the group algebras of ``self.group()``. INPUT: - ``f`` -- a morphism of rings OUTPUT: A morphism of group algebras. EXAMPLES:: sage: G = SymmetricGroup(3) sage: A = GroupAlgebra(G, ZZ) sage: h = GF(5).coerce_map_from(ZZ) sage: hh = A.construction()[0](h); hh Generic morphism: From: Symmetric group algebra of order 3 over Integer Ring To: Symmetric group algebra of order 3 over Finite Field of size 5 sage: a = 2 * A.an_element(); a 2*() + 2*(2,3) + 6*(1,2,3) + 4*(1,3,2) sage: hh(a) 2*() + 2*(2,3) + (1,2,3) + 4*(1,3,2) """ from sage.categories.rings import Rings domain = self(f.domain()) codomain = self(f.codomain()) # we would want to use something like: # domain.module_morphism(on_coefficients=h, codomain=codomain, category=Rings()) return SetMorphism(domain.Hom(codomain, category=Rings()), lambda x: codomain.sum_of_terms((g, f(c)) for (g, c) in x))
def __init__(self, ambient, gens, ideal, order=None, category=None): r""" Initialize ``self``. TESTS:: sage: L.<X,Y,Z> = LieAlgebra(QQ, {('X','Y'): {'Z': 1}}) sage: S = L.subalgebra(X) sage: TestSuite(S).run() sage: I = L.ideal(X) sage: TestSuite(I).run() """ self._ambient = ambient self._gens = gens self._is_ideal = ideal # initialize helper variables for ordering if order is None: order = lambda x: x self._order = order self._reversed_indices = sorted(ambient.indices(), key=order, reverse=True) # helper to reorder a vector that has been jumbled by the above self._reorganized_indices = [self._reversed_indices.index(i) for i in ambient.indices()] sup = super(LieSubalgebra_finite_dimensional_with_basis, self) sup.__init__(ambient.base_ring(), category=category) # register a coercion to the ambient Lie algebra H = Hom(self, ambient) f = SetMorphism(H, self.lift) ambient.register_coercion(f)
def __init__(self, *args, **kwargs): r""" TESTS:: sage: sys.path.append(os.getcwd()); from mac_lane import * # optional: standalone sage: K.<x> = FunctionField(QQ) sage: K(1/2) in QQ True """ self.__old_init__(*args, **kwargs) from sage.categories.morphism import SetMorphism self._ring.register_conversion(SetMorphism(self.Hom(self._ring), self._to_polynomial)) try: self.constant_base_field().register_conversion(SetMorphism(self.Hom(self.constant_base_field()), self._to_constant)) except AssertionError: # since #21872 there is already such a conversion pass
def __init__(self, R, repr_var1 = 'x', repr_var2 = 'y', inversed_ring = None): self._coeffs_ring = MultivariatePolynomialAlgebra_generic(R, repr_var2, always_show_main_var = True) MultivariatePolynomialAlgebra_generic.__init__( self, self._coeffs_ring, repr_var1, always_show_main_var = True, extra_bases_category = Finite_rank_double_bases() ) self._repr_var1 = repr_var1 self._repr_var2 = repr_var2 self._coeffs_base_ring = R if(inversed_ring is None): self._inversed_ring = DoubleMultivariatePolynomialAlgebra_generic(R, repr_var2, repr_var1, self) else: self._inversed_ring = inversed_ring m = SetMorphism( Hom(self, self.inversed_ring()), lambda x : x.swap_coeffs_elements()) m.register_as_coercion()
def __init__(self, llt, prefix): r""" A class of methods which are common to both the hspin and hcospin of the LLT symmetric functions. INPUT: - ``self`` -- an instance of the LLT hspin or hcospin basis - ``llt`` -- a family of LLT symmetric functions EXAMPLES:: sage: SymmetricFunctions(FractionField(QQ['t'])).llt(3).hspin() Symmetric Functions over Fraction Field of Univariate Polynomial Ring in t over Rational Field in the level 3 LLT spin basis sage: SymmetricFunctions(QQ).llt(3,t=2).hspin() Symmetric Functions over Rational Field in the level 3 LLT spin with t=2 basis sage: QQz = FractionField(QQ['z']); z = QQz.gen() sage: SymmetricFunctions(QQz).llt(3,t=z).hspin() Symmetric Functions over Fraction Field of Univariate Polynomial Ring in z over Rational Field in the level 3 LLT spin with t=z basis """ s = self.__class__.__name__[4:] sfa.SymmetricFunctionAlgebra_generic.__init__( self, llt._sym, basis_name="level %s LLT " % llt.level() + s + llt._name_suffix, prefix=prefix) self.t = llt.t self._sym = llt._sym self._llt = llt self._k = llt._k sfa.SymmetricFunctionAlgebra_generic.__init__(self, self._sym) # temporary until Hom(GradedHopfAlgebrasWithBasis work better) category = sage.categories.all.ModulesWithBasis(self._sym.base_ring()) self._m = llt._sym.m() self.register_coercion( SetMorphism(Hom(self._m, self, category), self._m_to_self)) self._m.register_coercion( SetMorphism(Hom(self, self._m, category), self._self_to_m))
def __init__(self, R, k, t=None): """ EXAMPLES:: sage: kSchurFunctions(QQ, 3).base_ring() Univariate Polynomial Ring in t over Rational Field sage: kSchurFunctions(QQ, 3, t=1).base_ring() Rational Field sage: ks3 = kSchurFunctions(QQ, 3) sage: ks3 == loads(dumps(ks3)) True """ self.k = k self._name = "k-Schur Functions at level %s"%k self._prefix = "ks%s"%k self._element_class = kSchurFunctions_t.Element if t is None: R = R['t'] self.t = R.gen() elif t not in R: raise ValueError, "t (=%s) must be in R (=%s)"%(t,R) else: self.t = R(t) if str(t) != 't': self._name += " with t=%s"%self.t self._s_to_self_cache = s_to_k_cache.get(k, {}) self._self_to_s_cache = k_to_s_cache.get(k, {}) # This is an abuse, since kschur functions do not form a basis of Sym sfa.SymmetricFunctionAlgebra_generic.__init__(self, R) # so we need to take some counter measures self._basis_keys = sage.combinat.partition.Partitions(NonNegativeIntegers(), max_part=k) self._s = sfa.SFASchur(self.base_ring()) # temporary until Hom(GradedHopfAlgebrasWithBasis work better) category = sage.categories.all.ModulesWithBasis(self.base_ring()) # This really should be a conversion, not a coercion (it can fail) self .register_coercion(SetMorphism(Hom(self._s, self, category), self._s_to_self)) self._s.register_coercion(SetMorphism(Hom(self, self._s, category), self._self_to_s))
def __init__(self, hall_littlewood): r""" A class with methods for working with Hall-Littlewood symmetric functions which are common to all bases. INPUT: - ``self`` -- a Hall-Littlewood symmetric function basis - ``hall_littlewood`` -- a class of Hall-Littlewood bases TESTS:: sage: SymmetricFunctions(QQ['t'].fraction_field()).hall_littlewood().P() Symmetric Functions over Fraction Field of Univariate Polynomial Ring in t over Rational Field in the Hall-Littlewood P basis sage: SymmetricFunctions(QQ).hall_littlewood(t=2).P() Symmetric Functions over Rational Field in the Hall-Littlewood P with t=2 basis """ s = self.__class__.__name__[15:].capitalize() sfa.SymmetricFunctionAlgebra_generic.__init__( self, hall_littlewood._sym, basis_name="Hall-Littlewood " + s + hall_littlewood._name_suffix, prefix="HL" + s) self.t = hall_littlewood.t self._sym = hall_littlewood._sym self._hall_littlewood = hall_littlewood self._s = self._sym.schur() # This coercion is broken: HLP = HallLittlewoodP(QQ); HLP(HLP._s[1]) # Bases defined by orthotriangularity should inherit from some # common category BasesByOrthotriangularity (shared with Jack, HL, orthotriang, Mcdo) if hasattr(self, "_s_cache"): # temporary until Hom(GradedHopfAlgebrasWithBasis work better) category = sage.categories.all.ModulesWithBasis( self._sym.base_ring()) self.register_coercion( SetMorphism(Hom(self._s, self, category), self._s_to_self)) self._s.register_coercion( SetMorphism(Hom(self, self._s, category), self._self_to_s))
def _composition_(self, right, homset): """ Helper to construct the composition of two morphisms. Override this if you want to have a different behaviour of composition INPUT: - ``right`` -- a map or callable - ``homset`` -- a homset containing the composed map OUTPUT: An element of ``homset``. The output is obtained by converting the arguments to :class:`~sage.categories.morphism.SetMorphism` if necessary, and then forming a :class:`~sage.categories.map.FormalCompositeMap` EXAMPLES:: sage: X = AffineSpace(QQ,2) sage: f = X.structure_morphism() sage: Y = Spec(QQ) sage: g = Y.structure_morphism() sage: g * f # indirect doctest Composite map: From: Affine Space of dimension 2 over Rational Field To: Spectrum of Integer Ring Defn: Generic morphism: From: Affine Space of dimension 2 over Rational Field To: Spectrum of Rational Field then Generic morphism: From: Spectrum of Rational Field To: Spectrum of Integer Ring """ if not isinstance(right, Map): right = SetMorphism(right.parent(), right) return FormalCompositeMap(homset, right, SetMorphism(self.parent(), self))
def _composition_(self, right, homset): """ Helper to construct the composition of two morphisms. Override this if you want to have a different behaviour of composition INPUT: - ``right`` -- a map or callable - ``homset`` -- a homset containing the composed map OUTPUT: An element of ``homset``. The output is obtained by converting the arguments to :class:`~sage.categories.morphism.SetMorphism` if necessary, and then forming a :class:`~sage.categories.map.FormalCompositeMap` EXAMPLES:: sage: X = AffineSpace(QQ,2) sage: f = X.structure_morphism() sage: Y = Spec(QQ) sage: g = Y.structure_morphism() sage: g * f # indirect doctest Composite map: From: Affine Space of dimension 2 over Rational Field To: Spectrum of Integer Ring Defn: Generic morphism: From: Affine Space of dimension 2 over Rational Field To: Spectrum of Rational Field then Generic morphism: From: Spectrum of Rational Field To: Spectrum of Integer Ring """ if not isinstance(right, Map): right = SetMorphism(right.parent(), right) return FormalCompositeMap(homset, right, SetMorphism(self.parent(),self))
def section(self): """ Return the section map of ``self``. EXAMPLES:: sage: R = FreeAlgebra(QQ, 3, 'x,y,z') sage: L.<x,y,z> = LieAlgebra(associative=R.gens()) sage: f = R.coerce_map_from(L) sage: f.section() Generic morphism: From: Free Algebra on 3 generators (x, y, z) over Rational Field To: Lie algebra generated by (x, y, z) in Free Algebra on 3 generators (x, y, z) over Rational Field """ return SetMorphism(Hom(self.codomain(), self.domain()), self.preimage)
def zero(self): """ Return the zero morphism. EXAMPLES:: sage: L = LieAlgebra(QQ, 'x,y,z') sage: Lyn = L.Lyndon() sage: H = L.Hall() sage: HS = Hom(Lyn, H) sage: HS.zero() Generic morphism: From: Free Lie algebra generated by (x, y, z) over Rational Field in the Lyndon basis To: Free Lie algebra generated by (x, y, z) over Rational Field in the Hall basis """ return SetMorphism(self, lambda x: self.codomain().zero())
def __init__(self, I, L, names, index_set, category=None): r""" Initialize ``self``. TESTS:: sage: L.<x,y,z> = LieAlgebra(SR, {('x','y'): {'x':1}}) sage: K = L.quotient(y) sage: K.dimension() 1 sage: TestSuite(K).run() """ B = L.basis() sm = L.module().submodule_with_basis( [I.reduce(B[i]).to_vector() for i in index_set]) SB = sm.basis() # compute and normalize structural coefficients for the quotient s_coeff = {} for i, ind_i in enumerate(index_set): for j in range(i + 1, len(index_set)): ind_j = index_set[j] brkt = I.reduce(L.bracket(SB[i], SB[j])) brktvec = sm.coordinate_vector(brkt.to_vector()) s_coeff[(ind_i, ind_j)] = dict(zip(index_set, brktvec)) s_coeff = LieAlgebraWithStructureCoefficients._standardize_s_coeff( s_coeff, index_set) self._ambient = L self._I = I self._sm = sm LieAlgebraWithStructureCoefficients.__init__(self, L.base_ring(), s_coeff, names, index_set, category=category) # register the quotient morphism as a conversion H = Hom(L, self) f = SetMorphism(H, self.retract) self.register_conversion(f)
def _coerce_map_from_(self, S): """ Define coercions. EXAMPLES: A place is converted to a prime divisor:: sage: K.<x> = FunctionField(GF(5)); R.<t> = PolynomialRing(K) sage: F.<y> = K.extension(t^2-x^3-1) sage: O = F.maximal_order() sage: I = O.ideal(x+1,y) sage: P = I.place() sage: y.divisor() + P -3*Place (1/x, 1/x^2*y) + 2*Place (x + 1, y) + Place (x^2 + 4*x + 1, y) """ if isinstance(S, PlaceSet): func = lambda place: prime_divisor(self._field, place) return SetMorphism(Hom(S, self), func)
def _apply_functor_to_morphism(self, f): r""" Given a morphism of commutative additive groups, return the corresponding morphism of multiplicative groups. INPUT: - A homomorphism `f` of commutative additive groups. OUTPUT: - The above homomorphism, but between the corresponding multiplicative groups. In the following example, ``self`` is the functor `GroupExp()` and `f` is an endomorphism of the additive group of integers. EXAMPLES:: sage: def double(x): ....: return x + x sage: from sage.categories.morphism import SetMorphism sage: from sage.categories.homset import Hom sage: f = SetMorphism(Hom(ZZ,ZZ,CommutativeAdditiveGroups()),double) sage: E = GroupExp() sage: EZ = E._apply_functor(ZZ) sage: F = E._apply_functor_to_morphism(f) sage: F.domain() == EZ True sage: F.codomain() == EZ True sage: F(EZ(3)) == EZ(3)*EZ(3) True """ new_domain = self._apply_functor(f.domain()) new_codomain = self._apply_functor(f.codomain()) new_f = lambda a: new_codomain(f(a.value)) return SetMorphism(Hom(new_domain, new_codomain, Groups()), new_f)