annotate DEPENDENCIES/generic/include/boost/numeric/interval/rounding.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/rounding.hpp template implementation file
Chris@16 2 *
Chris@16 3 * Copyright 2002-2003 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_ROUNDING_HPP
Chris@16 11 #define BOOST_NUMERIC_INTERVAL_ROUNDING_HPP
Chris@16 12
Chris@16 13 namespace boost {
Chris@16 14 namespace numeric {
Chris@16 15 namespace interval_lib {
Chris@16 16
Chris@16 17 /*
Chris@16 18 * Default rounding_control class (does nothing)
Chris@16 19 */
Chris@16 20
Chris@16 21 template<class T>
Chris@16 22 struct rounding_control
Chris@16 23 {
Chris@16 24 typedef int rounding_mode;
Chris@16 25 static void get_rounding_mode(rounding_mode&) {}
Chris@16 26 static void set_rounding_mode(rounding_mode) {}
Chris@16 27 static void upward() {}
Chris@16 28 static void downward() {}
Chris@16 29 static void to_nearest() {}
Chris@16 30 static const T& to_int(const T& x) { return x; }
Chris@16 31 static const T& force_rounding(const T& x) { return x; }
Chris@16 32 };
Chris@16 33
Chris@16 34 /*
Chris@16 35 * A few rounding control classes (exact/std/opp: see documentation)
Chris@16 36 * rounded_arith_* control the rounding of the arithmetic operators
Chris@16 37 * rounded_transc_* control the rounding of the transcendental functions
Chris@16 38 */
Chris@16 39
Chris@16 40 template<class T, class Rounding = rounding_control<T> >
Chris@16 41 struct rounded_arith_exact;
Chris@16 42
Chris@16 43 template<class T, class Rounding = rounding_control<T> >
Chris@16 44 struct rounded_arith_std;
Chris@16 45
Chris@16 46 template<class T, class Rounding = rounding_control<T> >
Chris@16 47 struct rounded_arith_opp;
Chris@16 48
Chris@16 49 template<class T, class Rounding>
Chris@16 50 struct rounded_transc_dummy;
Chris@16 51
Chris@16 52 template<class T, class Rounding = rounded_arith_exact<T> >
Chris@16 53 struct rounded_transc_exact;
Chris@16 54
Chris@16 55 template<class T, class Rounding = rounded_arith_std<T> >
Chris@16 56 struct rounded_transc_std;
Chris@16 57
Chris@16 58 template<class T, class Rounding = rounded_arith_opp<T> >
Chris@16 59 struct rounded_transc_opp;
Chris@16 60
Chris@16 61 /*
Chris@16 62 * State-saving classes: allow to set and reset rounding control
Chris@16 63 */
Chris@16 64
Chris@16 65 namespace detail {
Chris@16 66
Chris@16 67 template<class Rounding>
Chris@16 68 struct save_state_unprotected: Rounding
Chris@16 69 {
Chris@16 70 typedef save_state_unprotected<Rounding> unprotected_rounding;
Chris@16 71 };
Chris@16 72
Chris@16 73 } // namespace detail
Chris@16 74
Chris@16 75 template<class Rounding>
Chris@16 76 struct save_state: Rounding
Chris@16 77 {
Chris@16 78 typename Rounding::rounding_mode mode;
Chris@16 79 save_state() {
Chris@16 80 this->get_rounding_mode(mode);
Chris@16 81 this->init();
Chris@16 82 }
Chris@16 83 ~save_state() { this->set_rounding_mode(mode); }
Chris@16 84 typedef detail::save_state_unprotected<Rounding> unprotected_rounding;
Chris@16 85 };
Chris@16 86
Chris@16 87 template<class Rounding>
Chris@16 88 struct save_state_nothing: Rounding
Chris@16 89 {
Chris@16 90 typedef save_state_nothing<Rounding> unprotected_rounding;
Chris@16 91 };
Chris@16 92
Chris@16 93 template<class T>
Chris@16 94 struct rounded_math: save_state_nothing<rounded_arith_exact<T> >
Chris@16 95 {};
Chris@16 96
Chris@16 97 } // namespace interval_lib
Chris@16 98 } // namespace numeric
Chris@16 99 } // namespace boost
Chris@16 100
Chris@16 101 #endif // BOOST_NUMERIC_INTERVAL_ROUNDING_HPP