annotate DEPENDENCIES/generic/include/boost/numeric/interval/constants.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 /* Boost interval/constants.hpp template implementation file
Chris@16 2 *
Chris@16 3 * Copyright 2002 Hervé Brönnimann, Guillaume Melquiond, Sylvain Pion
Chris@16 4 *
Chris@16 5 * Distributed under the Boost Software License, Version 1.0.
Chris@16 6 * (See accompanying file LICENSE_1_0.txt or
Chris@16 7 * copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 8 */
Chris@16 9
Chris@16 10 #ifndef BOOST_NUMERIC_INTERVAL_CONSTANTS_HPP
Chris@16 11 #define BOOST_NUMERIC_INTERVAL_CONSTANTS_HPP
Chris@16 12
Chris@16 13 namespace boost {
Chris@16 14 namespace numeric {
Chris@16 15 namespace interval_lib {
Chris@16 16 namespace constants {
Chris@16 17
Chris@16 18 // These constants should be exactly computed.
Chris@16 19 // Decimal representations wouldn't do it since the standard doesn't
Chris@16 20 // specify the rounding (even nearest) that should be used.
Chris@16 21
Chris@16 22 static const float pi_f_l = 13176794.0f/(1<<22);
Chris@16 23 static const float pi_f_u = 13176795.0f/(1<<22);
Chris@16 24 static const double pi_d_l = (3373259426.0 + 273688.0 / (1<<21)) / (1<<30);
Chris@16 25 static const double pi_d_u = (3373259426.0 + 273689.0 / (1<<21)) / (1<<30);
Chris@16 26
Chris@16 27 template<class T> inline T pi_lower() { return 3; }
Chris@16 28 template<class T> inline T pi_upper() { return 4; }
Chris@16 29 template<class T> inline T pi_half_lower() { return 1; }
Chris@16 30 template<class T> inline T pi_half_upper() { return 2; }
Chris@16 31 template<class T> inline T pi_twice_lower() { return 6; }
Chris@16 32 template<class T> inline T pi_twice_upper() { return 7; }
Chris@16 33
Chris@16 34 template<> inline float pi_lower<float>() { return pi_f_l; }
Chris@16 35 template<> inline float pi_upper<float>() { return pi_f_u; }
Chris@16 36 template<> inline float pi_half_lower<float>() { return pi_f_l / 2; }
Chris@16 37 template<> inline float pi_half_upper<float>() { return pi_f_u / 2; }
Chris@16 38 template<> inline float pi_twice_lower<float>() { return pi_f_l * 2; }
Chris@16 39 template<> inline float pi_twice_upper<float>() { return pi_f_u * 2; }
Chris@16 40
Chris@16 41 template<> inline double pi_lower<double>() { return pi_d_l; }
Chris@16 42 template<> inline double pi_upper<double>() { return pi_d_u; }
Chris@16 43 template<> inline double pi_half_lower<double>() { return pi_d_l / 2; }
Chris@16 44 template<> inline double pi_half_upper<double>() { return pi_d_u / 2; }
Chris@16 45 template<> inline double pi_twice_lower<double>() { return pi_d_l * 2; }
Chris@16 46 template<> inline double pi_twice_upper<double>() { return pi_d_u * 2; }
Chris@16 47
Chris@16 48 template<> inline long double pi_lower<long double>() { return pi_d_l; }
Chris@16 49 template<> inline long double pi_upper<long double>() { return pi_d_u; }
Chris@16 50 template<> inline long double pi_half_lower<long double>() { return pi_d_l / 2; }
Chris@16 51 template<> inline long double pi_half_upper<long double>() { return pi_d_u / 2; }
Chris@16 52 template<> inline long double pi_twice_lower<long double>() { return pi_d_l * 2; }
Chris@16 53 template<> inline long double pi_twice_upper<long double>() { return pi_d_u * 2; }
Chris@16 54
Chris@16 55 } // namespace constants
Chris@16 56
Chris@16 57 template<class I> inline
Chris@16 58 I pi()
Chris@16 59 {
Chris@16 60 typedef typename I::base_type T;
Chris@16 61 return I(constants::pi_lower<T>(),
Chris@16 62 constants::pi_upper<T>(), true);
Chris@16 63 }
Chris@16 64
Chris@16 65 template<class I> inline
Chris@16 66 I pi_half()
Chris@16 67 {
Chris@16 68 typedef typename I::base_type T;
Chris@16 69 return I(constants::pi_half_lower<T>(),
Chris@16 70 constants::pi_half_upper<T>(), true);
Chris@16 71 }
Chris@16 72
Chris@16 73 template<class I> inline
Chris@16 74 I pi_twice()
Chris@16 75 {
Chris@16 76 typedef typename I::base_type T;
Chris@16 77 return I(constants::pi_twice_lower<T>(),
Chris@16 78 constants::pi_twice_upper<T>(), true);
Chris@16 79 }
Chris@16 80
Chris@16 81 } // namespace interval_lib
Chris@16 82 } // namespace numeric
Chris@16 83 } // namespace boost
Chris@16 84
Chris@16 85 #endif // BOOST_NUMERIC_INTERVAL_CONSTANTS_HPP