當前位置: 首頁>>代碼示例>>Python>>正文


Python hilbert_field.HilbertNumberField類代碼示例

本文整理匯總了Python中lmfdb.hilbert_modular_forms.hilbert_field.HilbertNumberField的典型用法代碼示例。如果您正苦於以下問題:Python HilbertNumberField類的具體用法?Python HilbertNumberField怎麽用?Python HilbertNumberField使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了HilbertNumberField類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: check_ideal_labels

def check_ideal_labels(field_label='2.2.5.1', min_norm=0, max_norm=None, fix=False, verbose=False):
    r""" Go through all curves with the given field label, assumed totally
    real, check whether the ideal label agrees with the level_label of
    the associated Hilbert Modular Form.
    """
    hmfs = conn.hmfs
    forms = hmfs.forms
    fields = hmfs.fields
    query = {}
    query['field_label'] = field_label
    query['conductor_norm'] = {'$gte' : int(min_norm)}
    if max_norm:
        query['conductor_norm']['$lte'] = int(max_norm)
    else:
        max_norm = 'infinity'
    cursor = nfcurves.find(query)
    nfound = 0
    nnotfound = 0
    K = HilbertNumberField(field_label)
    # NB We used to have 20 in the next line but that is insufficient
    # to distinguish the a_p for forms 2.2.12.1-150.1-a and
    # 2.2.12.1-150.1-b !
    primes = [P['ideal'] for P in K.primes_iter(30)]
    remap = {} # remap[old_label] = new_label

    for ec in cursor:
        fix_needed = False
        cond_label = ec['conductor_label']
        if cond_label in remap:
            new_cond_label = remap[cond_label]
            fix_needed=(cond_label!=new_cond_label)
            if not fix_needed:
                if verbose:
                    print("conductor label %s ok" % cond_label)
        else:
            conductor = make_conductor(ec,K)
            level = K.ideal(cond_label)
            new_cond_label = K.ideal_label(conductor)
            remap[cond_label] = new_cond_label
            fix_needed=(cond_label!=new_cond_label)

        if fix_needed:
            print("conductor label for curve %s is wrong, should be %s not %s" % (ec['label'],new_cond_label, cond_label))
            if fix:
                iso = ec['iso_label']
                num = str(ec['number'])
                newlabeldata = {}
                newlabeldata['conductor_label'] = new_cond_label
                newlabeldata['short_class_label'] = '-'.join([new_cond_label,iso])
                newlabeldata['short_label'] = ''.join([newlabeldata['short_class_label'],num])
                newlabeldata['class_label'] = '-'.join([field_label,
                                                        newlabeldata['short_class_label']])
                newlabeldata['label'] = '-'.join([field_label,
                                                  newlabeldata['short_label']])
                nfcurves.update({'_id': ec['_id']}, {"$set": newlabeldata}, upsert=True)
        else:
            if verbose:
                print("conductor label %s ok" % cond_label)

    return dict([(k,remap[k]) for k in remap if not k==remap[k]])
開發者ID:jbalakrishnan,項目名稱:lmfdb,代碼行數:60,代碼來源:hmf_check_find.py

示例2: compare_with_db

    def compare_with_db(self, field=None):
        lab = self.dbdata['label']
        f = WebHMF.by_label(lab)
        if f==None:
            print("No Hilbert newform in the database has label %s" % lab)
            return False
        if field==None:
            field = HilbertNumberField(self.dbdata['field_label'])
        agree = True
        for key in self.dbdata.keys():
            if key in ['is_base_change', 'is_CM']:
                continue
            if key=='hecke_eigenvalues':
                if self.dbdata[key]!=f.dbdata[key]:
                    agree = False
                    print("Inconsistent data for HMF %s in field %s" % (lab,key))
                    print("self has %s entries, \ndb   has %s entries" % (len(self.dbdata[key]),len(f.dbdata[key])))
                    print("Entries differ at indices %s" % [i for i in range(len(self.dbdata[key])) if self.dbdata[key][i]!=f.dbdata[key][i]])
            elif key=='level_ideal':
                if self.dbdata[key]!=f.dbdata[key]:
                    I = field.ideal_from_str(f.dbdata['level_ideal'])[2]
                    J = field.ideal_from_str(self.dbdata['level_ideal'])[2]
                    if I==J:
                        print("OK, these are the same ideal")
                    else:
                        agree = False
                        print("These are different ideals!")

            else:
                if self.dbdata[key]!=f.dbdata[key]:
                    agree = False
                    print("Inconsistent data for HMF %s in field %s" % (lab,key))
        return agree
開發者ID:koffie,項目名稱:lmfdb,代碼行數:33,代碼來源:web_HMF.py

示例3: check_multiplicity_one

def check_multiplicity_one(label):
    F = HilbertNumberField(label)
    count = 0
    for N in F.ideals_iter():
        Lf = forms.find({'field_label':label, 'level_label':N['label']})
        Lf = [f for f in Lf]
        n = len(Lf)
        for i in range(n):
            for j in range(i+1,n):
                if forms_equal(Lf[i],Lf[j]):
                    count += 1
                    print "duplicates: "+Lf[i]['label']+" and "+Lf[j]['label']
    print("Found "+str(count)+" duplicate forms.")
開發者ID:sehlen,項目名稱:lmfdb,代碼行數:13,代碼來源:check_conjugates.py

示例4: checkprimes

def checkprimes(label):
    Fdata = get_Fdata(label)
    gen_name = findvar(Fdata['ideals'])
    WebF = get_WNF(label, gen_name)
    F = WebF.K()
    # ideals = niceideals(F, Fdata['ideals']) # never used
    primes = niceideals(F, Fdata['primes'])
    F = HilbertNumberField(label)
    L = []
    for prhnf,prideal,prlabel in primes:
        ideal = F.ideal(prlabel)
        if ideal != prideal:
            L.append(prlabel)
    return L
開發者ID:sehlen,項目名稱:lmfdb,代碼行數:14,代碼來源:check_conjugates.py

示例5: export_magma_output

def export_magma_output(infilename, outfilename=None, verbose=False):
    r"""
    Convert Magma search output to a curves file.

    INPUT:

    - ``infilename`` (string) -- name of file containing Magma output

    - ``outfilename`` (string, default ``None``) -- name of output file

    - ``verbose`` (boolean, default ``False``) -- verbosity flag.
    """
    if outfilename:
        outfile = file(outfilename, mode="w")

    def output(L):
        if outfilename:
            outfile.write(L)
        if verbose:
            sys.stdout.write(L)

    K = None

    for field_label, cond_label, iso_label, num, cond_ideal, ai in magma_output_iter(infilename):
        ec = {}
        ec['field_label'] = field_label
        if not K:
            K = HilbertNumberField(field_label)
        ec['conductor_label'] = cond_label
        ec['iso_label'] = iso_label
        ec['number'] = num
        N = K.ideal(cond_label)
        norm = N.norm()
        hnf = N.pari_hnf()
        ec['conductor_ideal'] = cond_ideal
        ec['conductor_ideal'] = "[%i,%s,%s]" % (norm, hnf[1][0], hnf[1][1])
        ec['conductor_norm'] = norm
        ec['ainvs'] = [[str(c) for c in list(a)] for a in ai]
        ec['cm'] = '?'
        ec['base_change'] = []
        output(make_curves_line(ec) + "\n")
開發者ID:sehlen,項目名稱:lmfdb,代碼行數:41,代碼來源:hmf_check_find.py

示例6: create_from_data_string

    def create_from_data_string(self, label_or_field, L):
        """Takes an input line L from a raw data file and constructs the
        associated HMF object with given base field.

        String sample:
        <[31, 31, w + 12], "a", [-3, -2, 2, 4, -4, ...]>,
        """
        data = self.dbdata = {}
        if isinstance(label_or_field, str):
            label = label_or_field
            data['field_label'] = label
            F = HilbertNumberField(label)
            if not F:
                raise ValueError("No Hilbert number field with label %s is in the database" % label)
        elif label_or_field == None:
            raise ValueError("Must specify a valid field label")
        else: # we were passed a HilbertNumberField already
            F = label_or_field
            data['field_label'] = F.label
        #print("data['field_label'] = %s" % data['field_label'])

        # The level

        i = L.find('[')
        j = L.find(']')
        data['level_ideal'] = L[i:j+1]
        #print("data['level_ideal'] = %s" % data['level_ideal'])
        N, n, alpha = data['level_ideal'][1:-1].split(',')
        data['level_norm'] = int(N)
        #print("data['level_norm'] = %s" % data['level_norm'])
        level = F.ideal_from_str(data['level_ideal'])[2]
        #print("level = %s" % level)
        data['level_label'] = F.ideal_label(level)
        #print("data['level_label'] = %s" % data['level_label'])

        # The weight

        data['parallel_weight'] = int(2)
        data['weight'] = str([data['parallel_weight']] * F.degree())
        weight = [2] * F.degree()

        # The label

        i = L.find('"')
        j = L.find('"', i+1)
        data['label_suffix'] = L[i+1:j].replace(" ","")

        data['label'] = construct_full_label(data['field_label'],
                                             weight,
                                             data['level_label'],
                                             data['label_suffix'])
        data['short_label'] = '-'.join([data['level_label'], data['label_suffix']])
        #print("data['label'] = %s" % data['label'] )
        #print("data['short_label'] = %s" % data['short_label'] )

        # The hecke polynomial and degree

        if 'x' in L:
            # non-rational
            i = L.find("x")
            j = L.find(i+1,",")
            data['hecke_polynomial'] = pol = L[i:j]
            data['dimension'] = int(1)
            x = polygen(QQ)
            hpol = x.parent()(str(pol))
            data['dimension'] = int(hpol.degree())
        else:
            # rational
            data['hecke_polynomial'] = 'x'
            data['dimension'] = int(1)

        i = L.rfind("[")
        j = L.rfind("]")
        data['hecke_eigenvalues'] = L[i+1:j].replace(" ","").split(",")
        data['hecke_eigenvalues'] = [unicode(s) for s in data['hecke_eigenvalues']]
        #print("hecke_eigenvalues = %s..." % data['hecke_eigenvalues'][:20])

        # Find (some of the) AL-eigenvalues

        BP = level.prime_factors()
        BP_indices = [F.prime_index(P) for P in BP]
        print("BP_indices = %s" % BP_indices)
        BP_exponents = [level.valuation(P) for P in BP]
        #print("BP_exponents = %s" % BP_exponents)
        AL_eigs = [int(data['hecke_eigenvalues'][k]) for k in BP_indices]
        #print("AL_eigs      = %s" % AL_eigs)
        if not all([(e==1 and eig in [-1,1]) or (eig==0)
                    for e,eig in zip(BP_exponents,AL_eigs)]):
            print("Some bad AL-eigenvalues found")
        # NB the following will put 0 for the eigenvalue for primes
        # whose quare divides the level; this will need fixing later.
        data['AL_eigenvalues'] = [[F.primes[k],data['hecke_eigenvalues'][k]] for k in BP_indices]

        data['is_CM'] = '?'
        data['is_base_change'] = '?'
開發者ID:koffie,項目名稱:lmfdb,代碼行數:95,代碼來源:web_HMF.py

示例7: find_curve_labels

def find_curve_labels(field_label='2.2.5.1', min_norm=0, max_norm=None, outfilename=None, verbose=False):
    r""" Go through all Hilbert Modular Forms with the given field label,
    assumed totally real, for level norms in the given range, test
    whether an elliptic curve exists with the same label.
    """
    hmfs = conn.hmfs
    forms = hmfs.forms
    fields = hmfs.fields
    query = {}
    query['field_label'] = field_label
    if fields.count({'label':field_label})==0:
        if verbose:
            print("No HMF data for field %s" % field_label)
        return None

    query['dimension'] = 1 # only look at rational newforms
    query['level_norm'] = {'$gte' : int(min_norm)}
    if max_norm:
        query['level_norm']['$lte'] = int(max_norm)
    else:
        max_norm = 'infinity'
    cursor = forms.find(query)
    nfound = 0
    nnotfound = 0
    nok = 0
    missing_curves = []
    K = HilbertNumberField(field_label)
    primes = [P['ideal'] for P in K.primes_iter(100)]
    curve_ap = {} # curve_ap[conductor_label] will be a dict iso -> ap
    form_ap = {}  # form_ap[conductor_label]  will be a dict iso -> ap

    # Step 1: look at all newforms, check that there is an elliptic
    # curve of the same label, and if so compare ap-lists.  The
    # dicts curve_ap and form_ap store these when there is
    # disagreement: e.g. curve_ap[conductor_label][iso_label] =
    # aplist.

    for f in cursor:
        curve_label = f['label']
        ec = nfcurves.find_one({'field_label' : field_label, 'class_label' : curve_label, 'number' : 1})
        if ec:
            if verbose:
                print("curve with label %s found" % curve_label)
            nfound +=1
            ainvsK = [K.K()([QQ(str(c)) for c in ai]) for ai in ec['ainvs']]
            E = EllipticCurve(ainvsK)
            good_flags = [E.has_good_reduction(P) for P in primes]
            good_primes = [P for (P,flag) in zip(primes,good_flags) if flag]
            aplist = [E.reduction(P).trace_of_frobenius() for P in good_primes[:30]]
            f_aplist = [int(a) for a in f['hecke_eigenvalues'][:40]]
            f_aplist = [ap for ap,flag in zip(f_aplist,good_flags) if flag][:30]
            if aplist==f_aplist:
                nok += 1
                if verbose:
                    print("Curve %s and newform agree!" % ec['short_label'])
            else:
                print("Curve %s does NOT agree with newform" % ec['short_label'])
                if verbose:
                    print("ap from curve: %s" % aplist)
                    print("ap from  form: %s" % f_aplist)
                if not ec['conductor_label'] in curve_ap:
                    curve_ap[ec['conductor_label']] = {}
                    form_ap[ec['conductor_label']] = {}
                curve_ap[ec['conductor_label']][ec['iso_label']] = aplist
                form_ap[ec['conductor_label']][f['label_suffix']] = f_aplist
        else:
            if verbose:
                print("No curve with label %s found!" % curve_label)
            missing_curves.append(f['short_label'])
            nnotfound +=1

    # Report progress:

    n = nfound+nnotfound
    if nnotfound:
        print("Out of %s newforms, %s curves were found and %s were not found" % (n,nfound,nnotfound))
    else:
        print("Out of %s newforms, all %s had curves with the same label and ap" % (n,nfound))
    if nfound==nok:
        print("All curves agree with matching newforms")
    else:
        print("%s curves agree with matching newforms, %s do not" % (nok,nfound-nok))
    if nnotfound:
        print("Missing curves: %s" % missing_curves)
    else:
        return

    # Step 2: for each newform for which there was no curve, create a
    # Magma file containing code to search for such a curve.

    # First output Magma code to define the field and primes:
    if outfilename:
        output_magma_field(field_label,K.K(),primes,outfilename)
        if verbose:
            print("...output definition of field and primes finished")
    if outfilename:
        outfile=file(outfilename, mode="a")

    for nf_label in missing_curves:
        if verbose:
#.........這裏部分代碼省略.........
開發者ID:jbalakrishnan,項目名稱:lmfdb,代碼行數:101,代碼來源:hmf_check_find.py

示例8: check_curve_labels

def check_curve_labels(field_label='2.2.5.1', min_norm=0, max_norm=None, fix=False, verbose=False):
    r""" Go through all curves with the given field label, assumed totally
    real, test whether a Hilbert Modular Form exists with the same
    label.
    """
    hmfs = conn.hmfs
    forms = hmfs.forms
    fields = hmfs.fields
    query = {}
    query['field_label'] = field_label
    query['number'] = 1 # only look at first curve in each isogeny class
    query['conductor_norm'] = {'$gte' : int(min_norm)}
    if max_norm:
        query['conductor_norm']['$lte'] = int(max_norm)
    else:
        max_norm = 'infinity'
    cursor = nfcurves.find(query)
    nfound = 0
    nnotfound = 0
    nok = 0
    bad_curves = []
    K = HilbertNumberField(field_label)
    primes = [P['ideal'] for P in K.primes_iter(30)]
    curve_ap = {} # curve_ap[conductor_label] will be a dict iso -> ap
    form_ap = {}  # form_ap[conductor_label]  will be a dict iso -> ap

    # Step 1: look at all curves (one per isogeny class), check that
    # there is a Hilbert newform of the same label, and if so compare
    # ap-lists.  The dicts curve_ap and form_ap store these when
    # there is disagreement:
    # e.g. curve_ap[conductor_label][iso_label] = aplist.

    for ec in cursor:
        hmf_label = "-".join([ec['field_label'],ec['conductor_label'],ec['iso_label']])
        f = forms.find_one({'field_label' : field_label, 'label' : hmf_label})
        if f:
            if verbose:
                print("hmf with label %s found" % hmf_label)
            nfound +=1
            ainvsK = [K.K()([QQ(str(c)) for c in ai]) for ai in ec['ainvs']]
            E = EllipticCurve(ainvsK)
            good_flags = [E.has_good_reduction(P) for P in primes]
            good_primes = [P for (P,flag) in zip(primes,good_flags) if flag]
            aplist = [E.reduction(P).trace_of_frobenius() for P in good_primes[:10]]
            f_aplist = [int(a) for a in f['hecke_eigenvalues'][:30]]
            f_aplist = [ap for ap,flag in zip(f_aplist,good_flags) if flag][:10]
            if aplist==f_aplist:
                nok += 1
                if verbose:
                    print("Curve %s and newform agree!" % ec['short_label'])
            else:
                bad_curves.append(ec['short_label'])
                print("Curve %s does NOT agree with newform" % ec['short_label'])
                if verbose:
                    print("ap from curve: %s" % aplist)
                    print("ap from  form: %s" % f_aplist)
                if not ec['conductor_label'] in curve_ap:
                    curve_ap[ec['conductor_label']] = {}
                    form_ap[ec['conductor_label']] = {}
                curve_ap[ec['conductor_label']][ec['iso_label']] = aplist
                form_ap[ec['conductor_label']][f['label_suffix']] = f_aplist
        else:
            if verbose:
                print("No hmf with label %s found!" % hmf_label)
            nnotfound +=1

    # Report progress:

    n = nfound+nnotfound
    if nnotfound:
        print("Out of %s forms, %s were found and %s were not found" % (n,nfound,nnotfound))
    else:
        print("Out of %s classes of curve, all %s had newforms with the same label" % (n,nfound))
    if nfound==nok:
        print("All curves agree with matching newforms")
    else:
        print("%s curves agree with matching newforms, %s do not" % (nok,nfound-nok))
        #print("Bad curves: %s" % bad_curves)

    # Step 2: for each conductor_label for which there was a
    # discrepancy, create a dict giving the permutation curve -->
    # newform, so remap[conductor_label][iso_label] = form_label

    remap = {}
    for level in curve_ap.keys():
        remap[level] = {}
        c_dat = curve_ap[level]
        f_dat = form_ap[level]
        for a in c_dat.keys():
            aplist = c_dat[a]
            for b in f_dat.keys():
                if aplist==f_dat[b]:
                    remap[level][a] = b
                    break
    if verbose:
        print("remap: %s" % remap)

    # Step 3, for through all curves with these bad conductors and
    # create new labels for them, update the database with these (if
    # fix==True)
#.........這裏部分代碼省略.........
開發者ID:jbalakrishnan,項目名稱:lmfdb,代碼行數:101,代碼來源:hmf_check_find.py

示例9: find_curves

def find_curves(field_label='2.2.5.1', min_norm=0, max_norm=None, label=None, outfilename=None, verbose=False, effort=500):
    r""" Go through all Hilbert Modular Forms with the given field label,
    assumed totally real, for level norms in the given range, test
    whether an elliptic curve exists with the same label; if not, find
    the curves using Magma; output these to a file.
    """
    print("Checking forms over {}, norms from {} to {}".format(field_label,min_norm,max_norm))
    if outfilename:
        print("Output of curves found to {}".format(outfilename))
    else:
        print("No curve search or output, just checking")
    query = {}
    query['field_label'] = field_label
    if fields.find({'label': field_label}).count() == 0:
        if verbose:
            print("No HMF data for field %s" % field_label)
        return None

    query['dimension'] = 1  # only look at rational newforms
    if label:
        print("looking for {} only".format(label))
        query['short_label'] = label # e.g. '91.1-a'
    else:
        query['level_norm'] = {'$gte': int(min_norm)}
        if max_norm:
            query['level_norm']['$lte'] = int(max_norm)
    cursor = forms.find(query)
    cursor.sort([('level_norm', pymongo.ASCENDING)])
    labels = [f['label'] for f in cursor]
    nfound = 0
    nnotfound = 0
    nok = 0
    missing_curves = []
    K = HilbertNumberField(field_label)
    primes = [P['ideal'] for P in K.primes_iter(1000)]
    curve_ap = {}  # curve_ap[conductor_label] will be a dict iso -> ap
    form_ap = {}  # form_ap[conductor_label]  will be a dict iso -> ap

    # Step 1: look at all newforms, check that there is an elliptic
    # curve of the same label, and if so compare ap-lists.  The
    # dicts curve_ap and form_ap store these when there is
    # disagreement: e.g. curve_ap[conductor_label][iso_label] =
    # aplist.

    for curve_label in labels:
        # We find the forms again since otherwise the cursor might timeout during the loop.
        f = forms.find_one({'label': curve_label})
        ec = nfcurves.find_one({'field_label': field_label, 'class_label': curve_label, 'number': 1})
        if ec:
            if verbose:
                print("curve with label %s found in the database" % curve_label)
            nfound += 1
            ainvsK = parse_ainvs(K.K(), ec['ainvs'])
            E = EllipticCurve(ainvsK)
            good_flags = [E.has_good_reduction(P) for P in primes]
            good_primes = [P for (P, flag) in zip(primes, good_flags) if flag]
            aplist = [E.reduction(P).trace_of_frobenius() for P in good_primes]
            f_aplist = [int(a) for a in f['hecke_eigenvalues']]
            f_aplist = [ap for ap, flag in zip(f_aplist, good_flags) if flag]
            nap = min(len(aplist), len(f_aplist))
            if aplist[:nap] == f_aplist[:nap]:
                nok += 1
                if verbose:
                    print("Curve {} and newform agree! (checked {} ap)".format(ec['short_label'],nap))
            else:
                print("Curve {} does NOT agree with newform".format(ec['short_label']))
                if verbose:
                    for P,aPf,aPc in zip(good_primes[:nap], f_aplist[:nap], aplist[:nap]):
                        if aPf!=aPc:
                            print("P = {} with norm {}".format(P,P.norm().factor()))
                            print("ap from curve: %s" % aPc)
                            print("ap from  form: %s" % aPf)
                if not ec['conductor_label'] in curve_ap:
                    curve_ap[ec['conductor_label']] = {}
                    form_ap[ec['conductor_label']] = {}
                curve_ap[ec['conductor_label']][ec['iso_label']] = aplist
                form_ap[ec['conductor_label']][f['label_suffix']] = f_aplist
        else:
            if verbose:
                print("No curve with label %s found in the database!" % curve_label)
            missing_curves.append(f['short_label'])
            nnotfound += 1

    # Report progress:

    n = nfound + nnotfound
    if nnotfound:
        print("Out of %s newforms, %s curves were found in the database and %s were not found" % (n, nfound, nnotfound))
    else:
        print("Out of %s newforms, all %s had curves with the same label and ap" % (n, nfound))
    if nfound == nok:
        print("All curves agree with matching newforms")
    else:
        print("%s curves agree with matching newforms, %s do not" % (nok, nfound - nok))
    if nnotfound:
        print("%s missing curves" % len(missing_curves))
    else:
        return

    # Step 2: for each newform for which there was no curve, call interface to Magma's EllipticCurveSearch()
#.........這裏部分代碼省略.........
開發者ID:sehlen,項目名稱:lmfdb,代碼行數:101,代碼來源:hmf_check_find.py

示例10: find_curves

def find_curves(field_label='2.2.5.1', min_norm=0, max_norm=None, outfilename=None, verbose=False):
    r""" Go through all Hilbert Modular Forms with the given field label,
    assumed totally real, for level norms in the given range, test
    whether an elliptic curve exists with the same label; if not, find
    the curves using Magma; output these to a file.
    """
    query = {}
    query['field_label'] = field_label
    if fields.find({'label': field_label}).count() == 0:
        if verbose:
            print("No HMF data for field %s" % field_label)
        return None

    query['dimension'] = 1  # only look at rational newforms
    query['level_norm'] = {'$gte': int(min_norm)}
    if max_norm:
        query['level_norm']['$lte'] = int(max_norm)
    else:
        max_norm = 'infinity'
    cursor = forms.find(query)
    cursor.sort([('level_norm', pymongo.ASCENDING)])
    labels = [f['label'] for f in cursor]
    nfound = 0
    nnotfound = 0
    nok = 0
    missing_curves = []
    K = HilbertNumberField(field_label)
    primes = [P['ideal'] for P in K.primes_iter(100)]
    curve_ap = {}  # curve_ap[conductor_label] will be a dict iso -> ap
    form_ap = {}  # form_ap[conductor_label]  will be a dict iso -> ap

    # Step 1: look at all newforms, check that there is an elliptic
    # curve of the same label, and if so compare ap-lists.  The
    # dicts curve_ap and form_ap store these when there is
    # disagreement: e.g. curve_ap[conductor_label][iso_label] =
    # aplist.

    for curve_label in labels:
        # We find the forms again since otherwise the cursor might timeout during the loop.
        f = forms.find_one({'label': curve_label})
        ec = nfcurves.find_one({'field_label': field_label, 'class_label': curve_label, 'number': 1})
        if ec:
            if verbose:
                print("curve with label %s found in the database" % curve_label)
            nfound += 1
            ainvsK = [K.K()([QQ(str(c)) for c in ai]) for ai in ec['ainvs']]
            E = EllipticCurve(ainvsK)
            good_flags = [E.has_good_reduction(P) for P in primes]
            good_primes = [P for (P, flag) in zip(primes, good_flags) if flag]
            aplist = [E.reduction(P).trace_of_frobenius() for P in good_primes[:30]]
            f_aplist = [int(a) for a in f['hecke_eigenvalues'][:40]]
            f_aplist = [ap for ap, flag in zip(f_aplist, good_flags) if flag][:30]
            if aplist == f_aplist:
                nok += 1
                if verbose:
                    print("Curve %s and newform agree!" % ec['short_label'])
            else:
                print("Curve %s does NOT agree with newform" % ec['short_label'])
                if verbose:
                    print("ap from curve: %s" % aplist)
                    print("ap from  form: %s" % f_aplist)
                if not ec['conductor_label'] in curve_ap:
                    curve_ap[ec['conductor_label']] = {}
                    form_ap[ec['conductor_label']] = {}
                curve_ap[ec['conductor_label']][ec['iso_label']] = aplist
                form_ap[ec['conductor_label']][f['label_suffix']] = f_aplist
        else:
            if verbose:
                print("No curve with label %s found in the database!" % curve_label)
            missing_curves.append(f['short_label'])
            nnotfound += 1

    # Report progress:

    n = nfound + nnotfound
    if nnotfound:
        print("Out of %s newforms, %s curves were found in the database and %s were not found" % (n, nfound, nnotfound))
    else:
        print("Out of %s newforms, all %s had curves with the same label and ap" % (n, nfound))
    if nfound == nok:
        print("All curves agree with matching newforms")
    else:
        print("%s curves agree with matching newforms, %s do not" % (nok, nfound - nok))
    if nnotfound:
        print("%s missing curves" % len(missing_curves))
    else:
        return

    # Step 2: for each newform for which there was no curve, call interface to Magma's EllipticCurveSearch()

    if outfilename:
        outfile = file(outfilename, mode="w")
    def output(L):
        if outfilename:
            outfile.write(L)
        if verbose:
            sys.stdout.write(L)

    for nf_label in missing_curves:
        if verbose:
#.........這裏部分代碼省略.........
開發者ID:JRSijsling,項目名稱:lmfdb,代碼行數:101,代碼來源:hmf_check_find.py


注:本文中的lmfdb.hilbert_modular_forms.hilbert_field.HilbertNumberField類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。