00001 #ifndef SYNAPS_ARITHM_RG_MPZ_H
00002 #define SYNAPS_ARITHM_RG_MPZ_H
00003 
00004 
00005 #include <synaps/init.h>
00006 
00007 __BEGIN_NAMESPACE_SYNAPS
00008 
00009 
00010 std::ostream& Print(std::ostream& os, const MPZ& b)
00011  { mpz_out_str(stdout, 10, &b);  return os; }
00012 
00013 void init(MPZ& rep) { mpz_init(&rep); }
00014 void init_set(MPZ& rep, int si)      {mpz_init_set_si(&rep, si);}
00015 void init_set(MPZ& rep, long int sl) {mpz_init_set_si(&rep, sl);}
00016 void init_set(MPZ& rep, const char*& str, unsigned int b) 
00017 {if (mpz_init_set_str(&rep, str, b))
00018         std::cerr<<"MPZ: The string "<<str<<" is not a valid number in base "<<b<<std::endl;
00019 }
00020 
00021 void clear(MPZ& rep) { mpz_clear(&rep); }
00022 
00023 int  cmp(const MPZ& r1, const Rg<MPZ>&  r2){ return mpz_cmp(&r1,&r2.rep()); }
00024 int  cmp(const MPZ& r1, int  r2)           { return mpz_cmp_si(&r1,(long)r2); }
00025 int  cmp(const MPZ& r1, long r2)           { return mpz_cmp_si(&r1,(long)r2); }
00026 int  cmp(const MPZ& r1, unsigned r2)       { return mpz_cmp_ui(&r1, r2); }
00027 int  cmp(const MPZ& r1, unsigned long r2)  { return mpz_cmp_ui(&r1, r2); }
00028 
00029 inline void assign(MPZ& p, const MPZ& q)   {  mpz_set(&p,&q); }
00030 
00031 inline void add(MPZ& p, const MPZ& a, const MPZ& b) {mpz_add(&p,&a,&b);}
00032 
00033 inline void add(MPZ& p, const MPZ& a, int b) {mpz_add_ui(&p, &a,b);}
00034 
00035 inline void sub(MPZ& p, const MPZ& a, const MPZ& b){mpz_sub(&p,&a,&b);}
00036 
00037 inline void mul(MPZ& p, const MPZ& a, const MPZ& b) {mpz_mul(&p,&a,&b);}
00038 inline void mul(MPZ& p, const MPZ& a, int b)        {mpz_mul_si(&p,&a,b);}
00039 
00040 inline void div(MPZ& p, const MPZ& a, const MPZ& b) {mpz_div(&p,&a,&b);}
00041 inline void div(MPZ& p, const MPZ& a, unsigned   b) {mpz_div_ui(&p,&a,b);}
00042 
00043 inline void mod(MPZ& p, const MPZ& a, const MPZ& b) {mpz_mod(&p,&a,&b);}
00044 inline void mod(MPZ& p, const MPZ& a, unsigned   b) {mpz_mod_ui(&p,&a,b);}
00045 
00046 
00047 
00048 
00049 
00050 
00051 
00052 
00053 
00054 
00055 
00056 
00057 
00058 
00059 
00060 
00061 
00062 
00063 
00064 
00065 
00066 
00067 
00068 
00069 
00070 
00071 
00072 
00073 
00074 
00075 
00076 
00077 
00078 __END_NAMESPACE_SYNAPS
00079 
00080 #endif // SYNAPS_ARITHM_RG_MPZ_H
00081