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