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,146 @@
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_REC_BOOL_FUNC_IMPL_HPP
27
+ #define LIBIEEEP1788_P1788_FLAVOR_INFSUP_SETBASED_MPFR_BIN_IEEE754_FLAVOR_REC_BOOL_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
+ // is_common_interval ( bare interval )
43
+ template<typename T>
44
+ bool mpfr_bin_ieee754_flavor<T>::is_common_interval(mpfr_bin_ieee754_flavor<T>::representation const& x)
45
+ {
46
+ if (!is_valid(x))
47
+ return false;
48
+
49
+ return !is_empty(x)
50
+ && x.first > -std::numeric_limits<T>::infinity()
51
+ && x.second < std::numeric_limits<T>::infinity();
52
+ }
53
+
54
+ // is_common_interval (decorated interval)
55
+ template<typename T>
56
+ bool mpfr_bin_ieee754_flavor<T>::is_common_interval(mpfr_bin_ieee754_flavor<T>::representation_dec const& x)
57
+ {
58
+ if (!is_valid(x) || is_nai(x))
59
+ return false;
60
+
61
+ // call bare version
62
+ return is_common_interval(x.first);
63
+ }
64
+
65
+ // is_singleton ( bare interval )
66
+ template<typename T>
67
+ bool mpfr_bin_ieee754_flavor<T>::is_singleton(mpfr_bin_ieee754_flavor<T>::representation const& x)
68
+ {
69
+ if (!is_valid(x))
70
+ return false;
71
+
72
+ return x.first == x.second;
73
+ }
74
+
75
+ // is_singleton (decorated interval)
76
+ template<typename T>
77
+ bool mpfr_bin_ieee754_flavor<T>::is_singleton(mpfr_bin_ieee754_flavor<T>::representation_dec const& x)
78
+ {
79
+ if (!is_valid(x) || is_nai(x))
80
+ return false;
81
+
82
+ // call bare version
83
+ return is_singleton(x.first);
84
+ }
85
+
86
+ // is_member (bare interval)
87
+ template<typename T>
88
+ bool mpfr_bin_ieee754_flavor<T>::is_member(T m, mpfr_bin_ieee754_flavor<T>::representation const& x)
89
+ {
90
+ if (!is_valid(x))
91
+ return false;
92
+
93
+ // call bare mixed type
94
+ return is_member<T>(m, x);
95
+ }
96
+
97
+ // is_member (decorated interval)
98
+ template<typename T>
99
+ bool mpfr_bin_ieee754_flavor<T>::is_member(T m, mpfr_bin_ieee754_flavor<T>::representation_dec const& x)
100
+ {
101
+ if (!is_valid(x) || is_nai(x))
102
+ return false;
103
+
104
+ // call bare mixed type version if not NaI
105
+ return is_member<T>(m, x.first);
106
+ }
107
+
108
+ // is_member (bare interval) mixed type
109
+ template<typename T>
110
+ template<typename T_>
111
+ bool mpfr_bin_ieee754_flavor<T>::is_member(T_ m, mpfr_bin_ieee754_flavor<T>::representation const& x)
112
+ {
113
+ static_assert(std::numeric_limits<T_>::is_iec559, "Only IEEE 754 binary compliant types are supported!");
114
+
115
+ if (!mpfr_bin_ieee754_flavor<T>::is_valid(x))
116
+ return false;
117
+
118
+ return x.first <= m && m <= x.second
119
+ && !std::isinf(m);
120
+ }
121
+
122
+ // is_member (decorated interval) mixed type
123
+ template<typename T>
124
+ template<typename T_>
125
+ bool mpfr_bin_ieee754_flavor<T>::is_member(T_ m, mpfr_bin_ieee754_flavor<T>::representation_dec const& x)
126
+ {
127
+ static_assert(std::numeric_limits<T_>::is_iec559, "Only IEEE 754 binary compliant types are supported!");
128
+
129
+ if (!mpfr_bin_ieee754_flavor<T>::is_valid(x) || mpfr_bin_ieee754_flavor<T>::is_nai(x))
130
+ return false;
131
+
132
+ // call bare mixed type version if not NaI
133
+ return is_member(m, x.first);
134
+ }
135
+
136
+
137
+ } // namespace setbased
138
+
139
+ } // namespace infsup
140
+
141
+ } // namespace flavor
142
+
143
+ } // namespace p1788
144
+
145
+
146
+ #endif // LIBIEEEP1788_P1788_FLAVOR_INFSUP_SETBASED_MPFR_BIN_IEEE754_FLAVOR_REC_BOOL_FUNC_IMPL_HPP
@@ -0,0 +1,188 @@
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_REC_OVERLAP_IMPL_HPP
27
+ #define LIBIEEEP1788_P1788_FLAVOR_INFSUP_SETBASED_MPFR_BIN_IEEE754_FLAVOR_REC_OVERLAP_IMPL_HPP
28
+
29
+ namespace p1788
30
+ {
31
+
32
+ namespace flavor
33
+ {
34
+
35
+ namespace infsup
36
+ {
37
+
38
+ namespace setbased
39
+ {
40
+
41
+ // overlap ( bare interval, bare interval )
42
+ template<typename T>
43
+ p1788::overlapping::overlapping_state
44
+ mpfr_bin_ieee754_flavor<T>::overlap(mpfr_bin_ieee754_flavor<T>::representation const& x,
45
+ mpfr_bin_ieee754_flavor<T>::representation const& y)
46
+ {
47
+ // call bare mixed type version
48
+ return overlap<T>(x,y);
49
+ }
50
+
51
+
52
+ // overlap ( bare interval, bare interval ) mixedtype
53
+ template<typename T>
54
+ template<typename T_>
55
+ p1788::overlapping::overlapping_state
56
+ mpfr_bin_ieee754_flavor<T>::overlap(mpfr_bin_ieee754_flavor<T>::representation const& x,
57
+ mpfr_bin_ieee754_flavor<T>::representation_type<T_> const& y)
58
+ {
59
+ if (!is_valid(x) || !mpfr_bin_ieee754_flavor<T_>::is_valid(y))
60
+ return p1788::overlapping::overlapping_state::undefined;
61
+
62
+ if (is_empty(x))
63
+ {
64
+ if (mpfr_bin_ieee754_flavor<T_>::is_empty(y))
65
+ {
66
+ return p1788::overlapping::overlapping_state::both_empty;
67
+ }
68
+ else
69
+ {
70
+ return p1788::overlapping::overlapping_state::first_empty;
71
+ }
72
+ }
73
+ if (mpfr_bin_ieee754_flavor<T_>::is_empty(y))
74
+ {
75
+ return p1788::overlapping::overlapping_state::second_empty;
76
+ }
77
+
78
+ // !before
79
+ if (x.second >= y.first)
80
+ {
81
+
82
+ if (x.second <= y.second)
83
+ {
84
+ if (x.first == y.first)
85
+ {
86
+ if (x.second < y.second)
87
+ {
88
+ return p1788::overlapping::overlapping_state::starts;
89
+ }
90
+ else
91
+ {
92
+ return p1788::overlapping::overlapping_state::equal;
93
+ }
94
+ }
95
+
96
+ if (x.second == y.second)
97
+ {
98
+ if (x.first < y.first)
99
+ {
100
+ return p1788::overlapping::overlapping_state::finished_by;
101
+ }
102
+ else
103
+ {
104
+ return p1788::overlapping::overlapping_state::finishes;
105
+ }
106
+ }
107
+
108
+ if (x.second > y.first)
109
+ {
110
+ if (x.first < y.first)
111
+ {
112
+ return p1788::overlapping::overlapping_state::overlaps;
113
+ }
114
+ else
115
+ {
116
+ return p1788::overlapping::overlapping_state::contained_by;
117
+ }
118
+ }
119
+
120
+ return p1788::overlapping::overlapping_state::meets;
121
+ }
122
+
123
+ if (x.first <= y.second)
124
+ {
125
+ if (x.first <= y.first)
126
+ {
127
+ if (x.first < y.first)
128
+ {
129
+ return p1788::overlapping::overlapping_state::contains;
130
+ }
131
+ else
132
+ {
133
+ return p1788::overlapping::overlapping_state::started_by;
134
+ }
135
+ }
136
+
137
+ if (x.first < y.second)
138
+ {
139
+ return p1788::overlapping::overlapping_state::overlapped_by;
140
+ }
141
+
142
+ return p1788::overlapping::overlapping_state::met_by;
143
+ }
144
+
145
+ return p1788::overlapping::overlapping_state::after;
146
+ }
147
+ // before
148
+ return p1788::overlapping::overlapping_state::before;
149
+ }
150
+
151
+
152
+ // overlap ( decorated interval, decorated interval )
153
+ template<typename T>
154
+ p1788::overlapping::overlapping_state
155
+ mpfr_bin_ieee754_flavor<T>::overlap(mpfr_bin_ieee754_flavor<T>::representation_dec const& x,
156
+ mpfr_bin_ieee754_flavor<T>::representation_dec const& y)
157
+ {
158
+ // call decorated mixed type version
159
+ return overlap<T>(x,y);
160
+ }
161
+
162
+
163
+ // overlap ( decorated interval, decorated interval ) mixedtyoe
164
+ template<typename T>
165
+ template<typename T_>
166
+ p1788::overlapping::overlapping_state
167
+ mpfr_bin_ieee754_flavor<T>::overlap(mpfr_bin_ieee754_flavor<T>::representation_dec const& x,
168
+ mpfr_bin_ieee754_flavor<T>::representation_dec_type<T_> const& y)
169
+ {
170
+ if (!is_valid(x) || !mpfr_bin_ieee754_flavor<T_>::is_valid(y) || is_nai(x) || mpfr_bin_ieee754_flavor<T_>::is_nai(y))
171
+ return p1788::overlapping::overlapping_state::undefined;
172
+
173
+
174
+ // call bare mixed type version
175
+ return overlap(x.first, y.first);
176
+ }
177
+
178
+
179
+ } // namespace setbased
180
+
181
+ } // namespace infsup
182
+
183
+ } // namespace flavor
184
+
185
+ } // namespace p1788
186
+
187
+
188
+ #endif // LIBIEEEP1788_P1788_FLAVOR_INFSUP_SETBASED_MPFR_BIN_IEEE754_FLAVOR_REC_OVERLAP_IMPL_HPP