Changeset 5789:bc830aafbcdc


Ignore:
Timestamp:
08/18/07 16:15:46 (6 years ago)
Author:
William Stein <wstein@…>
Branch:
default
Message:

improved some of the code for modular forms.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sage/modular/modform/space.py

    r4875 r5789  
    403403    def integral_basis(self): 
    404404        """ 
    405  
     405        Return an integral basis for this space of modular forms. 
     406         
     407        EXAMPLES: 
    406408        """ 
    407409        try: 
     
    417419            return I 
    418420 
    419     def _q_expansion_module(self, prec=None): 
     421    def _q_expansion_module(self): 
     422        """ 
     423        Return module spanned by coefficients of q-expansions to 
     424        sufficient precision to determine elements of this space. 
     425 
     426        EXAMPLES: 
     427        """ 
    420428        try: 
    421429            return self.__q_expansion_module 
    422430        except AttributeError: 
    423431            pass 
    424         if prec is None: 
    425             prec = int(1.2*self.dimension()) + 2 
    426         C = self.q_expansion_basis(prec) 
    427         V = self.base_ring()**prec 
    428         try: 
    429             W = V.span_of_basis([f.padded_list(prec) for f in C]) 
    430         except AttributeError: 
    431             return self._q_expansion_module(self, 2*prec) 
     432        prec = int(1.2*self.dimension()) + 3         # +3 for luck. 
     433        tries = 0 
     434        while True: 
     435            C = self.q_expansion_basis(prec) 
     436            V = self.base_ring()**prec 
     437            try: 
     438                W = V.span_of_basis([f.padded_list(prec) for f in C]) 
     439                break 
     440            except Exception: 
     441                prec += self.dimension() 
     442                tries += 1 
     443                if tries > 5: 
     444                    print "WARNING: possibly bug in _q_expansion_module for modular forms space %s"%self 
    432445        self.__q_expansion_module = W 
    433446        return W 
     
    435448    def q_expansion_basis(self, prec=None): 
    436449        """ 
    437         The number of q-expansions returned equals the dimension. 
     450        Return a sequence of q-expansions for this space. 
    438451 
    439452        INPUT: 
     
    460473            current_prec, B = self.__q_expansion_basis 
    461474        except AttributeError: 
    462             current_prec, B = -1, Sequence([], cr=True) 
     475            (current_prec, B) = (-1, Sequence([], cr=True)) 
    463476        if current_prec == prec: 
    464477            return B 
Note: See TracChangeset for help on using the changeset viewer.