File indexing completed on 2025-01-30 09:49:07
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_NUMERIC_INTERVAL_CONSTANTS_HPP
0011 #define BOOST_NUMERIC_INTERVAL_CONSTANTS_HPP
0012
0013 namespace boost {
0014 namespace numeric {
0015 namespace interval_lib {
0016 namespace constants {
0017
0018
0019
0020
0021
0022 static const float pi_f_l = 13176794.0f/(1<<22);
0023 static const float pi_f_u = 13176795.0f/(1<<22);
0024 static const double pi_d_l = (3373259426.0 + 273688.0 / (1<<21)) / (1<<30);
0025 static const double pi_d_u = (3373259426.0 + 273689.0 / (1<<21)) / (1<<30);
0026
0027 template<class T> inline T pi_lower() { return 3; }
0028 template<class T> inline T pi_upper() { return 4; }
0029 template<class T> inline T pi_half_lower() { return 1; }
0030 template<class T> inline T pi_half_upper() { return 2; }
0031 template<class T> inline T pi_twice_lower() { return 6; }
0032 template<class T> inline T pi_twice_upper() { return 7; }
0033
0034 template<> inline float pi_lower<float>() { return pi_f_l; }
0035 template<> inline float pi_upper<float>() { return pi_f_u; }
0036 template<> inline float pi_half_lower<float>() { return pi_f_l / 2; }
0037 template<> inline float pi_half_upper<float>() { return pi_f_u / 2; }
0038 template<> inline float pi_twice_lower<float>() { return pi_f_l * 2; }
0039 template<> inline float pi_twice_upper<float>() { return pi_f_u * 2; }
0040
0041 template<> inline double pi_lower<double>() { return pi_d_l; }
0042 template<> inline double pi_upper<double>() { return pi_d_u; }
0043 template<> inline double pi_half_lower<double>() { return pi_d_l / 2; }
0044 template<> inline double pi_half_upper<double>() { return pi_d_u / 2; }
0045 template<> inline double pi_twice_lower<double>() { return pi_d_l * 2; }
0046 template<> inline double pi_twice_upper<double>() { return pi_d_u * 2; }
0047
0048 template<> inline long double pi_lower<long double>() { return pi_d_l; }
0049 template<> inline long double pi_upper<long double>() { return pi_d_u; }
0050 template<> inline long double pi_half_lower<long double>() { return pi_d_l / 2; }
0051 template<> inline long double pi_half_upper<long double>() { return pi_d_u / 2; }
0052 template<> inline long double pi_twice_lower<long double>() { return pi_d_l * 2; }
0053 template<> inline long double pi_twice_upper<long double>() { return pi_d_u * 2; }
0054
0055 }
0056
0057 template<class I> inline
0058 I pi()
0059 {
0060 typedef typename I::base_type T;
0061 return I(constants::pi_lower<T>(),
0062 constants::pi_upper<T>(), true);
0063 }
0064
0065 template<class I> inline
0066 I pi_half()
0067 {
0068 typedef typename I::base_type T;
0069 return I(constants::pi_half_lower<T>(),
0070 constants::pi_half_upper<T>(), true);
0071 }
0072
0073 template<class I> inline
0074 I pi_twice()
0075 {
0076 typedef typename I::base_type T;
0077 return I(constants::pi_twice_lower<T>(),
0078 constants::pi_twice_upper<T>(), true);
0079 }
0080
0081 }
0082 }
0083 }
0084
0085 #endif