1 /* Boost interval/detail/test_input.hpp file
2 *
3 * Copyright 2002 Hervé Brönnimann, Guillaume Melquiond, Sylvain Pion
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE_1_0.txt or
7 * copy at http://www.boost.org/LICENSE_1_0.txt)
8 */
9
10 #ifndef BOOST_NUMERIC_INTERVAL_DETAIL_TEST_INPUT_HPP
11 #define BOOST_NUMERIC_INTERVAL_DETAIL_TEST_INPUT_HPP
12
13 #include <boost/numeric/interval/detail/interval_prototype.hpp>
14
15 namespace boost {
16 namespace numeric {
17 namespace interval_lib {
18 namespace user {
19
20 template<class T> inline
is_zero(T const & v)21 bool is_zero(T const &v) { return v == static_cast<T>(0); }
22
23 template<class T> inline
is_neg(T const & v)24 bool is_neg (T const &v) { return v < static_cast<T>(0); }
25
26 template<class T> inline
is_pos(T const & v)27 bool is_pos (T const &v) { return v > static_cast<T>(0); }
28
29 } // namespace user
30
31 namespace detail {
32
33 template<class T, class Policies> inline
test_input(const interval<T,Policies> & x)34 bool test_input(const interval<T, Policies>& x) {
35 typedef typename Policies::checking checking;
36 return checking::is_empty(x.lower(), x.upper());
37 }
38
39 template<class T, class Policies1, class Policies2> inline
test_input(const interval<T,Policies1> & x,const interval<T,Policies2> & y)40 bool test_input(const interval<T, Policies1>& x, const interval<T, Policies2>& y) {
41 typedef typename Policies1::checking checking1;
42 typedef typename Policies2::checking checking2;
43 return checking1::is_empty(x.lower(), x.upper()) ||
44 checking2::is_empty(y.lower(), y.upper());
45 }
46
47 template<class T, class Policies> inline
test_input(const T & x,const interval<T,Policies> & y)48 bool test_input(const T& x, const interval<T, Policies>& y) {
49 typedef typename Policies::checking checking;
50 return checking::is_nan(x) || checking::is_empty(y.lower(), y.upper());
51 }
52
53 template<class T, class Policies> inline
test_input(const interval<T,Policies> & x,const T & y)54 bool test_input(const interval<T, Policies>& x, const T& y) {
55 typedef typename Policies::checking checking;
56 return checking::is_empty(x.lower(), x.upper()) || checking::is_nan(y);
57 }
58
59 template<class T, class Policies> inline
test_input(const T & x)60 bool test_input(const T& x) {
61 typedef typename Policies::checking checking;
62 return checking::is_nan(x);
63 }
64
65 template<class T, class Policies> inline
test_input(const T & x,const T & y)66 bool test_input(const T& x, const T& y) {
67 typedef typename Policies::checking checking;
68 return checking::is_nan(x) || checking::is_nan(y);
69 }
70
71 } // namespace detail
72 } // namespace interval_lib
73 } // namespace numeric
74 } // namespace boost
75
76 #endif // BOOST_NUMERIC_INTERVAL_DETAIL_TEST_INPUT_HPP
77