本文整理汇总了Python中sage.all.ZZ.is_prime方法的典型用法代码示例。如果您正苦于以下问题:Python ZZ.is_prime方法的具体用法?Python ZZ.is_prime怎么用?Python ZZ.is_prime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sage.all.ZZ
的用法示例。
在下文中一共展示了ZZ.is_prime方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: includes_composite
# 需要导入模块: from sage.all import ZZ [as 别名]
# 或者: from sage.all.ZZ import is_prime [as 别名]
def includes_composite(s):
s = s.replace(' ','').replace('..','-')
for interval in s.split(','):
if '-' in interval[1:]:
ix = interval.index('-',1)
a,b = int(interval[:ix]), int(interval[ix+1:])
if b == a:
if a != 1 and not a.is_prime():
return True
if b > a and b > 3:
return True
else:
a = ZZ(interval)
if a != 1 and not a.is_prime():
return True
示例2: includes_composite
# 需要导入模块: from sage.all import ZZ [as 别名]
# 或者: from sage.all.ZZ import is_prime [as 别名]
def includes_composite(s):
s = s.replace(" ", "").replace("..", "-")
for interval in s.split(","):
if "-" in interval[1:]:
ix = interval.index("-", 1)
a, b = int(interval[:ix]), int(interval[ix + 1 :])
if b == a:
if a != 1 and not a.is_prime():
return True
if b > a and b > 3:
return True
else:
a = ZZ(interval)
if a != 1 and not a.is_prime():
return True
示例3: find_curve
# 需要导入模块: from sage.all import ZZ [as 别名]
# 或者: from sage.all.ZZ import is_prime [as 别名]
def find_curve(P, DB, NE, prec, sign_ap = None, magma = None, return_all = False, initial_data = None, ramification_at_infinity = None, **kwargs):
r'''
EXAMPLES:
First example::
sage: from darmonpoints.findcurve import find_curve
sage: find_curve(5,6,30,20) # long time # optional - magma
# B = F<i,j,k>, with i^2 = -1 and j^2 = 3
...
'(1, 0, 1, -289, 1862)'
A second example, now over a real quadratic::
sage: from darmonpoints.findcurve import find_curve
sage: F.<r> = QuadraticField(5)
sage: P = F.ideal(3/2*r + 1/2)
sage: D = F.ideal(3)
sage: find_curve(P,D,P*D,30,ramification_at_infinity = F.real_places()[:1]) # long time # optional - magma
...
Now over a cubic of mixed signature::
sage: from darmonpoints.findcurve import find_curve
sage: F.<r> = NumberField(x^3 -3)
sage: P = F.ideal(r-2)
sage: D = F.ideal(r-1)
sage: find_curve(P,D,P*D,30) # long time # optional - magma
...
'''
config = ConfigParser.ConfigParser()
config.read('config.ini')
param_dict = config_section_map(config, 'General')
param_dict.update(config_section_map(config, 'FindCurve'))
param_dict.update(kwargs)
param = Bunch(**param_dict)
# Get general parameters
outfile = param.get('outfile')
use_ps_dists = param.get('use_ps_dists',False)
use_shapiro = param.get('use_shapiro',True)
use_sage_db = param.get('use_sage_db',False)
magma_seed = param.get('magma_seed',1515316)
parallelize = param.get('parallelize',False)
Up_method = param.get('up_method','naive')
use_magma = param.get('use_magma',True)
progress_bar = param.get('progress_bar',True)
sign_at_infinity = param.get('sign_at_infinity',ZZ(1))
# Get find_curve specific parameters
grouptype = param.get('grouptype')
hecke_bound = param.get('hecke_bound',3)
timeout = param.get('timeout',0)
check_conductor = param.get('check_conductor',True)
if initial_data is None:
page_path = os.path.dirname(__file__) + '/KleinianGroups-1.0/klngpspec'
if magma is None:
from sage.interfaces.magma import Magma
quit_when_done = True
magma = Magma()
else:
quit_when_done = False
if magma_seed is not None:
magma.eval('SetSeed(%s)'%magma_seed)
magma.attach_spec(page_path)
magma.eval('Page_initialized := true')
else:
quit_when_done = False
sys.setrecursionlimit(10**6)
# global qE, Linv, G, Coh, phiE, xgen, xi1, xi2, Phi
try:
F = P.ring()
Fdisc = F.discriminant()
if not (P*DB).divides(NE):
raise ValueError,'Conductor (NE) should be divisible by P*DB'
p = ZZ(P.norm()).abs()
except AttributeError:
F = QQ
P = ZZ(P)
p = ZZ(P)
Fdisc = ZZ(1)
if NE % (P*DB) != 0:
raise ValueError,'Conductor (NE) should be divisible by P*DB'
Ncartan = kwargs.get('Ncartan',None)
Np = NE / (P * DB)
if Ncartan is not None:
Np = Np / Ncartan**2
if use_ps_dists is None:
use_ps_dists = False # More efficient our own implementation
if not p.is_prime():
raise ValueError,'P (= %s) should be a prime, of inertia degree 1'%P
#.........这里部分代码省略.........