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,126 @@
|
|
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_BASE_INTERVAL_SET_OP_IMPL_HPP
|
27
|
+
#define LIBIEEEP1788_P1788_INFSUP_BASE_INTERVAL_SET_OP_IMPL_HPP
|
28
|
+
|
29
|
+
namespace p1788
|
30
|
+
{
|
31
|
+
|
32
|
+
namespace infsup
|
33
|
+
{
|
34
|
+
|
35
|
+
|
36
|
+
// intersection
|
37
|
+
|
38
|
+
// static
|
39
|
+
template<typename T, template<typename> class Flavor, typename RepType, class ConcreteInterval>
|
40
|
+
ConcreteInterval base_interval<T,Flavor,RepType,ConcreteInterval>::intersection(base_interval<T, Flavor, RepType, ConcreteInterval> const& x,
|
41
|
+
base_interval<T, Flavor, RepType, ConcreteInterval> const& y)
|
42
|
+
{
|
43
|
+
return concrete_interval(Flavor<T>::intersection(x.rep_, y.rep_));
|
44
|
+
}
|
45
|
+
|
46
|
+
// static mixed type
|
47
|
+
template<typename T, template<typename> class Flavor, typename RepType, class ConcreteInterval>
|
48
|
+
template<typename T1, typename RepType1, class ConcreteInterval1, typename T2, typename RepType2, class ConcreteInterval2>
|
49
|
+
ConcreteInterval base_interval<T,Flavor,RepType,ConcreteInterval>::intersection(base_interval<T1, Flavor, RepType1, ConcreteInterval1> const& x,
|
50
|
+
base_interval<T2, Flavor, RepType2, ConcreteInterval2> const& y)
|
51
|
+
{
|
52
|
+
// assert that only bare intervals or decorated intervals are used
|
53
|
+
static_assert( (std::is_same<typename Flavor<T>::representation, RepType>::value
|
54
|
+
&& std::is_same<typename Flavor<T1>::representation, RepType1>::value
|
55
|
+
&& std::is_same<typename Flavor<T2>::representation, RepType2>::value)
|
56
|
+
|| (std::is_same<typename Flavor<T>::representation_dec, RepType>::value
|
57
|
+
&& std::is_same<typename Flavor<T1>::representation_dec, RepType1>::value
|
58
|
+
&& std::is_same<typename Flavor<T2>::representation_dec, RepType2>::value),
|
59
|
+
"It is not supported by mixed type operations to use "
|
60
|
+
"interval and decorated_interval types together!"
|
61
|
+
);
|
62
|
+
|
63
|
+
// call of mixed-type version
|
64
|
+
return concrete_interval(Flavor<T>::intersection(x.rep_, y.rep_));
|
65
|
+
}
|
66
|
+
|
67
|
+
|
68
|
+
// function
|
69
|
+
template<typename T, template<typename> class Flavor, typename RepType, class ConcreteInterval>
|
70
|
+
ConcreteInterval intersection(base_interval<T, Flavor, RepType, ConcreteInterval> const& x,
|
71
|
+
base_interval<T, Flavor, RepType, ConcreteInterval> const& y)
|
72
|
+
{
|
73
|
+
return base_interval<T,Flavor,RepType,ConcreteInterval>::intersection(x, y);
|
74
|
+
}
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
// convex_hull
|
80
|
+
|
81
|
+
// static
|
82
|
+
template<typename T, template<typename> class Flavor, typename RepType, class ConcreteInterval>
|
83
|
+
ConcreteInterval base_interval<T,Flavor,RepType,ConcreteInterval>::convex_hull(base_interval<T, Flavor, RepType, ConcreteInterval> const& x,
|
84
|
+
base_interval<T, Flavor, RepType, ConcreteInterval> const& y)
|
85
|
+
{
|
86
|
+
return concrete_interval(Flavor<T>::convex_hull(x.rep_, y.rep_));
|
87
|
+
}
|
88
|
+
|
89
|
+
// static mixed type
|
90
|
+
template<typename T, template<typename> class Flavor, typename RepType, class ConcreteInterval>
|
91
|
+
template<typename T1, typename RepType1, class ConcreteInterval1, typename T2, typename RepType2, class ConcreteInterval2>
|
92
|
+
ConcreteInterval base_interval<T,Flavor,RepType,ConcreteInterval>::convex_hull(base_interval<T1, Flavor, RepType1, ConcreteInterval1> const& x,
|
93
|
+
base_interval<T2, Flavor, RepType2, ConcreteInterval2> const& y)
|
94
|
+
{
|
95
|
+
// assert that only bare intervals or decorated intervals are used
|
96
|
+
static_assert( (std::is_same<typename Flavor<T>::representation, RepType>::value
|
97
|
+
&& std::is_same<typename Flavor<T1>::representation, RepType1>::value
|
98
|
+
&& std::is_same<typename Flavor<T2>::representation, RepType2>::value)
|
99
|
+
|| (std::is_same<typename Flavor<T>::representation_dec, RepType>::value
|
100
|
+
&& std::is_same<typename Flavor<T1>::representation_dec, RepType1>::value
|
101
|
+
&& std::is_same<typename Flavor<T2>::representation_dec, RepType2>::value),
|
102
|
+
"It is not supported by mixed type operations to use "
|
103
|
+
"interval and decorated_interval types together!"
|
104
|
+
);
|
105
|
+
|
106
|
+
// call of mixed-type version
|
107
|
+
return concrete_interval(Flavor<T>::convex_hull(x.rep_, y.rep_));
|
108
|
+
}
|
109
|
+
|
110
|
+
|
111
|
+
// function
|
112
|
+
template<typename T, template<typename> class Flavor, typename RepType, class ConcreteInterval>
|
113
|
+
ConcreteInterval convex_hull(base_interval<T, Flavor, RepType, ConcreteInterval> const& x,
|
114
|
+
base_interval<T, Flavor, RepType, ConcreteInterval> const& y)
|
115
|
+
{
|
116
|
+
return base_interval<T,Flavor,RepType,ConcreteInterval>::convex_hull(x, y);
|
117
|
+
}
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
} // namespace infsup
|
122
|
+
|
123
|
+
} // namespace p1788
|
124
|
+
|
125
|
+
|
126
|
+
#endif // LIBIEEEP1788_P1788_INFSUP_BASE_INTERVAL_SET_OP_IMPL_HPP
|
@@ -0,0 +1,464 @@
|
|
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_DECORATED_INTERVAL_HPP
|
27
|
+
#define LIBIEEEP1788_P1788_INFSUP_DECORATED_INTERVAL_HPP
|
28
|
+
|
29
|
+
#include "p1788/infsup/forward_declaration.hpp"
|
30
|
+
#include "p1788/infsup/base_interval.hpp"
|
31
|
+
#include "p1788/decoration/decoration.hpp"
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
//------------------------------------------------------------------------------
|
37
|
+
//------------------------------------------------------------------------------
|
38
|
+
// Definition of class decorated_interval
|
39
|
+
//------------------------------------------------------------------------------
|
40
|
+
//------------------------------------------------------------------------------
|
41
|
+
|
42
|
+
|
43
|
+
namespace p1788
|
44
|
+
{
|
45
|
+
|
46
|
+
namespace infsup
|
47
|
+
{
|
48
|
+
|
49
|
+
|
50
|
+
/// \brief Decorated interval class
|
51
|
+
///
|
52
|
+
/// Front end of an inf-sup decorated interval.
|
53
|
+
/// All the behavior of the decorated interval type is specified by the
|
54
|
+
/// template policy class <c>Flavor</c>.
|
55
|
+
///
|
56
|
+
/// \tparam T type used for the interval bounds
|
57
|
+
/// \tparam Flavor template policy class specifying the behavior
|
58
|
+
///
|
59
|
+
template<typename T, template<typename> class Flavor>
|
60
|
+
class decorated_interval final
|
61
|
+
: public base_interval<T, Flavor, typename Flavor<T>::representation_dec, decorated_interval<T, Flavor>>
|
62
|
+
{
|
63
|
+
private:
|
64
|
+
|
65
|
+
// base interval type
|
66
|
+
typedef base_interval<T, Flavor, typename Flavor<T>::representation_dec, decorated_interval<T, Flavor>> base_interval_type;
|
67
|
+
|
68
|
+
|
69
|
+
public:
|
70
|
+
|
71
|
+
|
72
|
+
// -----------------------------------------------------------------------------
|
73
|
+
// Constructors
|
74
|
+
// -----------------------------------------------------------------------------
|
75
|
+
|
76
|
+
///@name Constructors
|
77
|
+
///
|
78
|
+
///
|
79
|
+
///@{
|
80
|
+
|
81
|
+
/// \brief Creates an empty decorated interval
|
82
|
+
///
|
83
|
+
/// \return \f$\emptyset\f$<sub>\link p1788::decoration::decoration trv\endlink</sub>
|
84
|
+
///
|
85
|
+
/// \note The function is forwarded to the function <c>Flavor\<T\>::empty_dec()</c>
|
86
|
+
/// which creates the representation for an empty decorated interval.
|
87
|
+
/// \see \link p1788::flavor::infsup::setbased::mpfr_bin_ieee754_flavor<T>::empty_dec() \endlink
|
88
|
+
///
|
89
|
+
inline
|
90
|
+
decorated_interval()
|
91
|
+
: base_interval_type(Flavor<T>::empty_dec())
|
92
|
+
{ }
|
93
|
+
|
94
|
+
|
95
|
+
/// \brief Creates a decorated interval with a lower and an upper bound
|
96
|
+
///
|
97
|
+
/// \param lower lower bound
|
98
|
+
/// \param upper upper bound
|
99
|
+
///
|
100
|
+
/// \return \li \f$[lower,upper]\f$<sub>\link p1788::decoration::decoration com\endlink</sub> if \p \f$ lower \leq upper \wedge lower \not= \pm\infty \wedge upper \not= \pm\infty \f$
|
101
|
+
/// \li \f$[lower,upper]\f$<sub>\link p1788::decoration::decoration dac\endlink</sub> if \p \f$ lower \leq upper \wedge (lower = -\infty \vee upper = +\infty) \f$
|
102
|
+
/// \li NaI otherwise
|
103
|
+
///
|
104
|
+
///
|
105
|
+
/// \note The function is forwarded to the function <c>Flavor\<T\>::nums_to_decorated_interval(T lower, T upper)</c>
|
106
|
+
/// which creates the representation for a decorated interval.
|
107
|
+
/// \see \link p1788::flavor::infsup::setbased::mpfr_bin_ieee754_flavor<T>::nums_to_decorated_interval(T lower , T upper) \endlink
|
108
|
+
///
|
109
|
+
inline
|
110
|
+
decorated_interval(T lower, T upper)
|
111
|
+
: base_interval_type(Flavor<T>::nums_to_decorated_interval(lower, upper))
|
112
|
+
{ }
|
113
|
+
|
114
|
+
/// \brief (Mixed type version) Creates a decorated interval with a lower and an upper bound
|
115
|
+
///
|
116
|
+
/// \param lower lower bound
|
117
|
+
/// \param upper upper bound
|
118
|
+
///
|
119
|
+
/// \return \li \f$[lower,upper]\f$<sub>\link p1788::decoration::decoration com\endlink</sub> if \p \f$ lower \leq upper \wedge lower \not= \pm\infty \wedge upper \not= \pm\infty \f$
|
120
|
+
/// \li \f$[lower,upper]\f$<sub>\link p1788::decoration::decoration dac\endlink</sub> if \p \f$ lower \leq upper \wedge (lower = -\infty \vee upper = +\infty) \f$
|
121
|
+
/// \li NaI otherwise
|
122
|
+
///
|
123
|
+
///
|
124
|
+
/// \note The function is forwarded to the function <c>Flavor\<T\>::nums_to_decorated_interval(L lower, U upper)</c>
|
125
|
+
/// which creates the representation for a decorated interval.
|
126
|
+
/// \see \link p1788::flavor::infsup::setbased::mpfr_bin_ieee754_flavor<T>::nums_to_decorated_interval(L_ lower , U_ upper) \endlink
|
127
|
+
///
|
128
|
+
template<typename L, typename U>
|
129
|
+
inline
|
130
|
+
decorated_interval(L lower, U upper)
|
131
|
+
: base_interval_type(Flavor<T>::nums_to_decorated_interval(lower, upper))
|
132
|
+
{ }
|
133
|
+
|
134
|
+
|
135
|
+
/// \brief Creates a decorated interval with a lower and an upper bound and a specified decoration
|
136
|
+
///
|
137
|
+
/// \param lower lower bound
|
138
|
+
/// \param upper upper bound
|
139
|
+
/// \param dec Decoration
|
140
|
+
///
|
141
|
+
/// \return \li Decorated interval combined out of \p other, \p upper and \p dec if the combination is valid
|
142
|
+
/// \li NaI otherwise
|
143
|
+
///
|
144
|
+
/// \note The function is forwarded to the function <c>Flavor\<T\>::nums_dec_to_decorated_interval(T lower, T upper, p1788::decoration::decoration dec)</c>
|
145
|
+
/// which creates the representation for a decorated interval.
|
146
|
+
/// \see \link p1788::flavor::infsup::setbased::mpfr_bin_ieee754_flavor<T>::nums_dec_to_decorated_interval(T lower, T upper, p1788::decoration::decoration dec) \endlink
|
147
|
+
///
|
148
|
+
inline
|
149
|
+
decorated_interval(T lower, T upper, p1788::decoration::decoration dec)
|
150
|
+
: base_interval_type(Flavor<T>::nums_dec_to_decorated_interval(lower, upper, dec))
|
151
|
+
{ }
|
152
|
+
|
153
|
+
/// \brief (Mixed type version) Creates a decorated interval with a lower and an upper bound and a specified decoration
|
154
|
+
///
|
155
|
+
/// \param lower lower bound
|
156
|
+
/// \param upper upper bound
|
157
|
+
/// \param dec Decoration
|
158
|
+
///
|
159
|
+
/// \return \li Decorated interval combined out of \p other, \p upper and \p dec if the combination is valid
|
160
|
+
/// \li NaI otherwise
|
161
|
+
///
|
162
|
+
/// \note The function is forwarded to the function <c>Flavor\<T\>::nums_dec_to_decorated_interval(L lower, U upper, p1788::decoration::decoration dec)</c>
|
163
|
+
/// which creates the representation for a decorated interval.
|
164
|
+
/// \see \link p1788::flavor::infsup::setbased::mpfr_bin_ieee754_flavor<T>::nums_dec_to_decorated_interval(L_ lower, U_ upper, p1788::decoration::decoration dec) \endlink
|
165
|
+
///
|
166
|
+
template<typename L, typename U>
|
167
|
+
inline
|
168
|
+
decorated_interval(L lower, U upper, p1788::decoration::decoration dec)
|
169
|
+
: base_interval_type(Flavor<T>::nums_dec_to_decorated_interval(lower, upper, dec))
|
170
|
+
{ }
|
171
|
+
|
172
|
+
|
173
|
+
/// \brief Creates a decorated interval out of an interval literal
|
174
|
+
///
|
175
|
+
/// \param str interval literal
|
176
|
+
///
|
177
|
+
/// \return \li decorated interval enclosing the provided interval literal if it is a valid inf-sup form or uncertain form literal
|
178
|
+
/// \li NaI otherwise
|
179
|
+
///
|
180
|
+
///
|
181
|
+
/// \note The function is forwarded to the function <c>Flavor\<T\>::text_to_decorated_interval(std::string const& str)</c>
|
182
|
+
/// which creates the representation for a decorated interval.
|
183
|
+
/// \see \link p1788::flavor::infsup::setbased::mpfr_bin_ieee754_flavor<T>::text_to_decorated_interval(std::string const& str) \endlink
|
184
|
+
///
|
185
|
+
inline explicit
|
186
|
+
decorated_interval(std::string const& str)
|
187
|
+
: base_interval_type(Flavor<T>::text_to_decorated_interval(str))
|
188
|
+
{ }
|
189
|
+
|
190
|
+
/// \brief Copy constructor
|
191
|
+
///
|
192
|
+
/// \param other Decorated interval to be copied
|
193
|
+
///
|
194
|
+
/// \return Copy of \p other
|
195
|
+
///
|
196
|
+
/// \note The function is forwarded to the function <c>Flavor\<T\>::copy(representation_dec const& other)</c>
|
197
|
+
/// which creates the representation for a decorated interval.
|
198
|
+
/// \see \link p1788::flavor::infsup::setbased::mpfr_bin_ieee754_flavor<T>::copy(representation_dec const& other) \endlink
|
199
|
+
///
|
200
|
+
inline
|
201
|
+
decorated_interval(decorated_interval<T, Flavor> const& other)
|
202
|
+
: base_interval_type(Flavor<T>::copy(other.rep_))
|
203
|
+
{ }
|
204
|
+
|
205
|
+
/// \brief Convert constructor
|
206
|
+
///
|
207
|
+
/// \param other Decorated interval to be converted
|
208
|
+
///
|
209
|
+
/// \return Hull of \p other
|
210
|
+
///
|
211
|
+
/// \note The function is forwarded to the function <c>Flavor\<T\>::convert_type(representation_dec_type<T_> const& other)</c>
|
212
|
+
/// which creates the representation for a decorated interval.
|
213
|
+
/// \see \link p1788::flavor::infsup::setbased::mpfr_bin_ieee754_flavor<T>::convert_type(representation_dec_type<T_> const& other) \endlink
|
214
|
+
///
|
215
|
+
template<typename T_>
|
216
|
+
inline explicit
|
217
|
+
decorated_interval(decorated_interval<T_, Flavor> const& other)
|
218
|
+
: base_interval_type(Flavor<T>::convert_type(other.rep_))
|
219
|
+
{ }
|
220
|
+
|
221
|
+
/// \brief Decorated interval out of a bare interval constructor
|
222
|
+
///
|
223
|
+
/// \param other Bare interval to be converted
|
224
|
+
///
|
225
|
+
/// \return \li \p other <sub> \link p1788::decoration::decoration com \endlink </sub> if \p other is finite
|
226
|
+
/// \li \p other <sub> \link p1788::decoration::decoration dac \endlink </sub> if \p other is infinite
|
227
|
+
/// \li \p other <sub> \link p1788::decoration::decoration trv \endlink </sub> if \p other is empty
|
228
|
+
///
|
229
|
+
/// \note The function is forwarded to the function <c>Flavor\<T\>::new_dec(representation const& other)</c>
|
230
|
+
/// which creates the representation for a decorated interval.
|
231
|
+
/// \see \link p1788::flavor::infsup::setbased::mpfr_bin_ieee754_flavor<T>::new_dec(representation const& other) \endlink
|
232
|
+
///
|
233
|
+
inline
|
234
|
+
decorated_interval(interval<T, Flavor> const& other)
|
235
|
+
: base_interval_type(Flavor<T>::new_dec(other.rep_))
|
236
|
+
{ }
|
237
|
+
|
238
|
+
/// \brief Decorated interval out of a converted bare interval constructor
|
239
|
+
///
|
240
|
+
/// \param other Bare interval to be converted
|
241
|
+
///
|
242
|
+
/// \return Hull of
|
243
|
+
/// \li \p other <sub> \link p1788::decoration::decoration com \endlink </sub> if hull of \p other is finite
|
244
|
+
/// \li \p other <sub> \link p1788::decoration::decoration dac \endlink </sub> if hull \p other is infinite
|
245
|
+
/// \li \p other <sub> \link p1788::decoration::decoration trv \endlink </sub> if hull \p other is empty
|
246
|
+
///
|
247
|
+
/// \note The function is forwarded to the function <c>Flavor\<T\>::new_dec(representation_type<T_> const& other)</c>
|
248
|
+
/// which creates the representation for a decorated interval.
|
249
|
+
/// \see \link p1788::flavor::infsup::setbased::mpfr_bin_ieee754_flavor<T>::new_dec(representation_type<T_> const& other) \endlink
|
250
|
+
///
|
251
|
+
template<typename T_>
|
252
|
+
inline explicit
|
253
|
+
decorated_interval(interval<T_, Flavor> const& other)
|
254
|
+
: base_interval_type(Flavor<T>::new_dec(other.rep_))
|
255
|
+
{ }
|
256
|
+
|
257
|
+
/// \brief Decorated interval out of a bare interval and a decoration constructor
|
258
|
+
///
|
259
|
+
/// \param other Bare interval to be converted
|
260
|
+
/// \param dec Decoration
|
261
|
+
///
|
262
|
+
/// \return \li Decorated interval combined out of \p other and \p dec if the combination is valid
|
263
|
+
/// \li NaI otherwise
|
264
|
+
///
|
265
|
+
/// \note The function is forwarded to the function <c>Flavor\<T\>::set_dec(representation const& other, p1788::decoration::decoration dec)</c>
|
266
|
+
/// which creates the representation for a decorated interval.
|
267
|
+
/// \see \link p1788::flavor::infsup::setbased::mpfr_bin_ieee754_flavor<T>::set_dec(representation const& other, p1788::decoration::decoration dec) \endlink
|
268
|
+
///
|
269
|
+
inline
|
270
|
+
decorated_interval(interval<T, Flavor> const& other, p1788::decoration::decoration dec)
|
271
|
+
: base_interval_type(Flavor<T>::set_dec(other.rep_, dec))
|
272
|
+
{ }
|
273
|
+
|
274
|
+
/// \brief Decorated interval out of a converted bare interval and a decoration constructor
|
275
|
+
///
|
276
|
+
/// \param other Bare interval to be converted
|
277
|
+
/// \param dec Decoration
|
278
|
+
///
|
279
|
+
/// \return \li Decorated interval combined out of hull of \p other and \p dec if the combination is valid
|
280
|
+
/// \li NaI otherwise
|
281
|
+
///
|
282
|
+
/// \note The function is forwarded to the function <c>Flavor\<T\>::set_dec(representation_type<T_> const& other, p1788::decoration::decoration dec)</c>
|
283
|
+
/// which creates the representation for a decorated interval.
|
284
|
+
/// \see \link p1788::flavor::infsup::setbased::mpfr_bin_ieee754_flavor<T>::set_dec(representation_type<T_> const& other, p1788::decoration::decoration dec) \endlink
|
285
|
+
///
|
286
|
+
template<typename T_>
|
287
|
+
inline explicit
|
288
|
+
decorated_interval(interval<T_, Flavor> const& other, p1788::decoration::decoration dec)
|
289
|
+
: base_interval_type(Flavor<T>::set_dec(other.rep_, dec))
|
290
|
+
{ }
|
291
|
+
|
292
|
+
///@}
|
293
|
+
|
294
|
+
// -----------------------------------------------------------------------------
|
295
|
+
// Interval constants
|
296
|
+
// -----------------------------------------------------------------------------
|
297
|
+
|
298
|
+
///@name Interval constants
|
299
|
+
///
|
300
|
+
///
|
301
|
+
///@{
|
302
|
+
|
303
|
+
/// \brief Returns an empty decorated interval
|
304
|
+
///
|
305
|
+
/// \return \f$\emptyset\f$<sub>\link p1788::decoration::decoration trv\endlink</sub>
|
306
|
+
///
|
307
|
+
/// \note The function is forwarded to the function <c>Flavor\<T\>::empty_dec()</c>
|
308
|
+
/// which creates the representation for an empty decorated interval.
|
309
|
+
/// \see \link p1788::flavor::infsup::setbased::mpfr_bin_ieee754_flavor<T>::empty_dec() \endlink
|
310
|
+
///
|
311
|
+
inline
|
312
|
+
static decorated_interval empty()
|
313
|
+
{
|
314
|
+
return decorated_interval(Flavor<T>::empty_dec());
|
315
|
+
}
|
316
|
+
|
317
|
+
/// \brief Returns an entire decorated interval
|
318
|
+
///
|
319
|
+
/// \return \f$[-\infty,+\infty]\f$<sub>\link p1788::decoration::decoration dac\endlink</sub>
|
320
|
+
///
|
321
|
+
/// \note The function is forwarded to the function <c>Flavor\<T\>::entire_dec()</c>
|
322
|
+
/// which creates the representation for an entire decorated interval.
|
323
|
+
/// \see \link p1788::flavor::infsup::setbased::mpfr_bin_ieee754_flavor<T>::entire_dec() \endlink
|
324
|
+
///
|
325
|
+
inline
|
326
|
+
static decorated_interval entire()
|
327
|
+
{
|
328
|
+
return decorated_interval(Flavor<T>::entire_dec());
|
329
|
+
}
|
330
|
+
|
331
|
+
/// \brief Returns an ill-formed decorated interval (Not an Interval)
|
332
|
+
///
|
333
|
+
/// \return NaI (= \f$\emptyset\f$<sub>\link p1788::decoration::decoration ill\endlink</sub>)
|
334
|
+
///
|
335
|
+
/// \note The function is forwarded to the function <c>Flavor\<T\>::nai()</c>
|
336
|
+
/// which creates the representation for an ill-formed decorated interval (NaI).
|
337
|
+
/// \see \link p1788::flavor::infsup::setbased::mpfr_bin_ieee754_flavor<T>::nai() \endlink
|
338
|
+
///
|
339
|
+
inline
|
340
|
+
static decorated_interval nai()
|
341
|
+
{
|
342
|
+
return decorated_interval(Flavor<T>::nai());
|
343
|
+
}
|
344
|
+
|
345
|
+
///@}
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
// -----------------------------------------------------------------------------
|
350
|
+
// Decorated interval specific methods
|
351
|
+
// -----------------------------------------------------------------------------
|
352
|
+
|
353
|
+
///@name Decorated interval specific functions
|
354
|
+
///
|
355
|
+
///
|
356
|
+
///@{
|
357
|
+
|
358
|
+
/// \brief Checks if the interval is NaI
|
359
|
+
///
|
360
|
+
/// The computation is delegated to the static function
|
361
|
+
/// <c>Flavor<T>::is_nai(representation_dec const& x)</c>
|
362
|
+
/// of the policy class <c>Flavor<T></c> by passing only the internal
|
363
|
+
/// representation of the interval.
|
364
|
+
///
|
365
|
+
/// \param x decorated interval
|
366
|
+
///
|
367
|
+
/// \retval true \p x is NaI
|
368
|
+
/// \retval false otherwise
|
369
|
+
///
|
370
|
+
/// \see <c>\link p1788::flavor::infsup::setbased::mpfr_bin_ieee754_flavor::is_nai(representation_dec const& x) mpfr_bin_ieee754_flavor::is_nai(representation_dec const& x) \endlink</c>
|
371
|
+
///
|
372
|
+
inline
|
373
|
+
static bool is_nai(decorated_interval<T,Flavor> const& x)
|
374
|
+
{
|
375
|
+
return Flavor<T>::is_nai(x.rep_);
|
376
|
+
}
|
377
|
+
|
378
|
+
|
379
|
+
/// \brief Returns the decoration of an decorated interval
|
380
|
+
///
|
381
|
+
/// The computation is delegated to the static function
|
382
|
+
/// <c>Flavor<T>::decoration(representation_dec const& x)</c>
|
383
|
+
/// of the policy class <c>Flavor<T></c> by passing only the internal
|
384
|
+
/// representation of the interval.
|
385
|
+
///
|
386
|
+
/// \param x decorated interval
|
387
|
+
///
|
388
|
+
/// \return decoration of \p x
|
389
|
+
///
|
390
|
+
/// \see <c>\link p1788::flavor::infsup::setbased::mpfr_bin_ieee754_flavor::decoration_part(representation_dec const& x) mpfr_bin_ieee754_flavor::decoration_part(representation_dec const& x) \endlink</c>
|
391
|
+
///
|
392
|
+
inline
|
393
|
+
static p1788::decoration::decoration decoration(decorated_interval<T,Flavor> const& x)
|
394
|
+
{
|
395
|
+
return Flavor<T>::decoration_part(x.rep_);
|
396
|
+
}
|
397
|
+
|
398
|
+
///@}
|
399
|
+
|
400
|
+
private:
|
401
|
+
|
402
|
+
// private constructor which is used by the base_interval to create concrete decorated intervals
|
403
|
+
inline explicit
|
404
|
+
decorated_interval(typename Flavor<T>::representation_dec rep)
|
405
|
+
: base_interval_type(rep)
|
406
|
+
{}
|
407
|
+
|
408
|
+
friend class base_interval<T, Flavor, typename Flavor<T>::representation_dec, decorated_interval<T, Flavor>>;
|
409
|
+
|
410
|
+
template<typename, template<typename> class>
|
411
|
+
friend class interval;
|
412
|
+
|
413
|
+
|
414
|
+
}; // class decorated_interval
|
415
|
+
|
416
|
+
|
417
|
+
|
418
|
+
|
419
|
+
///@name Decorated interval specific functions
|
420
|
+
///
|
421
|
+
///
|
422
|
+
///@{
|
423
|
+
|
424
|
+
|
425
|
+
/// \brief Checks if the interval is NaI
|
426
|
+
///
|
427
|
+
/// The computation is delegated to the static function
|
428
|
+
/// \link decorated_interval<T,Flavor>::is_nai(decorated_interval<T, Flavor> const& x) \endlink.
|
429
|
+
///
|
430
|
+
/// \param x decorated interval
|
431
|
+
///
|
432
|
+
/// \retval true \p x is NaI
|
433
|
+
/// \retval false otherwise
|
434
|
+
template<typename T, template<typename> class Flavor>
|
435
|
+
inline
|
436
|
+
bool is_nai(decorated_interval<T, Flavor> const& x)
|
437
|
+
{
|
438
|
+
return decorated_interval<T, Flavor>::is_nai(x);
|
439
|
+
}
|
440
|
+
|
441
|
+
/// \brief Returns the decoration of an decorated interval
|
442
|
+
///
|
443
|
+
/// The computation is delegated to the static function
|
444
|
+
/// \link decorated_interval<T,Flavor>::decoration(decorated_interval<T, Flavor> const& x) \endlink.
|
445
|
+
///
|
446
|
+
/// \param x decorated interval
|
447
|
+
///
|
448
|
+
/// \return decoration of \p x
|
449
|
+
template<typename T, template<typename> class Flavor>
|
450
|
+
inline
|
451
|
+
p1788::decoration::decoration decoration(decorated_interval<T, Flavor> const& x)
|
452
|
+
{
|
453
|
+
return decorated_interval<T, Flavor>::decoration(x);
|
454
|
+
}
|
455
|
+
|
456
|
+
///@}
|
457
|
+
|
458
|
+
|
459
|
+
} // namespace infsup
|
460
|
+
|
461
|
+
} // namespace p1788
|
462
|
+
|
463
|
+
|
464
|
+
#endif // LIBIEEEP1788_P1788_INFSUP_DECORATED_INTERVAL_HPP
|
@@ -0,0 +1,66 @@
|
|
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_FORWARD_DECLARATION_HPP
|
27
|
+
#define LIBIEEEP1788_P1788_INFSUP_FORWARD_DECLARATION_HPP
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
//------------------------------------------------------------------------------
|
32
|
+
//------------------------------------------------------------------------------
|
33
|
+
// Forward declaration
|
34
|
+
//------------------------------------------------------------------------------
|
35
|
+
//------------------------------------------------------------------------------
|
36
|
+
|
37
|
+
|
38
|
+
namespace p1788
|
39
|
+
{
|
40
|
+
|
41
|
+
namespace infsup
|
42
|
+
{
|
43
|
+
|
44
|
+
|
45
|
+
// base type
|
46
|
+
template<typename T, template<typename> class Flavor, typename RepType, class ConcreteInterval>
|
47
|
+
class base_interval;
|
48
|
+
|
49
|
+
// bare interval
|
50
|
+
template<typename T, template<typename> class Flavor>
|
51
|
+
class interval;
|
52
|
+
|
53
|
+
// decorated interval
|
54
|
+
template<typename T, template<typename> class Flavor>
|
55
|
+
class decorated_interval;
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
} // namespace infsup
|
60
|
+
|
61
|
+
|
62
|
+
} // namespace p1788
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
#endif // LIBIEEEP1788_P1788_INFSUP_FORWARD_DECLARATION_HPP
|