本文整理汇总了Python中sage.all.EllipticCurve类的典型用法代码示例。如果您正苦于以下问题:Python EllipticCurve类的具体用法?Python EllipticCurve怎么用?Python EllipticCurve使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EllipticCurve类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: modular_form_display
def modular_form_display(label, number):
try:
number = int(number)
except:
number = 10
if number < 10:
number = 10
# if number > 100000:
# number = 20
# if number > 50000:
# return "OK, I give up."
# if number > 20000:
# return "This incident will be reported to the appropriate authorities."
# if number > 9600:
# return "You have been banned from this website."
# if number > 4800:
# return "Seriously."
# if number > 2400:
# return "I mean it."
# if number > 1200:
# return "Please stop poking me."
if number > 1000:
number = 1000
data = db_ec().find_one({'lmfdb_label': label})
if data is None:
return elliptic_curve_jump_error(label, {})
ainvs = [int(a) for a in data['ainvs']]
E = EllipticCurve(ainvs)
modform = E.q_eigenform(number)
modform_string = web_latex_split_on_pm(modform)
return modform_string
开发者ID:sibilant,项目名称:lmfdb,代码行数:31,代码来源:elliptic_curve.py
示例2: add_isogeny_matrices
def add_isogeny_matrices(N1,N2):
"""
Add the 'isogeny_matrix' field to every curve in the database
whose conductor is between N1 and N2 inclusive. The matrix is
stored as a list of n lists of n ints, where n is the size of the
class and the (i,j) entry is the degree of a cyclic isogeny from
curve i to curve j in the class, using the lmfdb numbering within
each class. Hence this matrix is exactly the same for all curves
in the class. This was added in July 2014 to save recomputing the
complete isogeny class every time despite the fact that the curves
in the class were already in the database.
"""
query = {}
query['conductor'] = { '$gt': int(N1)-1, '$lt': int(N2)+1 }
query['number'] = int(1)
res = curves.find(query)
res = res.sort([('conductor', pymongo.ASCENDING),
('lmfdb_iso', pymongo.ASCENDING)])
for C in res:
if 'isogeny_matrix' in C:
print("class {} has isogeny matrix already, skipping".format(C['label']))
continue
lmfdb_iso = C['lmfdb_iso']
E = EllipticCurve([int(a) for a in C['ainvs']])
M = E.isogeny_class(order="lmfdb").matrix()
mat = [list([int(c) for c in r]) for r in M.rows()]
n = len(mat)
print("{} curves in class {}".format(n,lmfdb_iso))
for label_i in [lmfdb_iso+str(i+1) for i in range(n)]:
data = {}
data['lmfdb_label'] = label_i
data['isogeny_matrix'] = mat
curves.update({'lmfdb_label': label_i}, {"$set": data}, upsert=True)
开发者ID:AurelPage,项目名称:lmfdb,代码行数:33,代码来源:import_ec_data.py
示例3: add_heights
def add_heights(data, verbose = False):
r""" If data holds the data fields for a curve this returns the same
with the heights of the points included as a new field with key
'heights'. It is more convenient to do this separately than while
parsing the input files since curves() knows tha a-invariants but
not the gens and curve_data() vice versa.
"""
if 'heights' in data and 'reg' in data:
return data
ngens = data.get('ngens', 0)
if ngens == 0:
data['heights'] = []
data['reg'] = float(1)
return data
# Now there is work to do
K = nf_lookup(data['field_label'])
if 'ainvs' in data:
ainvs = data['ainvs']
else:
ainvs = nfcurves.find_one({'label':data['label']})['ainvs']
ainvsK = parse_ainvs(K, ainvs) # list of K-elements
E = EllipticCurve(ainvsK)
gens = [E(parse_point(K,x)) for x in data['gens']]
data['heights'] = [float(P.height()) for P in gens]
data['reg'] = float(E.regulator_of_points(gens))
if verbose:
print("added heights %s and regulator %s to %s" % (data['heights'],data['reg'], data['label']))
return data
开发者ID:sehlen,项目名称:lmfdb,代码行数:28,代码来源:import_ecnf_data.py
示例4: insert_EC_L_functions
def insert_EC_L_functions(start=1, end=100):
curves = C.ellcurves.curves
for N in range(start, end):
print "Processing conductor", N
sys.stdout.flush()
query = curves.find({'conductor': N, 'number': 1})
for curve in query:
E = EllipticCurve([int(x) for x in curve['ainvs']])
L = lc.Lfunction_from_elliptic_curve(E)
first_zeros = L.find_zeros_via_N(curve['rank'] + 1)
if len(first_zeros) > 1:
if not first_zeros[-2] == 0:
print "problem"
z = float(first_zeros[-1])
Lfunction_data = {}
Lfunction_data['first_zero'] = z
Lfunction_data['description'] = 'Elliptic curve L-function for curve ' + str(curve['label'][:-1])
Lfunction_data['degree'] = 2
Lfunction_data['signature'] = [0, 1]
Lfunction_data['eta'] = [(1.0, 0), ]
Lfunction_data['level'] = N
Lfunction_data['special'] = {'type': 'elliptic', 'label': curve['label'][:-1]}
coeffs = []
for k in range(1, 11):
coeffs.append(CC(E.an(k) / sqrt(k)))
Lfunction_data['coeffs'] = [(float(x.real()), float(x.imag())) for x in coeffs]
Lfunctions.insert(Lfunction_data)
开发者ID:WarrenMoore,项目名称:lmfdb,代码行数:34,代码来源:build_Lfunction_db.py
示例5: download_EC_qexp
def download_EC_qexp(label, limit):
N, iso, number = split_lmfdb_label(label)
if number:
ainvs = db.ec_curves.lookup(label, 'ainvs', 'lmfdb_label')
else:
ainvs = db.ec_curves.lookup(label, 'ainvs', 'lmfdb_iso')
E = EllipticCurve(ainvs)
response = make_response(','.join(str(an) for an in E.anlist(int(limit), python_ints=True)))
response.headers['Content-type'] = 'text/plain'
return response
开发者ID:koffie,项目名称:lmfdb,代码行数:10,代码来源:elliptic_curve.py
示例6: test1
def test1(B=10 ** 4):
from sage.all import polygen, primes, QQ, EllipticCurve
import psage.libs.smalljac.wrapper
x = polygen(QQ, "x")
J = psage.libs.smalljac.wrapper.SmallJac(x ** 3 + 17 * x + 3)
E = EllipticCurve([17, 3])
N = E.conductor()
for p in primes(B):
if N % p:
assert E.ap(p) == J.ap(p)
开发者ID:Alwnikrotikz,项目名称:purplesage,代码行数:11,代码来源:tests.py
示例7: test_ap_via_enumeration
def test_ap_via_enumeration(B=1000):
a4 = 6912*a - 5643
a6 = -131328*a + 298566
E = EllipticCurve([a4, a6])
D = E.discriminant()
for P in primes_of_bounded_norm(B):
if D.valuation(P) == 0:
R = sqrt5_fast.ResidueRing(P, 1)
ap0 = sqrt5.ap_via_enumeration(R(a4), R(a6))
k = P.residue_field(); E0 = E.change_ring(k); ap1 = k.cardinality() + 1 - E0.cardinality()
assert ap0 == ap1
开发者ID:Alwnikrotikz,项目名称:purplesage,代码行数:11,代码来源:sqrt5_test.py
示例8: download_EC_qexp
def download_EC_qexp(label, limit):
CDB = db_ec()
N, iso, number = split_lmfdb_label(label)
if number:
data = CDB.find_one({'lmfdb_label': label})
else:
data = CDB.find_one({'lmfdb_iso': label})
E = EllipticCurve(parse_ainvs(data['ainvs']))
response = make_response(','.join(str(an) for an in E.anlist(int(limit), python_ints=True)))
response.headers['Content-type'] = 'text/plain'
return response
开发者ID:haraldschilly,项目名称:lmfdb,代码行数:11,代码来源:elliptic_curve.py
示例9: plot_ec
def plot_ec(label):
ainvs = db.ec_curves.lookup(label, 'ainvs', 'lmfdb_label')
if ainvs is None:
return elliptic_curve_jump_error(label, {})
E = EllipticCurve(ainvs)
P = E.plot()
_, filename = tempfile.mkstemp('.png')
P.save(filename)
data = open(filename).read()
os.unlink(filename)
response = make_response(data)
response.headers['Content-type'] = 'image/png'
return response
开发者ID:koffie,项目名称:lmfdb,代码行数:13,代码来源:elliptic_curve.py
示例10: r_an
def r_an(ainvs, eps=1e-4):
E = EllipticCurve(F, ainvs)
L = E.lseries()
D = L.dokchitser(30)
f = D.taylor_series(1)
r = 0
while abs(f[r]) < eps:
r += 1
if D.eps == 1:
assert r%2 == 0
else:
assert r%2 == 1
return r
开发者ID:Alwnikrotikz,项目名称:purplesage,代码行数:13,代码来源:ranks.py
示例11: download_EC_qexp
def download_EC_qexp(label, limit):
logger.debug(label)
CDB = lmfdb.base.getDBConnection().elliptic_curves.curves
N, iso, number = lmfdb_label_regex.match(label).groups()
if number:
data = CDB.find_one({"lmfdb_label": label})
else:
data = CDB.find_one({"lmfdb_iso": label})
ainvs = data["ainvs"]
logger.debug(ainvs)
E = EllipticCurve([int(a) for a in ainvs])
response = make_response(",".join(str(an) for an in E.anlist(int(limit), python_ints=True)))
response.headers["Content-type"] = "text/plain"
return response
开发者ID:CleryFabien,项目名称:lmfdb,代码行数:14,代码来源:elliptic_curve.py
示例12: plot_ec
def plot_ec(label):
CDB = db_ec()
data = CDB.find_one({'lmfdb_label': label})
if data is None:
return elliptic_curve_jump_error(label, {})
E = EllipticCurve(parse_ainvs(data['xainvs']))
P = E.plot()
_, filename = tempfile.mkstemp('.png')
P.save(filename)
data = open(filename).read()
os.unlink(filename)
response = make_response(data)
response.headers['Content-type'] = 'image/png'
return response
开发者ID:haraldschilly,项目名称:lmfdb,代码行数:14,代码来源:elliptic_curve.py
示例13: download_EC_qexp
def download_EC_qexp(label, limit):
ec_logger.debug(label)
CDB = lmfdb.base.getDBConnection().elliptic_curves.curves
N, iso, number = split_lmfdb_label(label)
if number:
data = CDB.find_one({'lmfdb_label': label})
else:
data = CDB.find_one({'lmfdb_iso': label})
ainvs = data['ainvs']
ec_logger.debug(ainvs)
E = EllipticCurve([int(a) for a in ainvs])
response = make_response(','.join(str(an) for an in E.anlist(int(limit), python_ints=True)))
response.headers['Content-type'] = 'text/plain'
return response
开发者ID:sibilant,项目名称:lmfdb,代码行数:14,代码来源:elliptic_curve.py
示例14: plot_ec
def plot_ec(label):
C = lmfdb.base.getDBConnection()
data = C.elliptic_curves.curves.find_one({'lmfdb_label': label})
if data is None:
return elliptic_curve_jump_error(label, {})
ainvs = [int(a) for a in data['ainvs']]
E = EllipticCurve(ainvs)
P = E.plot()
_, filename = tempfile.mkstemp('.png')
P.save(filename)
data = open(filename).read()
os.unlink(filename)
response = make_response(data)
response.headers['Content-type'] = 'image/png'
return response
开发者ID:sibilant,项目名称:lmfdb,代码行数:15,代码来源:elliptic_curve.py
示例15: allgens
def allgens(line):
r""" Parses one line from an allgens file. Returns the label and
a dict containing fields with keys 'conductor', 'iso', 'number',
'ainvs', 'jinv', 'cm', 'rank', 'gens', 'torsion_order', 'torsion_structure',
'torsion_generators', all values being strings or ints.
Input line fields:
conductor iso number ainvs rank torsion_structure gens torsion_gens
Sample input line:
20202 i 2 [1,0,0,-298389,54947169] 1 [2,4] [-570:6603:1] [-622:311:1] [834:19239:1]
"""
data = split(line)
label = data[0] + data[1] + data[2]
rank = int(data[4])
t = data[5]
if t=='[]':
t = []
else:
t = [int(c) for c in t[1:-1].split(",")]
torsion = int(prod([ti for ti in t], 1))
ainvs = parse_ainvs(data[3])
E = EllipticCurve([ZZ(a) for a in ainvs])
jinv = unicode(str(E.j_invariant()))
if E.has_cm():
cm = int(E.cm_discriminant())
else:
cm = int(0)
content = {
'conductor': int(data[0]),
'iso': data[0] + data[1],
'number': int(data[2]),
'ainvs': ainvs,
'jinv': jinv,
'cm': cm,
'rank': int(data[4]),
'gens': ["(%s)" % gen[1:-1] for gen in data[6:6 + rank]],
'torsion': torsion,
'torsion_structure': ["%s" % tor for tor in t],
'torsion_generators': ["%s" % parse_tgens(tgens[1:-1]) for tgens in data[6 + rank:]],
}
extra_data = make_extra_data(label,content['number'],ainvs,content['gens'])
content.update(extra_data)
return label, content
开发者ID:AurelPage,项目名称:lmfdb,代码行数:48,代码来源:import_ec_data.py
示例16: modular_form_display
def modular_form_display(label, number):
try:
number = int(number)
except ValueError:
number = 10
if number < 10:
number = 10
if number > 1000:
number = 1000
data = db_ec().find_one({'lmfdb_label': label})
if data is None:
return elliptic_curve_jump_error(label, {})
E = EllipticCurve(parse_ainvs(data['xainvs']))
modform = E.q_eigenform(number)
modform_string = web_latex_split_on_pm(modform)
return modform_string
开发者ID:haraldschilly,项目名称:lmfdb,代码行数:16,代码来源:elliptic_curve.py
示例17: by_weierstrass
def by_weierstrass(eqn):
w = weierstrass_eqn_regex.match(eqn)
if not w:
w = short_weierstrass_eqn_regex.match(eqn)
if not w:
return elliptic_curve_jump_error(eqn, {})
try:
ainvs = [ZZ(ai) for ai in w.groups()]
except TypeError:
return elliptic_curve_jump_error(eqn, {})
E = EllipticCurve(ainvs).global_minimal_model()
N = E.conductor()
data = db_ec().find_one({'xainvs': EC_ainvs(E)})
if data is None:
return elliptic_curve_jump_error(eqn, {'conductor':N}, missing_curve=True)
return redirect(url_for(".by_ec_label", label=data['lmfdb_label']), 301)
开发者ID:haraldschilly,项目名称:lmfdb,代码行数:16,代码来源:elliptic_curve.py
示例18: _test_an_dict_over_Q
def _test_an_dict_over_Q(ainvs, B=100):
"""
Test that the an_dict function works and gives the correct answer
for an elliptic curve defined over QQ, by computing using the
generic code in this file, and comparing with the output of Sage's
anlist function for rational elliptic curves.
"""
from sage.all import polygen, QQ, NumberField, EllipticCurve
x = polygen(QQ,'x')
F = NumberField(x - 1,'a'); a = F.gen()
E = EllipticCurve(F, ainvs)
EQ = EllipticCurve(QQ, ainvs)
v = EQ.anlist(B)
an = an_dict(E, B)
for i, j in an.iteritems():
assert j == v[i[0]]
开发者ID:Alwnikrotikz,项目名称:purplesage,代码行数:16,代码来源:aplist.py
示例19: __init__
def __init__(self, ec, P = None, dmap = None, order = None, pairing="weil", k = None, seed=None):
self.ec = ec
self.P = P
self.distortion = self._deco(dmap)
if dmap == None:
self.distortion = self._ext
if order == None:
self.order = P.order()
else:
self.order = order
self.pairing = pairing
ord = self.ec.base_ring().cardinality()
if k == None:
k = Zmod(self.order)(ord).multiplicative_order()
self.k = k
random.seed(seed)
self.t = random.randint(2, self.order-1)
base = FiniteField(ord**self.k, 'b')
self.hom = Hom(self.ec.base_ring(), base)(base.gen()**((ord**self.k-1)/(ord-1)))
self.ec2 = EllipticCurve(map(int,self.ec.a_invariants())).change_ring(base)
开发者ID:dscharles,项目名称:impluniversidad,代码行数:26,代码来源:BasicIdent.py
示例20: modular_form_display
def modular_form_display(label, number):
try:
number = int(number)
except ValueError:
number = 10
if number < 10:
number = 10
if number > 1000:
number = 1000
ainvs = db.ec_curves.lookup(label, 'ainvs', 'lmfdb_label')
if ainvs is None:
return elliptic_curve_jump_error(label, {})
E = EllipticCurve(ainvs)
modform = E.q_eigenform(number)
modform_string = web_latex_split_on_pm(modform)
return modform_string
开发者ID:koffie,项目名称:lmfdb,代码行数:16,代码来源:elliptic_curve.py
注:本文中的sage.all.EllipticCurve类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论