Exemple #1
0
def compute_more_rational_eigenvalues(s, N, bound, verb=False):
    """
    Computes rational eigenvalues for all rational eigenvectors in the
    given space up to the given bound.  Commits result to database only
    if it succeeds at computing all the (good) eigenvalues.
    """
    if not know_all_rational_newforms(s, N):
        if verb: print "Can't compute more rational eigenvalues until we know all rational eigenvectors at level %s (of norm %s)"%(N, N.norm())
        return
    else:
        print "Computing more rational eigenvalues for eigenvectors of level %s (of norm %s)"%(N, N.norm())
    NrmN = N.norm()
    H = get_space(s, N)
    M = H.hmf()
    V = M.vector_space()
    I = M._icosians_mod_p1
    import sys
    for f in H.rational_newforms:
        vector = V(eval(f.vector)) if f.vector is not None else None
        dual_vector = V(eval(f.dual_vector))
        i = dual_vector.nonzero_positions()[0]
        c = dual_vector[i]
        for P in primes_of_bounded_norm(bound):
            Ps = P.sage_ideal()
            # 1. Do we already know this eigenvalue or not?
            if s.query(RationalEigenvalue).filter(
                         RationalEigenvalue.newform_id == f.id).filter(
                         RationalEigenvalue.p == P.p).filter(
                         RationalEigenvalue.r == P.r).count() > 0:
                continue
                
            # 2. We do not know it, so compute it -- two cases:
            #   2a. if it has residue char coprime to the level, use dual eigenvector
            ap = None
            if NrmN % P.p != 0:
                print P,; sys.stdout.flush()
                ap = I.hecke_operator_on_basis_element(Ps, i).dot_product(dual_vector)/c
            
            #   2b. if it has residue char not coprime to level, use slower direct approaches
            else:
                if (Ps*Ps).divides(N):
                    ap = 0
                elif not Ps.divides(N):
                    if vector is None:
                        if verb: print "You need to compute subspace vector to compute a_p at present."
                    else:
                        j = vector.nonzero_positions()[0]
                        ap = (vector*M.hecke_matrix(Ps))[j] / vector[j]
                else:
                    # we have no algorithm directly at present to decide if this is 1 or -1.
                    if verb: print "Can't compute ap for p=%s"%P
            
            # 3. Store eigenvalue ap in the database.
            if ap is not None:
                f.store_eigenvalue(P, ap)
Exemple #2
0
def compute_more_rational_eigenvalues_in_parallel(B1, B2, bound, ncpus=8):
    print "Preloading Hecke operator sets before forking."
    from sage.modular.hilbert.sqrt5 import hecke_elements
    from ideals_of_norm import ideals_of_norm
    
    for P in primes_of_bounded_norm(bound):
        print P, len(hecke_elements(P.sage_ideal()))
    
    @parallel(ncpus)
    def f(N):
        for I in ideals_of_norm(N): 
            s = session()
            compute_more_rational_eigenvalues(s, I, bound=bound)
            s.commit()
        
    for X in f(range(max(2,B1), B2+1)):
        print X
Exemple #3
0
 def known_aplist(self):
     """
     Output is a 2-tuple (aplist, primes,), where:
         aplist = list of integers of None
         primes = list of psage fast primes
     """
     if len(self.eigenvalues) == 0:
         return [], [], []
     B = self.eigenvalues[-1].norm
     primes = primes_of_bounded_norm(B+1)
     aplist = [None]*len(primes)
     last_p = None
     for ap in self.eigenvalues:
         P = Prime(ap.p, ap.r, first = (last_p != ap.p))
         last_p = ap.p
         i = primes.index(P)  # potentially "slow" but nothing compared to DB accesses...
         aplist[i] = ap.value
     return aplist, primes
Exemple #4
0
def compute_rational_eigenvectors(s, N, bound=100):
    """
    N = ideal, the level
    bound = compute this many a_p and use this many for ruling out oldforms
    
    This functions calls the "inefficient" elliptic_curve_factors method on the Hilbert
    modular forms space of level N, which has some problems:
        (1) some of the returned factors may actually be *old*
        (2) it is potentially very slow, since it computes the factors of all dimensions

    WARNING!: Just *loading* from disk the pre-computed elts of norm pi_p up to
    norm 4096 takes nearly *20 minutes*, but afterwards computing particular
    aplists for any form takes way under 20 *seconds*.
    """
    # First do a query to see if we already know *all* of the rational
    # eigenvectors.
    if know_all_rational_newforms(s, N):
        print "We already know all rational eigenvectors at level %s (of norm %s)"%(N, N.norm())
        return
    H = get_space(s, N)
    M = H.hmf()
    primes = primes_of_bounded_norm(bound)
    num_forms = 0
    for E in M.elliptic_curve_factors():
        if not N.is_prime():
            # worry about E possibly actually being old
            v = E.aplist(bound)
            if is_rational_old(s, v, primes, N)[0]:
                print "*"*80
                print "skipping a form that is old"
                print "*"*80                
        f = store_rational_newform(s, M, E._S.basis()[0], E.dual_eigenvector())
        num_forms += 1
        print "*"*80
        print "form %s"%num_forms
        print "*"*80
        # store eigenvalues
        v = E.aplist(bound)
        for i in range(len(v)):
            if v[i] != '?':
                f.store_eigenvalue(primes[i], int(v[i]))
    H.number_of_rational_newforms = num_forms
    s.commit()