| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
7.2 Functions on modular integers
Given a modular integer ring R, the following members can be used.
cl_I R->modulus-
This is the ring’s modulus, normalized to be nonnegative:
abs(N). cl_MI R->zero()-
This returns
0 mod N. cl_MI R->one()-
This returns
1 mod N. cl_MI R->canonhom (const cl_I& x)-
This returns
x mod N. cl_I R->retract (const cl_MI& x)-
This is a partial inverse function to
R->canonhom. It returns the standard representative (>=0,<N) ofx. cl_MI R->random(random_state& randomstate)cl_MI R->random()-
This returns a random integer modulo
N.
The following operations are defined on modular integers.
cl_modint_ring x.ring ()-
Returns the ring to which the modular integer
xbelongs. cl_MI operator+ (const cl_MI&, const cl_MI&)-
Returns the sum of two modular integers. One of the arguments may also be a plain integer.
cl_MI operator- (const cl_MI&, const cl_MI&)-
Returns the difference of two modular integers. One of the arguments may also be a plain integer.
cl_MI operator- (const cl_MI&)Returns the negative of a modular integer.
cl_MI operator* (const cl_MI&, const cl_MI&)-
Returns the product of two modular integers. One of the arguments may also be a plain integer.
cl_MI square (const cl_MI&)-
Returns the square of a modular integer.
cl_MI recip (const cl_MI& x)-
Returns the reciprocal
x^-1of a modular integerx.xmust be coprime to the modulus, otherwise an error message is issued. cl_MI div (const cl_MI& x, const cl_MI& y)-
Returns the quotient
x*y^-1of two modular integersx,y.ymust be coprime to the modulus, otherwise an error message is issued. cl_MI expt_pos (const cl_MI& x, const cl_I& y)-
ymust be > 0. Returnsx^y. cl_MI expt (const cl_MI& x, const cl_I& y)-
Returns
x^y. Ifyis negative,xmust be coprime to the modulus, else an error message is issued. cl_MI operator<< (const cl_MI& x, const cl_I& y)-
Returns
x*2^y. cl_MI operator>> (const cl_MI& x, const cl_I& y)-
Returns
x*2^-y. Whenyis positive, the modulus must be odd, or an error message is issued. bool operator== (const cl_MI&, const cl_MI&)bool operator!= (const cl_MI&, const cl_MI&)-
Compares two modular integers, belonging to the same modular integer ring, for equality.
bool zerop (const cl_MI& x)-
Returns true if
xis0 mod N.
The following output functions are defined (see also the chapter on input/output).
void fprint (std::ostream& stream, const cl_MI& x)std::ostream& operator<< (std::ostream& stream, const cl_MI& x)-
Prints the modular integer
xon thestream. The output may depend on the global printer settings in the variabledefault_print_flags.
| [ << ] | [ < ] | [ Up ] | [ > ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated on August 27, 2013 using texi2html 5.0.
