Types.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #ifndef MANDEL_TYPES_H
  2. #define MANDEL_TYPES_H
  3. #include <cinttypes>
  4. #include <cmath>
  5. #ifdef WITH_BOOST
  6. # include <boost/multiprecision/cpp_bin_float.hpp>
  7. # if defined(__GNUC__) || defined(__INTEL_COMPILER)
  8. # include <boost/multiprecision/float128.hpp>
  9. # endif
  10. # include <boost/multiprecision/cpp_int.hpp>
  11. #endif
  12. namespace mnd
  13. {
  14. #ifdef WITH_BOOST
  15. #if 0//defined(__GNUC__) || defined(__INTEL_COMPILER)
  16. using Float128 = boost::multiprecision::float128;
  17. #else
  18. //using Float128 = boost::multiprecision::cpp_bin_float_quad;
  19. using Float128 = boost::multiprecision::number<
  20. boost::multiprecision::backends::cpp_bin_float<
  21. 112, boost::multiprecision::backends::digit_base_2, void, boost::int16_t, -16382, 16383>,
  22. boost::multiprecision::et_off>;
  23. #endif
  24. inline Float128 abs(const Float128& x) { return boost::multiprecision::abs(x); }
  25. inline Float128 floor(const Float128& x) { return boost::multiprecision::floor(x); }
  26. inline Float128 log(const Float128& x) { return boost::multiprecision::log(x); }
  27. inline Float128 log2(const Float128& x) { return boost::multiprecision::log2(x); }
  28. inline Float128 pow(const Float128& x, const Float128& y) { return boost::multiprecision::pow(x, y); }
  29. /*
  30. using Float256 = boost::multiprecision::number<
  31. boost::multiprecision::backends::cpp_bin_float<
  32. 240, boost::multiprecision::backends::digit_base_2, void, boost::int16_t, -16382, 16383>,
  33. boost::multiprecision::et_off>;
  34. */
  35. using Float256 = long double;
  36. /*inline Float256 abs(const Float256& x) { return boost::multiprecision::abs(x); }
  37. inline Float256 floor(const Float256& x) { return boost::multiprecision::floor(x); }
  38. inline Float256 log(const Float256& x) { return boost::multiprecision::log(x); }
  39. inline Float256 log2(const Float256& x) { return boost::multiprecision::log2(x); }
  40. inline Float256 pow(const Float256& x, const Float256& y) { return boost::multiprecision::pow(x, y); }
  41. */
  42. using Real = Float128;
  43. using Integer = boost::multiprecision::int256_t;
  44. #else
  45. using Real = double;
  46. using Integer = int64_t;
  47. #endif
  48. inline double abs(double x) { return ::abs(x); }
  49. inline float abs(float x) { return ::abs(x); }
  50. inline double floor(double x) { return ::floor(x); }
  51. inline float floor(float x) { return ::floorf(x); }
  52. inline double log(double x) { return ::log(x); }
  53. inline float log(float x) { return ::logf(x); }
  54. inline double log2(double x) { return ::log2(x); }
  55. inline float log2(float x) { return ::log2f(x); }
  56. inline double pow(double x, double y) { return ::pow(x, y); }
  57. inline float pow(float x, float y) { return ::powf(x, y); }
  58. }
  59. #endif // MANDEL_TYPES_H