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>
44namespace boost{
namespace multiprecision{
namespace backends{
46inline void eval_convert_to(CGAL::Gmpq* result,
const float128_backend& val)
49 *result =
static_cast<CGAL::Gmpq
>(double(val.value()));
57using boost::multiprecision::float128;
60class Is_valid<float128>:
public std::unary_function<float128,bool> {
62 bool operator()(
const float128& x )
const {
return ! boost::math::isnan(x); }
66class 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));
85class 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);
103is_integer(float128
d)
105 return boost::math::isfinite(
d) && (ceil(
d) ==
d);
110std::pair<float128, float128>
111split_numerator_denominator(float128
d)
116 while (ceil(num) != num) {
120 CGAL_postcondition(
d == num/den);
121 return std::make_pair(num, den);
126nextafter(float128 d1, float128 d2)
128 return ::nextafter(d1,d2);
space_mult_list< T, M > pow(const space_basic< T, M > &X, size_t n)
t operator()(const t &a, const t &b)