Types.h 2.7 KB

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