code / alex / psage / psage / modform / fourier_expansion_framework / monoidpowerseries / monoidpowerseries_ambient.py
241852 views"""1Ambients of monoid power series and ambients of equivariant monoid power series.23AUTHOR :4- Martin Raum (2010 - 02 - 10) Initial version5"""67#===============================================================================8#9# Copyright (C) 2010 Martin Raum10#11# This program is free software; you can redistribute it and/or12# modify it under the terms of the GNU General Public License13# as published by the Free Software Foundation; either version 314# of the License, or (at your option) any later version.15#16# This program is distributed in the hope that it will be useful,17# but WITHOUT ANY WARRANTY; without even the implied warranty of18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU19# General Public License for more details.20#21# You should have received a copy of the GNU General Public License22# along with this program; if not, see <http://www.gnu.org/licenses/>.23#24#===============================================================================2526from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_element import MonoidPowerSeries, EquivariantMonoidPowerSeries27from sage.rings.all import Integer28from sage.structure.element import Element2930#===============================================================================31# MonoidPowerSeriesAmbient_abstract32#===============================================================================3334class MonoidPowerSeriesAmbient_abstract :35r"""36Given some `K` module or algebra `A` and a monoid `S` filtered over37a net `\Lambda` construct a module or ring of monoid power series.3839Set `R = B[S]`. Then the projective limit of `R / R_\lambda` for40`\lambda \in \Lambda \rightarrow \infty` considered as a41`K` module or algebra is implemented by this class.42"""4344def __init__(self, A, S) :45r"""46INPUT:47- `A` -- A ring or module.48- `S` -- A monoid as implemented in :class:~`from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids.NNMonoid`.4950TESTS::51sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids import *52sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_ambient import MonoidPowerSeriesAmbient_abstract53sage: mps = MonoidPowerSeriesAmbient_abstract(QQ, NNMonoid(False))54"""55self.__monoid = S5657self._set_multiply_function()58self.__coefficient_domain = A5960if not hasattr(self, "_element_class") :61self._element_class = MonoidPowerSeries6263def is_exact(self) :64r"""65TESTS::66sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids import *67sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_ring import MonoidPowerSeriesRing68sage: mps = MonoidPowerSeriesRing(QQ, NNMonoid(False))69sage: mps.is_exact()70False71"""72return False7374def monoid(self) :75r"""76Return the index monoid of ``self``.7778OUTPUT:79A monoid.8081TESTS::82sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids import *83sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_ambient import MonoidPowerSeriesAmbient_abstract84sage: mps = MonoidPowerSeriesAmbient_abstract(QQ, NNMonoid(False))85sage: mps.monoid()86NN87"""88return self.__monoid8990def coefficient_domain(self) :91r"""92The coefficient domain of ``self``.9394OUTPUT:95A ring or module.9697TESTS::98sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids import *99sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_ambient import MonoidPowerSeriesAmbient_abstract100sage: mps = MonoidPowerSeriesAmbient_abstract(QQ, NNMonoid(False))101sage: mps.coefficient_domain()102Rational Field103sage: mps = MonoidPowerSeriesAmbient_abstract(FreeModule(ZZ, 3), NNMonoid(False))104sage: mps.coefficient_domain()105Ambient free module of rank 3 over the principal ideal domain Integer Ring106"""107return self.__coefficient_domain108109def _multiply_function(self) :110r"""111Return the currect multiply function.112113The standard implementation of elements asks its parent to114provide a multiplication function, which has the following signature:115116multiply function INPUT:117- `k` -- Element of the index monoid; An index.118- ``lcoeffs`` -- A dictionary; Coefficient dictionary of the left factor.119- ``rcoeffs`` -- A dictionary; Coefficient dictionary of the right factor.120- ``null`` -- An element of a ring or module; An initialized zero object121of the coefficient domain.122multiply function OUTPUT:123A ring element. The `k`-th coefficent of the product ``left * right``.124125TESTS::126sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids import *127sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_ring import MonoidPowerSeriesRing128sage: mps = MonoidPowerSeriesRing(QQ, NNMonoid(False))129sage: h = mps._multiply_function()130"""131return self.__multiply_function132133def _set_multiply_function(self, f = None) :134r"""135Set the multiply function that is decribed in :meth:~`._multiply_function`.136If `f` is ``None`` an iteration over the decompositions in the137monoid is used.138139INPUT:140- `f` -- A function or ``None`` (default: ``None``).141142OUTPUT:143``None``.144145TESTS::146sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids import *147sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_ring import MonoidPowerSeriesRing148sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_element import MonoidPowerSeries149sage: mps = MonoidPowerSeriesRing(QQ, NNMonoid(False))150sage: e = MonoidPowerSeries( mps, { 4 : 1, 5 : 2}, mps.monoid().filter_all() )151sage: h = e * e # indirect doctest152sage: h = lambda : None153sage: mps._set_multiply_function(h)154sage: h == mps._multiply_function()155True156"""157if not f is None :158self.__multiply_function = f159return160161def mul(s, lcoeffs, rcoeffs, res) :162for s1, s2 in self.__monoid.decompositions(s) :163try :164v1 = lcoeffs[s1]165v2 = rcoeffs[s2]166except KeyError :167continue168169res += v1 * v2170171return res172#! def mul173174self.__multiply_function = mul175176def _coerce_map_from_(self, other) :177r"""178TESTS::179sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids import *180sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_ring import MonoidPowerSeriesRing181sage: mps = MonoidPowerSeriesRing(QQ, NNMonoid(False))182sage: mps.has_coerce_map_from( MonoidPowerSeriesRing(ZZ, NNMonoid(False)) ) # indirect doctest183True184"""185if isinstance(other, MonoidPowerSeriesAmbient_abstract) :186if self.monoid() == other.monoid() and \187self.coefficient_domain().has_coerce_map_from(other.coefficient_domain()) :188from sage.structure.coerce_maps import CallableConvertMap189return CallableConvertMap(other, self, self._element_constructor_)190191def _element_constructor_(self, x) :192r"""193TESTS::194sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids import *195sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_ring import MonoidPowerSeriesRing196sage: mps = MonoidPowerSeriesRing(QQ, NNMonoid(False))197sage: h = mps(dict()) # indirect doctest198sage: h = mps(h) # indirect doctest199"""200if isinstance(x, dict) :201return self._element_class(self, x, self.monoid().filter_all())202if isinstance(x, Element) :203P = x.parent()204if P is self :205return x206elif isinstance(P, MonoidPowerSeriesAmbient_abstract) :207if self.coefficient_domain() is P.coefficient_domain() :208return self._element_class( self,209x.coefficients(), x.precision() )210else :211coefficient_domain = self.coefficient_domain()212return self._element_class( self,213dict( (k,coefficient_domain(c)) for (k,c) in x.coefficients().iteritems() ),214x.precision() )215216raise (TypeError, "Cannot construct an element of %s" % (x))217218def __cmp__(self, other) :219r"""220TESTS::221sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids import *222sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_ambient import MonoidPowerSeriesAmbient_abstract223sage: mps = MonoidPowerSeriesAmbient_abstract(QQ, NNMonoid(False))224sage: mps2 = MonoidPowerSeriesAmbient_abstract(ZZ, NNMonoid(False))225sage: mps == MonoidPowerSeriesAmbient_abstract(QQ, NNMonoid(False))226True227sage: mps == mps2228False229"""230c = cmp(type(self), type(other))231232if c == 0 :233c = cmp(self.coefficient_domain(), other.coefficient_domain())234if c == 0 :235c = cmp(self.monoid(), other.monoid())236237return c238239###############################################################################240###############################################################################241###############################################################################242243#===============================================================================244# EquivariantMonoidPowerSeriesAmbient_abstract245#===============================================================================246247class EquivariantMonoidPowerSeriesAmbient_abstract :248r"""249Given some ring or module `A`, a monoid `S` filtered over some originated250net `\Lambda` such that all induced submonoids are finite, a group `G`, a251semigroup `C` with a map `c \rightarrow \mathrm{Hom}(G, Aut_K(A))`, a252homomorphism `\phi : G -> Aut(S)` and a homomorphism `\eta : G -> C`, where253`K` is the base ring of `A`.254255Suppose for every `c, c'` in `C`, and `g` in `G`, and `a, a'` in `A` we have256`(c c') (g) (a a') = c(g)(a) c'(g)(a')`.257Set `R = B[C][S]`. Then the projective limit of258`R / R_\lambda` for `\lambda \in \Lambda \rightarrow \infinity` is a259`K`-algebra or -module.260"""261262def __init__(self, O, C, R) :263r"""264INPUT:265- `O` -- A monoid with an action of a group; As implemented in266:class:~`fourier_expansion_framework.monoidpowerseries.NNMonoid`.267- `C` -- A monoid of characters; As implemented in ::class:~`fourier_expansion_framework.monoidpowerseries.CharacterMonoid_class`.268- `R` -- A representation on an algebra or module; As implemented269in :class:~`fourier_expansion_framework.monoidpowerseries.TrivialRepresentation`.270271EXAMPLES::272sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids import *273sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_ring import EquivariantMonoidPowerSeriesRing274sage: emps = EquivariantMonoidPowerSeriesRing(NNMonoid(True), TrivialCharacterMonoid("1", QQ), TrivialRepresentation("1", QQ)) # indirect doctest275"""276self.__action = O277self.__characters = C278self.__representation = R279280self.__coefficient_domain = R.codomain()281self.__monoid = O.monoid()282283self._set_reduction_function()284self._set_character_eval_function()285self._set_apply_function()286self._set_multiply_function()287288if not hasattr(self, "_element_class") :289self._element_class = EquivariantMonoidPowerSeries290291def is_exact(self) :292r"""293TESTS::294sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids import *295sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_ring import EquivariantMonoidPowerSeriesRing296sage: emps = EquivariantMonoidPowerSeriesRing(NNMonoid(True), TrivialCharacterMonoid("1", QQ), TrivialRepresentation("1", QQ))297sage: emps.is_exact()298False299"""300return False301302def coefficient_domain(self) :303r"""304The domain of coefficients.305306OUTPUT:307Either a ring or a module.308309EXAMPLES::310sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids import *311sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_ring import EquivariantMonoidPowerSeriesRing312sage: emps = EquivariantMonoidPowerSeriesRing(NNMonoid(True), TrivialCharacterMonoid("1", QQ), TrivialRepresentation("1", QQ))313sage: emps.coefficient_domain() == QQ314True315"""316return self.__coefficient_domain317318def group(self) :319r"""320The group acting on the index monoid.321322OUTPUT:323Of arbitrary type.324325NOTE:326The framework might change at a later time such that this327function returns a group.328329EXAMPLES::330sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids import *331sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_ring import EquivariantMonoidPowerSeriesRing332sage: emps = EquivariantMonoidPowerSeriesRing(NNMonoid(True), TrivialCharacterMonoid("1", QQ), TrivialRepresentation("1", QQ))333sage: emps.group()334'1'335"""336return self.__action.group()337338def monoid(self) :339r"""340The index monoid.341342OUTPUT:343A monoid as implemented in :class:~`fourier_expansion_framework.monoidpowerseries.NNMonoid`.344345EXAMPLES::346sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids import *347sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_ring import EquivariantMonoidPowerSeriesRing348sage: emps = EquivariantMonoidPowerSeriesRing(NNMonoid(True), TrivialCharacterMonoid("1", QQ), TrivialRepresentation("1", QQ))349sage: emps.monoid()350NN351"""352return self.__action.monoid()353354def action(self) :355r"""356The index monoid with the action of a group.357358OUTPUT:359A monoid with action as implemented in :class:~`fourier_expansion_framework.monoidpowerseries.NNMonoid`.360361EXAMPLES::362sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids import *363sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_ring import EquivariantMonoidPowerSeriesRing364sage: emps = EquivariantMonoidPowerSeriesRing(NNMonoid(True), TrivialCharacterMonoid("1", QQ), TrivialRepresentation("1", QQ))365sage: emps.action()366NN with action367"""368return self.__action369370def characters(self) :371r"""372The monoid of characters associated to the monoid index' group.373374OUTPUT:375A monoid as implemented in :class:~`fourier_expansion_framework.monoidpowerseries.CharacterMonoid_class`.376377EXAMPLES::378sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids import *379sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_ring import EquivariantMonoidPowerSeriesRing380sage: emps = EquivariantMonoidPowerSeriesRing(NNMonoid(True), TrivialCharacterMonoid("1", QQ), TrivialRepresentation("1", QQ))381sage: emps.characters()382Character monoid over Trivial monoid383"""384return self.__characters385386def representation(self) :387r"""388The representation on the coefficient domain.389390OUTPUT:391A representation as implemented in :class:~`fourier_expansion_framework.monoidpowerseries.TrivialRepresentation`.392393EXAMPLES::394sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids import *395sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_ring import EquivariantMonoidPowerSeriesRing396sage: emps = EquivariantMonoidPowerSeriesRing(NNMonoid(True), TrivialCharacterMonoid("1", QQ), TrivialRepresentation("1", QQ))397sage: emps.representation()398Trivial representation of 1 on Rational Field399"""400return self.__representation401402def _reduction_function(self) :403r"""404The reduction function accepts an index `s`. It returns the pair405reduction `(rs = g^-1 s, g)` of `s` with a group element `g`.406407OUTPUT:408A function.409410TESTS::411sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids import *412sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_ring import EquivariantMonoidPowerSeriesRing413sage: emps = EquivariantMonoidPowerSeriesRing(NNMonoid(True), TrivialCharacterMonoid("1", QQ), TrivialRepresentation("1", QQ))414sage: red_function = emps._reduction_function()415sage: red_function(2)416(2, 1)417"""418return self.__reduction_function419420def _set_reduction_function(self, f = None) :421r"""422Set the reduction function, explained in :class:~`._reduction_function`.423If `f` is ``None`` the reduction function of the action is used.424425INPUT:426- `f` -- A function or ``None`` (default: ``None``).427428TESTS::429sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids import *430sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_ring import EquivariantMonoidPowerSeriesRing431sage: emps = EquivariantMonoidPowerSeriesRing(NNMonoid(True), TrivialCharacterMonoid("1", QQ), TrivialRepresentation("1", QQ))432sage: h = lambda : None433sage: emps._set_reduction_function(h)434sage: h == emps._reduction_function()435True436sage: emps._set_reduction_function() ## This is important since emps is globally unique437"""438if not f is None :439self.__reduction_function = f440return441442self.__reduction_function = self.__action._reduction_function()443444def _character_eval_function(self) :445r"""446The character evaluation function. It accepts a character `c` and447a group element `g` and returns `c(g)`.448449OUTPUT:450A function.451452TESTS::453sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids import *454sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_ring import EquivariantMonoidPowerSeriesRing455sage: emps = EquivariantMonoidPowerSeriesRing(NNMonoid(True), TrivialCharacterMonoid("1", QQ), TrivialRepresentation("1", QQ))456sage: eval_func = emps._character_eval_function()457sage: eval_func(emps.characters().one_element(), 1)4581459"""460return self.__character_eval_function461462def _set_character_eval_function(self, f = None) :463r"""464Set the character evaluation function. If `f` is ``None``, the465implementation of the character monoid is used.466467INPUT:468- `f` -- A function or ``None`` (default: ``None``).469470TESTS::471sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids import *472sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_ring import EquivariantMonoidPowerSeriesRing473sage: emps = EquivariantMonoidPowerSeriesRing(NNMonoid(True), TrivialCharacterMonoid("1", QQ), TrivialRepresentation("1", QQ))474sage: h = lambda c,g: 1475sage: emps._set_character_eval_function(h)476sage: h == emps._character_eval_function()477True478sage: emps._set_character_eval_function() ## This is important since emps is globally unique479"""480if not f is None :481self.__character_eval_function = f482return483484self.__character_eval_function = self.__characters._eval_function()485486def _apply_function(self) :487r"""488The apply function. It applies a group element `g` to an element `v`489of the coefficient domain, the base space of the representation.490491OUTPUT:492A function.493494TESTS::495sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids import *496sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_ring import EquivariantMonoidPowerSeriesRing497sage: emps = EquivariantMonoidPowerSeriesRing(NNMonoid(True), TrivialCharacterMonoid("1", QQ), TrivialRepresentation("1", QQ))498sage: app_func = emps._apply_function()499sage: app_func(1, 1/2)5001/2501"""502return self.__apply_function503504def _set_apply_function(self, f = None) :505r"""506Set the apply function. If `f` is ``None``, the implementation of507the representation is used.508509INPUT:510- `f` -- A function or ``None`` (default: ``None``).511512TESTS::513sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids import *514sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_ring import EquivariantMonoidPowerSeriesRing515sage: emps = EquivariantMonoidPowerSeriesRing(NNMonoid(True), TrivialCharacterMonoid("1", QQ), TrivialRepresentation("1", QQ))516sage: h = lambda : None517sage: emps._set_apply_function(h)518sage: h == emps._apply_function()519True520sage: emps._set_apply_function() ## This is important since emps is globally unique521"""522if not f is None :523self.__apply_function = f524return525526self.__apply_function = self.__representation._apply_function()527528def _multiply_function(self) :529r"""530The standard implementation of elements of this ring will ask its531parent to provide multplication function, which has the532following signature:533534multiply function INPUT :535- `k` -- An index.536- ``lcoeffs`` -- A dictionary; The coefficient dictionary of the left factor.537- ``rcoeffs`` -- A dictionary; The coefficient dictionary of the right factor.538- ``lch`` -- A character; The character of the left factor.539- ``rch`` -- A character; The character of the right factor.540- ``null`` -- A ring or module element; TA initialized zero object of541the coefficient domain.542multiply function OUTPUT :543A ring or module element. The `k`-th coefficent of the product544``left * right``, where the power series transform with character545``lch`` and ``rch`` respectively under the action of the power series'546symmetry group.547548TESTS::549sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids import *550sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_ring import EquivariantMonoidPowerSeriesRing551sage: emps = EquivariantMonoidPowerSeriesRing(NNMonoid(True), TrivialCharacterMonoid("1", QQ), TrivialRepresentation("1", QQ))552sage: h = emps._multiply_function()553sage: e = emps( {emps.characters().one_element() : {4 : 3, 5 : 3} } )554sage: (e * e).coefficients() # indirect doctest555{8: 9, 9: 18, 10: 9}556"""557return self.__multiply_function558559def _set_multiply_function(self, f = None) :560r"""561Set the multiply function. If `f` is ``None`` an iteration over the562decompositions in the monoid is used.563564INPUT:565- `f` -- A function or ``None`` (default: ``None``).566567TESTS::568sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids import *569sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_ring import EquivariantMonoidPowerSeriesRing570sage: emps = EquivariantMonoidPowerSeriesRing(NNMonoid(True), TrivialCharacterMonoid("1", QQ), TrivialRepresentation("1", QQ))571sage: h = lambda : None572sage: emps._set_multiply_function(h)573sage: h == emps._multiply_function()574True575"""576if not f is None :577self.__multiply_function = f578return579580def mul(s, lcoeffs, rcoeffs, cl, cr, res) :581reduction = self._reduction_function()582apply = self._apply_function()583character_ev = self._character_eval_function()584585rs, g = reduction(s)586587for s1, s2 in self.__monoid.decompositions(rs) :588rs1, g1 = reduction(s1)589rs2, g2 = reduction(s2)590591try :592v1 = lcoeffs[rs1]593v2 = rcoeffs[rs2]594except KeyError :595continue596v1 = apply(g1, v1)597v2 = apply(g2, v2)598599res += (character_ev(g1, cl) * character_ev(g2, cr)) * v1 * v2600601return character_ev(g, cl*cr) * apply(g, res)602#! def mul603604self.__multiply_function = mul605606def _coerce_map_from_(self, other) :607r"""608TODO:609This is a stub. The dream is that representations know about610compatible coercions and so would actions and characters. Then611every equivariant monoid power series ring would be a functorial612construction in all three parameters (The functor would then be613applied to a representation within a universe of representations).614615TESTS::616sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids import *617sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_ring import EquivariantMonoidPowerSeriesRing618sage: emps = EquivariantMonoidPowerSeriesRing(NNMonoid(True), TrivialCharacterMonoid("1", QQ), TrivialRepresentation("1", QQ))619sage: emps.has_coerce_map_from( EquivariantMonoidPowerSeriesRing(NNMonoid(True), TrivialCharacterMonoid("1", QQ), TrivialRepresentation("1", ZZ)) ) # indirect doctest620True621"""622if isinstance(other, EquivariantMonoidPowerSeriesAmbient_abstract) :623if self.action() == other.action() and \624self.characters() == other.characters() :625if self.representation().extends(other.representation()) :626from sage.structure.coerce_maps import CallableConvertMap627return CallableConvertMap(other, self, self._element_constructor_)628629def _element_constructor_(self, x) :630r"""631TESTS::632sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids import *633sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_ring import MonoidPowerSeriesRing, EquivariantMonoidPowerSeriesRing634sage: emps = EquivariantMonoidPowerSeriesRing(NNMonoid(True), TrivialCharacterMonoid("1", QQ), TrivialRepresentation("1", QQ))635sage: mps = MonoidPowerSeriesRing(QQ, NNMonoid(False))636sage: h = emps(dict()) # indirect doctest637sage: h = emps(1)638sage: h = emps(h)639sage: h = emps(mps(1))640"""641if isinstance(x, Element) :642P = x.parent()643if P is self :644return x645elif isinstance(P, EquivariantMonoidPowerSeriesAmbient_abstract) :646if self.coefficient_domain() is P.coefficient_domain() :647return self._element_class( self,648x.coefficients(True), x.precision() )649else :650coefficient_domain = self.coefficient_domain()651652return self._element_class( self,653dict( (ch, dict( (k,coefficient_domain(c)) for (k,c) in coeffs.iteritems()) )654for (ch, coeffs) in x.coefficients(True).iteritems() ),655x.precision() )656657elif isinstance(P, MonoidPowerSeriesAmbient_abstract) :658if self.coefficient_domain() is P.coefficient_domain() :659return self._element_class(660self, dict([(self.__characters.one_element(),661x.coefficients())]),662self.action().filter(x.precision()),663symmetrise = True )664else :665return self._element_class(666self, dict([(self.__characters.one_element(),667dict( (k,coefficient_domain(c)) for (k,c) in x.coefficients().iteritems()) )]),668self.action().filter(x.precision()),669symmetrise = True )670elif isinstance(x, dict) :671if len(x) != 0 :672try :673if x.keys()[0].parent() is self.__characters :674return self._element_class( self,675x, self.action().filter_all() )676except AttributeError :677pass678679return self._element_class( self,680dict([(self.__characters.one_element(), x)]),681self.action().filter_all() )682683raise TypeError, "can't convert %s into %s" % (x, self)684685def __cmp__(self, other) :686r"""687TESTS::688sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_basicmonoids import *689sage: from psage.modform.fourier_expansion_framework.monoidpowerseries.monoidpowerseries_ambient import EquivariantMonoidPowerSeriesAmbient_abstract690sage: emps = EquivariantMonoidPowerSeriesAmbient_abstract(NNMonoid(True), TrivialCharacterMonoid("1", QQ), TrivialRepresentation("1", QQ))691sage: emps == EquivariantMonoidPowerSeriesAmbient_abstract(NNMonoid(True), TrivialCharacterMonoid("1", QQ), TrivialRepresentation("1", QQ))692True693sage: emps2 = EquivariantMonoidPowerSeriesAmbient_abstract(NNMonoid(True), TrivialCharacterMonoid("1", ZZ), TrivialRepresentation("1", ZZ))694sage: emps == emps2695False696"""697c = cmp(type(self), type(other))698699if c == 0 :700c = cmp(self.action(), other.action())701if c == 0 :702c = cmp(self.representation(), other.representation())703if c == 0 :704c = cmp(self.characters(), other.characters())705706return c707708709