1 #ifndef mmx_gmp_kernel_hpp
2 #define mmx_gmp_kernel_hpp
60 inline int sign(
const QQ& a) {
return mpq_sgn(&a.
rep()); }
66 inline double to_double(
const RR& a) {
return mpf_get_d(&a.
rep()); }
67 inline double as_double(
const RR& a) {
return mpf_get_d(&a.
rep()); }
78 mpf_set_default_prec(l);
87 mpf_set_prec(&b.
rep(),l);
90 inline double gcd (
const double&,
const double&) {
return 1; }
97 inline void assign(QQ& x,
const ZZ& r) { mpq_set_z(&x.
rep(), &r.
rep());}
98 inline void assign(RR& r,
const ZZ& x) { mpf_set_z(&r.
rep(),&x.
rep());}
100 inline void assign(mpz_t r,
const ZZ& x) { mpz_set(r, &x.
rep());}
101 inline void assign(mpf_t r,
const ZZ& x) { mpf_set_z(r,&x.
rep());}
102 inline void assign(mpf_t r,
const RR& x) { mpf_set(r,&x.
rep());}
106 mpf_t n, d; mpf_init (n); mpf_init (d);
116 template<
class T,
class U>
struct as_helper;
118 template<>
struct as_helper<QQ,ZZ> {
static inline QQ
cv(
const ZZ& x)
119 { QQ r;mpq_set_z(&r.
rep(),&x.
rep());
return r; } };
121 template<>
struct as_helper<ZZ,QQ> {
static inline ZZ
cv(
const QQ& r)
124 template<>
struct as_helper<QQ,RR> {
static inline QQ
cv(
const RR& x)
125 { QQ r;mpq_set_f(&r.
rep(),&x.
rep());
return r; } };
127 template<>
struct as_helper<RR,QQ> {
static inline RR
cv(
const QQ& x)
128 { RR r;mpf_set_q(&r.
rep(),&x.
rep());
return r; } };
130 template<>
struct as_helper<ZZ,unsigned> {
static inline ZZ
cv(
const unsigned& x)
131 { ZZ r;mpz_set_ui(&r.
rep(),x);
return r; } };
133 template<>
struct as_helper<ZZ,double> {
static inline ZZ
cv(
const double& x)
134 { ZZ r;mpz_set_d(&r.
rep(),x);
return r; } };
136 template<>
struct as_helper<RR,double> {
static inline RR
cv(
const double& x)
137 { RR r;mpf_set_d(&r.
rep(),x);
return r; } };
139 template<>
struct as_helper<double,RR> {
static inline double cv(
const RR& x)
140 {
return mpf_get_d(&x.
rep()); } };
142 template<>
struct as_helper<double,mpf_t> {
static inline double cv(
const mpf_t& x)
143 {
return mpf_get_d(x); } };
166 inline QQ
to_FT(
const ZZ& a,
const ZZ&
b = 1) {
172 inline QQ
to_FT(
const QQ& a,
const QQ&
b = 1) {
return a/
b; }
static ZZ cv(const unsigned &x)
Definition: GMP.hpp:130
texp::rationalof< C >::T to_FT(const C &a, const C &b)
Definition: contfrac_intervaldata.hpp:93
true_t T
Definition: GMP.hpp:47
const C & b
Definition: Interval_glue.hpp:25
GMP::extended_rational EQQ
Definition: GMP.hpp:41
Definition: assign.hpp:48
bool with_plus_sign(const ZZ &c)
Definition: GMP.hpp:62
static ZZ cv(const QQ &r)
Definition: GMP.hpp:121
double gcd(const double &, const double &)
Definition: GMP.hpp:90
GMP::floating RR
Definition: GMP.hpp:39
T & rep()
Definition: scalar.hpp:30
Interval< extended_rational > interval_extended_rational
Definition: GMP.hpp:34
static Interval< double > cv(const QQ &x)
Definition: GMP.hpp:147
GMP T
Definition: GMP.hpp:54
double to_double(const RR &a)
Definition: GMP.hpp:66
GMP T
Definition: GMP.hpp:56
static RR cv(const double &x)
Definition: GMP.hpp:136
scalar< extended< MPQ > > extended_rational
Definition: GMP.hpp:31
Definition: rounding_mode.hpp:71
GMP::rational QQ
Definition: GMP.hpp:37
double ieee
Definition: GMP.hpp:27
structure defining a positive answer
Definition: texp_bool.hpp:7
double to_XT(const ZZ &a)
Definition: GMP.hpp:69
static double cv(const RR &x)
Definition: GMP.hpp:139
Interval< rational > interval_rational
Definition: GMP.hpp:33
GMP T
Definition: GMP.hpp:52
ZZ numerator(const QQ &a)
Definition: GMPXX.hpp:95
scalar< MPZ > integer
Definition: GMP.hpp:28
GMP T
Definition: GMP.hpp:57
false_t T
Definition: GMP.hpp:45
static QQ cv(const RR &x)
Definition: GMP.hpp:124
GMP T
Definition: GMP.hpp:53
scalar< MPF > floating
Definition: GMP.hpp:32
GMP::extended_integer EZZ
Definition: GMP.hpp:42
ZZ denominator(const QQ &a)
Definition: GMPXX.hpp:96
scalar< MPQ > rational
Definition: GMP.hpp:29
Generic class for intervals.
Definition: Interval.hpp:44
true_t T
Definition: GMP.hpp:46
const C & c
Definition: Interval_glue.hpp:45
static QQ cv(const ZZ &x)
Definition: GMP.hpp:118
structure defining a negative answer
Definition: texp_bool.hpp:9
int sign(const QQ &a)
Definition: GMP.hpp:60
void bit_precision(unsigned long l)
Definition: GMP.hpp:77
void assign(A &a, const B &b)
Generic definition of the assignement function.
Definition: assign.hpp:97
static ZZ cv(const double &x)
Definition: GMP.hpp:133
static double cv(const mpf_t &x)
Definition: GMP.hpp:142
GMP T
Definition: GMP.hpp:51
double as_double(const RR &a)
Definition: GMP.hpp:67
Definition: scalar.hpp:24
return the arithmetic kernel from which the unqualified type X comes from.
Definition: GMP.hpp:50
Numerical kernel based on gmp.
Definition: GMP.hpp:26
static RR cv(const QQ &x)
Definition: GMP.hpp:127
GMP::integer ZZ
Definition: GMP.hpp:38
scalar< extended< MPZ > > extended_integer
Definition: GMP.hpp:30