本文整理汇总了Python中sage.rings.all.ZZ.parent方法的典型用法代码示例。如果您正苦于以下问题:Python ZZ.parent方法的具体用法?Python ZZ.parent怎么用?Python ZZ.parent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sage.rings.all.ZZ
的用法示例。
在下文中一共展示了ZZ.parent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _element_constructor_
# 需要导入模块: from sage.rings.all import ZZ [as 别名]
# 或者: from sage.rings.all.ZZ import parent [as 别名]
def _element_constructor_(self, x):
r"""
Return the element of the algebra ``self`` corresponding to ``x``.
EXAMPLES::
sage: S = SiegelModularFormsAlgebra(coeff_ring=QQ)
sage: B = SiegelModularFormsAlgebra(coeff_ring=ZZ).1
sage: S(B)
Igusa_6
sage: S(1/5)
1/5
sage: S(1/5).parent() is S
True
sage: S._element_constructor_(2.67)
Traceback (most recent call last):
...
TypeError: Unable to construct an element of Algebra of Siegel modular forms of degree 2 and even weights on Sp(4,Z) over Rational Field corresponding to 2.67000000000000
sage: S.base_extend(RR)._element_constructor_(2.67)
2.67000000000000
"""
if isinstance(x, (int, long)):
x = ZZ(x)
if isinstance(x, float):
from sage.rings.all import RR
x = RR(x)
if isinstance(x, complex):
from sage.rings.all import CC
x = CC(x)
if isinstance(x.parent(), SiegelModularFormsAlgebra_class):
d = dict((f, self.coeff_ring()(x[f])) for f in x.coeffs())
return self.element_class(parent=self, weight=x.weight(), coeffs=d, prec=x.prec(), name=x.name())
R = self.base_ring()
if R.has_coerce_map_from(x.parent()):
d = {(0, 0, 0): R(x)}
from sage.rings.all import infinity
return self.element_class(parent=self, weight=0, coeffs=d, prec=infinity, name=str(x))
else:
raise TypeError, "Unable to construct an element of %s corresponding to %s" %(self, x)
示例2: is_cm_j_invariant
# 需要导入模块: from sage.rings.all import ZZ [as 别名]
# 或者: from sage.rings.all.ZZ import parent [as 别名]
def is_cm_j_invariant(j, method='new'):
"""
Return whether or not this is a CM `j`-invariant.
INPUT:
- ``j`` -- an element of a number field `K`
OUTPUT:
A pair (bool, (d,f)) which is either (False, None) if `j` is not a
CM j-invariant or (True, (d,f)) if `j` is the `j`-invariant of the
imaginary quadratic order of discriminant `D=df^2` where `d` is
the associated fundamental discriminant and `f` the index.
.. note::
The current implementation makes use of the classification of
all orders of class number up to 100, and hence will raise an
error if `j` is an algebraic integer of degree greater than
this. It would be possible to implement a more general
version, using the fact that `d` must be supported on the
primes dividing the discriminant of the minimal polynomial of
`j`.
EXAMPLES::
sage: from sage.schemes.elliptic_curves.cm import is_cm_j_invariant
sage: is_cm_j_invariant(0)
(True, (-3, 1))
sage: is_cm_j_invariant(8000)
(True, (-8, 1))
sage: K.<a> = QuadraticField(5)
sage: is_cm_j_invariant(282880*a + 632000)
(True, (-20, 1))
sage: K.<a> = NumberField(x^3 - 2)
sage: is_cm_j_invariant(31710790944000*a^2 + 39953093016000*a + 50337742902000)
(True, (-3, 6))
TESTS::
sage: from sage.schemes.elliptic_curves.cm import is_cm_j_invariant
sage: all([is_cm_j_invariant(j) == (True, (d,f)) for d,f,j in cm_j_invariants_and_orders(QQ)])
True
"""
# First we check that j is an algebraic number:
from sage.rings.all import NumberFieldElement, NumberField
if not isinstance(j, NumberFieldElement) and not j in QQ:
raise NotImplementedError("is_cm_j_invariant() is only implemented for number field elements")
# for j in ZZ we have a lookup-table:
if j in ZZ:
j = ZZ(j)
table = dict([(jj,(d,f)) for d,f,jj in cm_j_invariants_and_orders(QQ)])
if j in table:
return True, table[j]
return False, None
# Otherwise if j is in Q then it is not integral so is not CM:
if j in QQ:
return False, None
# Now j has degree at least 2. If it is not integral so is not CM:
if not j.is_integral():
return False, None
# Next we find its minimal polynomial and degree h, and if h is
# less than the degree of j.parent() we recreate j as an element
# of Q(j):
jpol = PolynomialRing(QQ,'x')([-j,1]) if j in QQ else j.absolute_minpoly()
h = jpol.degree()
# This will be used as a fall-back if we cannot determine the
# result using local data. For this to be necessary there would
# have to be very few primes of degree 1 and norm under 1000,
# since we only need to find one prime of degree 1, good
# reduction for which a_P is nonzero.
if method=='old':
if h>100:
raise NotImplementedError("CM data only available for class numbers up to 100")
for d,f in cm_orders(h):
if jpol == hilbert_class_polynomial(d*f**2):
return True, (d,f)
return False, None
# replace j by a clone whose parent is Q(j), if necessary:
K = j.parent()
if h < K.absolute_degree():
K = NumberField(jpol, 'j')
j = K.gen()
# Construct an elliptic curve with j-invariant j, with
#.........这里部分代码省略.........