1 #ifndef _RHEO_CGAL_KERNEL_FLOAT128_H
2 #define _RHEO_CGAL_KERNEL_FLOAT128_H
26 #if defined(_RHEOLEF_HAVE_FLOAT128) && defined(_RHEOLEF_HAVE_CGAL)
27 #include "rheolef/compiler.h"
28 #include <CGAL/utils.h>
29 #include <CGAL/utils_classes.h>
30 #include <CGAL/number_utils.h>
31 #include <CGAL/Gmpq.h>
44 namespace boost{
namespace multiprecision{
namespace backends{
46 inline void eval_convert_to(CGAL::Gmpq* result,
const float128_backend& val)
49 *result =
static_cast<CGAL::Gmpq
>(double(val.value()));
57 using boost::multiprecision::float128;
60 class Is_valid<float128>:
public std::unary_function<float128,bool> {
62 bool operator()(
const float128& x )
const {
return ! boost::math::isnan(x); }
66 class Algebraic_structure_traits<float128>
67 :
public Algebraic_structure_traits_base<float128,Field_with_kth_root_tag> {
69 typedef Tag_false Is_exact;
70 typedef Tag_true Is_numerical_sensitive;
72 class Sqrt:
public std::unary_function<Type,Type> {
74 Type operator() (
const Type& x)
const {
return sqrt(x); }
76 class Kth_root:
public std::binary_function<int,Type,Type> {
78 Type operator() (
int k,
const Type& x)
const {
79 CGAL_precondition_msg(k > 0,
"'k' must be positive for k-th roots");
80 return pow(x, 1.0/float128(k));
85 class Real_embeddable_traits<float128>
86 :
public INTERN_RET::Real_embeddable_traits_base<float128,CGAL::Tag_true> {
88 class Abs:
public std::unary_function<Type,Type> {
90 Type operator() (
const Type& x)
const {
94 class Is_finite:
public std::unary_function<Type,bool> {
96 bool operator() (
const Type& x)
const {
97 return boost::math::isfinite(x);
103 is_integer(float128
d)
105 return boost::math::isfinite(
d) && (ceil(
d) ==
d);
110 std::pair<float128, float128>
111 split_numerator_denominator(float128
d)
116 while (ceil(num) != num) {
120 CGAL_postcondition(
d == num/den);
121 return std::make_pair(num, den);
126 nextafter(float128 d1, float128 d2)
128 return ::nextafter(d1,d2);
133 #endif // _RHEOLEF_HAVE_FLOAT128 && _RHEOLEF_HAVE_CGAL
134 #endif // _RHEO_CGAL_KERNEL_FLOAT128_H