Example #1
0
def compute_atkin_lehner(N, k, i):
    filename = filenames.ambient(N, k, i)
    if not os.path.exists(filename):
        print "Ambient (%s,%s,%s) space not computed."%(N,k,i)
        return
        #compute_ambient_space(N, k, i)

    print "computing atkin-lehner for (%s,%s,%s)"%(N,k,i)
    m = filenames.number_of_known_factors(N, k, i)    
    M = load_ambient_space(N, k, i)
    for d in range(m):
        atkin_lehner_file = filenames.factor_atkin_lehner(N, k, i, d, False)
        if os.path.exists(atkin_lehner_file):
            print "skipping computing atkin_lehner for (%s,%s,%s,%s) since it already exists"%(N,k,i,d)
            # already done
            continue
        
        # compute atkin_lehner
        print "computing atkin_lehner for (%s,%s,%s,%s)"%(N,k,i,d)
        t = cputime()
        A = load_factor(N, k, i, d, M)
        al = ' '.join(['+' if a > 0 else '-' for a in atkin_lehner_signs(A)])
        print al
        open(atkin_lehner_file, 'w').write(al)
        tm = cputime(t)
        meta = {'cputime':tm, 'version':version()}
        save(meta, filenames.meta(atkin_lehner_file))
Example #2
0
def compute_ambient_space(N, k, i):
    if i == 'all':
        G = DirichletGroup(N).galois_orbits()
        sgn = (-1)**k
        for j, g in enumerate(G):
            if g[0](-1) == sgn:
                compute_ambient_space(N,k,j)
        return

    if i == 'quadratic':
        G = DirichletGroup(N).galois_orbits()
        sgn = (-1)**k
        for j, g in enumerate(G):
            if g[0](-1) == sgn and g[0].order()==2:
                compute_ambient_space(N,k,j)
        return

    filename = filenames.ambient(N, k, i)
    if os.path.exists(filename):
        return

    eps = character(N, i)
    t = cputime()
    M = ModularSymbols(eps, weight=k, sign=1)
    tm = cputime(t)
    save(M, filename)
    meta = {'cputime':tm, 'dim':M.dimension(), 'M':str(M), 'version':version()}
    save(meta, filenames.meta(filename))
Example #3
0
def save_ambient_space(M, i):
    N = M.level()
    k = M.weight()
    fname = filenames.ambient(N, k, i, makedir=True)
    if os.path.exists(fname):
        print "%s already exists; not recreating"%fname
        return 
    print "Creating ", fname
    save(ambient_to_dict(M, i), fname)
Example #4
0
def compute_aplists(N, k, i, *args):
    if i == 'all':
        G = DirichletGroup(N).galois_orbits()
        sgn = (-1)**k
        for j, g in enumerate(G):
            if g[0](-1) == sgn:
                compute_aplists(N,k,j,*args)
        return

    if i == 'quadratic':
        G = DirichletGroup(N).galois_orbits()
        sgn = (-1)**k
        for j, g in enumerate(G):
            if g[0](-1) == sgn and g[0].order()==2:
                compute_aplists(N,k,j,*args)
        return

    if len(args) == 0:
        args = (100, )

    filename = filenames.ambient(N, k, i)
    if not os.path.exists(filename):
        print "Ambient (%s,%s,%s) space not computed."%(N,k,i)
        return
        #compute_ambient_space(N, k, i)

    print "computing aplists for (%s,%s,%s)"%(N,k,i)
        
    m = filenames.number_of_known_factors(N, k, i)

    if m == 0:
        # nothing to do
        return
    
    M = load_ambient_space(N, k, i)
    for d in range(m):
        aplist_file = filenames.factor_aplist(N, k, i, d, False, *args)
        if os.path.exists(aplist_file):
            print "skipping computing aplist(%s) for (%s,%s,%s,%s) since it already exists"%(args, N,k,i,d)
            # already done
            continue
        
        # compute aplist
        print "computing aplist(%s) for (%s,%s,%s,%s)"%(args, N,k,i,d)
        t = cputime()
        A = load_factor(N, k, i, d, M)
        aplist, _ = A.compact_system_of_eigenvalues(prime_range(*args), 'a')
        print aplist, aplist_file
        save(aplist, aplist_file)
        tm = cputime(t)
        meta = {'cputime':tm, 'version':version()}
        save(meta, filenames.meta(aplist_file))
Example #5
0
def compute_decompositions(N, k, i):
    if i == 'all':
        G = DirichletGroup(N).galois_orbits()
        sgn = (-1)**k
        for j, g in enumerate(G):
            if g[0](-1) == sgn:
                compute_decompositions(N,k,j)
        return

    if i == 'quadratic':
        G = DirichletGroup(N).galois_orbits()
        sgn = (-1)**k
        for j, g in enumerate(G):
            if g[0](-1) == sgn and g[0].order()==2:
                compute_decompositions(N,k,j)
        return

    filename = filenames.ambient(N, k, i)
    if not os.path.exists(filename):
        print "Ambient space (%s,%s,%s) not computed."%(N,k,i)
        return
        #compute_ambient_space(N, k, i)
    if not os.path.exists(filename):
        return 
    
    eps = DirichletGroup(N).galois_orbits()[i][0]

    if os.path.exists(filenames.factor(N, k, i, 0, makedir=False)):
        return
    
    t = cputime()
    M = load_ambient_space(N, k, i)
    D = M.cuspidal_subspace().new_subspace().decomposition()
    for d in range(len(D)):
        f = filenames.factor_basis_matrix(N, k, i, d)
        if os.path.exists(f):
            continue
        A = D[d]
        B  = A.free_module().basis_matrix()
        Bd = A.dual_free_module().basis_matrix()
        v  = A.dual_eigenvector(names='a', lift=False)    # vector over number field
        nz = A._eigen_nonzero()
        
        save(B, filenames.factor_basis_matrix(N, k, i, d))
        save(Bd, filenames.factor_dual_basis_matrix(N, k, i, d))
        save(v, filenames.factor_dual_eigenvector(N, k, i, d))
        save(nz, filenames.factor_eigen_nonzero(N, k, i, d))
        
    tm = cputime(t)
    meta = {'cputime':tm, 'number':len(D), 'version':version()}
    save(meta, filenames.decomp_meta(N, k, i))
def generate_fundom_plots(N, group='Gamma0'):
    gps = C['SL2Zsubgroups']['groups']
    if group == 'Gamma0':
        G = Gamma0(N)
        grouptype = int(0)
    else:
        G = Gamma1(N)
        grouptype = int(1)
    dom = draw_fundamental_domain(N, group)
    filename = 'domain' + str(N) + '.png'
    save(dom, filename)
    data = open(filename).read()
    idins = gps.insert({'level': int(N), 'index': int(G.index(
    )), 'G': pymongo.binary.Binary(dumps(G)), 'domain': pymongo.binary.Binary(data), 'type': grouptype})
    print "inserted: ", N, " ", idins
def generate_fundom_plots(N, group='Gamma0'):
    gps = C['SL2Zsubgroups']['groups']
    if group == 'Gamma0':
        G = Gamma0(N)
        grouptype = int(0)
    else:
        G = Gamma1(N)
        grouptype = int(1)
    dom = draw_fundamental_domain(N, group)
    filename = 'domain' + str(N) + '.png'
    save(dom, filename)
    data = open(filename).read()
    idins = gps.insert({
        'level': int(N),
        'index': int(G.index()),
        'G': pymongo.binary.Binary(dumps(G)),
        'domain': pymongo.binary.Binary(data),
        'type': grouptype
    })
    print "inserted: ", N, " ", idins
def generate_fundom_plots(N, group="Gamma0"):
    gps = C["SL2Zsubgroups"]["groups"]
    if group == "Gamma0":
        G = Gamma0(N)
        grouptype = int(0)
    else:
        G = Gamma1(N)
        grouptype = int(1)
    dom = draw_fundamental_domain(N, group)
    filename = "domain" + str(N) + ".png"
    save(dom, filename)
    data = open(filename).read()
    idins = gps.insert(
        {
            "level": int(N),
            "index": int(G.index()),
            "G": pymongo.binary.Binary(dumps(G)),
            "domain": pymongo.binary.Binary(data),
            "type": grouptype,
        }
    )
    print "inserted: ", N, " ", idins
Example #9
0
def safe_save(obj, path):
    """
    Save data after unlinking the target, if it is a symlink.

    EXAMPLES::

        sage: from pGroupCohomology.auxiliaries import safe_save
        sage: d = tmp_dir()
        sage: save(1, os.path.join(d, 'orig'))
        sage: os.symlink(os.path.join(d, 'orig.sobj'), os.path.join(d, 'copy.sobj'))

    By saving data to the symlink, we change the original data::

        sage: save(2, os.path.join(d, 'copy.sobj'))
        sage: load(os.path.join(d, 'orig.sobj'))
        2
        sage: load(os.path.join(d, 'copy.sobj'))
        2

    The function :func:`safe_save` protects the original data::

        sage: d = tmp_dir()
        sage: save(1, os.path.join(d, 'orig'))
        sage: os.symlink(os.path.join(d, 'orig.sobj'), os.path.join(d, 'copy.sobj'))
        sage: safe_save(2, os.path.join(d, 'copy.sobj'))
        sage: load(os.path.join(d, 'orig.sobj'))
        1
        sage: load(os.path.join(d, 'copy.sobj'))
        2

    """
    if not path.endswith('.sobj'):
        path = path + '.sobj'
    if os.path.islink(path):
        os.unlink(path)
    save(obj, path)
Example #10
0
def main():
    import argparse
    parser = argparse.ArgumentParser()
    parser.add_argument("-server", type=str, default="", help="server name (eg solardiesel_)")
    parser.add_argument("-file", type=str, default="", help="filename")
    args = parser.parse_args()

    if args.file != "":
        stats = parse(filename=args.file)
        save(stats, "%s.sobj" % args.file)
        return

    # gen
    for full in [True, False]:
        for hag in [True, False]:
            try:
                stats = parse(filename="./%sgen_full_atk_%s_hag_%s" % (args.server, full, hag))
                save(stats, "./%sgen_full_atk_%s_hag_%s.sobj" % (args.server, full, hag))
            except:
                print("%sgen_full_atk_%s_hag_%s not available" % (args.server, full, hag))

    # sidh
    for full in [True, False]:
        for hag in [True, False]:
            for precomp in [True, False]:
                try:
                    stats = parse(filename="./%ssidh_full_atk_%s_hag_%s_precomp_%s" % (args.server, full, hag, precomp))
                    save(stats, "./%ssidh_full_atk_%s_hag_%s_precomp_%s.sobj" % (args.server, full, hag, precomp))
                except:
                    print("%ssidh_full_atk_%s_hag_%s_precomp_%s not available" % (args.server, full, hag, precomp))

    # sike
    for full in [True, False]:
        for hag in [True, False]:
            for precomp in [20]:
                try:
                    stats = parse(filename="./%ssike_full_atk_%s_hag_%s_precomp_%s" % (args.server, full, hag, precomp))
                    save(stats, "./%ssike_full_atk_%s_hag_%s_precomp_%s.sobj" % (args.server, full, hag, precomp))
                except:
                    print("%ssike_full_atk_%s_hag_%s_precomp_%s not available" % (args.server, full, hag, precomp))
# generate lattice instance
FPLLL.set_random_seed(1337)
q = 2**30
mat = IntegerMatrix.random(2 * n_halfs, "qary", q=q, k=n_halfs)
A = LLL.reduction(mat)
M = GSO.Mat(A)
M.update_gso()

cn11 = CN11_simulate(M, BKZ.Param(block_size=block_size, max_loops=max_loops))
bsw18 = BSW18.simulate(M, BKZ.Param(block_size=block_size,
                                    max_loops=max_loops))
og = og.simulate(M, BKZ.Param(block_size=block_size, max_loops=max_loops))
g = line([(i, log(cn11[0][i])/2 - log(q)/2) for i in range(len(cn11[0]))]) \
    + line([(i, log(bsw18[0][i])/2 - log(q)/2) for i in range(len(bsw18[0]))], color='red', thickness=2) \
    + line([(i, log(og[0][i])/2 - log(q)/2) for i in range(len(og[0]))], color='green')
save(g, "test.png", dpi=150)

log_vol_cn11 = sum(map(lambda x: log(x) / 2, cn11[0]))
log_vol_bsw18 = sum(map(lambda x: log(x) / 2, bsw18[0]))
log_vol_og = sum(map(lambda x: log(x) / 2, og[0]))

smat = matrix(M.d, M.d)
mat.to_matrix(smat)
vol = abs(smat.determinant())
log_vol = log(vol).n()

print("log vol %.6f" % log_vol)
print("   cn11 %.6f" % log_vol_cn11)
print("  bsw18 %.6f" % log_vol_bsw18)
print("     og %.6f" % log_vol_og)
Example #12
0
 def save_as_binary(self, filename):
     save(self._to_format_dct(), filename)
Example #13
0
 def save_as_binary(self, filename):
     data_dict = self._to_format_dct()
     save(data_dict, filename)
Example #14
0

def rhf(b_1_sqr, log_vol, dim):
    log_b_sqr = log(b_1_sqr)
    log_rhf = (0.5 * log_b_sqr - log_vol / dim) / dim
    return exp(log_rhf)


profile_bsw18 = [M.get_r(i, i) for i in range(M.d)]
profile_cn11 = [M.get_r(i, i) for i in range(M.d)]
rhfs_bsw18 = []
rhfs_cn11 = []
rhfs_bsw18.append((0, rhf(profile_bsw18[0], log_vol, M.d)))
rhfs_cn11.append((0, rhf(profile_cn11[0], log_vol, M.d)))
for tour in range(1, max_loops + 1):
    profile_bsw18 = BSW18.simulate(
        profile_bsw18, BKZ.Param(block_size=block_size, max_loops=1))[0]
    profile_cn11 = CN11_simulate(profile_cn11,
                                 BKZ.Param(block_size=block_size,
                                           max_loops=1))[0]
    rhfs_bsw18.append((tour, rhf(profile_bsw18[0], log_vol, M.d)))
    rhfs_cn11.append((tour, rhf(profile_cn11[0], log_vol, M.d)))

g = line(rhfs_bsw18,
         legend_label="BSW18",
         linestyle="dashed",
         title=f"dim = {M.d}, beta = {block_size}",
         axes_labels=["tours", "rhf"])
g += line(rhfs_cn11, legend_label="CN11", linestyle="dashed", color="red")
save(g, f"rhf-{M.d}-{block_size}.png", dpi=150)
Example #15
0
dgm_big = dgModule(TerminalCategory, ZZ, f_law, [d_law], target_cat=Gop)
top_deg = 100
dgm = prune_dg_module_on_poset(dgm_big, (0, top_deg),
                               verbose=verbose,
                               assume_sorted=True)

print
print 'Homological computation begins'
for x in G.objects:
    free = G.free_module(ZZ, [x])
    print 'Graph ' + str(x)
    print 'computing complex'
    Ch = ChainComplex({
        k: free(dgm.differential('*', (k, )).transpose())
        for k in range(top_deg)
    })
    print 'computing homology'
    h = Ch.homology()
    print h
    print

diff_dict = {d: dgm.differential('*', (d, )) for d in range(-1, top_deg + 1)}
save_dict = {
    d: (diff_dict[d].source, diff_dict[d].data_vector, diff_dict[d].target)
    for d in range(-1, top_deg + 1)
}

save(save_dict, 'conf-3-circle-mod-rotation')
print 'small complex saved'
Example #16
0
 def save_basis_as_binary(self, filename):
     basis = self.basis()
     dicts = [b._to_format_dct() for b in basis]
     save(dicts, filename)
Example #17
0
from sage.all import EllipticCurve, load, save

from testcong import make_hash, test_cong, test_irred, report
import sys

try:
    hashtab11_50 = load('hashtab11_50')
except IOError:
    hashtab11_50 = make_hash(11,11,500000,50)
    hashtab11_50 = dict([(k,v) for k,v in hashtab11_50.items() if len(v)>1])
    save(hashtab11_50, 'hashtab11_50')
    len(hashtab11_50)

def find_bad_pairs(ht=hashtab11_50):
    bad_pairs = []
    for s in ht.values():
        if len(s)>1:
            E1 = EllipticCurve(s[0])
            for r in s[1:]:
                E2 = EllipticCurve(r)
                res, info = test_cong(11,E1,E2, mumax=10^7)
                if not res:
                    report(res,info,11,s[0],r)
                    bad_pairs.append([s[0],r])
    return bad_pairs

# bad_pairs = find_bad_pairs(hashtab7_50)
# previous cell takes ages; this is the output

bad_pairs = []
isom_sets = [s for s in hashtab11_50.values() if len(s)>1]
Example #18
0
def gram_matrix(N,
                weight,
                prec=501,
                tol=1E-40,
                sv_min=1E-1,
                sv_max=1E15,
                bl=None,
                set_dim=None,
                force_prec=False):
    r""" Computes a matrix of p_{r,D}(r',D')
    for a basis of P_{r,D}, i.e. dim linearly independent P's
    INPUT: N      = Integer
           weight = Real
    OPTIONAL: 
           tol    = error bound for the Poincaré series
           sv_min = minimal allowed singular value when determining whether a given set is linarly independent or not.
           sv_max = maximally allowed singular value
           bl     = list of pairs (D_i,r_i) from which  we compute a matrix of coeffficients p_{D_i,r_i}(D_j,r_j)
        """
    # If we have supplied a list of D's and r's we make a gram matrix relative to these
    # otherwise we find a basis, i.e. linearly independent forms with correct dimension
    # find the dimension
    wt = '%.4f' % weight
    if (N < 10):
        stN = "0" + str(N)
    else:
        stN = str(N)
    v = dict()
    filename_work = "__N" + stN + "-" + wt + "--finding basis.txt"
    fp = open(filename_work, "write")
    fp.write("starting to find basis")
    fp.close()
    if (silent > 0):
        print("Forcing precision:{0}".format(force_prec))
    set_verbose(0)
    if (bl != None):
        dim = len(bl)
        l = bl
    else:
        if (set_dim != None and set_dim > 0):
            dim = set_dim
        else:
            dim = dimension_jac_cusp_forms(int(weight + 0.5), N, -1)
        l = list_of_basis(N, weight, prec, tol, sv_min, sv_max, set_dim=dim)
    j = 0
    for [D, r] in l.values():
        for [Dp, rp] in l.values():
            # Recall that the gram matrix is symmetric. We need only compute the upper diagonal
            if (list(v.values()).count([Dp, rp, D, r]) == 0):
                v[j] = [D, r, Dp, rp]
                j = j + 1
    # now v is a list we can get into computing coefficients
    # first we print the "gram data" (list of indices) to the file
    s = str(N) + ": (AI[" + str(N) + "],["
    indices = dict()
    for j in range(len(l)):
        Delta = l[j][0]
        r = l[j][1]
        diff = (r * r - Delta) % (4 * N)
        if diff != 0:
            raise ValueError(
                "ERROR r^2={0} not congruent to Delta={1} mod {2}!".format(
                    r * r, Delta, 4 * N))
        s = s + "(" + str(Delta) + "," + str(r) + ")"
        indices[j] = [Delta, r]
        if j < len(l) - 1:
            s = s + ","
        else:
            s = s + "]),"
    s = s + "\n"
    if silent > 0:
        print(s + "\n")
    filename2 = "PS_Gramdata" + stN + "-" + wt + ".txt"
    fp = open(filename2, "write")
    fp.write(s)
    fp.close()
    try:
        os.remove(filename_work)
    except os.error:
        print("Could not remove file:{0}".format(filename_work))
        pass
    filename_work = "__N" + stN + "-" + wt + "--computing_gram_matrix.txt"
    fp = open(filename_work, "write")
    fp.write("")
    fp.close()
    #print "tol=",tol
    #set_verbose(2)
    #print "force_prec(gram_mat)=",force_prec
    res = ps_coefficients_holomorphic_vec(N,
                                          weight,
                                          v,
                                          tol,
                                          prec,
                                          force_prec=force_prec)
    set_verbose(0)

    res['indices'] = indices
    maxerr = 0.0
    for j in res['errs'].keys():
        tmperr = abs(res['errs'][j])
        #print "err(",j,")=",tmperr
        if (tmperr > maxerr):
            maxerr = tmperr
        # switch format for easier vewing
        res['errs'][j] = RR(tmperr)
    if silent > 0:
        print("maxerr={0}".format(RR(maxerr)))
    res['maxerr'] = maxerr
    wt_phalf = '%.4f' % (weight + 0.5)
    filename3 = "PS_Gramerr" + stN + "-" + wt + ".txt"
    fp = open(filename3, "write")
    wt
    s = "MAXERR[" + wt_phalf + "][" + stN + "]=" + str(RR(maxerr))
    fp.write(s)
    fp.close()
    if (res['ok']):
        Cps = res['data']
    else:
        print("Failed to compute Fourier coefficients!")
        return 0
    RF = RealField(prec)
    A = matrix(RF, dim)
    kappa = weight
    fourpi = RF(4.0) * pi.n(prec)
    one = RF(1.0)
    N4 = RF(4 * N)
    C = dict()
    if (silent > 1):
        print("v={0}".format(v))
        print("dim={0}".format(dim))
    lastix = 0
    # First set the upper right part of A
    for j in range(dim):
        ddim = dim - j
        if (silent > 1):
            print("j={0} ddim={1} lastix={2]".format(j, ddim, lastix))
        for k in range(0, ddim):
            # need to scale with |D|^(k+0.5)
            if (silent > 1):
                print("k={0}".format(k))
                print("lastix+k={0}".format(lastix + k))
            mm = RF(abs(v[lastix + k][0])) / N4
            tmp = RF(mm**(weight - one))
            if (silent > 1):
                print("ddim+k={0}".format(ddim + k))
            A[j, j + k] = Cps[lastix + k] * tmp
            C[v[lastix + k][0], v[lastix + k][1]] = Cps[lastix + k]
        lastix = lastix + k + 1
    # And add the lower triangular part to mak the matrix symmetric
    for j in range(dim):
        for k in range(0, j):
            A[j, k] = A[k, j]
    # And print the gram matrix
    res['matrix'] = A
    dold = mpmath.mp.dps
    mpmath.mp.dps = int(prec / 3.3)
    AInt = mpmath.matrix(int(A.nrows()), int(A.ncols()))
    AMp = mpmath.matrix(int(A.nrows()), int(A.ncols()))
    for ir in range(A.nrows()):
        for ik in range(A.ncols()):
            AInt[ir, ik] = mpmath.mpi(A[ir, ik] - tol, A[ir, ik] + tol)
            AMp[ir, ik] = mpmath.mpf(A[ir, ik])
    d = mpmath.det(AMp)
    if (silent > 1):
        print("det(A-as-mpmath)={0}".format(d))
    di = mpmath.det(AInt)
    if (silent > 1):
        print("det(A-as-interval)={0}".format(di))
    res['det'] = (RF(di.a), RF(di.b))

    filename = "PS_Gram" + stN + "-" + wt + ".txt"
    if (silent > 1):
        print("printing to file: {0}".format(filename))
    print_matrix_to_file(A, filename, 'A[' + str(N) + ']')
    if (silent > 1):
        print("A-A.transpose()={0}".format(norm(A - A.transpose())))
    B = A ^ -1
    #[d,B]=mat_inverse(A)
    if (silent > 1):
        print("A={0}".format(A.n(100)))
        print("det(A)={0}".format(di))
        print("Done making inverse!")
    #res['det']=d
    res['inv'] = B
    mpmath.mp.dps = dold
    filename = "PS_Gram-inv" + stN + "-" + wt + ".txt"
    print_matrix_to_file(B, filename, ' AI[' + str(N) + ']')
    # first make the filename
    s = '%.1e' % tol
    filename3 = "PS_Coeffs" + stN + "-" + wt + "-" + s + ".sobj"
    # If the file already exist we load it and append the new data
    if (silent > 0):
        print("saving data to: {0}".format(filename3))
    try:
        f = open(filename3, "read")
    except IOError:
        if (silent > 0):
            print("no file before!")
        # do nothing
    else:
        if silent > 0:
            print("file: {0} exists!".format(filename3))
        f.close()
        Cold = load(filename3)
        for key in Cold.keys():
            #                print"key:",key
            if key not in C:  # then we add it
                print("key:", key, " does not exist in the new version!")
                C[key] = Cold[key]
                save(C, filename3)
    ## Save the whole thing
    filename = "PS_all_gram" + stN + "-" + wt + ".sobj"
    save(res, filename)
    ## our work is completed and we can remove the file
    try:
        os.remove(filename_work)
    except os.error:
        print("Could not remove file: {0}".format(filename_work))
        pass
    return res
Example #19
0
import os
from sage.all import save
from sage.env import SAGE_SHARE
from sage.misc.misc import sage_makedirs

install_root = os.path.join(SAGE_SHARE, 'odlyzko')
target = os.path.join(install_root, 'zeros.sobj')

if __name__ == '__main__':
    sage_makedirs(install_root)
    print("Creating Odlyzko database.")
    F = [float(x) for x in open("src/zeros6").readlines()]
    save(F, target)
Example #20
0
from sage.all import EllipticCurve, load, save

from testcong import make_hash, test_cong, test_irred, report
from XE7 import test_isom
import sys

try:
    hashtab7_50 = load('hashtab7_50')
except IOError:
    hashtab7_50 = make_hash(7, 11, 500000, 50)
    hashtab7_50 = dict([(k, v) for k, v in hashtab7_50.items() if len(v) > 1])
    save(hashtab7_50, 'hashtab7_50')
    len(hashtab7_50)


def find_bad_pairs(ht=hashtab7_50):
    bad_pairs = []
    for s in ht.values():
        if len(s) > 1:
            E1 = EllipticCurve(s[0])
            for r in s[1:]:
                E2 = EllipticCurve(r)
                res, info = test_cong(7, E1, E2, mumax=10 ^ 7)
                if not res:
                    report(res, info, 7, s[0], r)
                    bad_pairs.append([s[0], r])
    return bad_pairs


# bad_pairs = find_bad_pairs(hashtab7_50)
# previous cell takes ages; this is the output