BVB Source Codes

mars Show fpclassify.hpp Source code

Return Download mars: download fpclassify.hpp Source code - Download mars Source code - Type:.hpp
  1. //  Copyright John Maddock 2005-2008.
  2. //  Copyright (c) 2006-2008 Johan Rade
  3. //  Use, modification and distribution are subject to the
  4. //  Boost Software License, Version 1.0. (See accompanying file
  5. //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6.  
  7. #ifndef BOOST_MATH_FPCLASSIFY_HPP
  8. #define BOOST_MATH_FPCLASSIFY_HPP
  9.  
  10. #ifdef _MSC_VER
  11. #pragma once
  12. #endif
  13.  
  14. #include <math.h>
  15. #include <boost/config/no_tr1/cmath.hpp>
  16. #include <boost/limits.hpp>
  17. #include <boost/math/tools/real_cast.hpp>
  18. #include <boost/type_traits/is_floating_point.hpp>
  19. #include <boost/math/special_functions/math_fwd.hpp>
  20. #include <boost/math/special_functions/detail/fp_traits.hpp>
  21. /*!
  22.   \file fpclassify.hpp
  23.   \brief Classify floating-point value as normal, subnormal, zero, infinite, or NaN.
  24.   \version 1.0
  25.   \author John Maddock
  26.  */
  27.  
  28. /*
  29.  
  30. 1. If the platform is C99 compliant, then the native floating point
  31. classification functions are used.  However, note that we must only
  32. define the functions which call std::fpclassify etc if that function
  33. really does exist: otherwise a compiler may reject the code even though
  34. the template is never instantiated.
  35.  
  36. 2. If the platform is not C99 compliant, and the binary format for
  37. a floating point type (float, double or long double) can be determined
  38. at compile time, then the following algorithm is used:
  39.  
  40.         If all exponent bits, the flag bit (if there is one),
  41.         and all significand bits are 0, then the number is zero.
  42.  
  43.         If all exponent bits and the flag bit (if there is one) are 0,
  44.         and at least one significand bit is 1, then the number is subnormal.
  45.  
  46.         If all exponent bits are 1 and all significand bits are 0,
  47.         then the number is infinity.
  48.  
  49.         If all exponent bits are 1 and at least one significand bit is 1,
  50.         then the number is a not-a-number.
  51.  
  52.         Otherwise the number is normal.
  53.  
  54.         This algorithm works for the IEEE 754 representation,
  55.         and also for several non IEEE 754 formats.
  56.  
  57.     Most formats have the structure
  58.         sign bit + exponent bits + significand bits.
  59.  
  60.     A few have the structure
  61.         sign bit + exponent bits + flag bit + significand bits.
  62.     The flag bit is 0 for zero and subnormal numbers,
  63.         and 1 for normal numbers and NaN.
  64.         It is 0 (Motorola 68K) or 1 (Intel) for infinity.
  65.  
  66.     To get the bits, the four or eight most significant bytes are copied
  67.     into an uint32_t or uint64_t and bit masks are applied.
  68.     This covers all the exponent bits and the flag bit (if there is one),
  69.     but not always all the significand bits.
  70.     Some of the functions below have two implementations,
  71.     depending on whether all the significand bits are copied or not.
  72.  
  73. 3. If the platform is not C99 compliant, and the binary format for
  74. a floating point type (float, double or long double) can not be determined
  75. at compile time, then comparison with std::numeric_limits values
  76. is used.
  77.  
  78. */
  79.  
  80. #if defined(_MSC_VER) || defined(__BORLANDC__)
  81. #include <float.h>
  82. #endif
  83. #ifdef BOOST_MATH_USE_FLOAT128
  84. #include "quadmath.h"
  85. #endif
  86.  
  87. #ifdef BOOST_NO_STDC_NAMESPACE
  88.   namespace std{ using ::abs; using ::fabs; }
  89. #endif
  90.  
  91. namespace mars_boost {} namespace boost = mars_boost; namespace mars_boost{
  92.  
  93. //
  94. // This must not be located in any namespace under mars_boost::math
  95. // otherwise we can get into an infinite loop if isnan is
  96. // a #define for "isnan" !
  97. //
  98. namespace math_detail{
  99.  
  100. #ifdef BOOST_MSVC
  101. #pragma warning(push)
  102. #pragma warning(disable:4800)
  103. #endif
  104.  
  105. template <class T>
  106. inline bool is_nan_helper(T t, const mars_boost::true_type&)
  107. {
  108. #ifdef isnan
  109.    return isnan(t);
  110. #elif defined(BOOST_MATH_DISABLE_STD_FPCLASSIFY) || !defined(BOOST_HAS_FPCLASSIFY)
  111.    (void)t;
  112.    return false;
  113. #else // BOOST_HAS_FPCLASSIFY
  114.    return (BOOST_FPCLASSIFY_PREFIX fpclassify(t) == (int)FP_NAN);
  115. #endif
  116. }
  117.  
  118. #ifdef BOOST_MSVC
  119. #pragma warning(pop)
  120. #endif
  121.  
  122. template <class T>
  123. inline bool is_nan_helper(T, const mars_boost::false_type&)
  124. {
  125.    return false;
  126. }
  127. #ifdef BOOST_MATH_USE_FLOAT128
  128. inline bool is_nan_helper(__float128 f, const mars_boost::true_type&) { return ::isnanq(f); }
  129. inline bool is_nan_helper(__float128 f, const mars_boost::false_type&) { return ::isnanq(f); }
  130. #endif
  131. }
  132.  
  133. namespace math{
  134.  
  135. namespace detail{
  136.  
  137. #ifdef BOOST_MATH_USE_STD_FPCLASSIFY
  138. template <class T>
  139. inline int fpclassify_imp BOOST_NO_MACRO_EXPAND(T t, const native_tag&)
  140. {
  141.    return (std::fpclassify)(t);
  142. }
  143. #endif
  144.  
  145. template <class T>
  146. inline int fpclassify_imp BOOST_NO_MACRO_EXPAND(T t, const generic_tag<true>&)
  147. {
  148.    BOOST_MATH_INSTRUMENT_VARIABLE(t);
  149.  
  150.    // whenever possible check for Nan's first:
  151. #if defined(BOOST_HAS_FPCLASSIFY)  && !defined(BOOST_MATH_DISABLE_STD_FPCLASSIFY)
  152.    if(::mars_boost::math_detail::is_nan_helper(t, ::mars_boost::is_floating_point<T>()))
  153.       return FP_NAN;
  154. #elif defined(isnan)
  155.    if(mars_boost::math_detail::is_nan_helper(t, ::mars_boost::is_floating_point<T>()))
  156.       return FP_NAN;
  157. #elif defined(_MSC_VER) || defined(__BORLANDC__)
  158.    if(::_isnan(mars_boost::math::tools::real_cast<double>(t)))
  159.       return FP_NAN;
  160. #endif
  161.    // std::fabs broken on a few systems especially for long long!!!!
  162.    T at = (t < T(0)) ? -t : t;
  163.  
  164.    // Use a process of exclusion to figure out
  165.    // what kind of type we have, this relies on
  166.    // IEEE conforming reals that will treat
  167.    // Nan's as unordered.  Some compilers
  168.    // don't do this once optimisations are
  169.    // turned on, hence the check for nan's above.
  170.    if(at <= (std::numeric_limits<T>::max)())
  171.    {
  172.       if(at >= (std::numeric_limits<T>::min)())
  173.          return FP_NORMAL;
  174.       return (at != 0) ? FP_SUBNORMAL : FP_ZERO;
  175.    }
  176.    else if(at > (std::numeric_limits<T>::max)())
  177.       return FP_INFINITE;
  178.    return FP_NAN;
  179. }
  180.  
  181. template <class T>
  182. inline int fpclassify_imp BOOST_NO_MACRO_EXPAND(T t, const generic_tag<false>&)
  183. {
  184. #ifdef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
  185.    if(std::numeric_limits<T>::is_specialized)
  186.       return fpclassify_imp(t, generic_tag<true>());
  187. #endif
  188.    //
  189.    // An unknown type with no numeric_limits support,
  190.    // so what are we supposed to do we do here?
  191.    //
  192.    BOOST_MATH_INSTRUMENT_VARIABLE(t);
  193.  
  194.    return t == 0 ? FP_ZERO : FP_NORMAL;
  195. }
  196.  
  197. template<class T>
  198. int fpclassify_imp BOOST_NO_MACRO_EXPAND(T x, ieee_copy_all_bits_tag)
  199. {
  200.    typedef BOOST_DEDUCED_TYPENAME fp_traits<T>::type traits;
  201.  
  202.    BOOST_MATH_INSTRUMENT_VARIABLE(x);
  203.  
  204.    BOOST_DEDUCED_TYPENAME traits::bits a;
  205.    traits::get_bits(x,a);
  206.    BOOST_MATH_INSTRUMENT_VARIABLE(a);
  207.    a &= traits::exponent | traits::flag | traits::significand;
  208.    BOOST_MATH_INSTRUMENT_VARIABLE((traits::exponent | traits::flag | traits::significand));
  209.    BOOST_MATH_INSTRUMENT_VARIABLE(a);
  210.  
  211.    if(a <= traits::significand) {
  212.       if(a == 0)
  213.          return FP_ZERO;
  214.       else
  215.          return FP_SUBNORMAL;
  216.    }
  217.  
  218.    if(a < traits::exponent) return FP_NORMAL;
  219.  
  220.    a &= traits::significand;
  221.    if(a == 0) return FP_INFINITE;
  222.  
  223.    return FP_NAN;
  224. }
  225.  
  226. template<class T>
  227. int fpclassify_imp BOOST_NO_MACRO_EXPAND(T x, ieee_copy_leading_bits_tag)
  228. {
  229.    typedef BOOST_DEDUCED_TYPENAME fp_traits<T>::type traits;
  230.  
  231.    BOOST_MATH_INSTRUMENT_VARIABLE(x);
  232.  
  233.    BOOST_DEDUCED_TYPENAME traits::bits a;
  234.    traits::get_bits(x,a);
  235.    a &= traits::exponent | traits::flag | traits::significand;
  236.  
  237.    if(a <= traits::significand) {
  238.       if(x == 0)
  239.          return FP_ZERO;
  240.       else
  241.          return FP_SUBNORMAL;
  242.    }
  243.  
  244.    if(a < traits::exponent) return FP_NORMAL;
  245.  
  246.    a &= traits::significand;
  247.    traits::set_bits(x,a);
  248.    if(x == 0) return FP_INFINITE;
  249.  
  250.    return FP_NAN;
  251. }
  252.  
  253. #if defined(BOOST_MATH_USE_STD_FPCLASSIFY) && (defined(BOOST_MATH_NO_NATIVE_LONG_DOUBLE_FP_CLASSIFY) || defined(BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS))
  254. inline int fpclassify_imp BOOST_NO_MACRO_EXPAND(long double t, const native_tag&)
  255. {
  256.    return mars_boost::math::detail::fpclassify_imp(t, generic_tag<true>());
  257. }
  258. #endif
  259.  
  260. }  // namespace detail
  261.  
  262. template <class T>
  263. inline int fpclassify BOOST_NO_MACRO_EXPAND(T t)
  264. {
  265.    typedef typename detail::fp_traits<T>::type traits;
  266.    typedef typename traits::method method;
  267.    typedef typename tools::promote_args_permissive<T>::type value_type;
  268. #ifdef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
  269.    if(std::numeric_limits<T>::is_specialized && detail::is_generic_tag_false(static_cast<method*>(0)))
  270.       return detail::fpclassify_imp(static_cast<value_type>(t), detail::generic_tag<true>());
  271.    return detail::fpclassify_imp(static_cast<value_type>(t), method());
  272. #else
  273.    return detail::fpclassify_imp(static_cast<value_type>(t), method());
  274. #endif
  275. }
  276.  
  277. #ifdef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
  278. template <>
  279. inline int fpclassify<long double> BOOST_NO_MACRO_EXPAND(long double t)
  280. {
  281.    typedef detail::fp_traits<long double>::type traits;
  282.    typedef traits::method method;
  283.    typedef long double value_type;
  284. #ifdef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
  285.    if(std::numeric_limits<long double>::is_specialized && detail::is_generic_tag_false(static_cast<method*>(0)))
  286.       return detail::fpclassify_imp(static_cast<value_type>(t), detail::generic_tag<true>());
  287.    return detail::fpclassify_imp(static_cast<value_type>(t), method());
  288. #else
  289.    return detail::fpclassify_imp(static_cast<value_type>(t), method());
  290. #endif
  291. }
  292. #endif
  293.  
  294. namespace detail {
  295.  
  296. #ifdef BOOST_MATH_USE_STD_FPCLASSIFY
  297.     template<class T>
  298.     inline bool isfinite_impl(T x, native_tag const&)
  299.     {
  300.         return (std::isfinite)(x);
  301.     }
  302. #endif
  303.  
  304.     template<class T>
  305.     inline bool isfinite_impl(T x, generic_tag<true> const&)
  306.     {
  307.         return x >= -(std::numeric_limits<T>::max)()
  308.             && x <= (std::numeric_limits<T>::max)();
  309.     }
  310.  
  311.     template<class T>
  312.     inline bool isfinite_impl(T x, generic_tag<false> const&)
  313.     {
  314. #ifdef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
  315.       if(std::numeric_limits<T>::is_specialized)
  316.          return isfinite_impl(x, generic_tag<true>());
  317. #endif
  318.        (void)x; // warning suppression.
  319.        return true;
  320.     }
  321.  
  322.     template<class T>
  323.     inline bool isfinite_impl(T x, ieee_tag const&)
  324.     {
  325.         typedef BOOST_DEDUCED_TYPENAME detail::fp_traits<T>::type traits;
  326.         BOOST_DEDUCED_TYPENAME traits::bits a;
  327.         traits::get_bits(x,a);
  328.         a &= traits::exponent;
  329.         return a != traits::exponent;
  330.     }
  331.  
  332. #if defined(BOOST_MATH_USE_STD_FPCLASSIFY) && defined(BOOST_MATH_NO_NATIVE_LONG_DOUBLE_FP_CLASSIFY)
  333. inline bool isfinite_impl BOOST_NO_MACRO_EXPAND(long double t, const native_tag&)
  334. {
  335.    return mars_boost::math::detail::isfinite_impl(t, generic_tag<true>());
  336. }
  337. #endif
  338.  
  339. }
  340.  
  341. template<class T>
  342. inline bool (isfinite)(T x)
  343. { //!< \brief return true if floating-point type t is finite.
  344.    typedef typename detail::fp_traits<T>::type traits;
  345.    typedef typename traits::method method;
  346.    // typedef typename mars_boost::is_floating_point<T>::type fp_tag;
  347.    typedef typename tools::promote_args_permissive<T>::type value_type;
  348.    return detail::isfinite_impl(static_cast<value_type>(x), method());
  349. }
  350.  
  351. #ifdef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
  352. template<>
  353. inline bool (isfinite)(long double x)
  354. { //!< \brief return true if floating-point type t is finite.
  355.    typedef detail::fp_traits<long double>::type traits;
  356.    typedef traits::method method;
  357.    //typedef mars_boost::is_floating_point<long double>::type fp_tag;
  358.    typedef long double value_type;
  359.    return detail::isfinite_impl(static_cast<value_type>(x), method());
  360. }
  361. #endif
  362.  
  363. //------------------------------------------------------------------------------
  364.  
  365. namespace detail {
  366.  
  367. #ifdef BOOST_MATH_USE_STD_FPCLASSIFY
  368.     template<class T>
  369.     inline bool isnormal_impl(T x, native_tag const&)
  370.     {
  371.         return (std::isnormal)(x);
  372.     }
  373. #endif
  374.  
  375.     template<class T>
  376.     inline bool isnormal_impl(T x, generic_tag<true> const&)
  377.     {
  378.         if(x < 0) x = -x;
  379.         return x >= (std::numeric_limits<T>::min)()
  380.             && x <= (std::numeric_limits<T>::max)();
  381.     }
  382.  
  383.     template<class T>
  384.     inline bool isnormal_impl(T x, generic_tag<false> const&)
  385.     {
  386. #ifdef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
  387.       if(std::numeric_limits<T>::is_specialized)
  388.          return isnormal_impl(x, generic_tag<true>());
  389. #endif
  390.        return !(x == 0);
  391.     }
  392.  
  393.     template<class T>
  394.     inline bool isnormal_impl(T x, ieee_tag const&)
  395.     {
  396.         typedef BOOST_DEDUCED_TYPENAME detail::fp_traits<T>::type traits;
  397.         BOOST_DEDUCED_TYPENAME traits::bits a;
  398.         traits::get_bits(x,a);
  399.         a &= traits::exponent | traits::flag;
  400.         return (a != 0) && (a < traits::exponent);
  401.     }
  402.  
  403. #if defined(BOOST_MATH_USE_STD_FPCLASSIFY) && defined(BOOST_MATH_NO_NATIVE_LONG_DOUBLE_FP_CLASSIFY)
  404. inline bool isnormal_impl BOOST_NO_MACRO_EXPAND(long double t, const native_tag&)
  405. {
  406.    return mars_boost::math::detail::isnormal_impl(t, generic_tag<true>());
  407. }
  408. #endif
  409.  
  410. }
  411.  
  412. template<class T>
  413. inline bool (isnormal)(T x)
  414. {
  415.    typedef typename detail::fp_traits<T>::type traits;
  416.    typedef typename traits::method method;
  417.    //typedef typename mars_boost::is_floating_point<T>::type fp_tag;
  418.    typedef typename tools::promote_args_permissive<T>::type value_type;
  419.    return detail::isnormal_impl(static_cast<value_type>(x), method());
  420. }
  421.  
  422. #ifdef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
  423. template<>
  424. inline bool (isnormal)(long double x)
  425. {
  426.    typedef detail::fp_traits<long double>::type traits;
  427.    typedef traits::method method;
  428.    //typedef mars_boost::is_floating_point<long double>::type fp_tag;
  429.    typedef long double value_type;
  430.    return detail::isnormal_impl(static_cast<value_type>(x), method());
  431. }
  432. #endif
  433.  
  434. //------------------------------------------------------------------------------
  435.  
  436. namespace detail {
  437.  
  438. #ifdef BOOST_MATH_USE_STD_FPCLASSIFY
  439.     template<class T>
  440.     inline bool isinf_impl(T x, native_tag const&)
  441.     {
  442.         return (std::isinf)(x);
  443.     }
  444. #endif
  445.  
  446.     template<class T>
  447.     inline bool isinf_impl(T x, generic_tag<true> const&)
  448.     {
  449.         (void)x; // in case the compiler thinks that x is unused because std::numeric_limits<T>::has_infinity is false
  450.         return std::numeric_limits<T>::has_infinity
  451.             && ( x == std::numeric_limits<T>::infinity()
  452.                  || x == -std::numeric_limits<T>::infinity());
  453.     }
  454.  
  455.     template<class T>
  456.     inline bool isinf_impl(T x, generic_tag<false> const&)
  457.     {
  458. #ifdef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
  459.       if(std::numeric_limits<T>::is_specialized)
  460.          return isinf_impl(x, generic_tag<true>());
  461. #endif
  462.         (void)x; // warning suppression.
  463.         return false;
  464.     }
  465.  
  466.     template<class T>
  467.     inline bool isinf_impl(T x, ieee_copy_all_bits_tag const&)
  468.     {
  469.         typedef BOOST_DEDUCED_TYPENAME fp_traits<T>::type traits;
  470.  
  471.         BOOST_DEDUCED_TYPENAME traits::bits a;
  472.         traits::get_bits(x,a);
  473.         a &= traits::exponent | traits::significand;
  474.         return a == traits::exponent;
  475.     }
  476.  
  477.     template<class T>
  478.     inline bool isinf_impl(T x, ieee_copy_leading_bits_tag const&)
  479.     {
  480.         typedef BOOST_DEDUCED_TYPENAME fp_traits<T>::type traits;
  481.  
  482.         BOOST_DEDUCED_TYPENAME traits::bits a;
  483.         traits::get_bits(x,a);
  484.         a &= traits::exponent | traits::significand;
  485.         if(a != traits::exponent)
  486.             return false;
  487.  
  488.         traits::set_bits(x,0);
  489.         return x == 0;
  490.     }
  491.  
  492. #if defined(BOOST_MATH_USE_STD_FPCLASSIFY) && defined(BOOST_MATH_NO_NATIVE_LONG_DOUBLE_FP_CLASSIFY)
  493. inline bool isinf_impl BOOST_NO_MACRO_EXPAND(long double t, const native_tag&)
  494. {
  495.    return mars_boost::math::detail::isinf_impl(t, generic_tag<true>());
  496. }
  497. #endif
  498.  
  499. }   // namespace detail
  500.  
  501. template<class T>
  502. inline bool (isinf)(T x)
  503. {
  504.    typedef typename detail::fp_traits<T>::type traits;
  505.    typedef typename traits::method method;
  506.    // typedef typename mars_boost::is_floating_point<T>::type fp_tag;
  507.    typedef typename tools::promote_args_permissive<T>::type value_type;
  508.    return detail::isinf_impl(static_cast<value_type>(x), method());
  509. }
  510.  
  511. #ifdef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
  512. template<>
  513. inline bool (isinf)(long double x)
  514. {
  515.    typedef detail::fp_traits<long double>::type traits;
  516.    typedef traits::method method;
  517.    //typedef mars_boost::is_floating_point<long double>::type fp_tag;
  518.    typedef long double value_type;
  519.    return detail::isinf_impl(static_cast<value_type>(x), method());
  520. }
  521. #endif
  522. #ifdef BOOST_MATH_USE_FLOAT128
  523. template<>
  524. inline bool (isinf)(__float128 x)
  525. {
  526.    return ::isinfq(x);
  527. }
  528. #endif
  529.  
  530. //------------------------------------------------------------------------------
  531.  
  532. namespace detail {
  533.  
  534. #ifdef BOOST_MATH_USE_STD_FPCLASSIFY
  535.     template<class T>
  536.     inline bool isnan_impl(T x, native_tag const&)
  537.     {
  538.         return (std::isnan)(x);
  539.     }
  540. #endif
  541.  
  542.     template<class T>
  543.     inline bool isnan_impl(T x, generic_tag<true> const&)
  544.     {
  545.         return std::numeric_limits<T>::has_infinity
  546.             ? !(x <= std::numeric_limits<T>::infinity())
  547.             : x != x;
  548.     }
  549.  
  550.     template<class T>
  551.     inline bool isnan_impl(T x, generic_tag<false> const&)
  552.     {
  553. #ifdef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
  554.       if(std::numeric_limits<T>::is_specialized)
  555.          return isnan_impl(x, generic_tag<true>());
  556. #endif
  557.         (void)x; // warning suppression
  558.         return false;
  559.     }
  560.  
  561.     template<class T>
  562.     inline bool isnan_impl(T x, ieee_copy_all_bits_tag const&)
  563.     {
  564.         typedef BOOST_DEDUCED_TYPENAME fp_traits<T>::type traits;
  565.  
  566.         BOOST_DEDUCED_TYPENAME traits::bits a;
  567.         traits::get_bits(x,a);
  568.         a &= traits::exponent | traits::significand;
  569.         return a > traits::exponent;
  570.     }
  571.  
  572.     template<class T>
  573.     inline bool isnan_impl(T x, ieee_copy_leading_bits_tag const&)
  574.     {
  575.         typedef BOOST_DEDUCED_TYPENAME fp_traits<T>::type traits;
  576.  
  577.         BOOST_DEDUCED_TYPENAME traits::bits a;
  578.         traits::get_bits(x,a);
  579.  
  580.         a &= traits::exponent | traits::significand;
  581.         if(a < traits::exponent)
  582.             return false;
  583.  
  584.         a &= traits::significand;
  585.         traits::set_bits(x,a);
  586.         return x != 0;
  587.     }
  588.  
  589. }   // namespace detail
  590.  
  591. template<class T>
  592. inline bool (isnan)(T x)
  593. { //!< \brief return true if floating-point type t is NaN (Not A Number).
  594.    typedef typename detail::fp_traits<T>::type traits;
  595.    typedef typename traits::method method;
  596.    // typedef typename mars_boost::is_floating_point<T>::type fp_tag;
  597.    return detail::isnan_impl(x, method());
  598. }
  599.  
  600. #ifdef isnan
  601. template <> inline bool isnan BOOST_NO_MACRO_EXPAND<float>(float t){ return ::mars_boost::math_detail::is_nan_helper(t, mars_boost::true_type()); }
  602. template <> inline bool isnan BOOST_NO_MACRO_EXPAND<double>(double t){ return ::mars_boost::math_detail::is_nan_helper(t, mars_boost::true_type()); }
  603. template <> inline bool isnan BOOST_NO_MACRO_EXPAND<long double>(long double t){ return ::mars_boost::math_detail::is_nan_helper(t, mars_boost::true_type()); }
  604. #elif defined(BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS)
  605. template<>
  606. inline bool (isnan)(long double x)
  607. { //!< \brief return true if floating-point type t is NaN (Not A Number).
  608.    typedef detail::fp_traits<long double>::type traits;
  609.    typedef traits::method method;
  610.    //typedef mars_boost::is_floating_point<long double>::type fp_tag;
  611.    return detail::isnan_impl(x, method());
  612. }
  613. #endif
  614. #ifdef BOOST_MATH_USE_FLOAT128
  615. template<>
  616. inline bool (isnan)(__float128 x)
  617. {
  618.    return ::isnanq(x);
  619. }
  620. #endif
  621.  
  622. } // namespace math
  623. } // namespace mars_boost
  624.  
  625. #endif // BOOST_MATH_FPCLASSIFY_HPP
  626.  
  627.  
downloadfpclassify.hpp Source code - Download mars Source code
Related Source Codes/Software:
Hero - Elegant transition library for iOS & tvOS 2017-06-09
deep-photo-styletransfer - Code and data for paper "Deep Photo Style Transfer... 2017-06-09
mastodon - A GNU Social-compatible microblogging server ... 2017-06-09
plyr - A simple HTML5, YouTube and Vimeo player ... 2017-06-08
prepack - Prepack is a partial evaluator for JavaScript. Pre... 2017-06-08
Public-APIs - 2017-06-09
lottie-ios - An iOS library to natively render After Effects ve... 2017-06-09
Awesome-Hacking - A collection of various awesome lists for hackers,... 2017-06-09
algorithms - Minimal examples of data structures and algorithms... 2017-06-10
lectures - Oxford Deep NLP 2017 course 2017-06-10
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top