49 return (
int) mpfr_get_d(rep(),MPFR_RNDN);
55 return mpfr_get_d(ref.
rep(),MPFR_RNDN);
62 mpfr_init_set(rep(),rhs.
rep(),MPFR_RNDN);
68 mpfr_init_set_si(rep(),sl,MPFR_RNDN);
73 mpfr_init_set_ui(rep(),ul,MPFR_RNDN);
79 mpfr_init_set_si(rep(), si,MPFR_RNDN);
85 mpfr_set_default_prec(64);
86 if (mpfr_init_set_str(rep(), str, base, MPFR_RNDN))
87 std::cerr <<
"Scl<MPFR>: The string " << str
88 <<
" is not a valid number in base " << base << std::endl;
95 mpfr_init_set_d(rep(),d,MPFR_RNDN);
104 mpfr_set(rep(), rhs.
rep(),MPFR_RNDN);
113 return mpfr_cmp(rep(), rhs.
rep()) == 0;
118 return mpfr_cmp_si(rep(), sl) == 0;
123 return mpfr_cmp_si(rep(), (
long) si) == 0;
129 return mpfr_cmp_ui(rep(), ul) == 0;
134 return mpfr_cmp_d(rep(), ul) == 0;
141 return mpfr_cmp(rep(), rhs.
rep()) != 0;
145 return mpfr_cmp_d(rep(), sl) != 0;
151 return mpfr_cmp_si(rep(), sl) != 0;
156 return mpfr_cmp_si(rep(), (
long) si) != 0;
162 return mpfr_cmp_ui(rep(), ul) != 0;
169 return mpfr_cmp(rep(), rhs.
rep()) > 0;
174 return mpfr_cmp_d(rep(), sl) > 0;
179 return mpfr_cmp_si(rep(), sl) > 0;
184 return mpfr_cmp_si(rep(), (
long) si) > 0;
190 return mpfr_cmp_ui(rep(), ul) > 0;
198 return mpfr_cmp(rep(), rhs.
rep()) >= 0;
203 return mpfr_cmp_si(rep(), sl) >= 0;
207 return mpfr_cmp_d(rep(), sl) >= 0;
213 return mpfr_cmp_si(rep(), (
long) si) >= 0;
219 return mpfr_cmp_ui(rep(), ul) >= 0;
226 return mpfr_cmp(rep(), rhs.
rep()) < 0;
231 return mpfr_cmp_si(rep(), sl) < 0;
235 return mpfr_cmp_d(rep(), sl) < 0;
241 return mpfr_cmp_si(rep(), (
long) si) < 0;
248 return mpfr_cmp_ui(rep(), ul) < 0;
256 return mpfr_cmp(rep(), rhs.
rep()) <= 0;
260 return mpfr_cmp_d(rep(), sl) <= 0;
266 return mpfr_cmp_si(rep(), sl) <= 0;
272 return mpfr_cmp_si(rep(), (
long) si) <= 0;
278 return mpfr_cmp_ui(rep(), ul) <= 0;
285 mpfr_set_ui(rep(), ul,MPFR_RNDN);
return *
this;
291 mpfr_set_d(rep(), ul,MPFR_RNDN);
return *
this;
297 mpfr_set_si(rep(), sl,MPFR_RNDN);
return *
this;
303 mpfr_set_si(rep(), ul,MPFR_RNDN);
return *
this;
311 mpfr_add(tmp.
rep(), rep(), rhs.
rep(),MPFR_RNDN);
312 mpfr_swap(tmp.
rep(),rep());
320 mpfr_add_ui(rep(), rep(), ul,MPFR_RNDN);
328 mpfr_add_ui(rep(), rep(), (
unsigned long) sl,MPFR_RNDN);
330 mpfr_sub_ui(rep(), rep(), ((
unsigned long) -sl),MPFR_RNDN);
338 mpfr_add_ui(rep(), rep(), (
unsigned long) sl,MPFR_RNDN);
340 mpfr_sub_ui(rep(), rep(), ((
unsigned long) -sl),MPFR_RNDN);
355 mpfr_sub(rep(), rep(), rhs.
rep(),MPFR_RNDN);
369 mpfr_sub_ui(rep(), rep(), ul,MPFR_RNDN);
377 mpfr_sub_ui(rep(), rep(), (
unsigned long) sl,MPFR_RNDN);
379 mpfr_add_ui(rep(), rep(), (
unsigned long) -sl,MPFR_RNDN);
387 mpfr_sub_ui(rep(), rep(), (
unsigned long) sl,MPFR_RNDN);
389 mpfr_add_ui(rep(), rep(), (
unsigned long) -sl,MPFR_RNDN);
397 mpfr_mul(rep(), rep(), rhs.
rep(),MPFR_RNDN);
403 mpfr_mul_ui(rep(), rep(), ul,MPFR_RNDN);
410 mpfr_mul_ui(rep(), rep(), (
unsigned long) sl,MPFR_RNDN);
413 mpfr_neg(rep(),rep(),MPFR_RNDN);
414 mpfr_mul_ui(rep(), rep(),(
unsigned long)(-sl),MPFR_RNDN);
428 mpfr_mul_ui(rep(), rep(), (
unsigned long) ul,MPFR_RNDN);
430 mpfr_mul_ui(rep(), rep(), (
unsigned long) (-ul),MPFR_RNDN);
431 mpfr_neg(rep(), rep(),MPFR_RNDN);
439 mpfr_div(rep(), rep(), rhs.
rep(),MPFR_RNDN);
446 mpfr_div_ui(rep(), rep(), ul,MPFR_RNDN);
454 mpfr_div_ui(rep(), rep(), (
unsigned long) sl,MPFR_RNDN);
457 mpfr_neg(rep(),rep(),MPFR_RNDN);
458 mpfr_div_ui(rep(), rep(), ((
unsigned long) -sl),MPFR_RNDN);
466 mpfr_div_ui(rep(), rep(), (
unsigned long) sl,MPFR_RNDN);
469 mpfr_neg(rep(),rep(),MPFR_RNDN);
470 mpfr_div_ui(rep(), rep(), ((
unsigned long) -sl),MPFR_RNDN);
489 mpfr_add(result.
rep(), a1.
rep(), a2.
rep(),MPFR_RNDN);
496 mpfr_sub(result.
rep(), a1.
rep(), a2.
rep(),MPFR_RNDN);
503 mpfr_mul(result.
rep(), a1.
rep(), a2.
rep(),MPFR_RNDN);
517 mpfr_div(result.
rep(), a1.
rep(), a2.
rep(),MPFR_RNDN);
567 mpfr_add_ui(rep(), rep(), 1,MPFR_RNDN);
574 mpfr_sub_ui(rep(), rep(), 1,MPFR_RNDN);
580 mpfr_init_set_str(n.
rep(), s, 10,MPFR_RNDN);
587 std::ostream& operator << (std::ostream& os, const Scl<MPFR>&
x)
594 unsigned sz= mpfr_get_prec(
x.rep())+1;
596 char* tmp =
new char [sz];
598 int n = os.precision();
600 mpfr_get_str (tmp+1, &e, 10, n,
x.rep(), MPFR_RNDN);
618 std::string s; is >> s;
620 mpfr_init_set_str(b.
rep(), s.c_str(), 10, MPFR_RNDN);
637 mpfr_set_default_prec(l);
645 mpfr_set_prec(b.
rep(),l);
651 mpfr_div_2exp(rep(), rep(), exponent_of_2,MPFR_RNDN);
654 template<>
inline void
657 if (mpfr_sgn(rep()) < 0)
658 mpfr_neg(rep(),rep(),MPFR_RNDN);
664 mpfr_neg(rep(),rep(),MPFR_RNDN);
672 mpfr_sqrt(rep(), rep(),MPFR_RNDN);
680 mpfr_set_default_prec(mpfr_get_default_prec()+10);
682 mpfr_set(tmp,b.
rep(),MPFR_RNDN);
683 mpfr_log(tmp,tmp,MPFR_RNDN);
684 mpfr_set(res.
rep(),tmp,MPFR_RNDN);
693 return mpfr_sgn(b.
rep());
702 mpfr_pow_ui(rep(),rep(),exp,MPFR_RNDN);
717 mpfr_set(tmpb1,b1.
rep(),MPFR_RNDN);
718 mpfr_set(tmpb2,b2.
rep(),MPFR_RNDN);
719 mpfr_pow(tmpb1,tmpb1,tmpb2,MPFR_RNDN);
720 mpfr_set(res.
rep(),tmpb1,MPFR_RNDN);
729 mpfr_set(tmpb1,b1.
rep(),MPFR_RNDN);
730 mpfr_set(tmpb2,b2.
rep(),MPFR_RNDN);
731 mpfr_neg(tmpb2,tmpb2,MPFR_RNDN);
734 mpfr_pow(tmpb1,tmpb1,tmpb2,MPFR_RNDN);
737 mpfr_ui_div(tmpb1,1l,tmpb1,MPFR_RNDN);
738 mpfr_set(res.
rep(),tmpb1,MPFR_RNDN);
751 return mpfr_cmp(b1.
rep(), b2.
rep());
756 return mpfr_cmp_ui(b.
rep(), ul);
761 return mpfr_cmp_si(b.
rep(),
sl);
767 return mpfr_cmp_d(rhs.
rep(), ul) < 0;
769 bool operator < (double ul, const Scl<MPFR> &rhs)
771 return mpfr_cmp_d(rhs.rep(), ul) > 0;
773 bool operator < (int ul, const Scl<MPFR> &rhs)
775 return mpfr_cmp_si(rhs.rep(), ul) > 0;
780 return mpfr_cmp_si(rhs.
rep(), ul) < 0;
793 mpfr_set_default_prec(mpfr_get_default_prec()+10);
795 mpfr_set(tmp,x.
rep(),GMP_RNDN);
797 mpfr_neg(tmp,tmp,GMP_RNDN);
798 mpfr_log2(tmp,tmp,GMP_RNDN);
799 mpfr_set(res.
rep(),tmp,GMP_RNDN);
805 return mpfr_inf_p(x.
rep());
809 return (mpfr_inf_p(x.
rep())==0?1:0);
813 return mpfr_nan_p(x.
rep());
824 mpfr_copysign(res.
rep(),a.
rep(),b.
rep(), MPFR_RNDN);
832 #endif // //SCL_MPF_H
int sign(const Scl< MPFR > &b)
Definition: Scl_mpfr.hpp:691
bool has_positive_sign(const Scl< MPFR > &b)
Definition: Scl_mpfr.hpp:625
unsigned long MPFR_PRECISION
Definition: Scl_mpfr.hpp:27
bool operator>(double ul, const Scl< MPFR > &rhs)
Definition: Scl_mpfr.hpp:764
int isfinite(const Scl< MPFR > &x)
Definition: Scl_mpfr.hpp:808
int isinf(const Scl< MPFR > &x)
Definition: Scl_mpfr.hpp:804
void Div2Exp(unsigned long exponent_of_2)
Definition: Scl_mpfr.hpp:827
Scl< T > operator-=(const Scl< T > &rhs)
MSKaccmodee MSKint32t MSKsoltypee MSKstakeye MSKrealt MSKrealt * sl
Definition: mosek.h:3209
Scl< MPFR > logb(const Scl< MPFR > &x)
Definition: Scl_mpfr.hpp:790
Scl< T > operator+=(const Scl< T > &rhs)
int compare(const Scl< MPFR > &b1, const Scl< MPFR > &b2)
Definition: Scl_mpfr.hpp:749
static double castDouble(Scl< T > &ref)
bool operator>=(const Scl< T > &rhs) const
Scl< MPFR > log(const Scl< MPFR > &b)
Definition: Scl_mpfr.hpp:676
MSKaccmodee MSKint32t MSKsoltypee MSKstakeye MSKrealt * x
Definition: mosek.h:3209
Scl< T > operator*=(const Scl< T > &rhs)
bool operator==(const Scl< T > &rhs) const
MSKCONST char * str
Definition: mosek.h:2317
Scl< MPFR > fmax(const Scl< MPFR > &a, const Scl< MPFR > &b)
Definition: Scl_mpfr.hpp:783
Scl< MPFR > copysign(const Scl< MPFR > &a, const Scl< MPFR > &b)
Definition: Scl_mpfr.hpp:822
Scl< MPFR > operator/(const Scl< MPFR > &a1, const Scl< MPFR > &a2)
Definition: Scl_mpfr.hpp:514
mpfr_t MPFR
Definition: Scl_mpfr.hpp:25
Scl()
Definition: Scl.hpp:38
bool operator<=(const Scl< T > &rhs) const
Scl< T > operator/=(const Scl< T > &rhs)
int isnan(const Scl< MPFR > &x)
Definition: Scl_mpfr.hpp:812
Scl< MPFR > operator-(const Scl< MPFR > &a1, const Scl< MPFR > &a2)
Definition: Scl_mpfr.hpp:493
void convert(Scl< MPFR > &n, char *s)
Definition: Scl_mpfr.hpp:577
Scl< MPFR > fabs(const Scl< MPFR > &x)
Definition: Scl_mpfr.hpp:816
void Precision(unsigned long l)
Definition: Scl_mpfr.hpp:635
std::istream & operator>>(std::istream &is, Scl< MPFR > &b)
Definition: Scl_mpfr.hpp:616
Scl< T > operator=(const Scl< T > &rhs)
Scl< MPFR > operator+(const Scl< MPFR > &a1, const Scl< MPFR > &a2)
Definition: Scl_mpfr.hpp:486
bool operator>(const Scl< T > &rhs) const
MSKstreamtypee MSKint32t MSKint32t MSKint32t MSKint32t MSKint32t MSKint32t MSKint32t MSKint32t MSKint32t a
Definition: mosek.h:3833
Scl< MPFR > pow(const Scl< MPFR > &b1, const Scl< MPFR > &b2)
Definition: Scl_mpfr.hpp:707
T & rep()
Definition: Scl.hpp:35
~Scl()
Definition: Scl.hpp:49
bool operator!=(const Scl< T > &rhs) const
Scl< MPFR > operator*(const Scl< MPFR > &a1, const Scl< MPFR > &a2)
Definition: Scl_mpfr.hpp:500
bool operator<(const Scl< T > &rhs) const
Scl< MPFR > abs(const Scl< MPFR > &x)
Definition: Scl_mpfr.hpp:828