annotate DEPENDENCIES/generic/include/boost/units/detail/cmath_impl.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 // Boost.Units - A C++ library for zero-overhead dimensional analysis and
Chris@16 2 // unit/quantity manipulation and conversion
Chris@16 3 //
Chris@16 4 // Copyright (C) 2003-2008 Matthias Christian Schabel
Chris@16 5 // Copyright (C) 2008 Steven Watanabe
Chris@16 6 //
Chris@16 7 // Distributed under the Boost Software License, Version 1.0. (See
Chris@16 8 // accompanying file LICENSE_1_0.txt or copy at
Chris@16 9 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 10
Chris@16 11 #ifndef BOOST_UNITS_CMATH_IMPL_HPP
Chris@16 12 #define BOOST_UNITS_CMATH_IMPL_HPP
Chris@16 13
Chris@16 14 #include <boost/config.hpp>
Chris@16 15 #include <boost/math/special_functions/fpclassify.hpp>
Chris@16 16
Chris@16 17 namespace boost {
Chris@16 18 namespace units {
Chris@16 19 namespace detail {
Chris@16 20
Chris@16 21 template<class Y>
Chris@16 22 inline bool isgreater BOOST_PREVENT_MACRO_SUBSTITUTION(const Y& v1,const Y& v2)
Chris@16 23 {
Chris@16 24 if((boost::math::isnan)(v1) || (boost::math::isnan)(v2)) return false;
Chris@16 25 else return v1 > v2;
Chris@16 26 }
Chris@16 27
Chris@16 28 template<class Y>
Chris@16 29 inline bool isgreaterequal BOOST_PREVENT_MACRO_SUBSTITUTION(const Y& v1,const Y& v2)
Chris@16 30 {
Chris@16 31 if((boost::math::isnan)(v1) || (boost::math::isnan)(v2)) return false;
Chris@16 32 else return v1 >= v2;
Chris@16 33 }
Chris@16 34
Chris@16 35 template<class Y>
Chris@16 36 inline bool isless BOOST_PREVENT_MACRO_SUBSTITUTION(const Y& v1,const Y& v2)
Chris@16 37 {
Chris@16 38 if((boost::math::isnan)(v1) || (boost::math::isnan)(v2)) return false;
Chris@16 39 else return v1 < v2;
Chris@16 40 }
Chris@16 41
Chris@16 42 template<class Y>
Chris@16 43 inline bool islessequal BOOST_PREVENT_MACRO_SUBSTITUTION(const Y& v1,const Y& v2)
Chris@16 44 {
Chris@16 45 if((boost::math::isnan)(v1) || (boost::math::isnan)(v2)) return false;
Chris@16 46 else return v1 <= v2;
Chris@16 47 }
Chris@16 48
Chris@16 49 template<class Y>
Chris@16 50 inline bool islessgreater BOOST_PREVENT_MACRO_SUBSTITUTION(const Y& v1,const Y& v2)
Chris@16 51 {
Chris@16 52 if((boost::math::isnan)(v1) || (boost::math::isnan)(v2)) return false;
Chris@16 53 else return v1 < v2 || v1 > v2;
Chris@16 54 }
Chris@16 55
Chris@16 56 template<class Y>
Chris@16 57 inline bool isunordered BOOST_PREVENT_MACRO_SUBSTITUTION(const Y& v1,const Y& v2)
Chris@16 58 {
Chris@16 59 return (boost::math::isnan)(v1) || (boost::math::isnan)(v2);
Chris@16 60 }
Chris@16 61
Chris@16 62 template<class Y>
Chris@16 63 inline Y fdim BOOST_PREVENT_MACRO_SUBSTITUTION(const Y& v1,const Y& v2)
Chris@16 64 {
Chris@16 65 if((boost::math::isnan)(v1)) return v1;
Chris@16 66 else if((boost::math::isnan)(v2)) return v2;
Chris@16 67 else if(v1 > v2) return(v1 - v2);
Chris@16 68 else return(Y(0));
Chris@16 69 }
Chris@16 70
Chris@16 71 #if 0
Chris@16 72
Chris@16 73 template<class T>
Chris@16 74 struct fma_issue_warning {
Chris@16 75 enum { value = false };
Chris@16 76 };
Chris@16 77
Chris@16 78 template<class Y>
Chris@16 79 inline Y fma(const Y& v1,const Y& v2,const Y& v3)
Chris@16 80 {
Chris@16 81 //this implementation does *not* meet the
Chris@16 82 //requirement of infinite intermediate precision
Chris@16 83 BOOST_STATIC_WARNING((fma_issue_warning<Y>::value));
Chris@16 84
Chris@16 85 return v1 * v2 + v3;
Chris@16 86 }
Chris@16 87
Chris@16 88 #endif
Chris@16 89
Chris@16 90 template<class Y>
Chris@16 91 inline Y fmax BOOST_PREVENT_MACRO_SUBSTITUTION(const Y& v1,const Y& v2)
Chris@16 92 {
Chris@16 93 if((boost::math::isnan)(v1)) return(v2);
Chris@16 94 else if((boost::math::isnan)(v2)) return(v1);
Chris@16 95 else if(v1 > v2) return(v1);
Chris@16 96 else return(v2);
Chris@16 97 }
Chris@16 98
Chris@16 99 template<class Y>
Chris@16 100 inline Y fmin BOOST_PREVENT_MACRO_SUBSTITUTION(const Y& v1,const Y& v2)
Chris@16 101 {
Chris@16 102 if((boost::math::isnan)(v1)) return(v2);
Chris@16 103 else if((boost::math::isnan)(v2)) return(v1);
Chris@16 104 else if(v1 < v2) return(v1);
Chris@16 105 else return(v2);
Chris@16 106 }
Chris@16 107
Chris@16 108 //template<class Y>
Chris@16 109 //inline long long llrint(const Y& val)
Chris@16 110 //{
Chris@16 111 // return static_cast<long long>(rint(val));
Chris@16 112 //}
Chris@16 113 //
Chris@16 114 //template<class Y>
Chris@16 115 //inline long long llround(const Y& val)
Chris@16 116 //{
Chris@16 117 // return static_cast<long long>(round(val));
Chris@16 118 //}
Chris@16 119
Chris@16 120 #if 0
Chris@16 121
Chris@16 122 template<class Y>
Chris@16 123 inline Y nearbyint(const Y& val)
Chris@16 124 {
Chris@16 125 //this is not really correct.
Chris@16 126 //the result should be according to the
Chris@16 127 //current rounding mode.
Chris@16 128 using boost::math::round;
Chris@16 129 return round(val);
Chris@16 130 }
Chris@16 131
Chris@16 132 template<class Y>
Chris@16 133 inline Y rint(const Y& val)
Chris@16 134 {
Chris@16 135 //I don't feel like trying to figure out
Chris@16 136 //how to raise a floating pointer exception
Chris@16 137 return nearbyint(val);
Chris@16 138 }
Chris@16 139
Chris@16 140 #endif
Chris@16 141
Chris@16 142 template<class Y>
Chris@16 143 inline Y trunc BOOST_PREVENT_MACRO_SUBSTITUTION(const Y& val)
Chris@16 144 {
Chris@16 145 if(val > 0) return std::floor(val);
Chris@16 146 else if(val < 0) return std::ceil(val);
Chris@16 147 else return val;
Chris@16 148 }
Chris@16 149
Chris@16 150 }
Chris@16 151 }
Chris@16 152 }
Chris@16 153
Chris@16 154 #endif // BOOST_UNITS_CMATH_IMPL_HPP