8 #ifndef _scalar_integer_hpp 
    9 #define _scalar_integer_hpp 
   57   if (mpz_init_set_str(&
rep(), s, base))
 
   58     std::cerr << 
"scalar<MPZ>: The string " << s 
 
   59           << 
" is not a valid number in base " << base << std::endl;
 
   67   mpz_init_set(&
rep(), &rhs.
rep());      
 
   75   if (
this != &rhs) mpz_set(&
rep(), &rhs.
rep()); 
 
   82   mpz_set_ui(&
rep(), rhs); 
 
   89   return mpz_cmp(&
rep(), &rhs.
rep()) == 0;
 
   94   return mpz_cmp_si(&
rep(), sl) == 0;
 
   99   return mpz_cmp_si(&
rep(), (
long) si) == 0;
 
  105   return mpz_cmp_ui(&
rep(), ul) == 0;
 
  112   return mpz_cmp(&
rep(), &rhs.
rep()) != 0;
 
  117   return mpz_cmp_si(&
rep(), sl) != 0;
 
  122   return mpz_cmp_si(&
rep(), (
long) si) != 0;
 
  128   return mpz_cmp_ui(&
rep(), ul) != 0;
 
  134   return mpz_cmp(&
rep(), &rhs.
rep()) > 0;
 
  139   return mpz_cmp_si(&
rep(), sl) > 0;
 
  144   return mpz_cmp_si(&
rep(), (
long) si) > 0;
 
  150   return mpz_cmp_ui(&
rep(), ul) > 0;
 
  156   return mpz_cmp(&
rep(), &rhs.
rep()) >= 0;
 
  161   return mpz_cmp_si(&
rep(), sl) >= 0;
 
  167   return mpz_cmp_si(&
rep(), (
long) si) >= 0;
 
  173   return mpz_cmp_ui(&
rep(), ul) >= 0;
 
  180   return mpz_cmp(&
rep(), &rhs.
rep()) < 0;
 
  185   return mpz_cmp_si(&
rep(), sl) < 0;
 
  191   return mpz_cmp_si(&
rep(), (
long) si) < 0;
 
  197   return mpz_cmp_ui(&
rep(), ul) < 0;
 
  205   return mpz_cmp(&
rep(), &rhs.
rep()) <= 0;
 
  210   return mpz_cmp_si(&
rep(), sl) <= 0;
 
  216   return mpz_cmp_si(&
rep(), (
long) si) <= 0;
 
  222   return mpz_cmp_ui(&
rep(), ul) <= 0;
 
  229   mpz_set_ui(&
rep(), ul); 
return *
this;
 
  235   mpz_set_si(&
rep(), sl);  
return *
this;
 
  241   mpz_init_set_si(&(this->
rep()), ul);  
return *
this;
 
  247   mpz_add(&
rep(), &
rep(), &rhs.
rep());  
return *
this;
 
  253   mpz_add_ui(&
rep(), &
rep(), ul); 
return *
this;
 
  260     mpz_add_ui(&
rep(), &
rep(), (
unsigned long) sl);
 
  262     mpz_sub_ui(&
rep(), &
rep(), ((
unsigned long) -sl));
 
  276   mpz_sub(&
rep(), &
rep(), &rhs.
rep()); 
return *
this;
 
  282   mpz_sub_ui(&
rep(), &
rep(), ul); 
return *
this;
 
  289     mpz_sub_ui(&
rep(), &
rep(), (
unsigned long) sl);
 
  291     mpz_add_ui(&
rep(), &
rep(), (
unsigned long) sl);
 
  304   mpz_mul(&
rep(), &
rep(), &rhs.
rep()); 
return *
this;
 
  309   mpz_mul_ui(&
rep(), &
rep(), ul); 
return *
this;
 
  315     mpz_mul_ui(&
rep(), &
rep(), (
unsigned long) sl);
 
  318       rep()._mp_size = -
rep()._mp_size;
 
  319       mpz_mul_ui(&
rep(), &
rep(), ((
unsigned long) -sl));
 
  327      mpz_mul_ui(&
rep(), &
rep(), (
unsigned long) ul);
 
  329      mpz_mul_ui(&
rep(), &
rep(), (
unsigned long) (-ul));
 
  345   mpz_div_ui(&
rep(), &
rep(), ul); 
return *
this;
 
  352     mpz_div_ui(&
rep(), &
rep(), (
unsigned long) sl);
 
  355       rep()._mp_size = -
rep()._mp_size;
 
  356       mpz_div_ui(&
rep(), &
rep(), ((
unsigned long) -sl));
 
  365   mpz_mod(&
rep(), &
rep(), &rhs.
rep()); 
return *
this;
 
  371   mpz_mod_ui(&
rep(), &
rep(), ul); 
return *
this;
 
  381   mpz_add(&result.
rep(), &a1.
rep(), &a2.
rep());
 
  389    mpz_sub(&result.
rep(), &a1.
rep(), &a2.
rep());
 
  403   mpz_mul(&result.
rep(), &a1.
rep(), &a2.
rep());
 
  412   mpz_div(&result.
rep(), &a1.
rep(), &a2.
rep());
 
  420   mpz_add_ui(&
rep(), &
rep(), 1);
 
  427   mpz_sub_ui(&
rep(), &
rep(), 1);
 
  432   mpz_init_set_str(&n.
rep(), s, 10);
 
  438 std::ostream& operator << (std::ostream& os, const scalar<MPZ>& 
b)
 
  440   mpz_out_str(stdout, 10, &
b.rep());
 
  445   return mpz_get_str(NULL, 10, &b.
rep());
 
  449   char* str= mpz_get_str(NULL, 10, &b.
rep());
 
  450   return std::string(str);
 
  452 template<
class OSTREAM> 
inline void 
  460   std::string s;is >> s;
 
  461   mpz_init_set_str(&b.
rep(),s.c_str(), 10);
 
  467 template<> 
inline void 
  470   mpz_div_2exp(&
rep(), &
rep(), exponent_of_2);
 
  480 template<> 
inline void 
  483   mpz_mod_2exp(&
rep(), &
rep(), exponent_of_2);
 
  486 template<> 
inline void 
  489   mpz_mul_2exp(&
rep(), &
rep(), exponent_of_2);
 
  492 template<> 
inline void 
  498 template<> 
inline void 
  501   mpz_powm_ui(&
rep(), &
rep(), exp, &m.
rep());
 
  504 template<> 
inline void 
  507   if (
rep()._mp_size < 0)
 
  508     rep()._mp_size = - 
rep()._mp_size;
 
  511 template<> 
inline void 
  514   mpz_fac_ui(&
rep(), n);
 
  520   rep()._mp_size = - 
rep()._mp_size; 
return *
this;
 
  529   mpz_pow_ui(&
rep(), &
rep(), exp); 
return *
this;
 
  535   mpz_ui_pow_ui(&
rep(), base, exp); 
return *
this;
 
  538 template<> 
inline void 
  541   mpz_mdiv (&
rep(), &
rep(), &divisor.
rep());
 
  544 template<> 
inline void 
  547   mpz_mdiv_ui(&
rep(), &
rep(), divisor);
 
  550 template<> 
inline void 
  553   mpz_mmod(&
rep(), &
rep(), &divisor.
rep());
 
  556 template<> 
inline unsigned long 
  559   return mpz_mmod_ui(&
rep(), &
rep(), divisor);
 
  562 template<> 
inline void 
  571   mpz_sqrtrem(&sqrt.
rep(), &rem.
rep(), &b.
rep());
 
  577   mpz_mdivmod(&q.
rep(), &r.
rep(), &divdend.
rep(), &divisor.
rep());
 
  583   return mpz_mdivmod_ui(&q.
rep(), &r.
rep(), &divdend.
rep(), divisor);
 
  589   mpz_divmod(&q.
rep(), &r.
rep(), &divdend.
rep(), &divisor.
rep());
 
  595   mpz_divmod_ui(&q.
rep(), &r.
rep(), &divdend.
rep(), divisor);
 
  609     mpz_gcdext(&gcd.
rep(), &a.
rep(), 0, &x.
rep(), &y.
rep());
 
  614   return mpz_get_ui(&b.
rep());
 
  619   return mpz_get_si(&b.
rep());
 
  624   return mpz_size(&b.
rep());
 
  629   assert(base >= 2 && base <= 36);
 
  630   return mpz_sizeinbase(&b.
rep(), base);
 
  635   if (b.
rep()._mp_size == 0)
 
  638     return b.
rep()._mp_size > 0 ? 1 : -1;
 
  643   return mpz_cmp(&b1.
rep(), &b2.
rep());
 
  648   return mpz_cmp_ui(&b.
rep(), ul);
 
  653   return mpz_cmp_si(&b.
rep(), sl);
 
  657   return b.
rep()._mp_size > 0;
 
  661   return b.
rep()._mp_size < 0;
 
  665   return b.
rep()._mp_size == 0;
 
  669   return b.
rep()._mp_size == 1 && b.
rep()._mp_d[0] == 1;
 
  673   return b.
rep()._mp_size == -1 && b.
rep()._mp_d[0] == 1;
 
  677   return b.
rep()._mp_size != 0 && (b.
rep()._mp_d[0] & ((mp_limb_t) 1));
 
  681   return b.
rep()._mp_size == 0 || (b.
rep()._mp_d[0] ^ ((mp_limb_t) 0));
 
  686   return mpz_perfect_square_p(&b.
rep());
 
  691   return mpz_probab_prime_p(&b.
rep(), reps);
 
  697   if (s >= 0) mpz_mul_2exp (&r.
rep(), &x.
rep(), s);
 
  698   else mpz_div_2exp (&r.
rep(), &x.
rep(), -s);
 
  705   if (s >= 0) mpz_mul_2exp (&x.
rep(), &x.
rep(), s);
 
  706   else mpz_div_2exp (&x.
rep(), &x.
rep(), -s);
 
  726   mpz_pow_ui(&r.
rep(), &a.
rep(), n);
 
  749 #ifndef __MMX__DOUBLE_HPP__ 
  752   template<
typename T,
typename F> 
struct as_helper;
 
  758 #endif // //SCL_MPZ_H 
TMPL void rem(POLYNOMIAL &r, const POLYNOMIAL &a, const POLYNOMIAL &b)
Definition: polynomial_operators.hpp:73
 
bool operator>(const scalar< T > &rhs) const 
 
scalar< T > & operator+=(const scalar< T > &rhs)
 
scalar()
Definition: scalar.hpp:37
 
T pow(const T &a, int i)
Definition: binomials.hpp:12
 
const C & b
Definition: Interval_glue.hpp:25
 
void DivMod(scalar< MPZ > &q, scalar< MPZ > &r, const scalar< MPZ > &divdend, const scalar< MPZ > &divisor)
Definition: scalar_integer.hpp:587
 
bool IsNegative(const scalar< MPZ > &b)
Definition: scalar_integer.hpp:660
 
bool IsPerfectSquare(const scalar< MPZ > &b)
Definition: scalar_integer.hpp:684
 
scalar< T > & operator=(const scalar< T > &rhs)
 
bool operator>=(const scalar< T > &rhs) const 
 
QQ Size(const QQ &r)
Definition: GMPXX.hpp:64
 
Definition: assign.hpp:48
 
void rem(const scalar< T > &divisor)
 
double gcd(const double &, const double &)
Definition: GMP.hpp:90
 
bool IsZero(const scalar< MPZ > &b)
Definition: scalar_integer.hpp:664
 
T & rep()
Definition: scalar.hpp:30
 
R & rep(R &r)
Definition: shared_object.hpp:180
 
signed long BigIntToSL(const scalar< MPZ > &b)
Definition: scalar_integer.hpp:617
 
scalar< T > & operator%=(const scalar< T > &rhs)
 
void PowMod(const scalar< T > &exp, const scalar< T > &m)
 
extended< NT > operator-(const extended< NT > &lhs, const extended< NT > &rhs)
Definition: extended.hpp:132
 
extended< NT > operator/(const extended< NT > &lhs, const extended< NT > &rhs)
Definition: extended.hpp:111
 
scalar< T > & pow(unsigned long exp)
 
scalar< T > & operator-=(const scalar< T > &rhs)
 
double to_double(const RR &a)
Definition: GMP.hpp:66
 
int compare(const QQ &a, const QQ &b)
Definition: GMPXX.hpp:71
 
std::string to_string(int x)
to_string convert int to std::string In C++11, it should use std::to_string 
Definition: assign.hpp:24
 
bool IsEven(const scalar< MPZ > &b)
Definition: scalar_integer.hpp:680
 
extended< NT > operator+(const extended< NT > &lhs, const extended< NT > &rhs)
Definition: extended.hpp:122
 
void Mul2Exp(unsigned long exponent_of_2)
 
bool operator<(const scalar< T > &rhs) const 
 
void quo(const scalar< T > &divisor)
 
void Mod2Exp(unsigned long exponent_of_2)
 
bool operator<=(const scalar< T > &rhs) const 
 
bool operator!=(const scalar< T > &rhs) const 
 
unsigned long BigIntToUL(const scalar< MPZ > &b)
Definition: scalar_integer.hpp:612
 
scalar< T > & operator*=(const scalar< T > &rhs)
 
long int bit_size(const ZZ &z)
Definition: GMPXX.hpp:32
 
static double cv(const scalar< MPZ > &x)
Definition: scalar_integer.hpp:754
 
ZZ isqrt(const ZZ &a)
Definition: GMPXX.hpp:104
 
double rceil(double x)
Definition: scalar.hpp:536
 
scalar< T > & operator/=(const scalar< T > &rhs)
 
char * as_charp(const scalar< MPZ > &b)
Definition: scalar_integer.hpp:444
 
void abs(Interval< C, r > &x, const Interval< C, r > &a)
Definition: Interval_fcts.hpp:185
 
void print(OSTREAM &os, const Interval< T, r > &a)
Definition: Interval.hpp:135
 
scalar< T > sqrt(const scalar< T > &b)
Definition: scalar.hpp:501
 
bool IsPositive(const scalar< MPZ > &b)
Definition: scalar_integer.hpp:656
 
bool operator==(const scalar< T > &rhs) const 
 
MP_INT MPZ
Definition: scalar_integer.hpp:18
 
void SqrtRem(scalar< MPZ > &sqrt, scalar< MPZ > &rem, const scalar< MPZ > &b)
Definition: scalar_integer.hpp:569
 
bool IsMinusOne(const scalar< MPZ > &b)
Definition: scalar_integer.hpp:672
 
std::istream & operator>>(std::istream &is, scalar< MPF > &b)
Definition: scalar_floating.hpp:453
 
void factorial(unsigned long n)
 
void GCD(const scalar< T > &b2)
 
int sign(const QQ &a)
Definition: GMP.hpp:60
 
bool IsOdd(const scalar< MPZ > &b)
Definition: scalar_integer.hpp:676
 
bool IsProbablyPrime(const scalar< MPZ > &b, int reps)
Definition: scalar_integer.hpp:689
 
void convert(scalar< MPF > &n, char *s)
Definition: scalar_floating.hpp:433
 
void assign(A &a, const B &b)
Generic definition of the assignement function. 
Definition: assign.hpp:97
 
double rfloor(double x)
Definition: scalar.hpp:535
 
extended< NT > operator*(const extended< NT > &lhs, const extended< NT > &rhs)
Definition: extended.hpp:101
 
double as_double(const RR &a)
Definition: GMP.hpp:67
 
Definition: scalar.hpp:24
 
size_t log(const scalar< MPF > &b)
Definition: scalar_floating.hpp:506
 
void Div2Exp(unsigned long exponent_of_2)
 
void HalfExtGCD(scalar< MPZ > &gcd, scalar< MPZ > &a, const scalar< MPZ > &x, const scalar< MPZ > &y)
Definition: scalar_integer.hpp:606
 
void ExtGCD(scalar< MPZ > &gcd, scalar< MPZ > &a, scalar< MPZ > &b, const scalar< MPZ > &x, const scalar< MPZ > &y)
Definition: scalar_integer.hpp:599
 
~scalar()
Definition: scalar.hpp:55
 
ZZ lcm(const ZZ &a, const ZZ &b)
Definition: GMPXX.hpp:58
 
void QuoRem(scalar< MPZ > &q, scalar< MPZ > &r, const scalar< MPZ > &divdend, const scalar< MPZ > &divisor)
Definition: scalar_integer.hpp:575
 
#define assert(expr, msg)
Definition: shared_object.hpp:57
 
bool IsOne(const scalar< MPZ > &b)
Definition: scalar_integer.hpp:668