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,275 @@
|
|
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_INFSUP_INTERVAL_HPP
|
27
|
+
#define LIBIEEEP1788_P1788_INFSUP_INTERVAL_HPP
|
28
|
+
|
29
|
+
#include "p1788/infsup/forward_declaration.hpp"
|
30
|
+
#include "p1788/infsup/base_interval.hpp"
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
//------------------------------------------------------------------------------
|
35
|
+
//------------------------------------------------------------------------------
|
36
|
+
// Definition of class interval
|
37
|
+
//------------------------------------------------------------------------------
|
38
|
+
//------------------------------------------------------------------------------
|
39
|
+
|
40
|
+
|
41
|
+
namespace p1788
|
42
|
+
{
|
43
|
+
|
44
|
+
namespace infsup
|
45
|
+
{
|
46
|
+
|
47
|
+
|
48
|
+
/// \brief Interval class
|
49
|
+
///
|
50
|
+
/// Front end of an inf-sup (bare) interval.
|
51
|
+
/// All the behavior of the interval type is specified by the
|
52
|
+
/// template policy class <c>Flavor</c>.
|
53
|
+
///
|
54
|
+
/// \tparam T type used for the interval bounds
|
55
|
+
/// \tparam Flavor template policy class specifying the behavior
|
56
|
+
///
|
57
|
+
template<typename T, template<typename> class Flavor>
|
58
|
+
class interval final
|
59
|
+
: public base_interval<T, Flavor, typename Flavor<T>::representation, interval<T, Flavor>>
|
60
|
+
{
|
61
|
+
private:
|
62
|
+
|
63
|
+
// base interval type
|
64
|
+
typedef base_interval<T, Flavor, typename Flavor<T>::representation, interval<T, Flavor>> base_interval_type;
|
65
|
+
|
66
|
+
|
67
|
+
public:
|
68
|
+
|
69
|
+
|
70
|
+
// -----------------------------------------------------------------------------
|
71
|
+
// Constructors
|
72
|
+
// -----------------------------------------------------------------------------
|
73
|
+
|
74
|
+
///@name Constructors
|
75
|
+
///
|
76
|
+
///
|
77
|
+
///@{
|
78
|
+
|
79
|
+
/// \brief Creates an empty interval
|
80
|
+
///
|
81
|
+
/// \return \f$\emptyset\f$
|
82
|
+
///
|
83
|
+
/// \note The function is forwarded to the function <c>Flavor\<T\>::empty()</c>
|
84
|
+
/// which creates the representation for an empty interval.
|
85
|
+
/// \see \link p1788::flavor::infsup::setbased::mpfr_bin_ieee754_flavor<T>::empty() \endlink
|
86
|
+
///
|
87
|
+
inline
|
88
|
+
interval()
|
89
|
+
: base_interval_type(Flavor<T>::empty())
|
90
|
+
{ }
|
91
|
+
|
92
|
+
/// \brief Creates an interval with a lower and an upper bound
|
93
|
+
///
|
94
|
+
/// \param lower lower bound
|
95
|
+
/// \param upper upper bound
|
96
|
+
///
|
97
|
+
/// \return \li \f$[lower,upper]\f$ if \p \f$ lower \leq upper \wedge lower < +\infty \wedge upper > -\infty \f$
|
98
|
+
/// \li \f$\emptyset\f$ otherwise
|
99
|
+
///
|
100
|
+
///
|
101
|
+
/// \note The function is forwarded to the function <c>Flavor\<T\>::nums_to_interval(T lower, T upper)</c>
|
102
|
+
/// which creates the representation for an interval.
|
103
|
+
/// \see \link p1788::flavor::infsup::setbased::mpfr_bin_ieee754_flavor<T>::nums_to_interval(T lower , T upper) \endlink
|
104
|
+
///
|
105
|
+
inline
|
106
|
+
interval(T lower, T upper)
|
107
|
+
: base_interval_type(Flavor<T>::nums_to_interval(lower, upper))
|
108
|
+
{ }
|
109
|
+
|
110
|
+
/// \brief (Mixed type version) Creates an interval with a lower and an upper bound
|
111
|
+
///
|
112
|
+
/// \param lower lower bound
|
113
|
+
/// \param upper upper bound
|
114
|
+
///
|
115
|
+
/// \return \li \f$[lower,upper]\f$ if \p \f$ lower \leq upper \wedge lower < +\infty \wedge upper > -\infty \f$
|
116
|
+
/// \li \f$\emptyset\f$ otherwise
|
117
|
+
///
|
118
|
+
///
|
119
|
+
/// \note The function is forwarded to the function <c>Flavor\<T\>::nums_to_interval(L lower, U upper)</c>
|
120
|
+
/// which creates the representation for an interval.
|
121
|
+
/// \see \link p1788::flavor::infsup::setbased::mpfr_bin_ieee754_flavor<T>::nums_to_interval(L_ lower , U_ upper) \endlink
|
122
|
+
///
|
123
|
+
template<typename L, typename U>
|
124
|
+
inline
|
125
|
+
interval(L lower, U upper)
|
126
|
+
: base_interval_type(Flavor<T>::nums_to_interval(lower, upper))
|
127
|
+
{ }
|
128
|
+
|
129
|
+
/// \brief Creates an interval out of an interval literal
|
130
|
+
///
|
131
|
+
/// \param str interval literal
|
132
|
+
///
|
133
|
+
/// \return \li interval enclosing the provided interval literal if it is a valid inf-sup form or uncertain form literal
|
134
|
+
/// \li \f$\emptyset\f$ otherwise
|
135
|
+
///
|
136
|
+
///
|
137
|
+
/// \note The function is forwarded to the function <c>Flavor\<T\>::text_to_interval(std::string const& str)</c>
|
138
|
+
/// which creates the representation for an interval.
|
139
|
+
/// \see \link p1788::flavor::infsup::setbased::mpfr_bin_ieee754_flavor<T>::text_to_interval(std::string const& str) \endlink
|
140
|
+
///
|
141
|
+
inline explicit
|
142
|
+
interval(std::string const& str)
|
143
|
+
: base_interval_type(Flavor<T>::text_to_interval(str))
|
144
|
+
{ }
|
145
|
+
|
146
|
+
|
147
|
+
/// \brief Copy constructor
|
148
|
+
///
|
149
|
+
/// \param other Interval to be copied
|
150
|
+
///
|
151
|
+
/// \return Copy of \p other
|
152
|
+
///
|
153
|
+
/// \note The function is forwarded to the function <c>Flavor\<T\>::copy(representation const& other)</c>
|
154
|
+
/// which creates the representation for an interval.
|
155
|
+
/// \see \link p1788::flavor::infsup::setbased::mpfr_bin_ieee754_flavor<T>::copy(representation const& other) \endlink
|
156
|
+
///
|
157
|
+
inline
|
158
|
+
interval(interval<T, Flavor> const& other)
|
159
|
+
: base_interval_type(Flavor<T>::copy(other.rep_))
|
160
|
+
{ }
|
161
|
+
|
162
|
+
/// \brief Convert constructor
|
163
|
+
///
|
164
|
+
/// \param other Interval to be converted
|
165
|
+
///
|
166
|
+
/// \return Hull of \p other
|
167
|
+
///
|
168
|
+
/// \note The function is forwarded to the function <c>Flavor\<T\>::convert_type(representation_type<T_> const& other)</c>
|
169
|
+
/// which creates the representation for an interval.
|
170
|
+
/// \see \link p1788::flavor::infsup::setbased::mpfr_bin_ieee754_flavor<T>::convert_type(representation_type<T_> const& other) \endlink
|
171
|
+
///
|
172
|
+
template<typename T_>
|
173
|
+
inline explicit
|
174
|
+
interval(interval<T_, Flavor> const& other)
|
175
|
+
: base_interval_type(Flavor<T>::convert_type(other.rep_))
|
176
|
+
{ }
|
177
|
+
|
178
|
+
/// \brief Interval part constructor
|
179
|
+
///
|
180
|
+
/// \param other Decorated interval to be converted
|
181
|
+
///
|
182
|
+
/// \return Bare interval of \p other
|
183
|
+
///
|
184
|
+
/// \note The function is forwarded to the function <c>Flavor\<T\>::interval_part(representation_dec const& other)</c>
|
185
|
+
/// which creates the representation for an interval.
|
186
|
+
/// \see \link p1788::flavor::infsup::setbased::mpfr_bin_ieee754_flavor<T>::interval_part(representation_dec const& other) \endlink
|
187
|
+
///
|
188
|
+
inline
|
189
|
+
interval(decorated_interval<T, Flavor> const& other)
|
190
|
+
: base_interval_type(Flavor<T>::interval_part(other.rep_))
|
191
|
+
{ }
|
192
|
+
|
193
|
+
/// \brief Interval part and convert constructor
|
194
|
+
///
|
195
|
+
/// \param other Decorated interval to be converted
|
196
|
+
///
|
197
|
+
/// \return Hull of bare interval of \p other
|
198
|
+
///
|
199
|
+
/// \note The function is forwarded to the function <c>Flavor\<T\>::interval_part(representation_dec_type<T_> const& other)</c>
|
200
|
+
/// which creates the representation for an interval.
|
201
|
+
/// \see \link p1788::flavor::infsup::setbased::mpfr_bin_ieee754_flavor<T>::interval_part(representation_dec_type<T_> const& other) \endlink
|
202
|
+
///
|
203
|
+
template<typename T_>
|
204
|
+
inline explicit
|
205
|
+
interval(decorated_interval<T_, Flavor> const& other)
|
206
|
+
: base_interval_type(Flavor<T>::interval_part(other.rep_))
|
207
|
+
{ }
|
208
|
+
|
209
|
+
///@}
|
210
|
+
|
211
|
+
// -----------------------------------------------------------------------------
|
212
|
+
// Interval constants
|
213
|
+
// -----------------------------------------------------------------------------
|
214
|
+
|
215
|
+
///@name Interval constants
|
216
|
+
///
|
217
|
+
///
|
218
|
+
///@{
|
219
|
+
|
220
|
+
/// \brief Returns an empty interval
|
221
|
+
///
|
222
|
+
/// \return \f$\emptyset\f$
|
223
|
+
///
|
224
|
+
/// \note The function is forwarded to the function <c>Flavor\<T\>::empty()</c>
|
225
|
+
/// which creates the representation for an empty interval.
|
226
|
+
/// \see \link p1788::flavor::infsup::setbased::mpfr_bin_ieee754_flavor<T>::empty() \endlink
|
227
|
+
///
|
228
|
+
inline
|
229
|
+
static interval empty()
|
230
|
+
{
|
231
|
+
return interval(Flavor<T>::empty());
|
232
|
+
}
|
233
|
+
|
234
|
+
/// \brief Returns an entire interval
|
235
|
+
///
|
236
|
+
/// \return \f$[-\infty,+\infty]\f$
|
237
|
+
///
|
238
|
+
/// \note The function is forwarded to the function <c>Flavor\<T\>::entire()</c>
|
239
|
+
/// which creates the representation for an entire interval.
|
240
|
+
/// \see \link p1788::flavor::infsup::setbased::mpfr_bin_ieee754_flavor<T>::entire() \endlink
|
241
|
+
///
|
242
|
+
inline
|
243
|
+
static interval entire()
|
244
|
+
{
|
245
|
+
return interval(Flavor<T>::entire());
|
246
|
+
}
|
247
|
+
|
248
|
+
///@}
|
249
|
+
|
250
|
+
|
251
|
+
private:
|
252
|
+
|
253
|
+
// private constructor which is used by the base_interval to create concrete intervals
|
254
|
+
inline
|
255
|
+
explicit interval(typename Flavor<T>::representation rep)
|
256
|
+
: base_interval_type(rep)
|
257
|
+
{}
|
258
|
+
|
259
|
+
|
260
|
+
friend class base_interval<T, Flavor, typename Flavor<T>::representation, interval<T, Flavor>>;
|
261
|
+
|
262
|
+
template<typename, template<typename> class>
|
263
|
+
friend class interval;
|
264
|
+
|
265
|
+
|
266
|
+
}; // class interval
|
267
|
+
|
268
|
+
|
269
|
+
|
270
|
+
} // namespace infsup
|
271
|
+
|
272
|
+
} // namespace p1788
|
273
|
+
|
274
|
+
|
275
|
+
#endif // LIBIEEEP1788_P1788_INFSUP_INTERVAL_HPP
|