1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/ossrv_pub/boost_apis/boost/numeric/interval/constants.hpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,85 @@
1.4 +/* Boost interval/constants.hpp template implementation file
1.5 + *
1.6 + * Copyright 2002 Hervé Brönnimann, Guillaume Melquiond, Sylvain Pion
1.7 + *
1.8 + * Distributed under the Boost Software License, Version 1.0.
1.9 + * (See accompanying file LICENSE_1_0.txt or
1.10 + * copy at http://www.boost.org/LICENSE_1_0.txt)
1.11 + */
1.12 +
1.13 +#ifndef BOOST_NUMERIC_INTERVAL_CONSTANTS_HPP
1.14 +#define BOOST_NUMERIC_INTERVAL_CONSTANTS_HPP
1.15 +
1.16 +namespace boost {
1.17 +namespace numeric {
1.18 +namespace interval_lib {
1.19 +namespace constants {
1.20 +
1.21 +// These constants should be exactly computed.
1.22 +// Decimal representations wouldn't do it since the standard doesn't
1.23 +// specify the rounding (even nearest) that should be used.
1.24 +
1.25 +static const float pi_f_l = 13176794.0f/(1<<22);
1.26 +static const float pi_f_u = 13176795.0f/(1<<22);
1.27 +static const double pi_d_l = (3373259426.0 + 273688.0 / (1<<21)) / (1<<30);
1.28 +static const double pi_d_u = (3373259426.0 + 273689.0 / (1<<21)) / (1<<30);
1.29 +
1.30 +template<class T> inline T pi_lower() { return 3; }
1.31 +template<class T> inline T pi_upper() { return 4; }
1.32 +template<class T> inline T pi_half_lower() { return 1; }
1.33 +template<class T> inline T pi_half_upper() { return 2; }
1.34 +template<class T> inline T pi_twice_lower() { return 6; }
1.35 +template<class T> inline T pi_twice_upper() { return 7; }
1.36 +
1.37 +template<> inline float pi_lower<float>() { return pi_f_l; }
1.38 +template<> inline float pi_upper<float>() { return pi_f_u; }
1.39 +template<> inline float pi_half_lower<float>() { return pi_f_l / 2; }
1.40 +template<> inline float pi_half_upper<float>() { return pi_f_u / 2; }
1.41 +template<> inline float pi_twice_lower<float>() { return pi_f_l * 2; }
1.42 +template<> inline float pi_twice_upper<float>() { return pi_f_u * 2; }
1.43 +
1.44 +template<> inline double pi_lower<double>() { return pi_d_l; }
1.45 +template<> inline double pi_upper<double>() { return pi_d_u; }
1.46 +template<> inline double pi_half_lower<double>() { return pi_d_l / 2; }
1.47 +template<> inline double pi_half_upper<double>() { return pi_d_u / 2; }
1.48 +template<> inline double pi_twice_lower<double>() { return pi_d_l * 2; }
1.49 +template<> inline double pi_twice_upper<double>() { return pi_d_u * 2; }
1.50 +
1.51 +template<> inline long double pi_lower<long double>() { return pi_d_l; }
1.52 +template<> inline long double pi_upper<long double>() { return pi_d_u; }
1.53 +template<> inline long double pi_half_lower<long double>() { return pi_d_l / 2; }
1.54 +template<> inline long double pi_half_upper<long double>() { return pi_d_u / 2; }
1.55 +template<> inline long double pi_twice_lower<long double>() { return pi_d_l * 2; }
1.56 +template<> inline long double pi_twice_upper<long double>() { return pi_d_u * 2; }
1.57 +
1.58 +} // namespace constants
1.59 +
1.60 +template<class I> inline
1.61 +I pi()
1.62 +{
1.63 + typedef typename I::base_type T;
1.64 + return I(constants::pi_lower<T>(),
1.65 + constants::pi_upper<T>(), true);
1.66 +}
1.67 +
1.68 +template<class I> inline
1.69 +I pi_half()
1.70 +{
1.71 + typedef typename I::base_type T;
1.72 + return I(constants::pi_half_lower<T>(),
1.73 + constants::pi_half_upper<T>(), true);
1.74 +}
1.75 +
1.76 +template<class I> inline
1.77 +I pi_twice()
1.78 +{
1.79 + typedef typename I::base_type T;
1.80 + return I(constants::pi_twice_lower<T>(),
1.81 + constants::pi_twice_upper<T>(), true);
1.82 +}
1.83 +
1.84 +} // namespace interval_lib
1.85 +} // namespace numeric
1.86 +} // namespace boost
1.87 +
1.88 +#endif // BOOST_NUMERIC_INTERVAL_CONSTANTS_HPP