本文整理汇总了Python中sage.rings.all.ZZ.residue_field方法的典型用法代码示例。如果您正苦于以下问题:Python ZZ.residue_field方法的具体用法?Python ZZ.residue_field怎么用?Python ZZ.residue_field使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sage.rings.all.ZZ
的用法示例。
在下文中一共展示了ZZ.residue_field方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: residue_field
# 需要导入模块: from sage.rings.all import ZZ [as 别名]
# 或者: from sage.rings.all.ZZ import residue_field [as 别名]
def residue_field(self):
r"""
Return the residue class field of this ideal, which must be prime.
.. TODO::
Implement this for more general rings. Currently only defined
for `\ZZ` and for number field orders.
EXAMPLES::
sage: P = ZZ.ideal(61); P
Principal ideal (61) of Integer Ring
sage: F = P.residue_field(); F
Residue field of Integers modulo 61
sage: pi = F.reduction_map(); pi
Partially defined reduction map:
From: Rational Field
To: Residue field of Integers modulo 61
sage: pi(123/234)
6
sage: pi(1/61)
Traceback (most recent call last):
...
ZeroDivisionError: Cannot reduce rational 1/61 modulo 61: it has negative valuation
sage: lift = F.lift_map(); lift
Lifting map:
From: Residue field of Integers modulo 61
To: Integer Ring
sage: lift(F(12345/67890))
33
sage: (12345/67890) % 61
33
TESTS::
sage: ZZ.ideal(96).residue_field()
Traceback (most recent call last):
...
ValueError: The ideal (Principal ideal (96) of Integer Ring) is not prime
::
sage: R.<x>=QQ[]
sage: I=R.ideal(x^2+1)
sage: I.is_prime()
True
sage: I.residue_field()
Traceback (most recent call last):
...
TypeError: residue fields only supported for polynomial rings over finite fields.
"""
if not self.is_prime():
raise ValueError("The ideal (%s) is not prime"%self)
from sage.rings.integer_ring import ZZ
if self.ring() is ZZ:
return ZZ.residue_field(self, check = False)
raise NotImplementedError("residue_field() is only implemented for ZZ and rings of integers of number fields.")