Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/boost/numeric/interval/compare/tribool.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /* Boost interval/compare/tribool.hpp template implementation file
0002  *
0003  * Copyright 2002-2003 Guillaume Melquiond
0004  *
0005  * Distributed under the Boost Software License, Version 1.0.
0006  * (See accompanying file LICENSE_1_0.txt or
0007  * copy at http://www.boost.org/LICENSE_1_0.txt)
0008  */
0009 
0010 #ifndef BOOST_NUMERIC_INTERVAL_COMPARE_TRIBOOL_HPP
0011 #define BOOST_NUMERIC_INTERVAL_COMPARE_TRIBOOL_HPP
0012 
0013 #include <boost/numeric/interval/detail/interval_prototype.hpp>
0014 #include <boost/numeric/interval/detail/test_input.hpp>
0015 #include <boost/logic/tribool.hpp>
0016 
0017 namespace boost {
0018 namespace numeric {
0019 namespace interval_lib {
0020 namespace compare {
0021 namespace tribool {
0022 
0023 template<class T, class Policies1, class Policies2> inline
0024 logic::tribool operator<(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
0025 {
0026   if (detail::test_input(x, y)) throw comparison_error();
0027   if (x.upper() < y.lower()) return true;
0028   if (x.lower() >= y.upper()) return false;
0029   return logic::indeterminate;
0030 }
0031 
0032 template<class T, class Policies> inline
0033 logic::tribool operator<(const interval<T, Policies>& x, const T& y)
0034 {
0035   if (detail::test_input(x, y)) throw comparison_error();
0036   if (x.upper() < y) return true;
0037   if (x.lower() >= y) return false;
0038   return logic::indeterminate;
0039 }
0040 
0041 template<class T, class Policies1, class Policies2> inline
0042 logic::tribool operator<=(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
0043 {
0044   if (detail::test_input(x, y)) throw comparison_error();
0045   if (x.upper() <= y.lower()) return true;
0046   if (x.lower() > y.upper()) return false;
0047   return logic::indeterminate;
0048 }
0049 
0050 template<class T, class Policies> inline
0051 logic::tribool operator<=(const interval<T, Policies>& x, const T& y)
0052 {
0053   if (detail::test_input(x, y)) throw comparison_error();
0054   if (x.upper() <= y) return true;
0055   if (x.lower() > y) return false;
0056   return logic::indeterminate;
0057 }
0058 
0059 template<class T, class Policies1, class Policies2> inline
0060 logic::tribool operator>(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
0061 {
0062   if (detail::test_input(x, y)) throw comparison_error();
0063   if (x.lower() > y.upper()) return true;
0064   if (x.upper() <= y.lower()) return false;
0065   return logic::indeterminate;
0066 }
0067 
0068 template<class T, class Policies> inline
0069 logic::tribool operator>(const interval<T, Policies>& x, const T& y)
0070 {
0071   if (detail::test_input(x, y)) throw comparison_error();
0072   if (x.lower() > y) return true;
0073   if (x.upper() <= y) return false;
0074   return logic::indeterminate;
0075 }
0076 
0077 template<class T, class Policies1, class Policies2> inline
0078 logic::tribool operator>=(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
0079 {
0080   if (detail::test_input(x, y)) throw comparison_error();
0081   if (x.lower() >= y.upper()) return true;
0082   if (x.upper() < y.lower()) return false;
0083   return logic::indeterminate;
0084 }
0085 
0086 template<class T, class Policies> inline
0087 logic::tribool operator>=(const interval<T, Policies>& x, const T& y)
0088 {
0089   if (detail::test_input(x, y)) throw comparison_error();
0090   if (x.lower() >= y) return true;
0091   if (x.upper() < y) return false;
0092   return logic::indeterminate;
0093 }
0094 
0095 template<class T, class Policies1, class Policies2> inline
0096 logic::tribool operator==(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
0097 {
0098   if (detail::test_input(x, y)) throw comparison_error();
0099   if (x.upper() == y.lower() && x.lower() == y.upper()) return true;
0100   if (x.upper() < y.lower() || x.lower() > y.upper()) return false;
0101   return logic::indeterminate;
0102 }
0103 
0104 template<class T, class Policies> inline
0105 logic::tribool operator==(const interval<T, Policies>& x, const T& y)
0106 {
0107   if (detail::test_input(x, y)) throw comparison_error();
0108   if (x.upper() == y && x.lower() == y) return true;
0109   if (x.upper() < y || x.lower() > y) return false;
0110   return logic::indeterminate;
0111 }
0112 
0113 template<class T, class Policies1, class Policies2> inline
0114 logic::tribool operator!=(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
0115 {
0116   if (detail::test_input(x, y)) throw comparison_error();
0117   if (x.upper() < y.lower() || x.lower() > y.upper()) return true;
0118   if (x.upper() == y.lower() && x.lower() == y.upper()) return false;
0119   return logic::indeterminate;
0120 }
0121 
0122 template<class T, class Policies> inline
0123 logic::tribool operator!=(const interval<T, Policies>& x, const T& y)
0124 {
0125   if (detail::test_input(x, y)) throw comparison_error();
0126   if (x.upper() < y || x.lower() > y) return true;
0127   if (x.upper() == y && x.lower() == y) return false;
0128   return logic::indeterminate;
0129 }
0130 
0131 } // namespace tribool
0132 } // namespace compare
0133 } // namespace interval_lib
0134 } // namespace numeric
0135 } // namespace boost
0136 
0137 
0138 #endif // BOOST_NUMERIC_INTERVAL_COMPARE_TRIBOOL_HPP