File indexing completed on 2025-01-30 09:45:16
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 #ifndef BOOST_MATH_REAL_CONCEPT_HPP
0024 #define BOOST_MATH_REAL_CONCEPT_HPP
0025
0026 #include <boost/math/special_functions/round.hpp>
0027 #include <boost/math/special_functions/trunc.hpp>
0028 #include <boost/math/special_functions/modf.hpp>
0029 #include <boost/math/tools/big_constant.hpp>
0030 #include <boost/math/tools/precision.hpp>
0031 #include <boost/math/tools/config.hpp>
0032 #include <boost/math/policies/policy.hpp>
0033 #include <boost/math/special_functions/asinh.hpp>
0034 #include <boost/math/special_functions/atanh.hpp>
0035 #if defined(__SGI_STL_PORT)
0036 # include <boost/math/tools/real_cast.hpp>
0037 #endif
0038 #include <ostream>
0039 #include <istream>
0040 #include <limits>
0041 #include <cmath>
0042 #include <cstdint>
0043
0044 #if defined(__SGI_STL_PORT) || defined(_RWSTD_VER) || defined(__LIBCOMO__)
0045 # include <cstdio>
0046 #endif
0047
0048 #if defined __has_include
0049 # if __cplusplus > 202002L || _MSVC_LANG > 202002L
0050 # if __has_include (<stdfloat>)
0051 # include <stdfloat>
0052 # endif
0053 # endif
0054 #endif
0055
0056 namespace boost{ namespace math{
0057
0058 namespace concepts
0059 {
0060
0061 #ifdef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
0062 typedef double real_concept_base_type;
0063 #else
0064 typedef long double real_concept_base_type;
0065 #endif
0066
0067 class real_concept
0068 {
0069 public:
0070
0071 real_concept() : m_value(0){}
0072 real_concept(char c) : m_value(c){}
0073 real_concept(wchar_t c) : m_value(c){}
0074 real_concept(unsigned char c) : m_value(c){}
0075 real_concept(signed char c) : m_value(c){}
0076 real_concept(unsigned short c) : m_value(c){}
0077 real_concept(short c) : m_value(c){}
0078 real_concept(unsigned int c) : m_value(c){}
0079 real_concept(int c) : m_value(c){}
0080 real_concept(unsigned long c) : m_value(c){}
0081 real_concept(long c) : m_value(c){}
0082 real_concept(unsigned long long c) : m_value(static_cast<real_concept_base_type>(c)){}
0083 real_concept(long long c) : m_value(static_cast<real_concept_base_type>(c)){}
0084 real_concept(float c) : m_value(c){}
0085 real_concept(double c) : m_value(c){}
0086 real_concept(long double c) : m_value(c){}
0087 #ifdef BOOST_MATH_USE_FLOAT128
0088 real_concept(BOOST_MATH_FLOAT128_TYPE c) : m_value(c){}
0089 #endif
0090 #ifdef __STDCPP_FLOAT32_T__
0091 real_concept(std::float32_t c) : m_value(static_cast<real_concept_base_type>(c)){}
0092 #endif
0093 #ifdef __STDCPP_FLOAT64_T__
0094 real_concept(std::float64_t c) : m_value(static_cast<real_concept_base_type>(c)){}
0095 #endif
0096
0097
0098 real_concept& operator=(char c) { m_value = c; return *this; }
0099 real_concept& operator=(unsigned char c) { m_value = c; return *this; }
0100 real_concept& operator=(signed char c) { m_value = c; return *this; }
0101 real_concept& operator=(wchar_t c) { m_value = c; return *this; }
0102 real_concept& operator=(short c) { m_value = c; return *this; }
0103 real_concept& operator=(unsigned short c) { m_value = c; return *this; }
0104 real_concept& operator=(int c) { m_value = c; return *this; }
0105 real_concept& operator=(unsigned int c) { m_value = c; return *this; }
0106 real_concept& operator=(long c) { m_value = c; return *this; }
0107 real_concept& operator=(unsigned long c) { m_value = c; return *this; }
0108 real_concept& operator=(long long c) { m_value = static_cast<real_concept_base_type>(c); return *this; }
0109 real_concept& operator=(unsigned long long c) { m_value = static_cast<real_concept_base_type>(c); return *this; }
0110 real_concept& operator=(float c) { m_value = c; return *this; }
0111 real_concept& operator=(double c) { m_value = c; return *this; }
0112 real_concept& operator=(long double c) { m_value = c; return *this; }
0113 #ifdef __STDCPP_FLOAT32_T__
0114 real_concept& operator=(std::float32_t c) { m_value = c; return *this; }
0115 #endif
0116 #ifdef __STDCPP_FLOAT64_T__
0117 real_concept& operator=(std::float64_t c) { m_value = c; return *this; }
0118 #endif
0119
0120
0121 real_concept_base_type value()const{ return m_value; }
0122
0123
0124 real_concept& operator+=(const real_concept& other)
0125 { m_value += other.value(); return *this; }
0126 real_concept& operator-=(const real_concept& other)
0127 { m_value -= other.value(); return *this; }
0128 real_concept& operator*=(const real_concept& other)
0129 { m_value *= other.value(); return *this; }
0130 real_concept& operator/=(const real_concept& other)
0131 { m_value /= other.value(); return *this; }
0132 real_concept operator-()const
0133 { return -m_value; }
0134 real_concept const& operator+()const
0135 { return *this; }
0136 real_concept& operator++()
0137 { ++m_value; return *this; }
0138 real_concept& operator--()
0139 { --m_value; return *this; }
0140
0141 private:
0142 real_concept_base_type m_value;
0143 };
0144
0145
0146 inline real_concept operator+(const real_concept& a, const real_concept& b)
0147 {
0148 real_concept result(a);
0149 result += b;
0150 return result;
0151 }
0152 inline real_concept operator-(const real_concept& a, const real_concept& b)
0153 {
0154 real_concept result(a);
0155 result -= b;
0156 return result;
0157 }
0158 inline real_concept operator*(const real_concept& a, const real_concept& b)
0159 {
0160 real_concept result(a);
0161 result *= b;
0162 return result;
0163 }
0164 inline real_concept operator/(const real_concept& a, const real_concept& b)
0165 {
0166 real_concept result(a);
0167 result /= b;
0168 return result;
0169 }
0170
0171
0172 inline bool operator == (const real_concept& a, const real_concept& b)
0173 { return a.value() == b.value(); }
0174 inline bool operator != (const real_concept& a, const real_concept& b)
0175 { return a.value() != b.value();}
0176 inline bool operator < (const real_concept& a, const real_concept& b)
0177 { return a.value() < b.value(); }
0178 inline bool operator <= (const real_concept& a, const real_concept& b)
0179 { return a.value() <= b.value(); }
0180 inline bool operator > (const real_concept& a, const real_concept& b)
0181 { return a.value() > b.value(); }
0182 inline bool operator >= (const real_concept& a, const real_concept& b)
0183 { return a.value() >= b.value(); }
0184
0185
0186 inline real_concept acos(real_concept a)
0187 { return std::acos(a.value()); }
0188 inline real_concept cos(real_concept a)
0189 { return std::cos(a.value()); }
0190 inline real_concept asin(real_concept a)
0191 { return std::asin(a.value()); }
0192 inline real_concept atan(real_concept a)
0193 { return std::atan(a.value()); }
0194 inline real_concept atan2(real_concept a, real_concept b)
0195 { return std::atan2(a.value(), b.value()); }
0196 inline real_concept ceil(real_concept a)
0197 { return std::ceil(a.value()); }
0198 #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
0199
0200
0201 #ifdef _WIN32_WCE
0202
0203
0204
0205 inline long double call_fmodl(long double a, long double b)
0206 { return fmodl(a, b); }
0207 inline real_concept fmod(real_concept a, real_concept b)
0208 { return call_fmodl(a.value(), b.value()); }
0209 #else
0210 inline real_concept fmod(real_concept a, real_concept b)
0211 { return fmodl(a.value(), b.value()); }
0212 #endif
0213 #endif
0214 inline real_concept cosh(real_concept a)
0215 { return std::cosh(a.value()); }
0216 inline real_concept exp(real_concept a)
0217 { return std::exp(a.value()); }
0218 inline real_concept fabs(real_concept a)
0219 { return std::fabs(a.value()); }
0220 inline real_concept abs(real_concept a)
0221 { return std::abs(a.value()); }
0222 inline real_concept floor(real_concept a)
0223 { return std::floor(a.value()); }
0224 inline real_concept modf(real_concept a, real_concept* ipart)
0225 {
0226 #ifdef __MINGW32__
0227 real_concept_base_type ip;
0228 real_concept_base_type result = boost::math::modf(a.value(), &ip);
0229 *ipart = ip;
0230 return result;
0231 #else
0232 real_concept_base_type ip;
0233 real_concept_base_type result = std::modf(a.value(), &ip);
0234 *ipart = ip;
0235 return result;
0236 #endif
0237 }
0238 inline real_concept frexp(real_concept a, int* expon)
0239 { return std::frexp(a.value(), expon); }
0240 inline real_concept ldexp(real_concept a, int expon)
0241 { return std::ldexp(a.value(), expon); }
0242 inline real_concept log(real_concept a)
0243 { return std::log(a.value()); }
0244 inline real_concept log10(real_concept a)
0245 { return std::log10(a.value()); }
0246 inline real_concept tan(real_concept a)
0247 { return std::tan(a.value()); }
0248 inline real_concept pow(real_concept a, real_concept b)
0249 { return std::pow(a.value(), b.value()); }
0250 #if !defined(__SUNPRO_CC)
0251 inline real_concept pow(real_concept a, int b)
0252 { return std::pow(a.value(), b); }
0253 #else
0254 inline real_concept pow(real_concept a, int b)
0255 { return std::pow(a.value(), static_cast<real_concept_base_type>(b)); }
0256 #endif
0257 inline real_concept sin(real_concept a)
0258 { return std::sin(a.value()); }
0259 inline real_concept sinh(real_concept a)
0260 { return std::sinh(a.value()); }
0261 inline real_concept sqrt(real_concept a)
0262 { return std::sqrt(a.value()); }
0263 inline real_concept tanh(real_concept a)
0264 { return std::tanh(a.value()); }
0265
0266
0267
0268
0269
0270
0271 inline boost::math::concepts::real_concept asinh(boost::math::concepts::real_concept a)
0272 {
0273 return boost::math::asinh(a.value(), boost::math::policies::make_policy(boost::math::policies::overflow_error<boost::math::policies::ignore_error>()));
0274 }
0275 inline boost::math::concepts::real_concept acosh(boost::math::concepts::real_concept a)
0276 {
0277 return boost::math::acosh(a.value(), boost::math::policies::make_policy(boost::math::policies::overflow_error<boost::math::policies::ignore_error>()));
0278 }
0279 inline boost::math::concepts::real_concept atanh(boost::math::concepts::real_concept a)
0280 {
0281 return boost::math::atanh(a.value(), boost::math::policies::make_policy(boost::math::policies::overflow_error<boost::math::policies::ignore_error>()));
0282 }
0283
0284
0285
0286
0287 template <class Policy>
0288 inline int iround(const concepts::real_concept& v, const Policy& pol)
0289 { return boost::math::iround(v.value(), pol); }
0290 inline int iround(const concepts::real_concept& v)
0291 { return boost::math::iround(v.value(), policies::policy<>()); }
0292 template <class Policy>
0293 inline long lround(const concepts::real_concept& v, const Policy& pol)
0294 { return boost::math::lround(v.value(), pol); }
0295 inline long lround(const concepts::real_concept& v)
0296 { return boost::math::lround(v.value(), policies::policy<>()); }
0297
0298 template <class Policy>
0299 inline long long llround(const concepts::real_concept& v, const Policy& pol)
0300 { return boost::math::llround(v.value(), pol); }
0301 inline long long llround(const concepts::real_concept& v)
0302 { return boost::math::llround(v.value(), policies::policy<>()); }
0303
0304 template <class Policy>
0305 inline int itrunc(const concepts::real_concept& v, const Policy& pol)
0306 { return boost::math::itrunc(v.value(), pol); }
0307 inline int itrunc(const concepts::real_concept& v)
0308 { return boost::math::itrunc(v.value(), policies::policy<>()); }
0309 template <class Policy>
0310 inline long ltrunc(const concepts::real_concept& v, const Policy& pol)
0311 { return boost::math::ltrunc(v.value(), pol); }
0312 inline long ltrunc(const concepts::real_concept& v)
0313 { return boost::math::ltrunc(v.value(), policies::policy<>()); }
0314
0315 template <class Policy>
0316 inline long long lltrunc(const concepts::real_concept& v, const Policy& pol)
0317 { return boost::math::lltrunc(v.value(), pol); }
0318 inline long long lltrunc(const concepts::real_concept& v)
0319 { return boost::math::lltrunc(v.value(), policies::policy<>()); }
0320
0321
0322 template <class charT, class traits>
0323 inline std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& os, const real_concept& a)
0324 {
0325 return os << a.value();
0326 }
0327 template <class charT, class traits>
0328 inline std::basic_istream<charT, traits>& operator>>(std::basic_istream<charT, traits>& is, real_concept& a)
0329 {
0330 real_concept_base_type v;
0331 is >> v;
0332 a = v;
0333 return is;
0334 }
0335
0336 }
0337
0338 namespace tools
0339 {
0340
0341 template <>
0342 inline concepts::real_concept make_big_value<concepts::real_concept>(boost::math::tools::largest_float val, const char* , std::false_type const&, std::false_type const&)
0343 {
0344 return val;
0345 }
0346
0347 template <>
0348 inline concepts::real_concept max_value<concepts::real_concept>(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::real_concept))
0349 {
0350 return max_value<concepts::real_concept_base_type>();
0351 }
0352
0353 template <>
0354 inline concepts::real_concept min_value<concepts::real_concept>(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::real_concept))
0355 {
0356 return min_value<concepts::real_concept_base_type>();
0357 }
0358
0359 template <>
0360 inline concepts::real_concept log_max_value<concepts::real_concept>(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::real_concept))
0361 {
0362 return log_max_value<concepts::real_concept_base_type>();
0363 }
0364
0365 template <>
0366 inline concepts::real_concept log_min_value<concepts::real_concept>(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::real_concept))
0367 {
0368 return log_min_value<concepts::real_concept_base_type>();
0369 }
0370
0371 template <>
0372 inline concepts::real_concept epsilon<concepts::real_concept>(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::real_concept))
0373 {
0374 #ifdef __SUNPRO_CC
0375 return std::numeric_limits<concepts::real_concept_base_type>::epsilon();
0376 #else
0377 return tools::epsilon<concepts::real_concept_base_type>();
0378 #endif
0379 }
0380
0381 template <>
0382 inline constexpr int digits<concepts::real_concept>(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::real_concept)) noexcept
0383 {
0384
0385
0386 return tools::digits<concepts::real_concept_base_type>();
0387
0388
0389
0390
0391
0392 }
0393
0394 }
0395 }
0396 }
0397
0398 #endif
0399
0400