Package sage :: Package rings :: Module integer_ring
[hide private]
[frames] | no frames]

Module integer_ring



File: sage/rings/integer_ring.pyx (starting at line 1)

\protect{Ring $\Z$ of Integers}

The class \\class{IntegerRing} represents
the ring $\\mathbf{Z}$ of (arbitrary precision) integers.  Each integer
is an instance of the class \\class{Integer}, which is defined
in a Pyrex extension module that wraps GMP integers 
(the \\class{mpz_t} type in GMP). 

    sage: Z = IntegerRing(); Z
    Integer Ring
    sage: Z.characteristic()
    0
    sage: Z.is_field()
    False

There is a unique instances of class \\class{IntegerRing}.  To create
an \\class{Integer}, coerce either a Python int, long, or a string.
Various other types will also coerce to the integers, when it makes
sense.

    sage: a = Z(1234); b = Z(5678); print a, b
    1234 5678
    sage: type(a)
    <type 'sage.rings.integer.Integer'>
    sage: a + b
    6912
    sage: Z('94803849083985934859834583945394')
    94803849083985934859834583945394

TESTS:
    sage: Z = IntegerRing()
    sage: Z == loads(dumps(Z))
    True



Classes [hide private]
  IntegerRing_class
File: sage/rings/integer_ring.pyx (starting at line 103) The ring of integers.
Functions [hide private]
 
IntegerRing(...)
File: sage/rings/integer_ring.pyx (starting at line 821)...
 
clear_mpz_globals(...)
File: sage/rings/../ext/gmp.pxi (starting at line 32)
 
crt_basis(...)
File: sage/rings/integer_ring.pyx (starting at line 848) Compute and return a Chinese Remainder Theorem basis for the list X of coprime integers.
 
factor(...)
File: sage/rings/integer_ring.pyx (starting at line 833) Return the factorization of the positive integer $n$ as a sorted list of tuples $(p_i,e_i)$ such that $n=\prod p_i^{e_i}$.
 
gmp_randrange(...)
File: sage/rings/../ext/gmp.pxi (starting at line 232)
 
init_mpz_globals(...)
File: sage/rings/../ext/gmp.pxi (starting at line 29)
 
is_IntegerRing(...)
File: sage/rings/integer_ring.pyx (starting at line 84)...
Variables [hide private]
  Z = ['4ti2-20061025', 'R-2.6.0', 'atlas-3.7.37', 'atlas-3.8.1'...
  ZZ = ['4ti2-20061025', 'R-2.6.0', 'atlas-3.7.37', 'atlas-3.8.1...
Function Details [hide private]

IntegerRing(...)

 
File: sage/rings/integer_ring.pyx (starting at line 821)

Return the integer ring

EXAMPLE:
    sage: IntegerRing()
    Integer Ring
    sage: ZZ==IntegerRing()
    True

crt_basis(...)

 
File: sage/rings/integer_ring.pyx (starting at line 848)

Compute and return a Chinese Remainder Theorem basis for the list
X of coprime integers.

INPUT:
    X -- a list of Integers that are coprime in pairs
OUTPUT:
    E -- a list of Integers such that E[i] = 1 (mod X[i])
         and E[i] = 0 (mod X[j]) for all j!=i.

The E[i] have the property that if A is a list of objects, e.g.,
integers, vectors, matrices, etc., where A[i] is moduli X[i], then
a CRT lift of A is simply
                   sum E[i] * A[i].

ALGORITHM:
To compute E[i], compute integers s and t such that

            s * X[i] + t * (prod over i!=j of X[j]) = 1.   (*)

Then E[i] = t * (prod over i!=j of X[j]).  Notice that equation
(*) implies that E[i] is congruent to 1 modulo X[i] and to 0
modulo the other X[j] for j!=i.

COMPLEXITY: We compute len(X) extended GCD's.

EXAMPLES:
    sage: X = [11,20,31,51]
    sage: E = crt_basis([11,20,31,51])
    sage: E[0]%X[0]; E[1]%X[0]; E[2]%X[0]; E[3]%X[0]
    1
    0
    0
    0
    sage: E[0]%X[1]; E[1]%X[1]; E[2]%X[1]; E[3]%X[1]
    0
    1
    0
    0
    sage: E[0]%X[2]; E[1]%X[2]; E[2]%X[2]; E[3]%X[2]
    0
    0
    1
    0
    sage: E[0]%X[3]; E[1]%X[3]; E[2]%X[3]; E[3]%X[3]
    0
    0
    0
    1

factor(...)

 
File: sage/rings/integer_ring.pyx (starting at line 833)

Return the factorization of the positive integer $n$ as a sorted
list of tuples $(p_i,e_i)$ such that $n=\prod p_i^{e_i}$.

For further documentation see sage.rings.arith.factor()

EXAMPLE:
    sage: sage.rings.integer_ring.factor(420)
    2^2 * 3 * 5 * 7

is_IntegerRing(...)

 
File: sage/rings/integer_ring.pyx (starting at line 84)

Internal funtion: returns true iff x is the ring ZZ of integers

EXAMPLES:
sage: from sage.rings.integer_ring import  is_IntegerRing
sage: is_IntegerRing(ZZ)
True          
sage: is_IntegerRing(QQ)
False
sage: is_IntegerRing(parent(3))
True  
sage: is_IntegerRing(parent(1/3))
False


Variables Details [hide private]

Z

Value:
['4ti2-20061025',
 'R-2.6.0',
 'atlas-3.7.37',
 'atlas-3.8.1',
 'atlas-3.8.1.p1',
 'atlas-3.8.1.p3',
 'atlas-3.8.p11',
 'atlas-3.8.p6',
...

ZZ

Value:
['4ti2-20061025',
 'R-2.6.0',
 'atlas-3.7.37',
 'atlas-3.8.1',
 'atlas-3.8.1.p1',
 'atlas-3.8.1.p3',
 'atlas-3.8.p11',
 'atlas-3.8.p6',
...