18 typedef __mpf_struct
MPF;
35 mpf_init_set(&
rep(),&rhs.
rep());
42 mpf_set(&
rep(), &rhs.
rep());
56 mpf_init_set_si(&
rep(), si);}
61 if (mpf_init_set_str(&
rep(),
string, base))
62 std::cerr <<
"scalar<MPF>: The string " <<
string
63 <<
" is not a valid number in base " << base << std::endl;
69 mpf_init_set_d(&
rep(),d);
77 return mpf_cmp(&
rep(), &rhs.
rep()) == 0;
82 return mpf_cmp_si(&
rep(), sl) == 0;
87 return mpf_cmp_si(&
rep(), (
long) si) == 0;
93 return mpf_cmp_ui(&
rep(), ul) == 0;
100 return mpf_cmp(&
rep(), &rhs.
rep()) != 0;
105 return mpf_cmp_si(&
rep(), sl) != 0;
110 return mpf_cmp_si(&
rep(), (
long) si) != 0;
116 return mpf_cmp_ui(&
rep(), ul) != 0;
122 return mpf_cmp(&
rep(), &rhs.
rep()) > 0;
127 return mpf_cmp_si(&
rep(), sl) > 0;
132 return mpf_cmp_si(&
rep(), (
long) si) > 0;
138 return mpf_cmp_ui(&
rep(), ul) > 0;
144 return mpf_cmp(&
rep(), &rhs.
rep()) >= 0;
149 return mpf_cmp_si(&
rep(), sl) >= 0;
155 return mpf_cmp_si(&
rep(), (
long) si) >= 0;
161 return mpf_cmp_ui(&
rep(), ul) >= 0;
168 return mpf_cmp(&
rep(), &rhs.
rep()) < 0;
173 return mpf_cmp_si(&
rep(), sl) < 0;
179 return mpf_cmp_si(&
rep(), (
long) si) < 0;
185 return mpf_cmp_ui(&
rep(), ul) < 0;
193 return mpf_cmp(&
rep(), &rhs.
rep()) <= 0;
198 return mpf_cmp_si(&
rep(), sl) <= 0;
204 return mpf_cmp_si(&
rep(), (
long) si) <= 0;
210 return mpf_cmp_ui(&
rep(), ul) <= 0;
217 mpf_set_ui(&
rep(), ul);
return *
this;
223 mpf_set_si(&
rep(), sl);
return *
this;
229 mpf_set_si(&
rep(), ul);
return *
this;
238 mpf_swap(&tmp.
rep(),&
rep());
246 mpf_add_ui(&
rep(), &
rep(), ul);
return *
this;
253 mpf_add_ui(&
rep(), &
rep(), (
unsigned long) sl);
255 mpf_sub_ui(&
rep(), &
rep(), ((
unsigned long) -sl));
269 mpf_sub(&
rep(), &
rep(), &rhs.
rep());
return *
this;
275 mpf_sub_ui(&
rep(), &
rep(), ul);
return *
this;
282 mpf_sub_ui(&
rep(), &
rep(), (
unsigned long) sl);
284 mpf_add_ui(&
rep(), &
rep(), (
unsigned long) sl);
297 mpf_mul(&
rep(), &
rep(), &rhs.
rep());
return *
this;
302 mpf_mul_ui(&
rep(), &
rep(), ul);
return *
this;
308 mpf_mul_ui(&
rep(), &
rep(), (
unsigned long) sl);
312 mpf_mul_ui(&
rep(), &
rep(),(
unsigned long)(-sl));
326 mpf_mul_ui(&
rep(), &
rep(), (
unsigned long) ul);
328 mpf_mul_ui(&
rep(), &
rep(), (
unsigned long) (-ul));
344 mpf_div_ui(&
rep(), &
rep(), ul);
return *
this;
351 mpf_div_ui(&
rep(), &
rep(), (
unsigned long) sl);
355 mpf_div_ui(&
rep(), &
rep(), ((
unsigned long) -sl));
363 mpf_div_ui(&
rep(), &
rep(), (
unsigned long) sl);
367 mpf_div_ui(&
rep(), &
rep(), ((
unsigned long) -sl));
385 mpf_add(&result.
rep(), &a1.
rep(), &a2.
rep());
393 mpf_sub(&result.
rep(),&a1.
rep(), &a2.
rep());
407 mpf_mul(&result.
rep(), &a1.
rep(), &a2.
rep());
415 mpf_div(&result.
rep(), &a1.
rep(), &a2.
rep());
423 mpf_add_ui(&
rep(), &
rep(), 1);
430 mpf_sub_ui(&
rep(), &
rep(), 1);
436 mpf_init_set_str(&n.
rep(), s, 10);
443 std::ostream& operator << (std::ostream& os, const scalar<MPF>&
b)
446 temp=mpf_get_d(&
b.rep());
455 std::string s;is >> s;
456 mpf_init_set_str(&b.
rep(),s.c_str(), 10);
467 mpf_set_default_prec(l);
475 mpf_set_prec(&b.
rep(),l);
481 mpf_div_2exp(&
rep(), &
rep(), exponent_of_2);
484 template<>
inline void
487 if (mpf_sgn(&
rep()) < 0)
508 return mpf_size(&b.
rep());
513 return mpf_sgn(&b.
rep());
518 return mpf_cmp(&b1.
rep(), &b2.
rep());
523 return mpf_cmp_ui(&b.
rep(), ul);
528 return mpf_cmp_si(&b.
rep(), sl);
542 #endif // //SCL_MPF_H
bool operator>(const scalar< T > &rhs) const
scalar< T > & operator+=(const scalar< T > &rhs)
scalar()
Definition: scalar.hpp:37
const C & b
Definition: Interval_glue.hpp:25
void Precision(unsigned long l)
Definition: GMPXX.hpp:112
scalar< T > & operator=(const scalar< T > &rhs)
bool operator>=(const scalar< T > &rhs) const
T & rep()
Definition: scalar.hpp:30
R & rep(R &r)
Definition: shared_object.hpp:180
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 > & operator-=(const scalar< T > &rhs)
int compare(const QQ &a, const QQ &b)
Definition: GMPXX.hpp:71
extended< NT > operator+(const extended< NT > &lhs, const extended< NT > &rhs)
Definition: extended.hpp:122
__mpf_struct MPF
Definition: scalar_floating.hpp:18
bool operator<(const scalar< T > &rhs) const
bool operator<=(const scalar< T > &rhs) const
bool operator!=(const scalar< T > &rhs) const
void assign(double &r, const scalar< MPF > &z)
Definition: scalar_floating.hpp:537
scalar< T > & operator*=(const scalar< T > &rhs)
scalar< T > & operator/=(const scalar< T > &rhs)
bool operator==(const scalar< T > &rhs) const
std::istream & operator>>(std::istream &is, scalar< MPF > &b)
Definition: scalar_floating.hpp:453
int sign(const QQ &a)
Definition: GMP.hpp:60
void convert(scalar< MPF > &n, char *s)
Definition: scalar_floating.hpp:433
extended< NT > operator*(const extended< NT > &lhs, const extended< NT > &rhs)
Definition: extended.hpp:101
Definition: scalar.hpp:24
size_t log(const scalar< MPF > &b)
Definition: scalar_floating.hpp:506
void Div2Exp(unsigned long exponent_of_2)
~scalar()
Definition: scalar.hpp:55