Home | Trees | Index | Help |
|
---|
Package sage :: Package rings :: Module integer_ring :: Class IntegerRing |
|
Ring
--+ |object
--+ | | |_uniq_int
--+ | IntegerRing
The ring of integers.
EXAMPLES: We create the rational numbers and call a few functions:>>> Z = IntegerRing(); Z Integer Ring >>> Z.characteristic() 0 >>> Z.is_field() FalseWe illustrate arithmetic in Z.
>>> a = Z(1234); b = Z(5678); print a, b 1234 5678 >>> type(a) <type '_integer.Integer'> >>> a + b 6912 >>> b + a 6912 >>> a * b 7006652 >>> b * a 7006652 >>> a - b -4444 >>> b - a 4444When we divide, the result is automatically coerced to the rationals, even if the result is an integer.
>>> a / b 617/2839 >>> type(a/b) <type '_rational.Rational'> >>> a/a 1 >>> type(a/a) <type '_rational.Rational'>Next we illustrate arithmetic with automatic coercion. The types that coerce are: str, int, long, Integer.
>>> a + 17 1251 >>> a * 374 461516 >>> 374 * a 461516 >>> a/19 1234/19 >>> 0 + Z(-64) -64Integers can be coerced:
>>> a = Z(-64) >>> int(a) -64 >>> long(a) -64L
Method Summary | |
---|---|
Coerce x into the ring. | |
__cmp__(self,
other)
| |
__contains__(self,
x)
| |
__repr__(self)
| |
Return 0 as a Python int. | |
Return True, since elements of the integers do not have to be printed with paranethesis around them, when they are coefficients, e.g., in a polynomial. | |
Return False. | |
Return the string "Z". | |
Return a random integer between -bound and bound, including both endpoints. | |
Return the integer -1, which is the root of unity of largest order in Z. | |
Inherited from object | |
x.__init__(...) initializes x; see x.__class__.__doc__ for signature | |
x.__delattr__('name') <==> del x.name | |
x.__getattribute__('name') <==> x.name | |
x.__hash__() <==> hash(x) | |
helper for pickle | |
helper for pickle | |
x.__setattr__('name', value) <==> x.name = value | |
x.__str__() <==> str(x) | |
Inherited from Ring | |
|
Instance Method Details |
---|
__call__(self,
x)
Coerce x into the ring.
|
characteristic(self)Return 0 as a Python int.
|
is_atomic_repr(self)Return True, since elements of the integers do not have to be printed with paranethesis around them, when they are coefficients, e.g., in a polynomial.
|
is_field(self)Return False.
|
name(self)Return the string "Z".
|
random(self, bound=5)Return a random integer between -bound and bound, including both endpoints. |
zeta(self)Return the integer -1, which is the root of unity of largest order in Z. |
Home | Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Mon May 9 17:57:03 2005 | http://epydoc.sf.net |