Public Types |
typedef std::vector< mp_limb_t > | vect_t |
| vector of limbs (ie a gmp number).
|
Public Member Functions |
int | sign () const |
mpz_ptr | get_mpz () |
|
| Integer (const std::vector< mp_limb_t > &vect_t) |
| Integer (int n=0) |
| Integer (long n) |
| Integer (unsigned char n) |
| Integer (unsigned int n) |
| Integer (unsigned long n) |
| Integer (double d) |
| Integer (const char *s) |
| Integer (const Integer &n) |
| ~Integer () |
|
Integer & | operator= (const Integer &n) |
Integer & | logcpy (const Integer &n) |
Integer & | copy (const Integer &n) |
|
Integer | operator^ (const Integer &) const |
Integer | operator| (const Integer &) const |
Integer | operator& (const Integer &) const |
unsigned long | operator^ (const unsigned long &a) const |
unsigned long | operator| (const unsigned long &a) const |
unsigned long | operator& (const unsigned long &a) const |
Integer | operator~ () const |
Integer & | operator^= (const Integer &) |
Integer & | operator|= (const Integer &) |
Integer & | operator&= (const Integer &) |
Integer | operator<< (int l) const |
Integer | operator>> (int l) const |
Integer | operator<< (long l) const |
Integer | operator>> (long l) const |
Integer | operator<< (unsigned int l) const |
Integer | operator>> (unsigned int l) const |
Integer | operator<< (unsigned long l) const |
Integer | operator>> (unsigned long l) const |
Integer & | operator<<= (int l) |
Integer & | operator>>= (int l) |
Integer & | operator<<= (long l) |
Integer & | operator>>= (long l) |
Integer & | operator<<= (unsigned int l) |
Integer & | operator>>= (unsigned int l) |
Integer & | operator<<= (unsigned long l) |
Integer & | operator>>= (unsigned long l) |
Static Public Member Functions |
|
Groups a multiplication adn an addition/division is a single function.
This is usually faster than doing the two operations separately.
|
static Integer & | axpy (Integer &res, const Integer &a, const Integer &x, const Integer &y) |
| axpy res = ax+y .
|
static Integer & | axpy (Integer &res, const Integer &a, const unsigned long x, const Integer &y) |
| axpy res = ax+y .
|
static Integer & | axpyin (Integer &res, const Integer &a, const Integer &x) |
| axpyin (inplace) res += ax .
|
static Integer & | axpyin (Integer &res, const Integer &a, const unsigned long x) |
| axpy res = ax+y .
|
static Integer & | maxpy (Integer &res, const Integer &a, const Integer &x, const Integer &y) |
| maxpy res = y - ax .
|
static Integer & | maxpy (Integer &res, const Integer &a, const unsigned long x, const Integer &y) |
| axpy res = ax+y .
|
static Integer & | maxpyin (Integer &res, const Integer &a, const Integer &x) |
| maxpyin res -= ax .
|
static Integer & | maxpyin (Integer &res, const Integer &a, const unsigned long x) |
| axpy res = ax+y .
|
static Integer & | axmy (Integer &res, const Integer &a, const Integer &x, const Integer &y) |
| axmy res = ax - y .
|
static Integer & | axmy (Integer &res, const Integer &a, const unsigned long x, const Integer &y) |
| axpy res = ax+y .
|
static Integer & | axmyin (Integer &res, const Integer &a, const Integer &x) |
| axmyin (in place) res = ax - res .
|
static Integer & | axmyin (Integer &res, const Integer &a, const unsigned long x) |
| axpy res = ax+y .
|
|
static void | seeding (unsigned long int s) |
| returns a random integer r in the intervall [[0, m-1]]
|
static void | seeding (Integer s) |
| returns a random integer r in the intervall [[0, m-1]]
|
static void | seeding () |
| returns a random integer r in the intervall [[0, m-1]]
|
static __gmp_randstate_struct | intializerandstate () |
| returns a random integer r in the intervall [[0, m-1]]
|
static __gmp_randstate_struct * | randstate () |
| returns a random integer r in the intervall [[0, m-1]]
|
static bool | RandBool () |
| returns a random integer r in the intervall [[0, m-1]]
|
template<bool U> |
static Integer & | random_lessthan (Integer &r, const Integer &m) |
| returns a random integer r in the intervall [[0, m-1]]
|
static Integer & | random_lessthan (Integer &r, const Integer &m) |
| returns a random integer r in the intervall [[0, m-1]]
|
template<bool U> |
static Integer & | random_lessthan_2exp (Integer &r, const unsigned long &m) |
| returns a random integer r of at most m bits
|
static Integer & | random_lessthan_2exp (Integer &r, const unsigned long &m) |
| returns a random integer r in the intervall [[0, m-1]]
|
template<bool U> |
static Integer | random_lessthan_2exp (const unsigned long &m) |
| returns a random integer r in the intervall [[0, m-1]]
|
static Integer | random_lessthan_2exp (const unsigned long &m) |
| returns a random integer r in the intervall [[0, m-1]]
|
template<bool U> |
static Integer & | random_lessthan (Integer &r, const unsigned long &m) |
| returns a random integer r in the intervall [[0, m-1]]
|
static Integer & | random_lessthan (Integer &r, const unsigned long &m) |
| returns a random integer r in the intervall [[0, m-1]]
|
template<bool U, class T > |
static Integer | random_lessthan (const T &m) |
| returns a random integer r in the intervall [[0, m-1]]
|
template<class T > |
static Integer | random_lessthan (const T &m) |
| returns a random integer r in the intervall [[0, m-1]]
|
template<bool U> |
static Integer & | random_exact (Integer &r, const Integer &s) |
| returns a reference to a random number r of the size of s , exactly.
|
static Integer & | random_exact (Integer &r, const Integer &s) |
| returns a random integer r in the intervall [[0, m-1]]
|
template<bool U> |
static Integer & | random_exact_2exp (Integer &r, const unsigned long int &m) |
| returns a reference to a random number r of the size m bits, exactly.
|
static Integer & | random_exact_2exp (Integer &r, const unsigned long int &m) |
| returns a random integer r in the intervall [[0, m-1]]
|
template<bool U> |
static Integer & | random_exact (Integer &r, const unsigned long int &m) |
| returns a random integer r in the intervall [[0, m-1]]
|
static Integer & | random_exact (Integer &r, const unsigned long int &m) |
| returns a random integer r in the intervall [[0, m-1]]
|
template<bool U, class T > |
static Integer & | random_exact (Integer &r, const T &m) |
| returns a random integer r in the intervall [[0, m-1]]
|
template<class T > |
static Integer & | random_exact (Integer &r, const T &m) |
| returns a random integer r in the intervall [[0, m-1]]
|
template<bool U, class T > |
static Integer | random_exact (const T &s) |
| returns a random integer r in the intervall [[0, m-1]]
|
template<class T > |
static Integer | random_exact (const T &s) |
| returns a random integer r in the intervall [[0, m-1]]
|
static Integer & | random_between (Integer &r, const Integer &m, const Integer &M) |
| returns a random integer r in the intervall [[0, m-1]]
|
static Integer | random_between (const Integer &m, const Integer &M) |
| returns a random integer r in the intervall [[0, m-1]]
|
static Integer & | random_between_2exp (Integer &r, const unsigned long int &m, const unsigned long int &M) |
| returns a random integer r in the intervall [[0, m-1]]
|
static Integer & | random_between (Integer &r, const unsigned long int &m, const unsigned long int &M) |
| returns a random integer r in the intervall [[0, m-1]]
|
static Integer | random_between_2exp (const unsigned long int &m, const unsigned long int &M) |
| returns a random integer r in the intervall [[0, m-1]]
|
static Integer | random_between (const unsigned long int &m, const unsigned long int &M) |
| returns a random integer r in the intervall [[0, m-1]]
|
template<class R > |
static Integer | random_between (const R &m, const R &M) |
| returns a random integer r in the intervall [[0, m-1]]
|
template<class R > |
static Integer & | random_between (Integer &r, const R &m, const R &M) |
| returns a random integer r in the intervall [[0, m-1]]
|
template<bool U, class T > |
static Integer & | random (Integer &r, const T &m) |
| returns a random integer less than...
|
template<class T > |
static Integer & | random (Integer &r, const T &m) |
| returns a random integer r in the intervall [[0, m-1]]
|
template<bool U, class T > |
static Integer | random (const T &sz) |
| returns a random integer less than...
|
template<class T > |
static Integer | random (const T &sz) |
| returns a random integer r in the intervall [[0, m-1]]
|
template<bool U> |
static Integer | random () |
| returns a random integer r in the intervall [[0, m-1]]
|
static Integer | random () |
| returns a random integer r in the intervall [[0, m-1]]
|
template<bool U, class T > |
static Integer | nonzerorandom (const T &sz) |
| returns a random integer r in the intervall [[0, m-1]]
|
template<bool U, class T > |
static Integer & | nonzerorandom (Integer &r, const T &size) |
| returns a random integer r in the intervall [[0, m-1]]
|
template<class T > |
static Integer | nonzerorandom (const T &sz) |
| returns a random integer r in the intervall [[0, m-1]]
|
template<class T > |
static Integer & | nonzerorandom (Integer &r, const T &size) |
| returns a random integer r in the intervall [[0, m-1]]
|
static Integer | nonzerorandom () |
| returns a random integer r in the intervall [[0, m-1]]
|
Static Public Attributes |
static const Integer | zero |
| zero
|
static const Integer | one |
| one
|
Protected Types |
typedef __mpz_struct | Rep |
Protected Member Functions |
int | priv_sign () const |
const Rep * | get_rep () const |
| Integer (unsigned long *d, long size) |
Protected Attributes |
Rep | gmp_rep |
Friends |
|
Integer | gcd (const Integer &a, const Integer &b) |
Integer | gcd (const Integer &a, const Integer &b, Integer &u, Integer &v) |
Integer & | gcd (Integer &g, const Integer &a, const Integer &b) |
Integer & | gcd (Integer &g, const Integer &a, const Integer &b, Integer &u, Integer &v) |
Integer & | inv (Integer &u, const Integer &a, const Integer &b) |
Integer & | invin (Integer &u, const Integer &b) |
Integer | pp (const Integer &P, const Integer &Q) |
Integer & | lcm (Integer &g, const Integer &a, const Integer &b) |
Integer | lcm (const Integer &a, const Integer &b) |
Integer & | pow (Integer &Res, const Integer &n, const long l) |
Integer & | pow (Integer &Res, const unsigned long n, const unsigned long l) |
Integer & | pow (Integer &Res, const Integer &n, const unsigned long l) |
Integer & | pow (Integer &Res, const Integer &n, const int l) |
Integer & | pow (Integer &Res, const Integer &n, const unsigned int l) |
Integer | pow (const Integer &n, const long l) |
Integer | pow (const Integer &n, const unsigned long l) |
Integer | pow (const Integer &n, const int l) |
Integer | pow (const Integer &n, const unsigned int l) |
Integer & | powmod (Integer &Res, const Integer &n, const unsigned long e, const Integer &m) |
Integer & | powmod (Integer &Res, const Integer &n, const long e, const Integer &m) |
Integer & | powmod (Integer &Res, const Integer &n, const unsigned int e, const Integer &m) |
Integer & | powmod (Integer &Res, const Integer &n, const int e, const Integer &m) |
Integer & | powmod (Integer &Res, const Integer &n, const Integer &e, const Integer &m) |
Integer | powmod (const Integer &n, const unsigned long e, const Integer &m) |
Integer | powmod (const Integer &n, const long e, const Integer &m) |
Integer | powmod (const Integer &n, const unsigned int e, const Integer &m) |
Integer | powmod (const Integer &n, const int e, const Integer &m) |
Integer | powmod (const Integer &n, const Integer &e, const Integer &m) |
Integer | fact (unsigned long l) |
Integer | sqrt (const Integer &p) |
Integer | sqrtrem (const Integer &p, Integer &rem) |
Integer & | sqrt (Integer &r, const Integer &p) |
Integer & | sqrtrem (Integer &r, const Integer &p, Integer &rem) |
bool | root (Integer &q, const Integer &, unsigned int n) |
long | logp (const Integer &a, const Integer &p) |
double | logtwo (const Integer &a) |
double | naturallog (const Integer &a) |
(in)equality |
int | operator!= (const int l) const |
int | operator!= (const long l) const |
int | operator!= (const unsigned long l) const |
int | operator> (const int l) const |
int | operator> (const long l) const |
int | operator> (const unsigned long l) const |
int | operator< (const int l) const |
int | operator< (const long l) const |
int | operator< (const unsigned long l) const |
int | compare (const Integer &a, const Integer &b) |
int | absCompare (const Integer &a, const Integer &b) |
Addition, substraction, multiplication |
Integer | operator+ (const Integer &n) const |
| operator + .
|
Integer | operator+ (const unsigned long n) const |
| operator + .
|
Integer | operator+ (const long n) const |
| operator + .
|
Integer & | operator+= (const Integer &n) |
| operator += .
|
Integer & | operator+= (const unsigned long n) |
| operator + .
|
Integer & | operator+= (const long n) |
| operator + .
|
template<class XXX > |
Integer & | operator+= (const XXX &n) |
| operator + .
|
Integer | operator- (const Integer &n) const |
| operator - .
|
Integer | operator- (const unsigned long n) const |
| operator + .
|
Integer | operator- (const long n) const |
| operator + .
|
Integer & | operator-= (const Integer &n) |
| operator -= .
|
Integer & | operator-= (const unsigned long n) |
| operator + .
|
Integer & | operator-= (const long n) |
| operator + .
|
template<class XXX > |
Integer & | operator-= (const XXX &n) |
| operator + .
|
Integer | operator- () const |
| Opposite.
|
Integer | operator* (const Integer &n) const |
| operator * .
|
Integer | operator* (const unsigned long n) const |
| operator + .
|
Integer | operator* (const long n) const |
| operator + .
|
Integer & | operator*= (const Integer &n) |
| operator *= .
|
Integer & | operator*= (const unsigned long n) |
| operator + .
|
Integer & | operator*= (const long n) |
| operator + .
|
template<class XXX > |
Integer & | operator*= (const XXX &n) |
| operator + .
|
static Integer & | addin (Integer &res, const Integer &n) |
| Addition (inplace) res+=n .
|
static Integer & | addin (Integer &res, const long n) |
| operator + .
|
static Integer & | addin (Integer &res, const unsigned long n) |
| operator + .
|
static Integer & | add (Integer &res, const Integer &n1, const Integer &n2) |
| Addition res=n1+n2 .
|
static Integer & | add (Integer &res, const Integer &n1, const long n2) |
| operator + .
|
static Integer & | add (Integer &res, const Integer &n1, const unsigned long n2) |
| operator + .
|
static Integer & | subin (Integer &res, const Integer &n) |
| Substraction (inplace) res-=n .
|
static Integer & | subin (Integer &res, const long n) |
| operator + .
|
static Integer & | subin (Integer &res, const unsigned long n) |
| operator + .
|
static Integer & | sub (Integer &res, const Integer &n1, const Integer &n2) |
| Substraction res=n1-n2 .
|
static Integer & | sub (Integer &res, const Integer &n1, const long n2) |
| operator + .
|
static Integer & | sub (Integer &res, const Integer &n1, const unsigned long n2) |
| operator + .
|
static Integer & | negin (Integer &res) |
| Negation (inplace) res=-res .
|
static Integer & | neg (Integer &res, const Integer &n) |
| Negation res=-n .
|
static Integer & | mulin (Integer &res, const Integer &n) |
| Multiplication (inplace) res*=n .
|
static Integer & | mulin (Integer &res, const long n) |
| operator + .
|
static Integer & | mulin (Integer &res, const unsigned long n) |
| operator + .
|
static Integer & | mul (Integer &res, const Integer &n1, const Integer &n2) |
| Multiplication res=n1*n2 .
|
static Integer & | mul (Integer &res, const Integer &n1, const long n2) |
| operator + .
|
static Integer & | mul (Integer &res, const Integer &n1, const unsigned long n2) |
| operator + .
|
Division/euclidean division/modulo |
The convention for rounding are the following :
q = a/b , or equivalent operations with the name div or divin , return q rounded towards 0 , in the same manner as C's '/' (truncated division).
r = a % b behaves like C %. The modulo function % rounds towards 0 and the sign of the dividend is preserved. This is :
r = a mod b or similar functions have the same behaviour as GMP mpz_mod , that is the remainder is always positive (>=0). This is the division algorithm convention that is used (see divmod ). In a formula :
- Warning:
- if
q=a/b and r= a % b then a = b q + r is always true (with in addition 0 <= |r| < |b| ). This is also true for divmod(q,a,b,r) (and 0<=r<|b| ). However, one should not mix the two conventions and expect equalities (except if a>=0).
|
Integer | operator/ (const Integer &d) const |
| Division operator.
|
Integer | operator/ (const unsigned long d) const |
| Division operator.
|
Integer | operator/ (const long d) const |
| Division operator.
|
Integer & | operator/= (const Integer &d) |
| Division operator (inplace).
|
Integer & | operator/= (const unsigned long d) |
| Division operator.
|
Integer & | operator/= (const long d) |
| Division operator.
|
template<class XXX > |
Integer & | operator/= (const XXX &d) |
| Division operator.
|
Integer | operator% (const Integer &n) const |
| Modulo operator.
|
long | operator% (const unsigned long n) const |
| Division operator.
|
long | operator% (const long n) const |
| Division operator.
|
double | operator% (const double n) const |
| Division operator.
|
short | operator% (const unsigned short n) const |
| Division operator.
|
template<class XXX > |
XXX | operator% (const XXX &n) const |
| Division operator.
|
Integer & | operator%= (const Integer &n) |
| Modulo operator (inplace).
|
Integer & | operator%= (const unsigned long n) |
| Division operator.
|
Integer & | operator%= (const long n) |
| Division operator.
|
template<class XXX > |
Integer & | operator%= (const XXX &n) |
| Division operator.
|
static Integer & | divin (Integer &q, const Integer &d) |
| Division q/=d .
|
static Integer & | divin (Integer &q, const long d) |
| Division operator.
|
static Integer & | divin (Integer &q, const unsigned long d) |
| Division operator.
|
static Integer & | div (Integer &q, const Integer &n, const Integer &d) |
| Division q=n/d .
|
static Integer & | div (Integer &q, const Integer &n, const long d) |
| Division operator.
|
static Integer & | div (Integer &q, const Integer &n, const int d) |
| Division operator.
|
static Integer & | div (Integer &q, const Integer &n, const unsigned long d) |
| Division operator.
|
static Integer & | divexact (Integer &q, const Integer &n, const Integer &d) |
| Division when d divides n .
|
static Integer | divexact (const Integer &n, const Integer &d) |
| Division when d divides n .
|
static Integer & | modin (Integer &r, const Integer &n) |
| Function mod (inplace).
|
static Integer & | modin (Integer &r, const long n) |
| Division operator.
|
static Integer & | modin (Integer &r, const unsigned long n) |
| Division operator.
|
static Integer & | mod (Integer &r, const Integer &n, const Integer &d) |
| Function mod .
|
static Integer & | mod (Integer &r, const Integer &n, const long d) |
| Division operator.
|
static Integer & | mod (Integer &r, const Integer &n, const unsigned long d) |
| Division operator.
|
static Integer & | divmod (Integer &q, Integer &r, const Integer &n, const Integer &d) |
| Euclidean division.
|
static Integer & | divmod (Integer &q, long &r, const Integer &n, const long d) |
| Division operator.
|
static Integer & | divmod (Integer &q, unsigned long &r, const Integer &n, const unsigned long d) |
| Division operator.
|
Miscellaneous. |
Integer & | operator++ () |
Integer | operator++ (int) |
Integer & | operator-- () |
Integer | operator-- (int) |
size_t | size () const |
size_t | size_in_base (int B) const |
size_t | bitsize () const |
unsigned long | operator[] (size_t i) const |
| operator bool () const |
| operator short () const |
| operator unsigned short () const |
| operator unsigned char () const |
| operator unsigned int () const |
| operator int () const |
| operator signed char () const |
| operator unsigned long () const |
| operator long () const |
| operator unsigned long long () const |
| operator long long () const |
| operator std::string () const |
| operator float () const |
| operator double () const |
| operator vect_t () const |
void | swap (Integer &, Integer &) |
int | sign (const Integer &a) |
int | isZero (const Integer &a) |
int | isOne (const Integer &a) |
int | isperfectpower (const Integer &) |
Integer | abs (const Integer &n) |
Integer & | prevprime (Integer &, const Integer &p) |
Integer & | nextprime (Integer &, const Integer &p) |
int | probab_prime (const Integer &p) |
int | probab_prime (const Integer &p, int r) |
int | jacobi (const Integer &u, const Integer &v) |
int | legendre (const Integer &u, const Integer &v) |
unsigned long | length (const Integer &a) |
I/O |
std::ostream & | print (std::ostream &o) const |
std::istream & | operator>> (std::istream &i, Integer &n) |
std::ostream & | operator<< (std::ostream &o, const Integer &n) |
std::ostream & | absOutput (std::ostream &o, const Integer &n) |
void | importWords (Integer &, size_t, int, int, int, size_t, const void *) |