New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
rounding.hpp in vendors/XIOS/current/extern/boost/include/boost/numeric/interval – NEMO

source: vendors/XIOS/current/extern/boost/include/boost/numeric/interval/rounding.hpp @ 3408

Last change on this file since 3408 was 3408, checked in by rblod, 12 years ago

importing initial XIOS vendor drop

  • Property svn:keywords set to Id
File size: 2.5 KB
Line 
1/* Boost interval/rounding.hpp template implementation file
2 *
3 * Copyright 2002-2003 Hervé Brönnimann, Guillaume Melquiond, Sylvain Pion
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE_1_0.txt or
7 * copy at http://www.boost.org/LICENSE_1_0.txt)
8 */
9
10#ifndef BOOST_NUMERIC_INTERVAL_ROUNDING_HPP
11#define BOOST_NUMERIC_INTERVAL_ROUNDING_HPP
12
13namespace boost {
14namespace numeric {
15namespace interval_lib {
16
17/*
18 * Default rounding_control class (does nothing)
19 */
20
21template<class T>
22struct rounding_control
23{
24  typedef int rounding_mode;
25  static void get_rounding_mode(rounding_mode&) {}
26  static void set_rounding_mode(rounding_mode)  {}
27  static void upward()     {}
28  static void downward()   {}
29  static void to_nearest() {}
30  static const T& to_int(const T& x)         { return x; }
31  static const T& force_rounding(const T& x) { return x; }
32};
33
34/*
35 * A few rounding control classes (exact/std/opp: see documentation)
36 *   rounded_arith_* control the rounding of the arithmetic operators
37 *   rounded_transc_* control the rounding of the transcendental functions
38 */
39
40template<class T, class Rounding = rounding_control<T> >
41struct rounded_arith_exact;
42
43template<class T, class Rounding = rounding_control<T> >
44struct rounded_arith_std;
45
46template<class T, class Rounding = rounding_control<T> >
47struct rounded_arith_opp;
48
49template<class T, class Rounding>
50struct rounded_transc_dummy;
51
52template<class T, class Rounding = rounded_arith_exact<T> > 
53struct rounded_transc_exact;
54
55template<class T, class Rounding = rounded_arith_std<T> > 
56struct rounded_transc_std;
57
58template<class T, class Rounding = rounded_arith_opp<T> > 
59struct rounded_transc_opp;
60
61/*
62 * State-saving classes: allow to set and reset rounding control
63 */
64
65namespace detail {
66
67template<class Rounding>
68struct save_state_unprotected: Rounding
69{
70  typedef save_state_unprotected<Rounding> unprotected_rounding;
71};
72
73} // namespace detail
74
75template<class Rounding>
76struct save_state: Rounding
77{
78  typename Rounding::rounding_mode mode;
79  save_state() {
80    this->get_rounding_mode(mode);
81    this->init();
82  }
83  ~save_state() { this->set_rounding_mode(mode); }
84  typedef detail::save_state_unprotected<Rounding> unprotected_rounding;
85};
86 
87template<class Rounding>
88struct save_state_nothing: Rounding
89{
90  typedef save_state_nothing<Rounding> unprotected_rounding;
91};
92 
93template<class T>
94struct rounded_math: save_state_nothing<rounded_arith_exact<T> >
95{};
96
97} // namespace interval_lib
98} // namespace numeric
99} // namespace boost
100
101#endif // BOOST_NUMERIC_INTERVAL_ROUNDING_HPP
Note: See TracBrowser for help on using the repository browser.