p1788 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.yardopts +8 -0
- data/AUTHORS +6 -0
- data/LICENSE +201 -0
- data/NOTICE +29 -0
- data/README.md +65 -0
- data/ext/libieeep1788_copy/README +3 -0
- data/ext/libieeep1788_copy/p1788/AUTHORS +16 -0
- data/ext/libieeep1788_copy/p1788/LICENSE +202 -0
- data/ext/libieeep1788_copy/p1788/NOTICE +14 -0
- data/ext/libieeep1788_copy/p1788/decoration/decoration.hpp +265 -0
- data/ext/libieeep1788_copy/p1788/exception/exception.hpp +302 -0
- data/ext/libieeep1788_copy/p1788/flavor/infsup/setbased/mpfr_bin_ieee754_flavor.hpp +3443 -0
- data/ext/libieeep1788_copy/p1788/flavor/infsup/setbased/mpfr_bin_ieee754_flavor_bool_func_impl.hpp +608 -0
- data/ext/libieeep1788_copy/p1788/flavor/infsup/setbased/mpfr_bin_ieee754_flavor_cancel_func_impl.hpp +229 -0
- data/ext/libieeep1788_copy/p1788/flavor/infsup/setbased/mpfr_bin_ieee754_flavor_class_impl.hpp +526 -0
- data/ext/libieeep1788_copy/p1788/flavor/infsup/setbased/mpfr_bin_ieee754_flavor_elem_func_impl.hpp +4533 -0
- data/ext/libieeep1788_copy/p1788/flavor/infsup/setbased/mpfr_bin_ieee754_flavor_io_impl.hpp +1421 -0
- data/ext/libieeep1788_copy/p1788/flavor/infsup/setbased/mpfr_bin_ieee754_flavor_mul_rev_to_pair_func_impl.hpp +347 -0
- data/ext/libieeep1788_copy/p1788/flavor/infsup/setbased/mpfr_bin_ieee754_flavor_num_func_impl.hpp +655 -0
- data/ext/libieeep1788_copy/p1788/flavor/infsup/setbased/mpfr_bin_ieee754_flavor_rec_bool_func_impl.hpp +146 -0
- data/ext/libieeep1788_copy/p1788/flavor/infsup/setbased/mpfr_bin_ieee754_flavor_rec_overlap_impl.hpp +188 -0
- data/ext/libieeep1788_copy/p1788/flavor/infsup/setbased/mpfr_bin_ieee754_flavor_rev_func_impl.hpp +1674 -0
- data/ext/libieeep1788_copy/p1788/flavor/infsup/setbased/mpfr_bin_ieee754_flavor_set_op_impl.hpp +216 -0
- data/ext/libieeep1788_copy/p1788/flavor/infsup/setbased/mpfr_bin_ieee754_flavor_setup_func_impl.hpp +68 -0
- data/ext/libieeep1788_copy/p1788/flavor/infsup/setbased/mpfr_bin_ieee754_flavor_util_func_impl.hpp +135 -0
- data/ext/libieeep1788_copy/p1788/flavor/infsup/setbased/mpfr_bin_ieee754_flavor_validation_func_impl.hpp +93 -0
- data/ext/libieeep1788_copy/p1788/infsup/base_interval.hpp +1529 -0
- data/ext/libieeep1788_copy/p1788/infsup/base_interval_bool_func_impl.hpp +481 -0
- data/ext/libieeep1788_copy/p1788/infsup/base_interval_cancel_func_impl.hpp +126 -0
- data/ext/libieeep1788_copy/p1788/infsup/base_interval_elem_func_impl.hpp +1581 -0
- data/ext/libieeep1788_copy/p1788/infsup/base_interval_io_impl.hpp +59 -0
- data/ext/libieeep1788_copy/p1788/infsup/base_interval_mul_rev_to_pair_func_impl.hpp +88 -0
- data/ext/libieeep1788_copy/p1788/infsup/base_interval_num_func_impl.hpp +345 -0
- data/ext/libieeep1788_copy/p1788/infsup/base_interval_rec_bool_func_impl.hpp +92 -0
- data/ext/libieeep1788_copy/p1788/infsup/base_interval_rec_overlap_impl.hpp +72 -0
- data/ext/libieeep1788_copy/p1788/infsup/base_interval_rev_func_impl.hpp +656 -0
- data/ext/libieeep1788_copy/p1788/infsup/base_interval_set_op_impl.hpp +126 -0
- data/ext/libieeep1788_copy/p1788/infsup/decorated_interval.hpp +464 -0
- data/ext/libieeep1788_copy/p1788/infsup/forward_declaration.hpp +66 -0
- data/ext/libieeep1788_copy/p1788/infsup/interval.hpp +275 -0
- data/ext/libieeep1788_copy/p1788/io/io_manip.hpp +531 -0
- data/ext/libieeep1788_copy/p1788/overlapping/overlapping.hpp +241 -0
- data/ext/libieeep1788_copy/p1788/p1788.hpp +45 -0
- data/ext/libieeep1788_copy/p1788/reduction/reduction.hpp +341 -0
- data/ext/libieeep1788_copy/p1788/util/io.hpp +63 -0
- data/ext/libieeep1788_copy/p1788/util/mixed_type_traits.hpp +140 -0
- data/ext/libieeep1788_copy/p1788/util/mpfr_util.hpp +77 -0
- data/ext/libieeep1788_copy/p1788/util/mpfr_var.hpp +119 -0
- data/ext/libieeep1788_copy/p1788/util/mpfr_var_impl.hpp +382 -0
- data/ext/libieeep1788_copy/p1788/version.hpp +34 -0
- data/ext/p1788/extconf.rb +49 -0
- data/ext/p1788/p1788.cc +3764 -0
- data/lib/p1788/version.rb +4 -0
- data/lib/p1788.rb +25 -0
- data/p1788.gemspec +72 -0
- metadata +99 -0
@@ -0,0 +1,347 @@
|
|
1
|
+
//
|
2
|
+
// libieeep1788
|
3
|
+
//
|
4
|
+
// An implementation of the preliminary IEEE P1788 standard for
|
5
|
+
// interval arithmetic
|
6
|
+
//
|
7
|
+
//
|
8
|
+
// Copyright 2013 - 2015
|
9
|
+
//
|
10
|
+
// Marco Nehmeier (nehmeier@informatik.uni-wuerzburg.de)
|
11
|
+
// Department of Computer Science,
|
12
|
+
// University of Wuerzburg, Germany
|
13
|
+
//
|
14
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
15
|
+
// you may not use this file except in compliance with the License.
|
16
|
+
// You may obtain a copy of the License at
|
17
|
+
//
|
18
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
19
|
+
//
|
20
|
+
// Unless required by applicable law or agreed to in writing, software
|
21
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
22
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
23
|
+
// See the License for the specific language governing permissions and
|
24
|
+
// limitations under the License.
|
25
|
+
|
26
|
+
#ifndef LIBIEEEP1788_P1788_FLAVOR_INFSUP_SETBASED_MPFR_BIN_IEEE754_FLAVOR_MUL_REV_TO_PAIR_FUNC_IMPL_HPP
|
27
|
+
#define LIBIEEEP1788_P1788_FLAVOR_INFSUP_SETBASED_MPFR_BIN_IEEE754_FLAVOR_MUL_REV_TO_PAIR_FUNC_IMPL_HPP
|
28
|
+
|
29
|
+
namespace p1788
|
30
|
+
{
|
31
|
+
|
32
|
+
namespace flavor
|
33
|
+
{
|
34
|
+
|
35
|
+
namespace infsup
|
36
|
+
{
|
37
|
+
|
38
|
+
namespace setbased
|
39
|
+
{
|
40
|
+
|
41
|
+
|
42
|
+
// mul_rev_to_pair ( bare interval ) private
|
43
|
+
template<typename T>
|
44
|
+
std::pair<typename mpfr_bin_ieee754_flavor<T>::representation, typename mpfr_bin_ieee754_flavor<T>::representation>
|
45
|
+
mpfr_bin_ieee754_flavor<T>::mul_rev_to_pair(int& t_fl, int& t_fu, int& t_sl, int& t_su,
|
46
|
+
mpfr_bin_ieee754_flavor<T>::representation const& b,
|
47
|
+
mpfr_bin_ieee754_flavor<T>::representation const& c)
|
48
|
+
{
|
49
|
+
t_fl = t_fu = t_sl = t_su = 0;
|
50
|
+
if (!is_valid(b) || !is_valid(c) || is_empty(b) || is_empty(c))
|
51
|
+
return std::pair<representation, representation>(empty(), empty());
|
52
|
+
|
53
|
+
// c = [-oo,+oo]
|
54
|
+
if (is_entire(c))
|
55
|
+
return std::pair<representation, representation>(entire(), empty()); // ([-oo,+oo], empty)
|
56
|
+
|
57
|
+
|
58
|
+
// c = [0,0]
|
59
|
+
if (c.first == 0.0 && c.second == 0.0)
|
60
|
+
return std::pair<representation, representation>(is_member(0.0, b) ? entire() : representation(0.0, 0.0),
|
61
|
+
empty());
|
62
|
+
|
63
|
+
|
64
|
+
mpfr_var::setup();
|
65
|
+
|
66
|
+
mpfr_var bl(b.first, MPFR_RNDD);
|
67
|
+
mpfr_var bu(b.second, MPFR_RNDU);
|
68
|
+
|
69
|
+
mpfr_var cl(c.first, MPFR_RNDD);
|
70
|
+
mpfr_var cu(c.second, MPFR_RNDU);
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
// c <= 0
|
75
|
+
if (c.second <= 0.0)
|
76
|
+
{
|
77
|
+
// b = [0,0]
|
78
|
+
if (b.first == 0.0 && b.second == 0.0)
|
79
|
+
return std::pair<representation, representation>(is_member(0.0, c) ? entire() : empty(),
|
80
|
+
empty());
|
81
|
+
|
82
|
+
// b contains 0 interior and c < 0 => return pair
|
83
|
+
if (b.first < 0.0 && b.second > 0.0 && c.second < 0.0)
|
84
|
+
{
|
85
|
+
mpfr_var f_u;
|
86
|
+
mpfr_var s_l;
|
87
|
+
|
88
|
+
t_fu = f_u.subnormalize(mpfr_div(f_u(), cu(), bu(), MPFR_RNDU), MPFR_RNDU);
|
89
|
+
t_sl = s_l.subnormalize(mpfr_div(s_l(), cu(), bl(), MPFR_RNDD), MPFR_RNDD);
|
90
|
+
|
91
|
+
return std::pair<representation, representation>(representation(-std::numeric_limits<T>::infinity(), f_u.template get<T>(MPFR_RNDU)),
|
92
|
+
representation(s_l.template get<T>(MPFR_RNDD), std::numeric_limits<T>::infinity()));
|
93
|
+
}
|
94
|
+
|
95
|
+
// b < 0.0
|
96
|
+
if (b.second < 0.0)
|
97
|
+
{
|
98
|
+
mpfr_var l;
|
99
|
+
mpfr_var u;
|
100
|
+
|
101
|
+
t_fl = l.subnormalize(mpfr_div(l(), cu(), bl(), MPFR_RNDD), MPFR_RNDD);
|
102
|
+
t_fu = u.subnormalize(mpfr_div(u(), cl(), bu(), MPFR_RNDU), MPFR_RNDU);
|
103
|
+
|
104
|
+
return std::pair<representation, representation>(representation(l.template get<T>(MPFR_RNDD), u.template get<T>(MPFR_RNDU)), empty());
|
105
|
+
}
|
106
|
+
|
107
|
+
// b = [x,0] and c < 0
|
108
|
+
if (b.second == 0.0 && c.second < 0.0)
|
109
|
+
{
|
110
|
+
mpfr_var l;
|
111
|
+
t_fl = l.subnormalize(mpfr_div(l(), cu(), bl(), MPFR_RNDD), MPFR_RNDD);
|
112
|
+
|
113
|
+
return std::pair<representation, representation>(representation(l.template get<T>(MPFR_RNDD), std::numeric_limits<T>::infinity()), empty());
|
114
|
+
}
|
115
|
+
|
116
|
+
|
117
|
+
// b > 0.0
|
118
|
+
if (b.first > 0.0)
|
119
|
+
{
|
120
|
+
mpfr_var l;
|
121
|
+
mpfr_var u;
|
122
|
+
|
123
|
+
t_fl = l.subnormalize(mpfr_div(l(), cl(), bl(), MPFR_RNDD), MPFR_RNDD);
|
124
|
+
t_fu = u.subnormalize(mpfr_div(u(), cu(), bu(), MPFR_RNDU), MPFR_RNDU);
|
125
|
+
|
126
|
+
return std::pair<representation, representation>(representation(l.template get<T>(MPFR_RNDD), u.template get<T>(MPFR_RNDU)), empty());
|
127
|
+
}
|
128
|
+
|
129
|
+
// b = [0,x] and c < 0
|
130
|
+
if (b.first == 0.0 && c.second < 0.0)
|
131
|
+
{
|
132
|
+
mpfr_var u;
|
133
|
+
t_fu = u.subnormalize(mpfr_div(u(), cu(), bu(), MPFR_RNDU), MPFR_RNDU);
|
134
|
+
|
135
|
+
return std::pair<representation, representation>(representation(-std::numeric_limits<T>::infinity(), u.template get<T>(MPFR_RNDU)), empty());
|
136
|
+
}
|
137
|
+
|
138
|
+
return std::pair<representation, representation>(entire(), empty());
|
139
|
+
|
140
|
+
} // c >= 0
|
141
|
+
else if (c.first >= 0.0)
|
142
|
+
{
|
143
|
+
// b = [0,0]
|
144
|
+
if (b.first == 0.0 && b.second == 0.0)
|
145
|
+
return std::pair<representation, representation>(is_member(0.0, c) ? entire() : empty(),
|
146
|
+
empty());
|
147
|
+
|
148
|
+
|
149
|
+
// b contains 0 interior and c > 0 => return pair
|
150
|
+
if (b.first < 0.0 && b.second > 0.0 && c.first > 0.0)
|
151
|
+
{
|
152
|
+
mpfr_var f_u;
|
153
|
+
mpfr_var s_l;
|
154
|
+
|
155
|
+
t_fu = f_u.subnormalize(mpfr_div(f_u(), cl(), bl(), MPFR_RNDU), MPFR_RNDU);
|
156
|
+
t_sl = s_l.subnormalize(mpfr_div(s_l(), cl(), bu(), MPFR_RNDD), MPFR_RNDD);
|
157
|
+
|
158
|
+
return std::pair<representation, representation>(representation(-std::numeric_limits<T>::infinity(), f_u.template get<T>(MPFR_RNDU)),
|
159
|
+
representation(s_l.template get<T>(MPFR_RNDD), std::numeric_limits<T>::infinity()));
|
160
|
+
}
|
161
|
+
|
162
|
+
|
163
|
+
// b < 0.0
|
164
|
+
if (b.second < 0.0)
|
165
|
+
{
|
166
|
+
mpfr_var l;
|
167
|
+
mpfr_var u;
|
168
|
+
|
169
|
+
t_fl = l.subnormalize(mpfr_div(l(), cu(), bu(), MPFR_RNDD), MPFR_RNDD);
|
170
|
+
t_fu = u.subnormalize(mpfr_div(u(), cl(), bl(), MPFR_RNDU), MPFR_RNDU);
|
171
|
+
|
172
|
+
return std::pair<representation, representation>(representation(l.template get<T>(MPFR_RNDD), u.template get<T>(MPFR_RNDU)), empty());
|
173
|
+
}
|
174
|
+
|
175
|
+
// b = [x,0] and c > 0
|
176
|
+
if (b.second == 0.0 && c.first > 0.0)
|
177
|
+
{
|
178
|
+
mpfr_var u;
|
179
|
+
t_fu = u.subnormalize(mpfr_div(u(), cl(), bl(), MPFR_RNDU), MPFR_RNDU);
|
180
|
+
|
181
|
+
return std::pair<representation, representation>(representation(-std::numeric_limits<T>::infinity(), u.template get<T>(MPFR_RNDU)), empty());
|
182
|
+
}
|
183
|
+
|
184
|
+
|
185
|
+
// b > 0.0
|
186
|
+
if (b.first > 0.0)
|
187
|
+
{
|
188
|
+
mpfr_var l;
|
189
|
+
mpfr_var u;
|
190
|
+
|
191
|
+
t_fl = l.subnormalize(mpfr_div(l(), cl(), bu(), MPFR_RNDD), MPFR_RNDD);
|
192
|
+
t_fu = u.subnormalize(mpfr_div(u(), cu(), bl(), MPFR_RNDU), MPFR_RNDU);
|
193
|
+
|
194
|
+
return std::pair<representation, representation>(representation(l.template get<T>(MPFR_RNDD), u.template get<T>(MPFR_RNDU)), empty());
|
195
|
+
}
|
196
|
+
|
197
|
+
// b = [0,x] and c > 0
|
198
|
+
if (b.first == 0.0 && c.first > 0.0)
|
199
|
+
{
|
200
|
+
mpfr_var l;
|
201
|
+
t_fl = l.subnormalize(mpfr_div(l(), cl(), bu(), MPFR_RNDD), MPFR_RNDD);
|
202
|
+
|
203
|
+
return std::pair<representation, representation>(representation(l.template get<T>(MPFR_RNDD), std::numeric_limits<T>::infinity()), empty());
|
204
|
+
}
|
205
|
+
|
206
|
+
return std::pair<representation, representation>(entire(), empty());
|
207
|
+
}
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
// c contains 0
|
212
|
+
|
213
|
+
// b = [0,0]
|
214
|
+
if (b.first == 0.0 && b.second == 0.0)
|
215
|
+
return std::pair<representation, representation>(entire(), empty());
|
216
|
+
|
217
|
+
|
218
|
+
// b < 0
|
219
|
+
if (b.second < 0.0)
|
220
|
+
{
|
221
|
+
mpfr_var l;
|
222
|
+
mpfr_var u;
|
223
|
+
|
224
|
+
t_fl = l.subnormalize(mpfr_div(l(), cu(), bu(), MPFR_RNDD), MPFR_RNDD);
|
225
|
+
t_fu = u.subnormalize(mpfr_div(u(), cl(), bu(), MPFR_RNDU), MPFR_RNDU);
|
226
|
+
|
227
|
+
return std::pair<representation, representation>(representation(l.template get<T>(MPFR_RNDD), u.template get<T>(MPFR_RNDU)),
|
228
|
+
empty());
|
229
|
+
}
|
230
|
+
|
231
|
+
// b > 0
|
232
|
+
if (b.first > 0.0)
|
233
|
+
{
|
234
|
+
mpfr_var l;
|
235
|
+
mpfr_var u;
|
236
|
+
|
237
|
+
t_fl = l.subnormalize(mpfr_div(l(), cl(), bl(), MPFR_RNDD), MPFR_RNDD);
|
238
|
+
t_fu = u.subnormalize(mpfr_div(u(), cu(), bl(), MPFR_RNDU), MPFR_RNDU);
|
239
|
+
|
240
|
+
return std::pair<representation, representation>(representation(l.template get<T>(MPFR_RNDD), u.template get<T>(MPFR_RNDU)),
|
241
|
+
empty());
|
242
|
+
}
|
243
|
+
|
244
|
+
return std::pair<representation, representation>(entire(), empty());
|
245
|
+
}
|
246
|
+
|
247
|
+
// mul_rev_to_pair ( bare interval )
|
248
|
+
template<typename T>
|
249
|
+
std::pair<typename mpfr_bin_ieee754_flavor<T>::representation, typename mpfr_bin_ieee754_flavor<T>::representation>
|
250
|
+
mpfr_bin_ieee754_flavor<T>::mul_rev_to_pair(mpfr_bin_ieee754_flavor<T>::representation const& b,
|
251
|
+
mpfr_bin_ieee754_flavor<T>::representation const& c)
|
252
|
+
{
|
253
|
+
int t_fl, t_fu, t_sl, t_su;
|
254
|
+
return mul_rev_to_pair(t_fl, t_fu, t_sl, t_su, b, c);
|
255
|
+
}
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
// mul_rev_to_pair ( bare interval ) mixed type
|
260
|
+
template<typename T>
|
261
|
+
template<typename T1, typename T2>
|
262
|
+
std::pair<typename mpfr_bin_ieee754_flavor<T>::representation, typename mpfr_bin_ieee754_flavor<T>::representation>
|
263
|
+
mpfr_bin_ieee754_flavor<T>::mul_rev_to_pair(mpfr_bin_ieee754_flavor<T>::representation_type<T1> const& b,
|
264
|
+
mpfr_bin_ieee754_flavor<T>::representation_type<T2> const& c)
|
265
|
+
{
|
266
|
+
static_assert(std::numeric_limits<T1>::is_iec559, "Only IEEE 754 binary compliant types are supported!");
|
267
|
+
static_assert(std::numeric_limits<T2>::is_iec559, "Only IEEE 754 binary compliant types are supported!");
|
268
|
+
|
269
|
+
if (!mpfr_bin_ieee754_flavor<T1>::is_valid(b) || !mpfr_bin_ieee754_flavor<T2>::is_valid(c))
|
270
|
+
std::pair<representation, representation>(empty(), empty());
|
271
|
+
|
272
|
+
// determine max. precision
|
273
|
+
typedef typename p1788::util::max_precision_type<T,T1,T2>::type T_MAX;
|
274
|
+
|
275
|
+
// 1.) convert inputs to max precision; 2.) compute result in max precision;
|
276
|
+
auto res = mpfr_bin_ieee754_flavor<T_MAX>::mul_rev_to_pair(
|
277
|
+
mpfr_bin_ieee754_flavor<T_MAX>::convert_hull(b),
|
278
|
+
mpfr_bin_ieee754_flavor<T_MAX>::convert_hull(c)
|
279
|
+
);
|
280
|
+
|
281
|
+
// 3.) convert result to desired precision
|
282
|
+
// Error free for floating point inf-sup intervals due to outward rounding
|
283
|
+
return std::pair<representation, representation>(convert_hull(res.first), convert_hull(res.second));
|
284
|
+
}
|
285
|
+
|
286
|
+
|
287
|
+
// mul_rev_to_pair ( decorated interval )
|
288
|
+
template<typename T>
|
289
|
+
std::pair<typename mpfr_bin_ieee754_flavor<T>::representation_dec, typename mpfr_bin_ieee754_flavor<T>::representation_dec>
|
290
|
+
mpfr_bin_ieee754_flavor<T>::mul_rev_to_pair(mpfr_bin_ieee754_flavor<T>::representation_dec const& b,
|
291
|
+
mpfr_bin_ieee754_flavor<T>::representation_dec const& c)
|
292
|
+
{
|
293
|
+
if (!is_valid(b) || !is_valid(c) || is_nai(b) || is_nai(c))
|
294
|
+
return std::pair<representation_dec, representation_dec>(nai(), nai());
|
295
|
+
|
296
|
+
// compute bare result
|
297
|
+
auto bare = mul_rev_to_pair(b.first, c.first);
|
298
|
+
|
299
|
+
// compute decoration
|
300
|
+
p1788::decoration::decoration dec = std::min(
|
301
|
+
std::min(b.second, c.second),
|
302
|
+
is_member(0.0, b) || is_empty(bare.first) ? p1788::decoration::decoration::trv :
|
303
|
+
is_common_interval(bare.first) ? p1788::decoration::decoration::com :
|
304
|
+
p1788::decoration::decoration::dac);
|
305
|
+
|
306
|
+
return std::pair<representation_dec, representation_dec>(representation_dec(bare.first, dec), representation_dec(bare.second, p1788::decoration::decoration::trv));
|
307
|
+
}
|
308
|
+
|
309
|
+
// mul_rev_to_pair ( decorated interval ) mixed type
|
310
|
+
template<typename T>
|
311
|
+
template<typename T1, typename T2>
|
312
|
+
std::pair<typename mpfr_bin_ieee754_flavor<T>::representation_dec, typename mpfr_bin_ieee754_flavor<T>::representation_dec>
|
313
|
+
mpfr_bin_ieee754_flavor<T>::mul_rev_to_pair(mpfr_bin_ieee754_flavor<T>::representation_dec_type<T1> const& b,
|
314
|
+
mpfr_bin_ieee754_flavor<T>::representation_dec_type<T2> const& c)
|
315
|
+
{
|
316
|
+
static_assert(std::numeric_limits<T1>::is_iec559, "Only IEEE 754 binary compliant types are supported!");
|
317
|
+
static_assert(std::numeric_limits<T2>::is_iec559, "Only IEEE 754 binary compliant types are supported!");
|
318
|
+
|
319
|
+
if (!mpfr_bin_ieee754_flavor<T1>::is_valid(b) || !mpfr_bin_ieee754_flavor<T2>::is_valid(c)
|
320
|
+
|| mpfr_bin_ieee754_flavor<T1>::is_nai(b) || mpfr_bin_ieee754_flavor<T2>::is_nai(c))
|
321
|
+
std::pair<representation_dec, representation_dec>(nai(), nai());
|
322
|
+
|
323
|
+
// determine max. precision
|
324
|
+
typedef typename p1788::util::max_precision_type<T,T1,T2>::type T_MAX;
|
325
|
+
|
326
|
+
// 1.) convert inputs to max precision; 2.) compute result in max precision;
|
327
|
+
auto res = mpfr_bin_ieee754_flavor<T_MAX>::mul_rev_to_pair(
|
328
|
+
mpfr_bin_ieee754_flavor<T_MAX>::convert_hull(b),
|
329
|
+
mpfr_bin_ieee754_flavor<T_MAX>::convert_hull(c)
|
330
|
+
);
|
331
|
+
|
332
|
+
// 3.) convert result to desired precision
|
333
|
+
// Error free for floating point inf-sup intervals due to outward rounding
|
334
|
+
return std::pair<representation_dec, representation_dec>(convert_hull(res.first), convert_hull(res.second));
|
335
|
+
}
|
336
|
+
|
337
|
+
|
338
|
+
} // namespace setbased
|
339
|
+
|
340
|
+
} // namespace infsup
|
341
|
+
|
342
|
+
} // namespace flavor
|
343
|
+
|
344
|
+
} // namespace p1788
|
345
|
+
|
346
|
+
|
347
|
+
#endif // LIBIEEEP1788_P1788_FLAVOR_INFSUP_SETBASED_MPFR_BIN_IEEE754_FLAVOR_MUL_REV_TO_PAIR_FUNC_IMPL_HPP
|