1 | /* Boost interval/rounded_transc.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_ROUNDED_TRANSC_HPP
|
---|
11 | #define BOOST_NUMERIC_INTERVAL_ROUNDED_TRANSC_HPP
|
---|
12 |
|
---|
13 | #include <boost/numeric/interval/rounding.hpp>
|
---|
14 | #include <boost/numeric/interval/detail/bugs.hpp>
|
---|
15 | #include <cmath>
|
---|
16 |
|
---|
17 | namespace boost {
|
---|
18 | namespace numeric {
|
---|
19 | namespace interval_lib {
|
---|
20 |
|
---|
21 | template<class T, class Rounding>
|
---|
22 | struct rounded_transc_exact: Rounding
|
---|
23 | {
|
---|
24 | # define BOOST_NUMERIC_INTERVAL_new_func(f) \
|
---|
25 | T f##_down(const T& x) { BOOST_NUMERIC_INTERVAL_using_math(f); return f(x); } \
|
---|
26 | T f##_up (const T& x) { BOOST_NUMERIC_INTERVAL_using_math(f); return f(x); }
|
---|
27 | BOOST_NUMERIC_INTERVAL_new_func(exp)
|
---|
28 | BOOST_NUMERIC_INTERVAL_new_func(log)
|
---|
29 | BOOST_NUMERIC_INTERVAL_new_func(sin)
|
---|
30 | BOOST_NUMERIC_INTERVAL_new_func(cos)
|
---|
31 | BOOST_NUMERIC_INTERVAL_new_func(tan)
|
---|
32 | BOOST_NUMERIC_INTERVAL_new_func(asin)
|
---|
33 | BOOST_NUMERIC_INTERVAL_new_func(acos)
|
---|
34 | BOOST_NUMERIC_INTERVAL_new_func(atan)
|
---|
35 | BOOST_NUMERIC_INTERVAL_new_func(sinh)
|
---|
36 | BOOST_NUMERIC_INTERVAL_new_func(cosh)
|
---|
37 | BOOST_NUMERIC_INTERVAL_new_func(tanh)
|
---|
38 | # undef BOOST_NUMERIC_INTERVAL_new_func
|
---|
39 | # define BOOST_NUMERIC_INTERVAL_new_func(f) \
|
---|
40 | T f##_down(const T& x) { BOOST_NUMERIC_INTERVAL_using_ahyp(f); return f(x); } \
|
---|
41 | T f##_up (const T& x) { BOOST_NUMERIC_INTERVAL_using_ahyp(f); return f(x); }
|
---|
42 | BOOST_NUMERIC_INTERVAL_new_func(asinh)
|
---|
43 | BOOST_NUMERIC_INTERVAL_new_func(acosh)
|
---|
44 | BOOST_NUMERIC_INTERVAL_new_func(atanh)
|
---|
45 | # undef BOOST_NUMERIC_INTERVAL_new_func
|
---|
46 | };
|
---|
47 |
|
---|
48 | template<class T, class Rounding>
|
---|
49 | struct rounded_transc_std: Rounding
|
---|
50 | {
|
---|
51 | # define BOOST_NUMERIC_INTERVAL_new_func(f) \
|
---|
52 | T f##_down(const T& x) \
|
---|
53 | { BOOST_NUMERIC_INTERVAL_using_math(f); \
|
---|
54 | this->downward(); return this->force_rounding(f(x)); } \
|
---|
55 | T f##_up (const T& x) \
|
---|
56 | { BOOST_NUMERIC_INTERVAL_using_math(f); \
|
---|
57 | this->upward(); return this->force_rounding(f(x)); }
|
---|
58 | BOOST_NUMERIC_INTERVAL_new_func(exp)
|
---|
59 | BOOST_NUMERIC_INTERVAL_new_func(log)
|
---|
60 | BOOST_NUMERIC_INTERVAL_new_func(sin)
|
---|
61 | BOOST_NUMERIC_INTERVAL_new_func(cos)
|
---|
62 | BOOST_NUMERIC_INTERVAL_new_func(tan)
|
---|
63 | BOOST_NUMERIC_INTERVAL_new_func(asin)
|
---|
64 | BOOST_NUMERIC_INTERVAL_new_func(acos)
|
---|
65 | BOOST_NUMERIC_INTERVAL_new_func(atan)
|
---|
66 | BOOST_NUMERIC_INTERVAL_new_func(sinh)
|
---|
67 | BOOST_NUMERIC_INTERVAL_new_func(cosh)
|
---|
68 | BOOST_NUMERIC_INTERVAL_new_func(tanh)
|
---|
69 | # undef BOOST_NUMERIC_INTERVAL_new_func
|
---|
70 | # define BOOST_NUMERIC_INTERVAL_new_func(f) \
|
---|
71 | T f##_down(const T& x) \
|
---|
72 | { BOOST_NUMERIC_INTERVAL_using_ahyp(f); \
|
---|
73 | this->downward(); return this->force_rounding(f(x)); } \
|
---|
74 | T f##_up (const T& x) \
|
---|
75 | { BOOST_NUMERIC_INTERVAL_using_ahyp(f); \
|
---|
76 | this->upward(); return this->force_rounding(f(x)); }
|
---|
77 | BOOST_NUMERIC_INTERVAL_new_func(asinh)
|
---|
78 | BOOST_NUMERIC_INTERVAL_new_func(acosh)
|
---|
79 | BOOST_NUMERIC_INTERVAL_new_func(atanh)
|
---|
80 | # undef BOOST_NUMERIC_INTERVAL_new_func
|
---|
81 | };
|
---|
82 |
|
---|
83 | template<class T, class Rounding>
|
---|
84 | struct rounded_transc_opp: Rounding
|
---|
85 | {
|
---|
86 | # define BOOST_NUMERIC_INTERVAL_new_func(f) \
|
---|
87 | T f##_down(const T& x) \
|
---|
88 | { BOOST_NUMERIC_INTERVAL_using_math(f); \
|
---|
89 | this->downward(); T y = this->force_rounding(f(x)); \
|
---|
90 | this->upward(); return y; } \
|
---|
91 | T f##_up (const T& x) \
|
---|
92 | { BOOST_NUMERIC_INTERVAL_using_math(f); \
|
---|
93 | return this->force_rounding(f(x)); }
|
---|
94 | BOOST_NUMERIC_INTERVAL_new_func(exp)
|
---|
95 | BOOST_NUMERIC_INTERVAL_new_func(log)
|
---|
96 | BOOST_NUMERIC_INTERVAL_new_func(cos)
|
---|
97 | BOOST_NUMERIC_INTERVAL_new_func(acos)
|
---|
98 | BOOST_NUMERIC_INTERVAL_new_func(cosh)
|
---|
99 | # undef BOOST_NUMERIC_INTERVAL_new_func
|
---|
100 | # define BOOST_NUMERIC_INTERVAL_new_func(f) \
|
---|
101 | T f##_down(const T& x) \
|
---|
102 | { BOOST_NUMERIC_INTERVAL_using_math(f); \
|
---|
103 | return -this->force_rounding(-f(x)); } \
|
---|
104 | T f##_up (const T& x) \
|
---|
105 | { BOOST_NUMERIC_INTERVAL_using_math(f); \
|
---|
106 | return this->force_rounding(f(x)); }
|
---|
107 | BOOST_NUMERIC_INTERVAL_new_func(sin)
|
---|
108 | BOOST_NUMERIC_INTERVAL_new_func(tan)
|
---|
109 | BOOST_NUMERIC_INTERVAL_new_func(asin)
|
---|
110 | BOOST_NUMERIC_INTERVAL_new_func(atan)
|
---|
111 | BOOST_NUMERIC_INTERVAL_new_func(sinh)
|
---|
112 | BOOST_NUMERIC_INTERVAL_new_func(tanh)
|
---|
113 | # undef BOOST_NUMERIC_INTERVAL_new_func
|
---|
114 | # define BOOST_NUMERIC_INTERVAL_new_func(f) \
|
---|
115 | T f##_down(const T& x) \
|
---|
116 | { BOOST_NUMERIC_INTERVAL_using_ahyp(f); \
|
---|
117 | this->downward(); T y = this->force_rounding(f(x)); \
|
---|
118 | this->upward(); return y; } \
|
---|
119 | T f##_up (const T& x) \
|
---|
120 | { BOOST_NUMERIC_INTERVAL_using_ahyp(f); \
|
---|
121 | return this->force_rounding(f(x)); }
|
---|
122 | BOOST_NUMERIC_INTERVAL_new_func(asinh)
|
---|
123 | BOOST_NUMERIC_INTERVAL_new_func(atanh)
|
---|
124 | # undef BOOST_NUMERIC_INTERVAL_new_func
|
---|
125 | # define BOOST_NUMERIC_INTERVAL_new_func(f) \
|
---|
126 | T f##_down(const T& x) \
|
---|
127 | { BOOST_NUMERIC_INTERVAL_using_ahyp(f); \
|
---|
128 | return -this->force_rounding(-f(x)); } \
|
---|
129 | T f##_up (const T& x) \
|
---|
130 | { BOOST_NUMERIC_INTERVAL_using_ahyp(f); \
|
---|
131 | return this->force_rounding(f(x)); }
|
---|
132 | BOOST_NUMERIC_INTERVAL_new_func(acosh)
|
---|
133 | # undef BOOST_NUMERIC_INTERVAL_new_func
|
---|
134 | };
|
---|
135 |
|
---|
136 | } // namespace interval_lib
|
---|
137 | } // namespace numeric
|
---|
138 | } // namespace boost
|
---|
139 |
|
---|
140 | #endif // BOOST_NUMERIC_INTERVAL_ROUNDED_TRANSC_HPP
|
---|