Esempio n. 1
0
decimal r_pi(bool round)
{
#ifdef USE_CGAL
	CGAL::Gmpfr m;
	mpfr_const_pi(m.fr(),MPFR_RNDN);
	return r_round_preference(decimal(m),round);
#else
	return r_round_preference(M_PI,round);
#endif
}
Esempio n. 2
0
decimal r_rand(const decimal& min,const decimal& max)
{
#ifdef USE_CGAL
	CGAL::Gmpfr m;
	mpfr_urandom(m.fr(),state,MPFR_RNDN);
	return r_round_preference((min>max)?decimal(m)*(min-max)+max:decimal(m)*(max-min)+min,true);
#else
	return (min>max)?r_rand()*(min-max)+max:r_rand()*(max-min)+min;
#endif
}
Esempio n. 3
0
decimal r_log10(const decimal& a,bool round)
{
#ifdef USE_CGAL
	CGAL::Gmpfr m;
	CGAL::Gmpfr n=to_gmpfr(a);
	mpfr_log10(m.fr(),n.fr(),MPFR_RNDN);
	return r_round_preference(decimal(m),round);
#else
	return r_round_preference(log10(a),round);
#endif
}
Esempio n. 4
0
decimal r_floor(const decimal& a)
{
#ifdef USE_CGAL
	CGAL::Gmpfr m;
	CGAL::Gmpfr n=to_gmpfr(a);
	mpfr_floor(m.fr(),n.fr());
	return decimal(m);
#else
	return floor(a);
#endif
}
Esempio n. 5
0
decimal r_pow(const decimal& a,const decimal& e,bool round)
{
#ifdef USE_CGAL
	CGAL::Gmpfr m;
	CGAL::Gmpfr n=to_gmpfr(a);
	CGAL::Gmpfr o=to_gmpfr(e);
	mpfr_pow(m.fr(),n.fr(),o.fr(),MPFR_RNDN);
	return r_round_preference(decimal(m),round);
#else
	return pow(a,e);
#endif
}
Esempio n. 6
0
decimal r_atan2(const decimal& a,const decimal& b,bool round)
{
#ifdef USE_CGAL
	CGAL::Gmpfr m;
	CGAL::Gmpfr n=to_gmpfr(a);
	CGAL::Gmpfr o=to_gmpfr(b);
	mpfr_atan2(m.fr(),n.fr(),o.fr(),MPFR_RNDN);
	return r_round_preference(decimal(m),round);
#else
	return r_round_preference(atan2(a,b),round);
#endif
}
Esempio n. 7
0
decimal r_mod(const decimal& a,const decimal& b)
{
#ifdef USE_CGAL
	CGAL::Gmpfr m;
	CGAL::Gmpfr n=to_gmpfr(a);
	CGAL::Gmpfr o=to_gmpfr(b);
	mpfr_fmod(m.fr(),n.fr(),o.fr(),MPFR_RNDN);
	return decimal(m);
#else
	return fmod(a,b);
#endif
}
Esempio n. 8
0
decimal r_round(const decimal& a,int places)
{
#ifdef USE_CGAL
	CGAL::Gmpfr m;
	CGAL::Gmpfr n(10.0);
	CGAL::Gmpfr o(places);
	mpfr_pow(m.fr(),n.fr(),o.fr(),MPFR_RNDN);
	decimal f(m);
#else
	decimal f=pow(10.0,places);
#endif
	return r_round(a*f)/f;
}
Esempio n. 9
0
CGAL::Gmpfr atan2(const CGAL::Gmpfr &y, const CGAL::Gmpfr &x)
{
    CGAL::Gmpfr result(0, std::max(gmp_result_precision(y), gmp_result_precision(x)));
    mpfr_atan2(result.fr(), y.fr(), x.fr(), gmp_rounding_mode(CGAL::Gmpfr::get_default_rndmode()));
    return result;
}
Esempio n. 10
0
CGAL::Gmpfr atan(const CGAL::Gmpfr &x)
{
    CGAL::Gmpfr result(0, gmp_result_precision(x));
    mpfr_atan(result.fr(), x.fr(), gmp_rounding_mode(CGAL::Gmpfr::get_default_rndmode()));
    return result;
}
Esempio n. 11
0
void print(const CGAL::Gmpfr &x)
{
    mpfr_out_str(stderr, 10, 0, x.fr(), GMP_RNDD);
}