Ticket #6768: hecke.patch

File hecke.patch, 3.4 KB (added by wakep, 13 years ago)
  • sage/modular/hecke/algebra.py

    # HG changeset patch
    # User Preston Wake <preston.wake@gmail.com>
    # Date 1250471218 14400
    # Node ID 0fce5ebf9305c04d7c997245e2608ed25c761f0d
    # Parent  2e793d2a0e123293b73eed40715e43185fd9ccfe
    Added code for bases of Hecke Algebras
    
    diff -r 2e793d2a0e12 -r 0fce5ebf9305 sage/modular/hecke/algebra.py
    a b  
    3131import math
    3232import weakref
    3333
     34import sage.rings.all as rings
    3435import sage.rings.arith as arith
    3536import sage.rings.infinity
    3637import sage.misc.latex as latex
     
    4041import sage.rings.commutative_algebra
    4142from sage.misc.misc import verbose
    4243from sage.matrix.constructor import matrix
     44from sage.rings.arith import lcm
     45from sage.matrix.matrix_space import MatrixSpace
    4346
    4447def is_HeckeAlgebra(x):
    4548    r"""
     
    142145    return T
    143146
    144147
     148def _heckebasis(M):
     149    r"""
     150    Gives a basis of the hecke algebra of M as a ZZ-module
     151
     152    INPUT:
     153
     154    - ``M`` - a hecke module
     155
     156    OUTPUT:
     157
     158    - a list of hecke algebra elements represented as matrices
     159
     160    EXAMPLES::
     161   
     162        sage: M = ModularSymbols(11,2,1)
     163        sage: sage.modular.hecke.algebra._heckebasis(M)
     164        [Hecke operator on Modular Symbols space of dimension 2 for Gamma_0(11) of weight 2 with sign 1 over Rational Field defined by:
     165        [1 0]
     166        [0 1],
     167        Hecke operator on Modular Symbols space of dimension 2 for Gamma_0(11) of weight 2 with sign 1 over Rational Field defined by:
     168        [0 1]
     169        [0 5]]
     170    """
     171    QQ = rings.QQ
     172    ZZ = rings.ZZ
     173    d = M.rank()
     174    VV = QQ**(d**2)
     175    WW = ZZ**(d**2)
     176    MM = MatrixSpace(QQ,d)
     177    MMZ = MatrixSpace(ZZ,d)
     178    S = []; Denom = []; B = []; B1 = []
     179    for i in xrange(1, M.hecke_bound() + 1):
     180        v = M.hecke_operator(i).matrix()
     181        den = v.denominator()
     182        Denom.append(den)
     183        S.append(v)
     184    den = lcm(Denom)
     185    for m in S:
     186        B.append(WW((den*m).list()))
     187    UU = WW.submodule(B)
     188    B = UU.basis()
     189    for u in B:
     190        u1 = u.list()
     191        m1 = M.hecke_algebra()(MM(u1), check=False)
     192        #m1 = MM(u1)
     193        B1.append((1/den)*m1)
     194    return B1
     195
     196
    145197class HeckeAlgebra_base(sage.rings.commutative_algebra.CommutativeAlgebra):
    146198    """
    147199    Base class for algebras of Hecke operators on a fixed Hecke module.
     
    404456    def basis(self):
    405457        r"""
    406458        Return a basis for this Hecke algebra as a free module over
    407         its base ring. Not implemented at present.
     459        its base ring.
    408460
    409461        EXAMPLE::
    410462
    411463            sage: ModularSymbols(Gamma1(3), 3).hecke_algebra().basis()
    412             Traceback (most recent call last):
    413             ...
    414             NotImplementedError
     464            [Hecke operator on Modular Symbols space of dimension 2 for Gamma_1(3) of weight 3 with sign 0 and over Rational Field defined by:
     465            [1 0]
     466            [0 1],
     467            Hecke operator on Modular Symbols space of dimension 2 for Gamma_1(3) of weight 3 with sign 0 and over Rational Field defined by:
     468            [0 0]
     469            [0 2]]
    415470        """
    416         raise NotImplementedError
     471        try:
     472            return self.__basis_cache
     473        except AttributeError:
     474            self.__basis_cache=_heckebasis(self.__M)
     475            return self.__basis_cache
    417476
    418477    def discriminant(self):
    419478        r"""