123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154 |
- #ifndef BOOST_UNITS_CMATH_IMPL_HPP
- #define BOOST_UNITS_CMATH_IMPL_HPP
- #include <boost/config.hpp>
- #include <boost/math/special_functions/fpclassify.hpp>
- namespace boost {
- namespace units {
- namespace detail {
- template<class Y>
- inline bool isgreater BOOST_PREVENT_MACRO_SUBSTITUTION(const Y& v1,const Y& v2)
- {
- if((boost::math::isnan)(v1) || (boost::math::isnan)(v2)) return false;
- else return v1 > v2;
- }
- template<class Y>
- inline bool isgreaterequal BOOST_PREVENT_MACRO_SUBSTITUTION(const Y& v1,const Y& v2)
- {
- if((boost::math::isnan)(v1) || (boost::math::isnan)(v2)) return false;
- else return v1 >= v2;
- }
- template<class Y>
- inline bool isless BOOST_PREVENT_MACRO_SUBSTITUTION(const Y& v1,const Y& v2)
- {
- if((boost::math::isnan)(v1) || (boost::math::isnan)(v2)) return false;
- else return v1 < v2;
- }
- template<class Y>
- inline bool islessequal BOOST_PREVENT_MACRO_SUBSTITUTION(const Y& v1,const Y& v2)
- {
- if((boost::math::isnan)(v1) || (boost::math::isnan)(v2)) return false;
- else return v1 <= v2;
- }
- template<class Y>
- inline bool islessgreater BOOST_PREVENT_MACRO_SUBSTITUTION(const Y& v1,const Y& v2)
- {
- if((boost::math::isnan)(v1) || (boost::math::isnan)(v2)) return false;
- else return v1 < v2 || v1 > v2;
- }
- template<class Y>
- inline bool isunordered BOOST_PREVENT_MACRO_SUBSTITUTION(const Y& v1,const Y& v2)
- {
- return (boost::math::isnan)(v1) || (boost::math::isnan)(v2);
- }
- template<class Y>
- inline Y fdim BOOST_PREVENT_MACRO_SUBSTITUTION(const Y& v1,const Y& v2)
- {
- if((boost::math::isnan)(v1)) return v1;
- else if((boost::math::isnan)(v2)) return v2;
- else if(v1 > v2) return(v1 - v2);
- else return(Y(0));
- }
- #if 0
- template<class T>
- struct fma_issue_warning {
- enum { value = false };
- };
- template<class Y>
- inline Y fma(const Y& v1,const Y& v2,const Y& v3)
- {
-
-
- BOOST_STATIC_WARNING((fma_issue_warning<Y>::value));
- return v1 * v2 + v3;
- }
- #endif
- template<class Y>
- inline Y fmax BOOST_PREVENT_MACRO_SUBSTITUTION(const Y& v1,const Y& v2)
- {
- if((boost::math::isnan)(v1)) return(v2);
- else if((boost::math::isnan)(v2)) return(v1);
- else if(v1 > v2) return(v1);
- else return(v2);
- }
- template<class Y>
- inline Y fmin BOOST_PREVENT_MACRO_SUBSTITUTION(const Y& v1,const Y& v2)
- {
- if((boost::math::isnan)(v1)) return(v2);
- else if((boost::math::isnan)(v2)) return(v1);
- else if(v1 < v2) return(v1);
- else return(v2);
- }
- #if 0
- template<class Y>
- inline Y nearbyint(const Y& val)
- {
-
-
-
- using boost::math::round;
- return round(val);
- }
- template<class Y>
- inline Y rint(const Y& val)
- {
-
-
- return nearbyint(val);
- }
- #endif
- template<class Y>
- inline Y trunc BOOST_PREVENT_MACRO_SUBSTITUTION(const Y& val)
- {
- if(val > 0) return std::floor(val);
- else if(val < 0) return std::ceil(val);
- else return val;
- }
- }
- }
- }
- #endif
|