Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/boost/numeric/interval/ext/x86_fast_rounding_control.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /* Boost interval/detail/x86gcc_rounding_control.hpp file
0002  *
0003  * This header provides a rounding control policy
0004  * that avoids flushing results to memory. In
0005  * order for this optimization to be reliable, it
0006  * should be used only when no underflow or
0007  * overflow would happen without it. Indeed, only
0008  * values in range are correctly rounded.
0009  *
0010  * Copyright 2002 Hervé Brönnimann, Guillaume Melquiond, Sylvain Pion
0011  *
0012  * Distributed under the Boost Software License, Version 1.0.
0013  * (See accompanying file LICENSE_1_0.txt or
0014  * copy at http://www.boost.org/LICENSE_1_0.txt)
0015  */
0016 
0017 #ifndef BOOST_NUMERIC_INTERVAL_EXT_X86_FAST_ROUNDING_CONTROL_HPP
0018 #define BOOST_NUMERIC_INTERVAL_EXT_X86_FAST_ROUNDING_CONTROL_HPP
0019 
0020 namespace boost {
0021 namespace numeric {
0022 namespace interval_lib {
0023 
0024 namespace detail {
0025 
0026 // exceptions masked, expected precision (the mask is 0x0300)
0027 static const fpu_rounding_modes rnd_mode_f = { 0x107f, 0x147f, 0x187f, 0x1c7f };
0028 static const fpu_rounding_modes rnd_mode_d = { 0x127f, 0x167f, 0x1a7f, 0x1e7f };
0029 static const fpu_rounding_modes rnd_mode_l = { 0x137f, 0x177f, 0x1b7f, 0x1f7f };
0030 
0031 } // namespace detail
0032 
0033 template<class T>
0034 struct x86_fast_rounding_control;
0035 
0036 template<>
0037 struct x86_fast_rounding_control<float>: detail::x86_rounding
0038 {
0039   static void to_nearest()  { set_rounding_mode(detail::rnd_mode_f.to_nearest);  }
0040   static void downward()    { set_rounding_mode(detail::rnd_mode_f.downward);    }
0041   static void upward()      { set_rounding_mode(detail::rnd_mode_f.upward);      }
0042   static void toward_zero() { set_rounding_mode(detail::rnd_mode_f.toward_zero); }
0043   static const float& force_rounding(const float& r) { return r; }
0044 };
0045 
0046 template<>
0047 struct x86_fast_rounding_control<double>: detail::x86_rounding
0048 {
0049   static void to_nearest()  { set_rounding_mode(detail::rnd_mode_d.to_nearest);  }
0050   static void downward()    { set_rounding_mode(detail::rnd_mode_d.downward);    }
0051   static void upward()      { set_rounding_mode(detail::rnd_mode_d.upward);      }
0052   static void toward_zero() { set_rounding_mode(detail::rnd_mode_d.toward_zero); }
0053   static const double& force_rounding(const double& r) { return r; }
0054 };
0055 
0056 template<>
0057 struct x86_fast_rounding_control<long double>: detail::x86_rounding
0058 {
0059   static void to_nearest()  { set_rounding_mode(detail::rnd_mode_l.to_nearest);  }
0060   static void downward()    { set_rounding_mode(detail::rnd_mode_l.downward);    }
0061   static void upward()      { set_rounding_mode(detail::rnd_mode_l.upward);      }
0062   static void toward_zero() { set_rounding_mode(detail::rnd_mode_l.toward_zero); }
0063   static const long double& force_rounding(const long double& r) { return r; }
0064 };
0065 
0066 } // namespace interval_lib
0067 } // namespace numeric
0068 } // namespace boost
0069 
0070 #endif // BOOST_NUMERIC_INTERVAL_EXT_X86_FAST_ROUNDING_CONTROL_HPP