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.
Files changed (57) hide show
  1. checksums.yaml +7 -0
  2. data/.yardopts +8 -0
  3. data/AUTHORS +6 -0
  4. data/LICENSE +201 -0
  5. data/NOTICE +29 -0
  6. data/README.md +65 -0
  7. data/ext/libieeep1788_copy/README +3 -0
  8. data/ext/libieeep1788_copy/p1788/AUTHORS +16 -0
  9. data/ext/libieeep1788_copy/p1788/LICENSE +202 -0
  10. data/ext/libieeep1788_copy/p1788/NOTICE +14 -0
  11. data/ext/libieeep1788_copy/p1788/decoration/decoration.hpp +265 -0
  12. data/ext/libieeep1788_copy/p1788/exception/exception.hpp +302 -0
  13. data/ext/libieeep1788_copy/p1788/flavor/infsup/setbased/mpfr_bin_ieee754_flavor.hpp +3443 -0
  14. data/ext/libieeep1788_copy/p1788/flavor/infsup/setbased/mpfr_bin_ieee754_flavor_bool_func_impl.hpp +608 -0
  15. data/ext/libieeep1788_copy/p1788/flavor/infsup/setbased/mpfr_bin_ieee754_flavor_cancel_func_impl.hpp +229 -0
  16. data/ext/libieeep1788_copy/p1788/flavor/infsup/setbased/mpfr_bin_ieee754_flavor_class_impl.hpp +526 -0
  17. data/ext/libieeep1788_copy/p1788/flavor/infsup/setbased/mpfr_bin_ieee754_flavor_elem_func_impl.hpp +4533 -0
  18. data/ext/libieeep1788_copy/p1788/flavor/infsup/setbased/mpfr_bin_ieee754_flavor_io_impl.hpp +1421 -0
  19. data/ext/libieeep1788_copy/p1788/flavor/infsup/setbased/mpfr_bin_ieee754_flavor_mul_rev_to_pair_func_impl.hpp +347 -0
  20. data/ext/libieeep1788_copy/p1788/flavor/infsup/setbased/mpfr_bin_ieee754_flavor_num_func_impl.hpp +655 -0
  21. data/ext/libieeep1788_copy/p1788/flavor/infsup/setbased/mpfr_bin_ieee754_flavor_rec_bool_func_impl.hpp +146 -0
  22. data/ext/libieeep1788_copy/p1788/flavor/infsup/setbased/mpfr_bin_ieee754_flavor_rec_overlap_impl.hpp +188 -0
  23. data/ext/libieeep1788_copy/p1788/flavor/infsup/setbased/mpfr_bin_ieee754_flavor_rev_func_impl.hpp +1674 -0
  24. data/ext/libieeep1788_copy/p1788/flavor/infsup/setbased/mpfr_bin_ieee754_flavor_set_op_impl.hpp +216 -0
  25. data/ext/libieeep1788_copy/p1788/flavor/infsup/setbased/mpfr_bin_ieee754_flavor_setup_func_impl.hpp +68 -0
  26. data/ext/libieeep1788_copy/p1788/flavor/infsup/setbased/mpfr_bin_ieee754_flavor_util_func_impl.hpp +135 -0
  27. data/ext/libieeep1788_copy/p1788/flavor/infsup/setbased/mpfr_bin_ieee754_flavor_validation_func_impl.hpp +93 -0
  28. data/ext/libieeep1788_copy/p1788/infsup/base_interval.hpp +1529 -0
  29. data/ext/libieeep1788_copy/p1788/infsup/base_interval_bool_func_impl.hpp +481 -0
  30. data/ext/libieeep1788_copy/p1788/infsup/base_interval_cancel_func_impl.hpp +126 -0
  31. data/ext/libieeep1788_copy/p1788/infsup/base_interval_elem_func_impl.hpp +1581 -0
  32. data/ext/libieeep1788_copy/p1788/infsup/base_interval_io_impl.hpp +59 -0
  33. data/ext/libieeep1788_copy/p1788/infsup/base_interval_mul_rev_to_pair_func_impl.hpp +88 -0
  34. data/ext/libieeep1788_copy/p1788/infsup/base_interval_num_func_impl.hpp +345 -0
  35. data/ext/libieeep1788_copy/p1788/infsup/base_interval_rec_bool_func_impl.hpp +92 -0
  36. data/ext/libieeep1788_copy/p1788/infsup/base_interval_rec_overlap_impl.hpp +72 -0
  37. data/ext/libieeep1788_copy/p1788/infsup/base_interval_rev_func_impl.hpp +656 -0
  38. data/ext/libieeep1788_copy/p1788/infsup/base_interval_set_op_impl.hpp +126 -0
  39. data/ext/libieeep1788_copy/p1788/infsup/decorated_interval.hpp +464 -0
  40. data/ext/libieeep1788_copy/p1788/infsup/forward_declaration.hpp +66 -0
  41. data/ext/libieeep1788_copy/p1788/infsup/interval.hpp +275 -0
  42. data/ext/libieeep1788_copy/p1788/io/io_manip.hpp +531 -0
  43. data/ext/libieeep1788_copy/p1788/overlapping/overlapping.hpp +241 -0
  44. data/ext/libieeep1788_copy/p1788/p1788.hpp +45 -0
  45. data/ext/libieeep1788_copy/p1788/reduction/reduction.hpp +341 -0
  46. data/ext/libieeep1788_copy/p1788/util/io.hpp +63 -0
  47. data/ext/libieeep1788_copy/p1788/util/mixed_type_traits.hpp +140 -0
  48. data/ext/libieeep1788_copy/p1788/util/mpfr_util.hpp +77 -0
  49. data/ext/libieeep1788_copy/p1788/util/mpfr_var.hpp +119 -0
  50. data/ext/libieeep1788_copy/p1788/util/mpfr_var_impl.hpp +382 -0
  51. data/ext/libieeep1788_copy/p1788/version.hpp +34 -0
  52. data/ext/p1788/extconf.rb +49 -0
  53. data/ext/p1788/p1788.cc +3764 -0
  54. data/lib/p1788/version.rb +4 -0
  55. data/lib/p1788.rb +25 -0
  56. data/p1788.gemspec +72 -0
  57. metadata +99 -0
@@ -0,0 +1,216 @@
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_SET_OP_IMPL_HPP
27
+ #define LIBIEEEP1788_P1788_FLAVOR_INFSUP_SETBASED_MPFR_BIN_IEEE754_FLAVOR_SET_OP_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
+ // intersection ( bare interval )
43
+ template<typename T>
44
+ typename mpfr_bin_ieee754_flavor<T>::representation
45
+ mpfr_bin_ieee754_flavor<T>::intersection(mpfr_bin_ieee754_flavor<T>::representation const& x,
46
+ mpfr_bin_ieee754_flavor<T>::representation const& y)
47
+ {
48
+ if (!is_valid(x) || !is_valid(y))
49
+ return empty();
50
+
51
+ if (disjoint(x, y))
52
+ return empty();
53
+ else
54
+ return representation(std::max(x.first, y.first),
55
+ std::min(x.second, y.second));
56
+ }
57
+
58
+ // intersection ( bare interval ) mixed type
59
+ template<typename T>
60
+ template<typename T1, typename T2>
61
+ typename mpfr_bin_ieee754_flavor<T>::representation
62
+ mpfr_bin_ieee754_flavor<T>::intersection(mpfr_bin_ieee754_flavor<T>::representation_type<T1> const& x,
63
+ mpfr_bin_ieee754_flavor<T>::representation_type<T2> const& y)
64
+ {
65
+ static_assert(std::numeric_limits<T1>::is_iec559, "Only IEEE 754 binary compliant types are supported!");
66
+ static_assert(std::numeric_limits<T2>::is_iec559, "Only IEEE 754 binary compliant types are supported!");
67
+
68
+ if (!mpfr_bin_ieee754_flavor<T1>::is_valid(x) || !mpfr_bin_ieee754_flavor<T2>::is_valid(y))
69
+ return empty();
70
+
71
+ // determine max. precision
72
+ typedef typename p1788::util::max_precision_type<T,T1,T2>::type T_MAX;
73
+
74
+ // 1.) convert inputs to max precision; 2.) compute result in max precision; 3.) convert result to desired precision
75
+ // Error free for floating point inf-sup intervals due to outward rounding
76
+ return convert_hull(
77
+ mpfr_bin_ieee754_flavor<T_MAX>::intersection(
78
+ mpfr_bin_ieee754_flavor<T_MAX>::convert_hull(x),
79
+ mpfr_bin_ieee754_flavor<T_MAX>::convert_hull(y)
80
+ )
81
+ );
82
+ }
83
+
84
+ // intersection ( decorated interval )
85
+ template<typename T>
86
+ typename mpfr_bin_ieee754_flavor<T>::representation_dec
87
+ mpfr_bin_ieee754_flavor<T>::intersection(mpfr_bin_ieee754_flavor<T>::representation_dec const& x,
88
+ mpfr_bin_ieee754_flavor<T>::representation_dec const& y)
89
+ {
90
+ if (!is_valid(x) || !is_valid(y) || is_nai(x) || is_nai(y))
91
+ return nai();
92
+
93
+ return representation_dec(intersection(x.first, y.first), p1788::decoration::decoration::trv);
94
+ }
95
+
96
+ // intersection ( decorated interval ) mixed type
97
+ template<typename T>
98
+ template<typename T1, typename T2>
99
+ typename mpfr_bin_ieee754_flavor<T>::representation_dec
100
+ mpfr_bin_ieee754_flavor<T>::intersection(mpfr_bin_ieee754_flavor<T>::representation_dec_type<T1> const& x,
101
+ mpfr_bin_ieee754_flavor<T>::representation_dec_type<T2> const& y)
102
+ {
103
+ static_assert(std::numeric_limits<T1>::is_iec559, "Only IEEE 754 binary compliant types are supported!");
104
+ static_assert(std::numeric_limits<T2>::is_iec559, "Only IEEE 754 binary compliant types are supported!");
105
+
106
+ if (!mpfr_bin_ieee754_flavor<T1>::is_valid(x) || !mpfr_bin_ieee754_flavor<T2>::is_valid(y)
107
+ || mpfr_bin_ieee754_flavor<T1>::is_nai(x) || mpfr_bin_ieee754_flavor<T2>::is_nai(y))
108
+ return nai();
109
+
110
+ // determine max. precision
111
+ typedef typename p1788::util::max_precision_type<T,T1,T2>::type T_MAX;
112
+
113
+ // 1.) convert inputs to max precision; 2.) compute result in max precision; 3.) convert result to desired precision
114
+ // Error free for floating point inf-sup intervals due to outward rounding
115
+ return convert_hull(
116
+ mpfr_bin_ieee754_flavor<T_MAX>::intersection(
117
+ mpfr_bin_ieee754_flavor<T_MAX>::convert_hull(x),
118
+ mpfr_bin_ieee754_flavor<T_MAX>::convert_hull(y)
119
+ )
120
+ );
121
+ }
122
+
123
+ // convex_hull ( bare interval )
124
+ template<typename T>
125
+ typename mpfr_bin_ieee754_flavor<T>::representation
126
+ mpfr_bin_ieee754_flavor<T>::convex_hull(mpfr_bin_ieee754_flavor<T>::representation const& x,
127
+ mpfr_bin_ieee754_flavor<T>::representation const& y)
128
+ {
129
+ if (!is_valid(x) || !is_valid(y))
130
+ return empty();
131
+
132
+ if (is_empty(x))
133
+ return y;
134
+ else if (is_empty(y))
135
+ return x;
136
+ else
137
+ return representation(std::min(x.first, y.first),
138
+ std::max(x.second, y.second));
139
+ }
140
+
141
+ // convex_hull ( bare interval ) mixed type
142
+ template<typename T>
143
+ template<typename T1, typename T2>
144
+ typename mpfr_bin_ieee754_flavor<T>::representation
145
+ mpfr_bin_ieee754_flavor<T>::convex_hull(mpfr_bin_ieee754_flavor<T>::representation_type<T1> const& x,
146
+ mpfr_bin_ieee754_flavor<T>::representation_type<T2> const& y)
147
+ {
148
+ static_assert(std::numeric_limits<T1>::is_iec559, "Only IEEE 754 binary compliant types are supported!");
149
+ static_assert(std::numeric_limits<T2>::is_iec559, "Only IEEE 754 binary compliant types are supported!");
150
+
151
+ if (!mpfr_bin_ieee754_flavor<T1>::is_valid(x) || !mpfr_bin_ieee754_flavor<T2>::is_valid(y))
152
+ return empty();
153
+
154
+ // determine max. precision
155
+ typedef typename p1788::util::max_precision_type<T,T1,T2>::type T_MAX;
156
+
157
+ // 1.) convert inputs to max precision; 2.) compute result in max precision; 3.) convert result to desired precision
158
+ // Error free for floating point inf-sup intervals due to outward rounding
159
+ return convert_hull(
160
+ mpfr_bin_ieee754_flavor<T_MAX>::convex_hull(
161
+ mpfr_bin_ieee754_flavor<T_MAX>::convert_hull(x),
162
+ mpfr_bin_ieee754_flavor<T_MAX>::convert_hull(y)
163
+ )
164
+ );
165
+ }
166
+
167
+ // convex_hull ( decorated interval )
168
+ template<typename T>
169
+ typename mpfr_bin_ieee754_flavor<T>::representation_dec
170
+ mpfr_bin_ieee754_flavor<T>::convex_hull(mpfr_bin_ieee754_flavor<T>::representation_dec const& x,
171
+ mpfr_bin_ieee754_flavor<T>::representation_dec const& y)
172
+ {
173
+ if (!is_valid(x) || !is_valid(y) || is_nai(x) || is_nai(y))
174
+ return nai();
175
+
176
+ return representation_dec(convex_hull(x.first, y.first), p1788::decoration::decoration::trv);
177
+ }
178
+
179
+ // convex_hull ( decorated interval ) mixed type
180
+ template<typename T>
181
+ template<typename T1, typename T2>
182
+ typename mpfr_bin_ieee754_flavor<T>::representation_dec
183
+ mpfr_bin_ieee754_flavor<T>::convex_hull(mpfr_bin_ieee754_flavor<T>::representation_dec_type<T1> const& x,
184
+ mpfr_bin_ieee754_flavor<T>::representation_dec_type<T2> const& y)
185
+ {
186
+ static_assert(std::numeric_limits<T1>::is_iec559, "Only IEEE 754 binary compliant types are supported!");
187
+ static_assert(std::numeric_limits<T2>::is_iec559, "Only IEEE 754 binary compliant types are supported!");
188
+
189
+ if (!mpfr_bin_ieee754_flavor<T1>::is_valid(x) || !mpfr_bin_ieee754_flavor<T2>::is_valid(y)
190
+ || mpfr_bin_ieee754_flavor<T1>::is_nai(x) || mpfr_bin_ieee754_flavor<T2>::is_nai(y))
191
+ return nai();
192
+
193
+ // determine max. precision
194
+ typedef typename p1788::util::max_precision_type<T,T1,T2>::type T_MAX;
195
+
196
+ // 1.) convert inputs to max precision; 2.) compute result in max precision; 3.) convert result to desired precision
197
+ // Error free for floating point inf-sup intervals due to outward rounding
198
+ return convert_hull(
199
+ mpfr_bin_ieee754_flavor<T_MAX>::convex_hull(
200
+ mpfr_bin_ieee754_flavor<T_MAX>::convert_hull(x),
201
+ mpfr_bin_ieee754_flavor<T_MAX>::convert_hull(y)
202
+ )
203
+ );
204
+ }
205
+
206
+
207
+ } // namespace setbased
208
+
209
+ } // namespace infsup
210
+
211
+ } // namespace flavor
212
+
213
+ } // namespace p1788
214
+
215
+
216
+ #endif // LIBIEEEP1788_P1788_FLAVOR_INFSUP_SETBASED_MPFR_BIN_IEEE754_FLAVOR_SET_OP_IMPL_HPP
@@ -0,0 +1,68 @@
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_SETUP_FUNC_IMPL_HPP
27
+ #define LIBIEEEP1788_P1788_FLAVOR_INFSUP_SETBASED_MPFR_BIN_IEEE754_FLAVOR_SETUP_FUNC_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
+ template<typename T>
44
+ void
45
+ mpfr_bin_ieee754_flavor<T>::setup()
46
+ {
47
+ // nothing to do
48
+ }
49
+
50
+ template<typename T>
51
+ void
52
+ mpfr_bin_ieee754_flavor<T>::teardown()
53
+ {
54
+ // frees the mpfr cache
55
+ mpfr_var::free_cache();
56
+ }
57
+
58
+
59
+ } // namespace setbased
60
+
61
+ } // namespace infsup
62
+
63
+ } // namespace flavor
64
+
65
+ } // namespace p1788
66
+
67
+
68
+ #endif // LIBIEEEP1788_P1788_FLAVOR_INFSUP_SETBASED_MPFR_BIN_IEEE754_FLAVOR_SETUP_FUNC_IMPL_HPP
@@ -0,0 +1,135 @@
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_UTIL_FUNC_IMPL_HPP
27
+ #define LIBIEEEP1788_P1788_FLAVOR_INFSUP_SETBASED_MPFR_BIN_IEEE754_FLAVOR_UTIL_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
+ // convert T_ to T with rounding to -oo
42
+ template<typename T>
43
+ template<typename T_>
44
+ T mpfr_bin_ieee754_flavor<T>::convert_rndd(T_ x)
45
+ {
46
+ static_assert(std::numeric_limits<T_>::is_iec559, "Only IEEE 754 binary compliant types are supported!");
47
+
48
+ mpfr_var::setup();
49
+
50
+ mpfr_var xx(x, MPFR_RNDD);
51
+
52
+ T res = xx.template get<T>(MPFR_RNDD);
53
+
54
+ return res == 0.0 ? -0.0 : res; // maps +-0.0 to -0.0
55
+ }
56
+
57
+ // convert T_ to T with rounding to nearest
58
+ template<typename T>
59
+ template<typename T_>
60
+ T mpfr_bin_ieee754_flavor<T>::convert_rndn(T_ x)
61
+ {
62
+ static_assert(std::numeric_limits<T_>::is_iec559, "Only IEEE 754 binary compliant types are supported!");
63
+
64
+ mpfr_var::setup();
65
+
66
+ mpfr_var xx(x, MPFR_RNDN);
67
+
68
+ T res = xx.template get<T>(MPFR_RNDN);
69
+
70
+ return res == 0.0 ? +0.0 : res; // maps +-0.0 to +0.0
71
+ }
72
+
73
+ // convert T_ to T with rounding to +oo
74
+ template<typename T>
75
+ template<typename T_>
76
+ T mpfr_bin_ieee754_flavor<T>::convert_rndu(T_ x)
77
+ {
78
+ static_assert(std::numeric_limits<T_>::is_iec559, "Only IEEE 754 binary compliant types are supported!");
79
+
80
+ mpfr_var::setup();
81
+
82
+ mpfr_var xx(x, MPFR_RNDU);
83
+
84
+ T res = xx.template get<T>(MPFR_RNDU);
85
+
86
+ return res == 0.0 ? +0.0 : res; // maps +-0.0 to +0.0
87
+ }
88
+
89
+
90
+ // convert bare interval with bounds T_ to bare interval with bounds T with outward rounding
91
+ template<typename T>
92
+ template<typename T_>
93
+ typename mpfr_bin_ieee754_flavor<T>::representation
94
+ mpfr_bin_ieee754_flavor<T>::convert_hull(representation_type<T_> const& x)
95
+ {
96
+ static_assert(std::numeric_limits<T_>::is_iec559, "Only IEEE 754 binary compliant types are supported!");
97
+
98
+ return representation(convert_rndd(x.first), convert_rndu(x.second));
99
+ }
100
+
101
+ // convert decorated interval with bounds T_ to decorated interval with bounds T with outward rounding
102
+ template<typename T>
103
+ template<typename T_>
104
+ typename mpfr_bin_ieee754_flavor<T>::representation_dec
105
+ mpfr_bin_ieee754_flavor<T>::convert_hull(representation_dec_type<T_> const& x)
106
+ {
107
+ static_assert(std::numeric_limits<T_>::is_iec559, "Only IEEE 754 binary compliant types are supported!");
108
+
109
+ if (mpfr_bin_ieee754_flavor<T_>::is_nai(x))
110
+ return nai();
111
+
112
+ representation bare(convert_rndd(x.first.first), convert_rndu(x.first.second));
113
+
114
+ if (x.second == p1788::decoration::decoration::com
115
+ && (bare.first == -std::numeric_limits<T>::infinity() || bare.second == std::numeric_limits<T>::infinity()))
116
+ {
117
+ return representation_dec(bare, p1788::decoration::decoration::dac);
118
+ }
119
+ else
120
+ {
121
+ return representation_dec(bare, x.second);
122
+ }
123
+ }
124
+
125
+
126
+ } // namespace setbased
127
+
128
+ } // namespace infsup
129
+
130
+ } // namespace flavor
131
+
132
+ } // namespace p1788
133
+
134
+
135
+ #endif // LIBIEEEP1788_P1788_FLAVOR_INFSUP_SETBASED_MPFR_BIN_IEEE754_FLAVOR_UTIL_FUNC_IMPL_HPP
@@ -0,0 +1,93 @@
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_VALIDATION_FUNC_IMPL_HPP
27
+ #define LIBIEEEP1788_P1788_FLAVOR_INFSUP_SETBASED_MPFR_BIN_IEEE754_FLAVOR_VALIDATION_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
+ // Check if x is a valid bare interval representation
43
+ template<typename T>
44
+ bool mpfr_bin_ieee754_flavor<T>::is_valid(representation const& x)
45
+ {
46
+ if ((std::isnan(x.first) && std::isnan(x.second))
47
+ || (x.first <= x.second
48
+ && x.first != std::numeric_limits<T>::infinity()
49
+ && x.second != -std::numeric_limits<T>::infinity()))
50
+ {
51
+ return true;
52
+ }
53
+
54
+ // invalid: signal invalid operand
55
+ return !p1788::exception::signal_invalid_operand();
56
+ }
57
+
58
+ // Check if x is a valid decorated interval representation
59
+ template<typename T>
60
+ bool mpfr_bin_ieee754_flavor<T>::is_valid(representation_dec const& x)
61
+ {
62
+ if ((std::isnan(x.first.first) && std::isnan(x.first.second)
63
+ && (x.second == p1788::decoration::decoration::ill
64
+ || x.second == p1788::decoration::decoration::trv))
65
+ || (x.second != p1788::decoration::decoration::ill
66
+ && (x.first.first <= x.first.second
67
+ && x.first.first != std::numeric_limits<T>::infinity()
68
+ && x.first.second != -std::numeric_limits<T>::infinity()
69
+ && (x.second != p1788::decoration::decoration::com
70
+ || (x.first.first != -std::numeric_limits<T>::infinity()
71
+ && x.first.second != std::numeric_limits<T>::infinity()))
72
+ )
73
+ )
74
+ )
75
+ {
76
+ return true;
77
+ }
78
+
79
+ // invalid: signal invalid operand
80
+ return !p1788::exception::signal_invalid_operand();
81
+ }
82
+
83
+
84
+ } // namespace setbased
85
+
86
+ } // namespace infsup
87
+
88
+ } // namespace flavor
89
+
90
+ } // namespace p1788
91
+
92
+
93
+ #endif // LIBIEEEP1788_P1788_FLAVOR_INFSUP_SETBASED_MPFR_BIN_IEEE754_FLAVOR_VALIDATION_FUNC_IMPL_HPP