os/ossrv/ossrv_pub/boost_apis/boost/numeric/interval/rounding.hpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/ossrv_pub/boost_apis/boost/numeric/interval/rounding.hpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,101 @@
     1.4 +/* Boost interval/rounding.hpp template implementation file
     1.5 + *
     1.6 + * Copyright 2002-2003 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_ROUNDING_HPP
    1.14 +#define BOOST_NUMERIC_INTERVAL_ROUNDING_HPP
    1.15 +
    1.16 +namespace boost {
    1.17 +namespace numeric {
    1.18 +namespace interval_lib {
    1.19 +
    1.20 +/*
    1.21 + * Default rounding_control class (does nothing)
    1.22 + */
    1.23 +
    1.24 +template<class T>
    1.25 +struct rounding_control
    1.26 +{
    1.27 +  typedef int rounding_mode;
    1.28 +  static void get_rounding_mode(rounding_mode&) {}
    1.29 +  static void set_rounding_mode(rounding_mode)  {}
    1.30 +  static void upward()     {}
    1.31 +  static void downward()   {}
    1.32 +  static void to_nearest() {}
    1.33 +  static const T& to_int(const T& x)         { return x; }
    1.34 +  static const T& force_rounding(const T& x) { return x; }
    1.35 +};
    1.36 +
    1.37 +/*
    1.38 + * A few rounding control classes (exact/std/opp: see documentation)
    1.39 + *   rounded_arith_* control the rounding of the arithmetic operators
    1.40 + *   rounded_transc_* control the rounding of the transcendental functions
    1.41 + */
    1.42 +
    1.43 +template<class T, class Rounding = rounding_control<T> >
    1.44 +struct rounded_arith_exact;
    1.45 +
    1.46 +template<class T, class Rounding = rounding_control<T> >
    1.47 +struct rounded_arith_std;
    1.48 +
    1.49 +template<class T, class Rounding = rounding_control<T> >
    1.50 +struct rounded_arith_opp;
    1.51 +
    1.52 +template<class T, class Rounding>
    1.53 +struct rounded_transc_dummy;
    1.54 +
    1.55 +template<class T, class Rounding = rounded_arith_exact<T> > 
    1.56 +struct rounded_transc_exact;
    1.57 +
    1.58 +template<class T, class Rounding = rounded_arith_std<T> > 
    1.59 +struct rounded_transc_std;
    1.60 +
    1.61 +template<class T, class Rounding = rounded_arith_opp<T> > 
    1.62 +struct rounded_transc_opp;
    1.63 +
    1.64 +/*
    1.65 + * State-saving classes: allow to set and reset rounding control
    1.66 + */
    1.67 +
    1.68 +namespace detail {
    1.69 +
    1.70 +template<class Rounding>
    1.71 +struct save_state_unprotected: Rounding
    1.72 +{
    1.73 +  typedef save_state_unprotected<Rounding> unprotected_rounding;
    1.74 +};
    1.75 +
    1.76 +} // namespace detail
    1.77 +
    1.78 +template<class Rounding>
    1.79 +struct save_state: Rounding
    1.80 +{
    1.81 +  typename Rounding::rounding_mode mode;
    1.82 +  save_state() {
    1.83 +    this->get_rounding_mode(mode);
    1.84 +    this->init();
    1.85 +  }
    1.86 +  ~save_state() { this->set_rounding_mode(mode); }
    1.87 +  typedef detail::save_state_unprotected<Rounding> unprotected_rounding;
    1.88 +};
    1.89 +  
    1.90 +template<class Rounding>
    1.91 +struct save_state_nothing: Rounding
    1.92 +{
    1.93 +  typedef save_state_nothing<Rounding> unprotected_rounding;
    1.94 +};
    1.95 +  
    1.96 +template<class T>
    1.97 +struct rounded_math: save_state_nothing<rounded_arith_exact<T> >
    1.98 +{};
    1.99 +
   1.100 +} // namespace interval_lib
   1.101 +} // namespace numeric
   1.102 +} // namespace boost
   1.103 +
   1.104 +#endif // BOOST_NUMERIC_INTERVAL_ROUNDING_HPP