00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef PPL_GMP_Integer_inlines_hh
00024 #define PPL_GMP_Integer_inlines_hh 1
00025
00026 namespace Parma_Polyhedra_Library {
00027
00028 inline void
00029 neg_assign(GMP_Integer& x) {
00030 mpz_neg(x.get_mpz_t(), x.get_mpz_t());
00031 }
00032
00033 inline void
00034 neg_assign(GMP_Integer& x, const GMP_Integer& y) {
00035 mpz_neg(x.get_mpz_t(), y.get_mpz_t());
00036 }
00037
00038 inline void
00039 gcd_assign(GMP_Integer& x, const GMP_Integer& y, const GMP_Integer& z) {
00040 mpz_gcd(x.get_mpz_t(), y.get_mpz_t(), z.get_mpz_t());
00041 }
00042
00043 inline void
00044 gcdext_assign(GMP_Integer& x,
00045 const GMP_Integer& y, const GMP_Integer& z,
00046 GMP_Integer& s, GMP_Integer& t) {
00047 mpz_gcdext(x.get_mpz_t(),
00048 s.get_mpz_t(), t.get_mpz_t(),
00049 y.get_mpz_t(), z.get_mpz_t());
00050 }
00051
00052 inline void
00053 lcm_assign(GMP_Integer& x, const GMP_Integer& y, const GMP_Integer& z) {
00054 mpz_lcm(x.get_mpz_t(), y.get_mpz_t(), z.get_mpz_t());
00055 }
00056
00057 inline void
00058 add_mul_assign(GMP_Integer& x, const GMP_Integer& y, const GMP_Integer& z) {
00059 mpz_addmul(x.get_mpz_t(), y.get_mpz_t(), z.get_mpz_t());
00060 }
00061
00062 inline void
00063 sub_mul_assign(GMP_Integer& x, const GMP_Integer& y, const GMP_Integer& z) {
00064 mpz_submul(x.get_mpz_t(), y.get_mpz_t(), z.get_mpz_t());
00065 }
00066
00067 inline void
00068 exact_div_assign(GMP_Integer& x, const GMP_Integer& y, const GMP_Integer& z) {
00069 assert(y % z == 0);
00070 mpz_divexact(x.get_mpz_t(), y.get_mpz_t(), z.get_mpz_t());
00071 }
00072
00073 inline void
00074 sqrt_assign(GMP_Integer& x, const GMP_Integer& y) {
00075 mpz_sqrt(x.get_mpz_t(), y.get_mpz_t());
00076 }
00077
00078 inline int
00079 cmp(const GMP_Integer& x, const GMP_Integer& y) {
00080 return mpz_cmp(x.get_mpz_t(), y.get_mpz_t());
00081 }
00082
00083 inline const mpz_class&
00084 raw_value(const GMP_Integer& x) {
00085 return x;
00086 }
00087
00088 inline mpz_class&
00089 raw_value(GMP_Integer& x) {
00090 return x;
00091 }
00092
00093 inline memory_size_type
00094 external_memory_in_bytes(const GMP_Integer& x) {
00095 return x.get_mpz_t()[0]._mp_alloc * SIZEOF_MP_LIMB_T;
00096 }
00097
00098 inline memory_size_type
00099 total_memory_in_bytes(const GMP_Integer& x) {
00100 return sizeof(x) + external_memory_in_bytes(x);
00101 }
00102
00103 }
00104
00106 inline void
00107 std::swap(Parma_Polyhedra_Library::GMP_Integer& x,
00108 Parma_Polyhedra_Library::GMP_Integer& y) {
00109 mpz_swap(x.get_mpz_t(), y.get_mpz_t());
00110 }
00111
00112 #endif // !defined(PPL_GMP_Integer_inlines_hh)