modulus) |
Create with the command IntegerModRing(modulus)
INPUT: modulus -- an integer > 1 OUTPUT: IntegerModRing -- the ring of integers modulo N.
First we compute with integers modulo
.
sage: FF = IntegerModRing(17) sage: FF Ring of integers modulo 17 sage: FF.is_field() True sage: FF.characteristic() 17 sage: FF.modulus() 17 sage: gens = FF.unit_gens() sage: a = gens[0] sage: a 3 sage: a.is_square() False sage: def pow(i): return a**i sage: [pow(i) for i in range(16)] [1, 3, 9, 10, 13, 5, 15, 11, 16, 14, 8, 7, 4, 12, 2, 6]
Next we compute with the integers modulo
.
sage: Z16 = IntegerModRing(16) sage: Z16.is_field() False sage: Z16.modulus() 16 sage: Z16.characteristic() 16 sage: gens = Z16.unit_gens() sage: gens [15, 5] sage: a = gens[0] sage: b = gens[1] sage: def powa(i): return a**i sage: def powb(i): return b**i sage: gp_exp = FF.unit_group_exponent() sage: gp_exp 16 sage: [powa(i) for i in range(15)] [1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1] sage: [powb(i) for i in range(15)] [1, 5, 9, 13, 1, 5, 9, 13, 1, 5, 9, 13, 1, 5, 9] sage: a.order() 2 sage: b.order() 4
characteristic,
factored_modulus,
is_field,
is_finite,
modulus,
random_element,
unit_gens,
unit_group_exponent
Further documentation:
[bound=None]) |
Return a random element of this ring.
If bound is not None, return the coercion of an integer in the interval [-bound, bound] into this ring.
) |
Returns generators for the unit group
.
We compute the list of generators using a deterministic
algorithm, so the generators list will always be the same.
Each generator corresponds to a prime divisor of
(or
possibly two prime divisors for p=2).
INPUT: (none) OUTPUT: list -- a list of elements of self
Instances of class IntegerModRing_generic also have the following special methods:
__call__,
__cmp__,
__getitem__,
__repr__,
_coerce_,
_IntegerModRing_generic__unit_gens_primecase,
_IntegerModRing_generic__unit_gens_primepowercase
Further documentation:
p, r) |
Find smallest generator for
.