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
data/ext/libieeep1788_copy/p1788/flavor/infsup/setbased/mpfr_bin_ieee754_flavor_class_impl.hpp
ADDED
@@ -0,0 +1,526 @@
|
|
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_CLASS_IMPL_HPP
|
27
|
+
#define LIBIEEEP1788_P1788_FLAVOR_INFSUP_SETBASED_MPFR_BIN_IEEE754_FLAVOR_CLASS_IMPL_HPP
|
28
|
+
|
29
|
+
|
30
|
+
namespace p1788
|
31
|
+
{
|
32
|
+
|
33
|
+
namespace flavor
|
34
|
+
{
|
35
|
+
|
36
|
+
namespace infsup
|
37
|
+
{
|
38
|
+
|
39
|
+
namespace setbased
|
40
|
+
{
|
41
|
+
|
42
|
+
|
43
|
+
// -----------------------------------------------------------------------------
|
44
|
+
// Interval constants
|
45
|
+
// -----------------------------------------------------------------------------
|
46
|
+
|
47
|
+
// empty bare interval
|
48
|
+
template<typename T>
|
49
|
+
typename mpfr_bin_ieee754_flavor<T>::representation
|
50
|
+
mpfr_bin_ieee754_flavor<T>::empty()
|
51
|
+
{
|
52
|
+
return representation(std::numeric_limits<T>::quiet_NaN(),
|
53
|
+
std::numeric_limits<T>::quiet_NaN());
|
54
|
+
}
|
55
|
+
|
56
|
+
// empty decorated interval
|
57
|
+
template<typename T>
|
58
|
+
typename mpfr_bin_ieee754_flavor<T>::representation_dec
|
59
|
+
mpfr_bin_ieee754_flavor<T>::empty_dec()
|
60
|
+
{
|
61
|
+
return representation_dec(representation(std::numeric_limits<T>::quiet_NaN(),
|
62
|
+
std::numeric_limits<T>::quiet_NaN()), p1788::decoration::decoration::trv);
|
63
|
+
}
|
64
|
+
|
65
|
+
// entire bare interval
|
66
|
+
template<typename T>
|
67
|
+
typename mpfr_bin_ieee754_flavor<T>::representation
|
68
|
+
mpfr_bin_ieee754_flavor<T>::entire()
|
69
|
+
{
|
70
|
+
return representation(-std::numeric_limits<T>::infinity(),
|
71
|
+
std::numeric_limits<T>::infinity());
|
72
|
+
}
|
73
|
+
|
74
|
+
// entire decorated interval
|
75
|
+
template<typename T>
|
76
|
+
typename mpfr_bin_ieee754_flavor<T>::representation_dec
|
77
|
+
mpfr_bin_ieee754_flavor<T>::entire_dec()
|
78
|
+
{
|
79
|
+
return representation_dec(representation(-std::numeric_limits<T>::infinity(),
|
80
|
+
std::numeric_limits<T>::infinity()), p1788::decoration::decoration::dac);
|
81
|
+
}
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
// nai decorated interval
|
86
|
+
template<typename T>
|
87
|
+
typename mpfr_bin_ieee754_flavor<T>::representation_dec
|
88
|
+
mpfr_bin_ieee754_flavor<T>::nai()
|
89
|
+
{
|
90
|
+
return representation_dec(representation(std::numeric_limits<T>::quiet_NaN(),
|
91
|
+
std::numeric_limits<T>::quiet_NaN()), p1788::decoration::decoration::ill);
|
92
|
+
}
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
// -----------------------------------------------------------------------------
|
97
|
+
// Constructors
|
98
|
+
// -----------------------------------------------------------------------------
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
// bare inf-sup interval
|
104
|
+
template<typename T>
|
105
|
+
typename mpfr_bin_ieee754_flavor<T>::representation
|
106
|
+
mpfr_bin_ieee754_flavor<T>::nums_to_interval(T lower, T upper)
|
107
|
+
{
|
108
|
+
// Comparison with NaN is always false!
|
109
|
+
if (lower <= upper
|
110
|
+
&& lower != std::numeric_limits<T>::infinity()
|
111
|
+
&& upper != -std::numeric_limits<T>::infinity())
|
112
|
+
{
|
113
|
+
return representation(lower, upper);
|
114
|
+
}
|
115
|
+
else
|
116
|
+
{
|
117
|
+
p1788::exception::signal_undefined_operation();
|
118
|
+
return empty();
|
119
|
+
}
|
120
|
+
}
|
121
|
+
|
122
|
+
// decorated inf-sup interval
|
123
|
+
template<typename T>
|
124
|
+
typename mpfr_bin_ieee754_flavor<T>::representation_dec
|
125
|
+
mpfr_bin_ieee754_flavor<T>::nums_to_decorated_interval(T lower, T upper)
|
126
|
+
{
|
127
|
+
// Comparison with NaN is always false!
|
128
|
+
if (lower <= upper
|
129
|
+
&& lower != std::numeric_limits<T>::infinity()
|
130
|
+
&& upper != -std::numeric_limits<T>::infinity())
|
131
|
+
{
|
132
|
+
return new_dec(representation(lower,upper));
|
133
|
+
}
|
134
|
+
else
|
135
|
+
{
|
136
|
+
p1788::exception::signal_undefined_operation();
|
137
|
+
return nai();
|
138
|
+
}
|
139
|
+
}
|
140
|
+
|
141
|
+
// bare inf-sup interval mixed type
|
142
|
+
template<typename T>
|
143
|
+
template<typename L_, typename U_>
|
144
|
+
typename mpfr_bin_ieee754_flavor<T>::representation
|
145
|
+
mpfr_bin_ieee754_flavor<T>::nums_to_interval(L_ lower, U_ upper)
|
146
|
+
{
|
147
|
+
static_assert(std::numeric_limits<L_>::is_iec559, "Only IEEE 754 binary compliant types are supported!");
|
148
|
+
static_assert(std::numeric_limits<U_>::is_iec559, "Only IEEE 754 binary compliant types are supported!");
|
149
|
+
|
150
|
+
// Comparison with NaN is always false!
|
151
|
+
if (lower <= upper
|
152
|
+
&& lower != std::numeric_limits<L_>::infinity()
|
153
|
+
&& upper != -std::numeric_limits<U_>::infinity())
|
154
|
+
{
|
155
|
+
return representation(convert_rndd(lower), convert_rndu(upper));
|
156
|
+
}
|
157
|
+
else
|
158
|
+
{
|
159
|
+
p1788::exception::signal_undefined_operation();
|
160
|
+
return empty();
|
161
|
+
}
|
162
|
+
}
|
163
|
+
|
164
|
+
// decorated inf-sup interval mixed type
|
165
|
+
template<typename T>
|
166
|
+
template<typename L_, typename U_>
|
167
|
+
typename mpfr_bin_ieee754_flavor<T>::representation_dec
|
168
|
+
mpfr_bin_ieee754_flavor<T>::nums_to_decorated_interval(L_ lower, U_ upper)
|
169
|
+
{
|
170
|
+
static_assert(std::numeric_limits<L_>::is_iec559, "Only IEEE 754 binary compliant types are supported!");
|
171
|
+
static_assert(std::numeric_limits<U_>::is_iec559, "Only IEEE 754 binary compliant types are supported!");
|
172
|
+
|
173
|
+
// Comparison with NaN is always false!
|
174
|
+
if (lower <= upper
|
175
|
+
&& lower != std::numeric_limits<L_>::infinity()
|
176
|
+
&& upper != -std::numeric_limits<U_>::infinity())
|
177
|
+
{
|
178
|
+
return new_dec(representation(convert_rndd(lower), convert_rndu(upper)));
|
179
|
+
}
|
180
|
+
else
|
181
|
+
{
|
182
|
+
p1788::exception::signal_undefined_operation();
|
183
|
+
return nai();
|
184
|
+
}
|
185
|
+
}
|
186
|
+
|
187
|
+
|
188
|
+
// decorated inf-sup-dec interval
|
189
|
+
template<typename T>
|
190
|
+
typename mpfr_bin_ieee754_flavor<T>::representation_dec
|
191
|
+
mpfr_bin_ieee754_flavor<T>::nums_dec_to_decorated_interval(T lower, T upper, p1788::decoration::decoration dec)
|
192
|
+
{
|
193
|
+
if (p1788::decoration::is_valid(dec))
|
194
|
+
{
|
195
|
+
// Comparison with NaN is always false!
|
196
|
+
if (dec != p1788::decoration::decoration::ill
|
197
|
+
&& (lower <= upper
|
198
|
+
&& lower != std::numeric_limits<T>::infinity()
|
199
|
+
&& upper != -std::numeric_limits<T>::infinity()
|
200
|
+
&& (dec != p1788::decoration::decoration::com
|
201
|
+
|| (lower != -std::numeric_limits<T>::infinity()
|
202
|
+
&& upper != std::numeric_limits<T>::infinity()))
|
203
|
+
)
|
204
|
+
)
|
205
|
+
{
|
206
|
+
return representation_dec(representation(lower,upper), dec);
|
207
|
+
}
|
208
|
+
else
|
209
|
+
{
|
210
|
+
p1788::exception::signal_undefined_operation();
|
211
|
+
}
|
212
|
+
}
|
213
|
+
|
214
|
+
return nai();
|
215
|
+
}
|
216
|
+
|
217
|
+
|
218
|
+
// decorated inf-sup-dec interval mixed type
|
219
|
+
template<typename T>
|
220
|
+
template<typename L_, typename U_>
|
221
|
+
typename mpfr_bin_ieee754_flavor<T>::representation_dec
|
222
|
+
mpfr_bin_ieee754_flavor<T>::nums_dec_to_decorated_interval(L_ lower, U_ upper, p1788::decoration::decoration dec)
|
223
|
+
{
|
224
|
+
static_assert(std::numeric_limits<L_>::is_iec559, "Only IEEE 754 binary compliant types are supported!");
|
225
|
+
static_assert(std::numeric_limits<U_>::is_iec559, "Only IEEE 754 binary compliant types are supported!");
|
226
|
+
|
227
|
+
if (p1788::decoration::is_valid(dec))
|
228
|
+
{
|
229
|
+
// Comparison with NaN is always false!
|
230
|
+
if (dec != p1788::decoration::decoration::ill
|
231
|
+
&& (lower <= upper
|
232
|
+
&& lower != std::numeric_limits<L_>::infinity()
|
233
|
+
&& upper != -std::numeric_limits<U_>::infinity()
|
234
|
+
&& (dec != p1788::decoration::decoration::com
|
235
|
+
|| (lower != -std::numeric_limits<L_>::infinity()
|
236
|
+
&& upper != std::numeric_limits<U_>::infinity()))
|
237
|
+
)
|
238
|
+
)
|
239
|
+
{
|
240
|
+
representation tmp(convert_rndd(lower), convert_rndu(upper));
|
241
|
+
return representation_dec(tmp,
|
242
|
+
std::min(dec,
|
243
|
+
std::isinf(tmp.first) || std::isinf(tmp.second)
|
244
|
+
? p1788::decoration::decoration::dac
|
245
|
+
: p1788::decoration::decoration::com ));
|
246
|
+
}
|
247
|
+
else
|
248
|
+
{
|
249
|
+
p1788::exception::signal_undefined_operation();
|
250
|
+
}
|
251
|
+
}
|
252
|
+
|
253
|
+
return nai();
|
254
|
+
}
|
255
|
+
|
256
|
+
|
257
|
+
// string literal bare interval
|
258
|
+
template<typename T>
|
259
|
+
typename mpfr_bin_ieee754_flavor<T>::representation
|
260
|
+
mpfr_bin_ieee754_flavor<T>::text_to_interval(std::string const& str)
|
261
|
+
{
|
262
|
+
representation rep;
|
263
|
+
std::istringstream s(str);
|
264
|
+
|
265
|
+
operator_text_to_interval(s, rep);
|
266
|
+
|
267
|
+
if (!s)
|
268
|
+
{
|
269
|
+
p1788::exception::signal_undefined_operation();
|
270
|
+
return empty();
|
271
|
+
}
|
272
|
+
|
273
|
+
char c;
|
274
|
+
while(s.get(c))
|
275
|
+
if (!std::isspace(c))
|
276
|
+
{
|
277
|
+
p1788::exception::signal_undefined_operation();
|
278
|
+
return empty();
|
279
|
+
}
|
280
|
+
|
281
|
+
return rep;
|
282
|
+
}
|
283
|
+
|
284
|
+
// string literal decorated interval
|
285
|
+
template<typename T>
|
286
|
+
typename mpfr_bin_ieee754_flavor<T>::representation_dec
|
287
|
+
mpfr_bin_ieee754_flavor<T>::text_to_decorated_interval(std::string const& str)
|
288
|
+
{
|
289
|
+
representation_dec rep;
|
290
|
+
std::istringstream s(str);
|
291
|
+
|
292
|
+
operator_text_to_interval(s, rep);
|
293
|
+
|
294
|
+
if (!s)
|
295
|
+
{
|
296
|
+
p1788::exception::signal_undefined_operation();
|
297
|
+
return nai();
|
298
|
+
}
|
299
|
+
|
300
|
+
char c;
|
301
|
+
while(s.get(c))
|
302
|
+
if (!std::isspace(c))
|
303
|
+
{
|
304
|
+
p1788::exception::signal_undefined_operation();
|
305
|
+
return nai();
|
306
|
+
}
|
307
|
+
|
308
|
+
return rep;
|
309
|
+
}
|
310
|
+
|
311
|
+
|
312
|
+
// copy constructor bare interval
|
313
|
+
template<typename T>
|
314
|
+
typename mpfr_bin_ieee754_flavor<T>::representation
|
315
|
+
mpfr_bin_ieee754_flavor<T>::copy(representation const& other)
|
316
|
+
{
|
317
|
+
if (!is_valid(other))
|
318
|
+
{
|
319
|
+
return empty();
|
320
|
+
}
|
321
|
+
|
322
|
+
return other;
|
323
|
+
}
|
324
|
+
|
325
|
+
// copy constructor decorated interval
|
326
|
+
template<typename T>
|
327
|
+
typename mpfr_bin_ieee754_flavor<T>::representation_dec
|
328
|
+
mpfr_bin_ieee754_flavor<T>::copy(representation_dec const& other)
|
329
|
+
{
|
330
|
+
if (!is_valid(other))
|
331
|
+
{
|
332
|
+
return nai();
|
333
|
+
}
|
334
|
+
|
335
|
+
return other;
|
336
|
+
}
|
337
|
+
|
338
|
+
|
339
|
+
// -----------------------------------------------------------------------------
|
340
|
+
// Convert
|
341
|
+
// -----------------------------------------------------------------------------
|
342
|
+
|
343
|
+
// convert bare interval mixed type
|
344
|
+
template<typename T>
|
345
|
+
template<typename T_>
|
346
|
+
typename mpfr_bin_ieee754_flavor<T>::representation
|
347
|
+
mpfr_bin_ieee754_flavor<T>::convert_type(representation_type<T_> const& other)
|
348
|
+
{
|
349
|
+
static_assert(std::numeric_limits<T_>::is_iec559, "Only IEEE 754 binary compliant types are supported!");
|
350
|
+
|
351
|
+
if (!mpfr_bin_ieee754_flavor<T_>::is_valid(other))
|
352
|
+
{
|
353
|
+
return empty();
|
354
|
+
}
|
355
|
+
|
356
|
+
return convert_hull(other);
|
357
|
+
}
|
358
|
+
|
359
|
+
// convert decorated interval mixed type
|
360
|
+
template<typename T>
|
361
|
+
template<typename T_>
|
362
|
+
typename mpfr_bin_ieee754_flavor<T>::representation_dec
|
363
|
+
mpfr_bin_ieee754_flavor<T>::convert_type(representation_dec_type<T_> const& other)
|
364
|
+
{
|
365
|
+
static_assert(std::numeric_limits<T_>::is_iec559, "Only IEEE 754 binary compliant types are supported!");
|
366
|
+
|
367
|
+
if (!mpfr_bin_ieee754_flavor<T_>::is_valid(other))
|
368
|
+
{
|
369
|
+
return nai();
|
370
|
+
}
|
371
|
+
|
372
|
+
return convert_hull(other);
|
373
|
+
}
|
374
|
+
|
375
|
+
|
376
|
+
// convert decorated interval -> bare interval
|
377
|
+
template<typename T>
|
378
|
+
typename mpfr_bin_ieee754_flavor<T>::representation
|
379
|
+
mpfr_bin_ieee754_flavor<T>::interval_part(representation_dec const& other)
|
380
|
+
{
|
381
|
+
if (!is_valid(other))
|
382
|
+
{
|
383
|
+
return empty();
|
384
|
+
}
|
385
|
+
else if (is_nai(other))
|
386
|
+
{
|
387
|
+
p1788::exception::signal_interval_part_of_nai();
|
388
|
+
return empty();
|
389
|
+
}
|
390
|
+
|
391
|
+
return other.first;
|
392
|
+
}
|
393
|
+
|
394
|
+
// convert decorated interval -> bare interval mixed type
|
395
|
+
template<typename T>
|
396
|
+
template<typename T_>
|
397
|
+
typename mpfr_bin_ieee754_flavor<T>::representation
|
398
|
+
mpfr_bin_ieee754_flavor<T>::interval_part(representation_dec_type<T_> const& other)
|
399
|
+
{
|
400
|
+
static_assert(std::numeric_limits<T_>::is_iec559, "Only IEEE 754 binary compliant types are supported!");
|
401
|
+
|
402
|
+
if (!mpfr_bin_ieee754_flavor<T_>::is_valid(other))
|
403
|
+
{
|
404
|
+
return empty();
|
405
|
+
}
|
406
|
+
else if (mpfr_bin_ieee754_flavor<T_>::is_nai(other))
|
407
|
+
{
|
408
|
+
p1788::exception::signal_interval_part_of_nai();
|
409
|
+
return empty();
|
410
|
+
}
|
411
|
+
|
412
|
+
return convert_hull(other.first);
|
413
|
+
}
|
414
|
+
|
415
|
+
// convert bare interval -> decorated interval
|
416
|
+
template<typename T>
|
417
|
+
typename mpfr_bin_ieee754_flavor<T>::representation_dec
|
418
|
+
mpfr_bin_ieee754_flavor<T>::new_dec(representation const& other)
|
419
|
+
{
|
420
|
+
if (!is_valid(other))
|
421
|
+
{
|
422
|
+
return nai();
|
423
|
+
}
|
424
|
+
else if (is_empty(other))
|
425
|
+
{
|
426
|
+
return representation_dec(other, p1788::decoration::decoration::trv);
|
427
|
+
}
|
428
|
+
else if (other.first == -std::numeric_limits<T>::infinity() || other.second == std::numeric_limits<T>::infinity())
|
429
|
+
{
|
430
|
+
return representation_dec(other, p1788::decoration::decoration::dac);
|
431
|
+
}
|
432
|
+
else
|
433
|
+
{
|
434
|
+
return representation_dec(other, p1788::decoration::decoration::com);
|
435
|
+
}
|
436
|
+
}
|
437
|
+
|
438
|
+
// convert bare interval -> decorated interval mixed type
|
439
|
+
template<typename T>
|
440
|
+
template<typename T_>
|
441
|
+
typename mpfr_bin_ieee754_flavor<T>::representation_dec
|
442
|
+
mpfr_bin_ieee754_flavor<T>::new_dec(representation_type<T_> const& other)
|
443
|
+
{
|
444
|
+
static_assert(std::numeric_limits<T_>::is_iec559, "Only IEEE 754 binary compliant types are supported!");
|
445
|
+
|
446
|
+
if (!mpfr_bin_ieee754_flavor<T_>::is_valid(other))
|
447
|
+
{
|
448
|
+
return nai();
|
449
|
+
}
|
450
|
+
|
451
|
+
representation r = convert_hull(other);
|
452
|
+
|
453
|
+
if (is_empty(r))
|
454
|
+
{
|
455
|
+
return representation_dec(r, p1788::decoration::decoration::trv);
|
456
|
+
}
|
457
|
+
else if (r.first == -std::numeric_limits<T>::infinity() || r.second == std::numeric_limits<T>::infinity())
|
458
|
+
{
|
459
|
+
return representation_dec(r, p1788::decoration::decoration::dac);
|
460
|
+
}
|
461
|
+
else
|
462
|
+
{
|
463
|
+
return representation_dec(r, p1788::decoration::decoration::com);
|
464
|
+
}
|
465
|
+
}
|
466
|
+
|
467
|
+
// set decoration constructor
|
468
|
+
template<typename T>
|
469
|
+
typename mpfr_bin_ieee754_flavor<T>::representation_dec
|
470
|
+
mpfr_bin_ieee754_flavor<T>::set_dec(representation const& other, p1788::decoration::decoration dec)
|
471
|
+
{
|
472
|
+
if (!p1788::decoration::is_valid(dec) || !is_valid(other) || dec == p1788::decoration::decoration::ill)
|
473
|
+
{
|
474
|
+
return nai();
|
475
|
+
}
|
476
|
+
|
477
|
+
if (is_empty(other))
|
478
|
+
{
|
479
|
+
return empty_dec();
|
480
|
+
}
|
481
|
+
|
482
|
+
if (dec == p1788::decoration::decoration::com
|
483
|
+
&& (other.first == -std::numeric_limits<T>::infinity() || other.second == +std::numeric_limits<T>::infinity()))
|
484
|
+
{
|
485
|
+
return representation_dec(other, p1788::decoration::decoration::dac);
|
486
|
+
}
|
487
|
+
|
488
|
+
return representation_dec(other, dec);
|
489
|
+
}
|
490
|
+
|
491
|
+
// set decoration constructor mixed type
|
492
|
+
template<typename T>
|
493
|
+
template<typename T_>
|
494
|
+
typename mpfr_bin_ieee754_flavor<T>::representation_dec
|
495
|
+
mpfr_bin_ieee754_flavor<T>::set_dec(representation_type<T_> const& other, p1788::decoration::decoration dec)
|
496
|
+
{
|
497
|
+
static_assert(std::numeric_limits<T_>::is_iec559, "Only IEEE 754 binary compliant types are supported!");
|
498
|
+
|
499
|
+
return convert_hull(mpfr_bin_ieee754_flavor<T_>::set_dec(other, dec));
|
500
|
+
}
|
501
|
+
|
502
|
+
|
503
|
+
// get decoration
|
504
|
+
template<typename T>
|
505
|
+
p1788::decoration::decoration
|
506
|
+
mpfr_bin_ieee754_flavor<T>::decoration_part(representation_dec const& other)
|
507
|
+
{
|
508
|
+
if (!is_valid(other))
|
509
|
+
{
|
510
|
+
return p1788::decoration::decoration::ill;
|
511
|
+
}
|
512
|
+
|
513
|
+
return other.second;
|
514
|
+
}
|
515
|
+
|
516
|
+
|
517
|
+
} // namespace setbased
|
518
|
+
|
519
|
+
} // namespace infsup
|
520
|
+
|
521
|
+
} // namespace flavor
|
522
|
+
|
523
|
+
} // namespace p1788
|
524
|
+
|
525
|
+
|
526
|
+
#endif // LIBIEEEP1788_P1788_FLAVOR_INFSUP_SETBASED_MPFR_BIN_IEEE754_FLAVOR_CLASS_IMPL_HPP
|