43 return (
int) mpf_get_d(rep());
49 return mpf_get_d(ref.
rep());
57 mpf_init_set(data,rhs.
rep());
66 mpf_set(rep(), rhs.
rep());
80 mpf_init_set_si(rep(), si);}
85 if (mpf_init_set_str(rep(),
string, base))
86 std::cerr <<
"Scl<MPF>: The string " <<
string
87 <<
" is not a valid number in base " << base << std::endl;
93 mpf_init_set_d(rep(),d);
99 return mpf_cmp(rep(), rhs.
rep()) == 0;
104 return mpf_cmp_si(rep(), sl) == 0;
109 return mpf_cmp_si(rep(), (
long) si) == 0;
115 return mpf_cmp_ui(rep(), ul) == 0;
120 return mpf_cmp_d(rep(), ul) == 0;
127 return mpf_cmp(rep(), rhs.
rep()) != 0;
131 return mpf_cmp_d(rep(), sl) != 0;
137 return mpf_cmp_si(rep(), sl) != 0;
142 return mpf_cmp_si(rep(), (
long) si) != 0;
148 return mpf_cmp_ui(rep(), ul) != 0;
155 return mpf_cmp(rep(), rhs.
rep()) > 0;
160 return mpf_cmp_d(rep(), sl) > 0;
165 return mpf_cmp_si(rep(), sl) > 0;
170 return mpf_cmp_si(rep(), (
long) si) > 0;
176 return mpf_cmp_ui(rep(), ul) > 0;
184 return mpf_cmp(rep(), rhs.
rep()) >= 0;
189 return mpf_cmp_si(rep(), sl) >= 0;
193 return mpf_cmp_d(rep(), sl) >= 0;
199 return mpf_cmp_si(rep(), (
long) si) >= 0;
205 return mpf_cmp_ui(rep(), ul) >= 0;
212 return mpf_cmp(rep(), rhs.
rep()) < 0;
217 return mpf_cmp_si(rep(), sl) < 0;
221 return mpf_cmp_d(rep(), sl) < 0;
227 return mpf_cmp_si(rep(), (
long) si) < 0;
234 return mpf_cmp_ui(rep(), ul) < 0;
242 return mpf_cmp(rep(), rhs.
rep()) <= 0;
246 return mpf_cmp_d(rep(), sl) <= 0;
252 return mpf_cmp_si(rep(), sl) <= 0;
258 return mpf_cmp_si(rep(), (
long) si) <= 0;
264 return mpf_cmp_ui(rep(), ul) <= 0;
271 mpf_set_ui(rep(), ul);
return *
this;
277 mpf_set_d(rep(), ul);
return *
this;
283 mpf_set_si(rep(), sl);
return *
this;
289 mpf_set_si(rep(), ul);
return *
this;
297 mpf_add(tmp.
rep(), rep(), rhs.
rep());
298 mpf_swap(tmp.
rep(),rep());
306 mpf_add_ui(rep(), rep(), ul);
return *
this;
313 mpf_add_ui(rep(), rep(), (
unsigned long) sl);
315 mpf_sub_ui(rep(), rep(), ((
unsigned long) -sl));
323 mpf_add_ui(rep(), rep(), (
unsigned long) sl);
325 mpf_sub_ui(rep(), rep(), ((
unsigned long) -sl));
333 *
this +=
Scl<MPF>(ul);
return *
this;
340 mpf_sub(rep(), rep(), rhs.
rep());
return *
this;
347 *
this-=tmp;
return *
this;
352 mpf_sub_ui(rep(), rep(), ul);
return *
this;
359 mpf_sub_ui(rep(), rep(), (
unsigned long) sl);
361 mpf_add_ui(rep(), rep(), (
unsigned long) -sl);
369 mpf_sub_ui(rep(), rep(), (
unsigned long) sl);
371 mpf_add_ui(rep(), rep(), (
unsigned long) -sl);
379 mpf_mul(rep(), rep(), rhs.
rep());
return *
this;
384 mpf_mul_ui(rep(), rep(), ul);
return *
this;
390 mpf_mul_ui(rep(), rep(), (
unsigned long) sl);
393 mpf_neg(rep(),rep());
394 mpf_mul_ui(rep(), rep(),(
unsigned long)(-sl));
408 mpf_mul_ui(rep(), rep(), (
unsigned long) ul);
410 mpf_mul_ui(rep(), rep(), (
unsigned long) (-ul));
411 mpf_neg(rep(), rep());
419 mpf_div(rep(), rep(), rhs.
rep());
426 mpf_div_ui(rep(), rep(), ul);
return *
this;
433 mpf_div_ui(rep(), rep(), (
unsigned long) sl);
436 mpf_neg(rep(),rep());
437 mpf_div_ui(rep(), rep(), ((
unsigned long) -sl));
445 mpf_div_ui(rep(), rep(), (
unsigned long) sl);
448 mpf_neg(rep(),rep());
449 mpf_div_ui(rep(), rep(), ((
unsigned long) -sl));
468 mpf_add(result.
rep(), a1.
rep(), a2.
rep());
475 mpf_sub(result.
rep(), a1.
rep(), a2.
rep());
482 mpf_mul(result.
rep(), a1.
rep(), a2.
rep());
496 mpf_div(result.
rep(), a1.
rep(), a2.
rep());
574 mpf_add_ui(rep(), rep(), 1);
581 mpf_sub_ui(rep(), rep(), 1);
587 mpf_init_set_str(n.
rep(), s, 10);
593 std::ostream& operator << (std::ostream& os, const Scl<MPF>& b)
596 unsigned sz= mpf_get_prec(b.rep())+1;
597 char* tmp =
new char [sz];
598 int n=os.precision();
599 gmp_sprintf(tmp,
"%.*Ff",n,b.rep());
604 char*
str = mpf_get_str(NULL,&exponent, 10, 0, b.rep());
606 if(mpf_cmp_si(b.rep(),0)<0) {
619 std::string s;is >> s;
621 mpf_init_set_str(b.
rep(),s.c_str(), 10);
640 mpf_set_default_prec(l);
648 mpf_set_prec(b.
rep(),l);
654 mpf_div_2exp(rep(), rep(), exponent_of_2);
657 template<>
inline void
660 if (mpf_sgn(rep()) < 0)
661 mpf_neg(rep(),rep());
667 mpf_neg(rep(),rep());
675 mpf_sqrt(rep(), rep());
684 mpfr_set_default_prec(mpf_get_default_prec()+10);
686 mpfr_set_f(tmp,b.
rep(),GMP_RNDN);
687 mpfr_log(tmp,tmp,GMP_RNDN);
688 mpfr_get_f(res.
rep(),tmp,GMP_RNDN);
697 return mpf_sgn(b.
rep());
710 mpf_pow_ui(rep(),rep(),exp);
725 mpfr_set_f(tmpb1,b1.
rep(),MPFR_RNDN);
726 mpfr_set_f(tmpb2,b2.
rep(),MPFR_RNDN);
727 mpfr_pow(tmpb1,tmpb1,tmpb2,MPFR_RNDN);
728 mpfr_get_f(res.
rep(),tmpb1,MPFR_RNDN);
737 mpfr_set_f(tmpb1,b1.
rep(),MPFR_RNDN);
738 mpfr_set_f(tmpb2,b2.
rep(),MPFR_RNDN);
739 mpfr_neg(tmpb2,tmpb2,MPFR_RNDN);
742 mpfr_pow(tmpb1,tmpb1,tmpb2,MPFR_RNDN);
745 mpfr_ui_div(tmpb1,1l,tmpb1,MPFR_RNDN);
746 mpfr_get_f(res.
rep(),tmpb1,MPFR_RNDN);
759 return mpf_cmp(b1.
rep(), b2.
rep());
764 return mpf_cmp_ui(b.
rep(), ul);
769 return mpf_cmp_si(b.
rep(),
sl);
775 return mpf_cmp_d(rhs.
rep(), ul) < 0;
777 bool operator < (double ul, const Scl<MPF> &rhs)
779 return mpf_cmp_d(rhs.rep(), ul) > 0;
781 bool operator < (int ul, const Scl<MPF> &rhs)
783 return mpf_cmp_si(rhs.rep(), ul) > 0;
788 return mpf_cmp_si(rhs.
rep(), ul) < 0;
791 #endif // //SCL_MPF_H
std::istream & operator>>(std::istream &is, Scl< MPF > &b)
Definition: Scl_mpf.hpp:617
void Div2Exp(unsigned long exponent_of_2)
Scl< MPF > operator*(const Scl< MPF > &a1, const Scl< MPF > &a2)
Definition: Scl_mpf.hpp:479
unsigned long MPF_PRECISION
Definition: Scl_mpf.hpp:25
Scl< T > operator-=(const Scl< T > &rhs)
MSKaccmodee MSKint32t MSKsoltypee MSKstakeye MSKrealt MSKrealt * sl
Definition: mosek.h:3209
Scl< MPF > pow(const Scl< MPF > &b1, const Scl< MPF > &b2)
Definition: Scl_mpf.hpp:715
Scl< T > operator+=(const Scl< T > &rhs)
Scl< MPF > operator-(const Scl< MPF > &a1, const Scl< MPF > &a2)
Definition: Scl_mpf.hpp:472
static double castDouble(Scl< T > &ref)
bool operator>=(const Scl< T > &rhs) const
bool has_positive_sign(const Scl< MPF > &b)
Definition: Scl_mpf.hpp:628
Scl< T > operator*=(const Scl< T > &rhs)
bool operator==(const Scl< T > &rhs) const
MSKCONST char * str
Definition: mosek.h:2317
Scl()
Definition: Scl.hpp:38
bool operator<=(const Scl< T > &rhs) const
bool operator>(double ul, const Scl< MPF > &rhs)
Definition: Scl_mpf.hpp:772
Scl< T > operator/=(const Scl< T > &rhs)
void mpf_precision(unsigned long l)
Definition: Scl_mpf.hpp:638
Scl< MPF > operator/(const Scl< MPF > &a1, const Scl< MPF > &a2)
Definition: Scl_mpf.hpp:493
void Precision(Scl< MPF > &b, unsigned long l)
Definition: Scl_mpf.hpp:646
Scl< T > operator=(const Scl< T > &rhs)
int compare(const Scl< MPF > &b1, const Scl< MPF > &b2)
Definition: Scl_mpf.hpp:757
Scl< MPF > operator+(const Scl< MPF > &a1, const Scl< MPF > &a2)
Definition: Scl_mpf.hpp:465
bool operator>(const Scl< T > &rhs) const
mpf_t MPF
Definition: Scl_mpf.hpp:23
int sign(const Scl< MPF > &b)
Definition: Scl_mpf.hpp:695
T & rep()
Definition: Scl.hpp:35
~Scl()
Definition: Scl.hpp:49
Scl< MPF > log(const Scl< MPF > &b)
Definition: Scl_mpf.hpp:680
void convert(Scl< MPF > &n, char *s)
Definition: Scl_mpf.hpp:584
bool operator!=(const Scl< T > &rhs) const
bool operator<(const Scl< T > &rhs) const