File indexing completed on 2025-01-30 09:49:07
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef BOOST_NUMERIC_INTERVAL_ARITH3_HPP
0016 #define BOOST_NUMERIC_INTERVAL_ARITH3_HPP
0017
0018 #include <boost/numeric/interval/detail/interval_prototype.hpp>
0019 #include <boost/numeric/interval/detail/test_input.hpp>
0020
0021 namespace boost {
0022 namespace numeric {
0023 namespace interval_lib {
0024
0025 template<class I> inline
0026 I add(const typename I::base_type& x, const typename I::base_type& y)
0027 {
0028 typedef typename I::traits_type Policies;
0029 if (detail::test_input<typename I::base_type, Policies>(x, y))
0030 return I::empty();
0031 typename Policies::rounding rnd;
0032 return I(rnd.add_down(x, y), rnd.add_up(x, y), true);
0033 }
0034
0035 template<class I> inline
0036 I sub(const typename I::base_type& x, const typename I::base_type& y)
0037 {
0038 typedef typename I::traits_type Policies;
0039 if (detail::test_input<typename I::base_type, Policies>(x, y))
0040 return I::empty();
0041 typename Policies::rounding rnd;
0042 return I(rnd.sub_down(x, y), rnd.sub_up(x, y), true);
0043 }
0044
0045 template<class I> inline
0046 I mul(const typename I::base_type& x, const typename I::base_type& y)
0047 {
0048 typedef typename I::traits_type Policies;
0049 if (detail::test_input<typename I::base_type, Policies>(x, y))
0050 return I::empty();
0051 typename Policies::rounding rnd;
0052 return I(rnd.mul_down(x, y), rnd.mul_up(x, y), true);
0053 }
0054
0055 template<class I> inline
0056 I div(const typename I::base_type& x, const typename I::base_type& y)
0057 {
0058 typedef typename I::traits_type Policies;
0059 if (detail::test_input<typename I::base_type, Policies>(x, y) || user::is_zero(y))
0060 return I::empty();
0061 typename Policies::rounding rnd;
0062 return I(rnd.div_down(x, y), rnd.div_up(x, y), true);
0063 }
0064
0065 }
0066 }
0067 }
0068
0069 #endif