source: NonGTP/Boost/boost/numeric/interval/compare/explicit.hpp @ 857

Revision 857, 6.2 KB checked in by igarcia, 19 years ago (diff)
Line 
1/* Boost interval/compare/explicit.hpp template implementation file
2 *
3 * Copyright 2000 Jens Maurer
4 * Copyright 2002 Hervé Brönnimann, Guillaume Melquiond, Sylvain Pion
5 *
6 * Distributed under the Boost Software License, Version 1.0.
7 * (See accompanying file LICENSE_1_0.txt or
8 * copy at http://www.boost.org/LICENSE_1_0.txt)
9 */
10
11#ifndef BOOST_NUMERIC_INTERVAL_COMPARE_EXPLICIT_HPP
12#define BOOST_NUMERIC_INTERVAL_COMPARE_EXPLICIT_HPP
13
14#include <boost/numeric/interval/detail/interval_prototype.hpp>
15
16namespace boost {
17namespace numeric {
18namespace interval_lib {
19
20/*
21 * Certainly... operations
22 */
23
24template<class T, class Policies1, class Policies2> inline
25bool cerlt(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
26{
27  return x.upper() < y.lower();
28}
29
30template<class T, class Policies> inline
31bool cerlt(const interval<T, Policies>& x, const T& y)
32{
33  return x.upper() < y;
34}
35
36template<class T, class Policies> inline
37bool cerlt(const T& x, const interval<T, Policies>& y)
38{
39  return x < y.lower();
40}
41
42template<class T, class Policies1, class Policies2> inline
43bool cerle(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
44{
45  return x.upper() <= y.lower();
46}
47
48template<class T, class Policies> inline
49bool cerle(const interval<T, Policies>& x, const T& y)
50{
51  return x.upper() <= y;
52}
53
54template<class T, class Policies> inline
55bool cerle(const T& x, const interval<T, Policies>& y)
56{
57  return x <= y.lower();
58}
59
60template<class T, class Policies1, class Policies2> inline
61bool cergt(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
62{
63  return x.lower() > y.upper();
64}
65
66template<class T, class Policies> inline
67bool cergt(const interval<T, Policies>& x, const T& y)
68{
69  return x.lower() > y;
70}
71
72template<class T, class Policies> inline
73bool cergt(const T& x, const interval<T, Policies>& y)
74{
75  return x > y.upper();
76}
77
78template<class T, class Policies1, class Policies2> inline
79bool cerge(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
80{
81  return x.lower() >= y.upper();
82}
83
84template<class T, class Policies> inline
85bool cerge(const interval<T, Policies>& x, const T& y)
86{
87  return x.lower() >= y;
88}
89
90template<class T, class Policies> inline
91bool cerge(const T& x, const interval<T, Policies>& y)
92{
93  return x >= y.upper();
94}
95
96template<class T, class Policies1, class Policies2> inline
97bool cereq(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
98{
99  return x.lower() == y.upper() && y.lower() == x.upper();
100}
101
102template<class T, class Policies> inline
103bool cereq(const interval<T, Policies>& x, const T& y)
104{
105  return x.lower() == y && x.upper() == y;
106}
107
108template<class T, class Policies> inline
109bool cereq(const T& x, const interval<T, Policies>& y)
110{
111  return x == y.lower() && x == y.upper();
112}
113
114template<class T, class Policies1, class Policies2> inline
115bool cerne(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
116{
117  return x.upper() < y.lower() || y.upper() < x.lower();
118}
119
120template<class T, class Policies> inline
121bool cerne(const interval<T, Policies>& x, const T& y)
122{
123  return x.upper() < y || y < x.lower();
124}
125
126template<class T, class Policies> inline
127bool cerne(const T& x, const interval<T, Policies>& y)
128{
129  return x < y.lower() || y.upper() < x;
130}
131
132/*
133 * Possibly... comparisons
134 */
135
136template<class T, class Policies1, class Policies2> inline
137bool poslt(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
138{
139  return x.lower() < y.upper();
140}
141
142template<class T, class Policies> inline
143bool poslt(const interval<T, Policies>& x, const T& y)
144{
145  return x.lower() < y;
146}
147
148template<class T, class Policies> inline
149bool poslt(const T& x, const interval<T, Policies>& y)
150{
151  return x < y.upper();
152}
153
154template<class T, class Policies1, class Policies2> inline
155bool posle(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
156{
157  return x.lower() <= y.upper();
158}
159
160template<class T, class Policies> inline
161bool posle(const interval<T, Policies>& x, const T& y)
162{
163  return x.lower() <= y;
164}
165
166template<class T, class Policies> inline
167bool posle(const T& x, const interval<T, Policies>& y)
168{
169  return x <= y.upper();
170}
171
172template<class T, class Policies1, class Policies2> inline
173bool posgt(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
174{
175  return x.upper() > y.lower();
176}
177
178template<class T, class Policies> inline
179bool posgt(const interval<T, Policies>& x, const T& y)
180{
181  return x.upper() > y;
182}
183
184template<class T, class Policies> inline
185bool posgt(const T& x, const interval<T, Policies> & y)
186{
187  return x > y.lower();
188}
189
190template<class T, class Policies1, class Policies2> inline
191bool posge(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
192{
193  return x.upper() >= y.lower();
194}
195
196template<class T, class Policies> inline
197bool posge(const interval<T, Policies>& x, const T& y)
198{
199  return x.upper() >= y;
200}
201
202template<class T, class Policies> inline
203bool posge(const T& x, const interval<T, Policies>& y)
204{
205  return x >= y.lower();
206}
207
208template<class T, class Policies1, class Policies2> inline
209bool poseq(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
210{
211  return x.upper() >= y.lower() && y.upper() >= x.lower();
212}
213
214template<class T, class Policies> inline
215bool poseq(const interval<T, Policies>& x, const T& y)
216{
217  return x.upper() >= y && y >= x.lower();
218}
219
220template<class T, class Policies> inline
221bool poseq(const T& x, const interval<T, Policies>& y)
222{
223  return x >= y.lower() && y.upper() >= x;
224}
225
226template<class T, class Policies1, class Policies2> inline
227bool posne(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
228{
229  return x.upper() != y.lower() || y.upper() != x.lower();
230}
231
232template<class T, class Policies> inline
233bool posne(const interval<T, Policies>& x, const T& y)
234{
235  return x.upper() != y || y != x.lower();
236}
237
238template<class T, class Policies> inline
239bool posne(const T& x, const interval<T, Policies>& y)
240{
241  return x != y.lower() || y.upper() != x;
242}
243
244} // namespace interval_lib
245} // namespace numeric
246} //namespace boost
247
248#endif // BOOST_NUMERIC_INTERVAL_COMPARE_EXPLICIT_HPP
Note: See TracBrowser for help on using the repository browser.