Path: blob/master/src/sage/modular/modform/ambient_R.py
8820 views
"""1Modular Forms over a Non-minimal Base Ring2"""34#########################################################################5# Copyright (C) 2006 William Stein <[email protected]>6#7# Distributed under the terms of the GNU General Public License (GPL)8#9# http://www.gnu.org/licenses/10#########################################################################1112import ambient13from cuspidal_submodule import CuspidalSubmodule_R14from sage.rings.all import ZZ1516class ModularFormsAmbient_R(ambient.ModularFormsAmbient):17def __init__(self, M, base_ring):18"""19Ambient space of modular forms over a ring other than QQ.2021EXAMPLES::2223sage: M = ModularForms(23,2,base_ring=GF(7)) ## indirect doctest24sage: M25Modular Forms space of dimension 3 for Congruence Subgroup Gamma0(23) of weight 2 over Finite Field of size 726sage: M == loads(dumps(M))27True28"""29self.__M = M30if M.character() is not None:31self.__R_character = M.character().change_ring(base_ring)32else:33self.__R_character = None34ambient.ModularFormsAmbient.__init__(self, M.group(), M.weight(), base_ring, M.character())3536def modular_symbols(self,sign=0):37r"""38Return the space of modular symbols attached to this space, with the given sign (default 0).3940TESTS::4142sage: K.<i> = QuadraticField(-1)43sage: chi = DirichletGroup(5, base_ring = K).044sage: L.<c> = K.extension(x^2 - 402*i)45sage: M = ModularForms(chi, 7, base_ring = L)46sage: symbs = M.modular_symbols()47sage: symbs.character() == chi48True49sage: symbs.base_ring() == L50True51"""52sign = ZZ(sign)53try:54return self.__modular_symbols[sign]55except AttributeError:56self.__modular_symbols = {}57except KeyError:58pass59M = self.__M.modular_symbols(sign).change_ring(self.base_ring())60self.__modular_symbols[sign] = M61return M6263def _repr_(self):64"""65String representation for self.6667EXAMPLES::6869sage: M = ModularForms(23,2,base_ring=GF(7)) ## indirect doctest70sage: M._repr_()71'Modular Forms space of dimension 3 for Congruence Subgroup Gamma0(23) of weight 2 over Finite Field of size 7'7273sage: chi = DirichletGroup(109).0 ** 3674sage: ModularForms(chi, 2, base_ring = chi.base_ring())75Modular Forms space of dimension 9, character [zeta3] and weight 2 over Cyclotomic Field of order 108 and degree 3676"""77s = str(self.__M)78i = s.find('over')79if i != -1:80s = s[:i]81return s + 'over %s'%self.base_ring()8283def _compute_q_expansion_basis(self, prec=None):84"""85Compute q-expansions for a basis of self to precision prec.8687EXAMPLES:88sage: M = ModularForms(23,2,base_ring=GF(7))89sage: M._compute_q_expansion_basis(5)90[1 + 5*q^3 + 5*q^4 + O(q^5),91q + 6*q^3 + 6*q^4 + O(q^5),92q^2 + 5*q^3 + 6*q^4 + O(q^5)]93"""94if prec == None:95prec = self.prec()96if self.base_ring().characteristic() == 0:97B = self.__M.q_expansion_basis(prec)98else:99B = self.__M.q_integral_basis(prec)100R = self._q_expansion_ring()101return [R(f) for f in B]102103def cuspidal_submodule(self):104r"""105Return the cuspidal subspace of this space.106107EXAMPLE::108109sage: C = CuspForms(7, 4, base_ring=CyclotomicField(5)) # indirect doctest110sage: type(C)111<class 'sage.modular.modform.cuspidal_submodule.CuspidalSubmodule_R_with_category'>112"""113return CuspidalSubmodule_R(self)114115116def change_ring(self, R):117r"""118Return this modular forms space with the base ring changed to the ring R.119120EXAMPLE::121122sage: chi = DirichletGroup(109, CyclotomicField(3)).0123sage: M9 = ModularForms(chi, 2, base_ring = CyclotomicField(9))124sage: M9.change_ring(CyclotomicField(15))125Modular Forms space of dimension 10, character [zeta3 + 1] and weight 2 over Cyclotomic Field of order 15 and degree 8126sage: M9.change_ring(QQ)127Traceback (most recent call last):128...129ValueError: Space cannot be defined over Rational Field130"""131if not R.has_coerce_map_from(self.__M.base_ring()):132raise ValueError, "Space cannot be defined over %s" % R133return ModularFormsAmbient_R(self.__M, R)134135136