Path: blob/master/src/sage/modular/modform/ambient_eps.py
8820 views
# -*- coding: utf-8 -*-1r"""2Modular Forms with Character34EXAMPLES::56sage: eps = DirichletGroup(13).07sage: M = ModularForms(eps^2, 2); M8Modular Forms space of dimension 3, character [zeta6] and weight 2 over Cyclotomic Field of order 6 and degree 2910sage: S = M.cuspidal_submodule(); S11Cuspidal subspace of dimension 1 of Modular Forms space of dimension 3, character [zeta6] and weight 2 over Cyclotomic Field of order 6 and degree 212sage: S.modular_symbols()13Modular Symbols subspace of dimension 2 of Modular Symbols space of dimension 4 and level 13, weight 2, character [zeta6], sign 0, over Cyclotomic Field of order 6 and degree 21415We create a spaces associated to Dirichlet characters of modulus 225::1617sage: e = DirichletGroup(225).018sage: e.order()19620sage: e.base_ring()21Cyclotomic Field of order 60 and degree 1622sage: M = ModularForms(e,3)2324Notice that the base ring is "minimized"::2526sage: M27Modular Forms space of dimension 66, character [zeta6, 1] and weight 328over Cyclotomic Field of order 6 and degree 22930If we don't want the base ring to change, we can explicitly specify it::3132sage: ModularForms(e, 3, e.base_ring())33Modular Forms space of dimension 66, character [zeta6, 1] and weight 334over Cyclotomic Field of order 60 and degree 163536Next we create a space associated to a Dirichlet character of order 20::3738sage: e = DirichletGroup(225).139sage: e.order()402041sage: e.base_ring()42Cyclotomic Field of order 60 and degree 1643sage: M = ModularForms(e,17); M44Modular Forms space of dimension 484, character [1, zeta20] and45weight 17 over Cyclotomic Field of order 20 and degree 84647We compute the Eisenstein subspace, which is fast even though48the dimension of the space is large (since an explicit basis49of `q`-expansions has not been computed yet).5051::5253sage: M.eisenstein_submodule()54Eisenstein subspace of dimension 8 of Modular Forms space of55dimension 484, character [1, zeta20] and weight 17 over Cyclotomic Field of order 20 and degree 85657sage: M.cuspidal_submodule()58Cuspidal subspace of dimension 476 of Modular Forms space of dimension 484, character [1, zeta20] and weight 17 over Cyclotomic Field of order 20 and degree 85960TESTS::6162sage: m = ModularForms(DirichletGroup(20).1,5)63sage: m == loads(dumps(m))64True65sage: type(m)66<class 'sage.modular.modform.ambient_eps.ModularFormsAmbient_eps_with_category'>67"""6869#########################################################################70# Copyright (C) 2006 William Stein <[email protected]>71#72# Distributed under the terms of the GNU General Public License (GPL)73#74# http://www.gnu.org/licenses/75#########################################################################7677import sage.rings.all as rings7879import sage.modular.arithgroup.all as arithgroup80import sage.modular.dirichlet as dirichlet81import sage.modular.modsym.modsym as modsym8283import ambient84import ambient_R85import cuspidal_submodule86import eisenstein_submodule8788class ModularFormsAmbient_eps(ambient.ModularFormsAmbient):89"""90A space of modular forms with character.91"""92def __init__(self, character, weight=2, base_ring=None):93"""94Create an ambient modular forms space with character.9596.. note::9798The base ring must be of characteristic 0. The ambient_R99Python module is used for computing in characteristic p,100which we view as the reduction of characteristic 0.101102INPUT:103104- ``weight`` - int105106- ``character`` - dirichlet.DirichletCharacter107108- ``base_ring`` - base field109110EXAMPLES::111112sage: m = ModularForms(DirichletGroup(11).0,3); m113Modular Forms space of dimension 3, character [zeta10] and weight 3 over Cyclotomic Field of order 10 and degree 4114sage: type(m)115<class 'sage.modular.modform.ambient_eps.ModularFormsAmbient_eps_with_category'>116"""117if not dirichlet.is_DirichletCharacter(character):118raise TypeError, "character (=%s) must be a Dirichlet character"%character119if base_ring==None: base_ring=character.base_ring()120if character.base_ring() != base_ring:121character = character.change_ring(base_ring)122if base_ring.characteristic() != 0:123raise ValueError, "the base ring must have characteristic 0."124group = arithgroup.Gamma1(character.modulus())125base_ring = character.base_ring()126ambient.ModularFormsAmbient.__init__(self, group, weight, base_ring, character)127128def _repr_(self):129"""130String representation of this space with character.131132EXAMPLES::133134sage: m = ModularForms(DirichletGroup(8).1,2)135sage: m._repr_()136'Modular Forms space of dimension 2, character [1, -1] and weight 2 over Rational Field'137138You can rename the space with the rename command.139140::141142sage: m.rename('Modforms of level 8')143sage: m144Modforms of level 8145"""146try:147d = self.dimension()148except NotImplementedError:149d = "(unknown)"150return "Modular Forms space of dimension %s, character %s and weight %s over %s"%(151d, self.character()._repr_short_(), self.weight(), self.base_ring())152153def cuspidal_submodule(self):154"""155Return the cuspidal submodule of this ambient space of modular forms.156157EXAMPLES::158159sage: eps = DirichletGroup(4).0160sage: M = ModularForms(eps, 5); M161Modular Forms space of dimension 3, character [-1] and weight 5 over Rational Field162sage: M.cuspidal_submodule()163Cuspidal subspace of dimension 1 of Modular Forms space of dimension 3, character [-1] and weight 5 over Rational Field164"""165try:166return self.__cuspidal_submodule167except AttributeError:168self.__cuspidal_submodule = cuspidal_submodule.CuspidalSubmodule_eps(self)169return self.__cuspidal_submodule170171def change_ring(self, base_ring):172"""173Return space with same defining parameters as this ambient174space of modular symbols, but defined over a different base175ring.176177EXAMPLES::178179sage: m = ModularForms(DirichletGroup(13).0^2,2); m180Modular Forms space of dimension 3, character [zeta6] and weight 2 over Cyclotomic Field of order 6 and degree 2181sage: m.change_ring(CyclotomicField(12))182Modular Forms space of dimension 3, character [zeta6] and weight 2 over Cyclotomic Field of order 12 and degree 4183184It must be possible to change the ring of the underlying Dirichlet character::185186sage: m.change_ring(QQ)187Traceback (most recent call last):188...189ValueError: cannot coerce element of order 6 into self190"""191if self.base_ring() == base_ring:192return self193return ambient_R.ModularFormsAmbient_R(self, base_ring = base_ring)194195def modular_symbols(self, sign=0):196"""197Return corresponding space of modular symbols with given sign.198199EXAMPLES::200201sage: eps = DirichletGroup(13).0202sage: M = ModularForms(eps^2, 2)203sage: M.modular_symbols()204Modular Symbols space of dimension 4 and level 13, weight 2, character [zeta6], sign 0, over Cyclotomic Field of order 6 and degree 2205sage: M.modular_symbols(1)206Modular Symbols space of dimension 3 and level 13, weight 2, character [zeta6], sign 1, over Cyclotomic Field of order 6 and degree 2207sage: M.modular_symbols(-1)208Modular Symbols space of dimension 1 and level 13, weight 2, character [zeta6], sign -1, over Cyclotomic Field of order 6 and degree 2209sage: M.modular_symbols(2)210Traceback (most recent call last):211...212ValueError: sign must be -1, 0, or 1213"""214sign = rings.Integer(sign)215try:216return self.__modsym[sign]217except AttributeError:218self.__modsym = {}219except KeyError:220pass221self.__modsym[sign] = modsym.ModularSymbols(\222self.character(),223weight = self.weight(),224sign = sign,225base_ring = self.base_ring())226return self.__modsym[sign]227228def eisenstein_submodule(self):229"""230Return the submodule of this ambient module with character that is231spanned by Eisenstein series. This is the Hecke stable complement232of the cuspidal submodule.233234EXAMPLES::235236sage: m = ModularForms(DirichletGroup(13).0^2,2); m237Modular Forms space of dimension 3, character [zeta6] and weight 2 over Cyclotomic Field of order 6 and degree 2238sage: m.eisenstein_submodule()239Eisenstein subspace of dimension 2 of Modular Forms space of dimension 3, character [zeta6] and weight 2 over Cyclotomic Field of order 6 and degree 2240"""241try:242return self.__eisenstein_submodule243except AttributeError:244self.__eisenstein_submodule = eisenstein_submodule.EisensteinSubmodule_eps(self)245return self.__eisenstein_submodule246247def hecke_module_of_level(self, N):248r"""249Return the Hecke module of level N corresponding to self, which is the250domain or codomain of a degeneracy map from self. Here N must be either251a divisor or a multiple of the level of self, and a multiple of the252conductor of the character of self.253254EXAMPLES::255256sage: M = ModularForms(DirichletGroup(15).0, 3); M.character().conductor()2573258sage: M.hecke_module_of_level(3)259Modular Forms space of dimension 2, character [-1] and weight 3 over Rational Field260sage: M.hecke_module_of_level(5)261Traceback (most recent call last):262...263ValueError: conductor(=3) must divide M(=5)264sage: M.hecke_module_of_level(30)265Modular Forms space of dimension 16, character [-1, 1] and weight 3 over Rational Field266"""267import constructor268if N % self.level() == 0:269return constructor.ModularForms(self.character().extend(N), self.weight(), self.base_ring(), prec=self.prec())270elif self.level() % N == 0:271return constructor.ModularForms(self.character().restrict(N), self.weight(), self.base_ring(), prec=self.prec())272else:273raise ValueError, "N (=%s) must be a divisor or a multiple of the level of self (=%s)" % (N, self.level())274275####################################################################276# Computations of Dimensions277####################################################################278def _dim_cuspidal(self):279"""280Return the dimension of the cuspidal subspace, computed using a dimension formula.281282EXAMPLES::283284sage: m = ModularForms(DirichletGroup(389,CyclotomicField(4)).0,3); m._dim_cuspidal()28564286"""287try:288return self.__the_dim_cuspidal289except AttributeError:290self.__the_dim_cuspidal = self.group().dimension_cusp_forms(291self.weight(), eps=self.character())292return self.__the_dim_cuspidal293294def _dim_eisenstein(self):295"""296Return the dimension of the Eisenstein subspace of this space, computed297using a dimension formula.298299EXAMPLES::300301sage: m = ModularForms(DirichletGroup(13).0,7); m302Modular Forms space of dimension 8, character [zeta12] and weight 7 over Cyclotomic Field of order 12 and degree 4303sage: m._dim_eisenstein()3042305sage: m._dim_cuspidal()3066307"""308try:309return self.__the_dim_eisenstein310except AttributeError:311self.__the_dim_eisenstein = self.group().dimension_eis(self.weight(), eps=self.character())312return self.__the_dim_eisenstein313314def _dim_new_cuspidal(self):315"""316Return the dimension of the new cuspidal subspace, computed317using a dimension formula.318319EXAMPLES::320321sage: m = ModularForms(DirichletGroup(33).0,7); m322Modular Forms space of dimension 26, character [-1, 1] and weight 7 over Rational Field323sage: m._dim_new_cuspidal()32420325sage: m._dim_cuspidal()32622327"""328try:329return self.__the_dim_new_cuspidal330except AttributeError:331self.__the_dim_new_cuspidal = self.group().dimension_new_cusp_forms(self.weight(), eps=self.character())332return self.__the_dim_new_cuspidal333334def _dim_new_eisenstein(self):335"""336Return the dimension of the new Eisenstein subspace, computed337by enumerating all Eisenstein series of the appropriate level.338339EXAMPLES::340341sage: m = ModularForms(DirichletGroup(36).0,5); m342Modular Forms space of dimension 28, character [-1, 1] and weight 5 over Rational Field343sage: m._dim_new_eisenstein()3442345sage: m._dim_eisenstein()3468347"""348try:349return self.__the_dim_new_eisenstein350except AttributeError:351if self.character().is_trivial() and self.weight() == 2:352if rings.is_prime(self.level()):353d = 1354else:355d = 0356else:357E = self.eisenstein_series()358d = len([g for g in E if g.new_level() == self.level()])359self.__the_dim_new_eisenstein = d360return self.__the_dim_new_eisenstein361362363364365