33#ifdef OGDF_INCLUDE_CGAL
35# include <CGAL/CORE_Expr.h>
36# include <CGAL/Gmpfr.h>
37# include <CGAL/Gmpq.h>
38# include <CGAL/gmpxx.h>
41# ifndef OGDF_GEOMETRIC_MPFR_NUMBER_OF_DIGITS
43# define OGDF_GEOMETRIC_MPFR_NUMBER_OF_DIGITS 77
47# ifndef OGDF_GEOMETRIC_MPFR_EQUALITY_THRESHOLD
48# define OGDF_GEOMETRIC_MPFR_EQUALITY_THRESHOLD 1e-20
58inline double cast(
const T& a) {
60 return CGAL::to_double(a);
64inline double cast(
const double& a) {
68inline mpfr_rnd_t std_rnd_to_mpfr_rnd(
const std::float_round_style& e) {
70 case std::round_indeterminate:
73 case std::round_toward_zero:
75 case std::round_to_nearest:
77 case std::round_toward_infinity:
79 case std::round_toward_neg_infinity:
88inline const T const_pi() {
93inline const CGAL::Gmpfr const_pi() {
95 mpfr_const_pi(y.fr(), std_rnd_to_mpfr_rnd(CGAL::Gmpfr::get_default_rndmode()));
100inline const T approx_sqrt(
const T& v) {
101 return (T)sqrt(CGAL::to_double(v));
104inline const mpz_class approx_sqrt(
const mpz_class& v) {
return sqrt(v); }
106inline const mpq_class approx_sqrt(
const mpq_class& v) {
107 return mpq_class(approx_sqrt(v.get_num()), approx_sqrt(v.get_den()));
110inline const CGAL::Gmpfr approx_sqrt(
const CGAL::Gmpfr& v) {
112 mpfr_sqrt(y.fr(), v.fr(), std_rnd_to_mpfr_rnd(CGAL::Gmpfr::get_default_rndmode()));
116inline const CORE::Expr approx_sqrt(
const CORE::Expr& v) {
return CGAL::sqrt(v); }
119inline const T acos(
const T& v) {
120 return (T)std::acos(CGAL::to_double(v));
124inline const CGAL::Gmpfr acos(
const CGAL::Gmpfr& v) {
126 mpfr_acos(y.fr(), v.fr(), std_rnd_to_mpfr_rnd(CGAL::Gmpfr::get_default_rndmode()));
131inline const CORE::Expr acos(
const CORE::Expr& v) {
132 return std::acos(CGAL::to_double(v));
139inline bool isEqual(
const t& a,
const t& b) {
144inline bool isEqual(
const double& a,
const double& b) {
145 return fabs(a - b) < OGDF_GEOMETRIC_MPFR_EQUALITY_THRESHOLD;
149inline bool isEqual(
const CGAL::Gmpfr& a,
const CGAL::Gmpfr& b) {
150 return abs(a - b) < OGDF_GEOMETRIC_MPFR_EQUALITY_THRESHOLD;
154inline bool isLessEqual(
const T& a,
const T& b) {
155 return (a < b) || isEqual(a, b);
159inline bool isLess(
const T& a,
const T& b) {
160 return (a < b) && !isEqual(a, b);
164inline bool isGreaterEqual(
const T& a,
const T& b) {
165 return (a > b) || isEqual(a, b);
169inline bool isGreater(
const T& a,
const T& b) {
170 return (a > b) && !isEqual(a, b);
174inline bool isZero(
const T& a) {
175 return isEqual(a, (T)0.0);
181inline std::ostream&
operator<<(std::ostream& os,
const CGAL::Gmpq& p) {
183 os << CGAL::to_double(p);
187inline std::ostream&
operator<<(std::ostream& os,
const CORE::Expr& p) {
189 os << CGAL::to_double(p);
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
The namespace for all OGDF objects.
std::ostream & operator<<(std::ostream &os, const ogdf::Array< E, INDEX > &a)
Prints array a to output stream os.