123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- #ifndef BOOST_NUMERIC_INTERVAL_ARITH3_HPP
- #define BOOST_NUMERIC_INTERVAL_ARITH3_HPP
- #include <boost/numeric/interval/detail/interval_prototype.hpp>
- #include <boost/numeric/interval/detail/test_input.hpp>
- namespace boost {
- namespace numeric {
- namespace interval_lib {
- template<class I> inline
- I add(const typename I::base_type& x, const typename I::base_type& y)
- {
- typedef typename I::traits_type Policies;
- if (detail::test_input<typename I::base_type, Policies>(x, y))
- return I::empty();
- typename Policies::rounding rnd;
- return I(rnd.add_down(x, y), rnd.add_up(x, y), true);
- }
- template<class I> inline
- I sub(const typename I::base_type& x, const typename I::base_type& y)
- {
- typedef typename I::traits_type Policies;
- if (detail::test_input<typename I::base_type, Policies>(x, y))
- return I::empty();
- typename Policies::rounding rnd;
- return I(rnd.sub_down(x, y), rnd.sub_up(x, y), true);
- }
- template<class I> inline
- I mul(const typename I::base_type& x, const typename I::base_type& y)
- {
- typedef typename I::traits_type Policies;
- if (detail::test_input<typename I::base_type, Policies>(x, y))
- return I::empty();
- typename Policies::rounding rnd;
- return I(rnd.mul_down(x, y), rnd.mul_up(x, y), true);
- }
- template<class I> inline
- I div(const typename I::base_type& x, const typename I::base_type& y)
- {
- typedef typename I::traits_type Policies;
- if (detail::test_input<typename I::base_type, Policies>(x, y) || user::is_zero(y))
- return I::empty();
- typename Policies::rounding rnd;
- return I(rnd.div_down(x, y), rnd.div_up(x, y), true);
- }
- }
- }
- }
- #endif
|