Ticket #1127: trac_1127.patch

File trac_1127.patch, 2.7 KB (added by AlexGhitza, 14 years ago)
  • sage/modular/hecke/submodule.py

    # HG changeset patch
    # User Alexandru Ghitza <aghitza@alum.mit.edu>
    # Date 1232666579 -39600
    # Node ID e588b6d284116f84a7791ba8d1160cdeda56e5ca
    # Parent  ea9e3daf12fa969af7fa58ef69888694c3b8640a
    trac 1127: fix complements of submodules of modular symbols
    
    diff -r ea9e3daf12fa -r e588b6d28411 sage/modular/hecke/submodule.py
    a b  
    154154    def complement(self, bound=None):
    155155        """
    156156        Return the largest Hecke-stable complement of this space.
     157
     158        EXAMPLES:
     159            sage: M = ModularSymbols(15, 6).cuspidal_subspace()
     160            sage: M.complement()
     161            Modular Symbols subspace of dimension 4 of Modular Symbols space of dimension 20 for Gamma_0(15) of weight 6 with sign 0 over Rational Field
     162            sage: E = EllipticCurve("128a")
     163            sage: ME = E.modular_symbol_space()
     164            sage: ME.complement()
     165            Modular Symbols subspace of dimension 17 of Modular Symbols space of dimension 18 for Gamma_0(128) of weight 2 with sign 1 over Rational Field
    157166        """
    158167        try:
    159168            return self.__complement
     
    180189        if bound is None:
    181190            bound = A.hecke_bound()
    182191        while True:
    183             misc.verbose("using T_%s"%p)
    184192            if anemic:
    185193                while N % p == 0: p = arith.next_prime(p)
     194            misc.verbose("using T_%s"%p)
    186195            f = self.hecke_polynomial(p)
    187196            T = A.hecke_matrix(p)
    188197            g = T.charpoly('x')
     
    197206            C = A.submodule(V, check=False)
    198207            self.__complement = C           
    199208            return C
    200         else:
    201             # failed
    202             raise RuntimeError, "Computation of complementary space failed (cut down to rank %s, but should have cut down to rank %s)."%(V.rank(), self.rank())
     209
     210        # first attempt to compute the complement failed, we now try
     211        # the following naive approach: decompose the ambient space,
     212        # decompose self, and sum the pieces of ambient that are not
     213        # subspaces of self
     214        misc.verbose("falling back on naive algorithm")
     215        D = A.decomposition()
     216        C = A.zero_submodule()
     217        for X in D:
     218            if self.intersection(X).dimension() == 0:
     219                C = C + X
     220        if C.rank() + self.rank() == A.rank():
     221            self.__complement = C
     222            return C
     223
     224        # failed miserably
     225        raise RuntimeError, "Computation of complementary space failed (cut down to rank %s, but should have cut down to rank %s)."%(V.rank(), A.rank()-self.rank())
    203226
    204227
    205228    def degeneracy_map(self, level, t=1):