Update contrib.
1 /* Boost interval/arith3.hpp template implementation file
3 * This headers provides arithmetical functions
4 * which compute an interval given some base
5 * numbers. The resulting interval encloses the
6 * real result of the arithmetic operation.
8 * Copyright 2003 Guillaume Melquiond
10 * Distributed under the Boost Software License, Version 1.0.
11 * (See accompanying file LICENSE_1_0.txt or
12 * copy at http://www.boost.org/LICENSE_1_0.txt)
15 #ifndef BOOST_NUMERIC_INTERVAL_ARITH3_HPP
16 #define BOOST_NUMERIC_INTERVAL_ARITH3_HPP
18 #include <boost/numeric/interval/detail/interval_prototype.hpp>
19 #include <boost/numeric/interval/detail/test_input.hpp>
23 namespace interval_lib {
25 template<class I> inline
26 I add(const typename I::base_type& x, const typename I::base_type& y)
28 typedef typename I::traits_type Policies;
29 if (detail::test_input<typename I::base_type, Policies>(x, y))
31 typename Policies::rounding rnd;
32 return I(rnd.add_down(x, y), rnd.add_up(x, y), true);
35 template<class I> inline
36 I sub(const typename I::base_type& x, const typename I::base_type& y)
38 typedef typename I::traits_type Policies;
39 if (detail::test_input<typename I::base_type, Policies>(x, y))
41 typename Policies::rounding rnd;
42 return I(rnd.sub_down(x, y), rnd.sub_up(x, y), true);
45 template<class I> inline
46 I mul(const typename I::base_type& x, const typename I::base_type& y)
48 typedef typename I::traits_type Policies;
49 if (detail::test_input<typename I::base_type, Policies>(x, y))
51 typename Policies::rounding rnd;
52 return I(rnd.mul_down(x, y), rnd.mul_up(x, y), true);
55 template<class I> inline
56 I div(const typename I::base_type& x, const typename I::base_type& y)
58 typedef typename I::traits_type Policies;
59 if (detail::test_input<typename I::base_type, Policies>(x, y) || user::is_zero(y))
61 typename Policies::rounding rnd;
62 return I(rnd.div_down(x, y), rnd.div_up(x, y), true);
65 } // namespace interval_lib
66 } // namespace numeric
69 #endif // BOOST_NUMERIC_INTERVAL_ARITH3_HPP