| 49 | } |
| 50 | |
| 51 | template<class T, class Policies> inline |
| 52 | interval<T, Policies> cos(const interval<T, Policies>& x) |
| 53 | { |
| 54 | if (interval_lib::detail::test_input(x)) |
| 55 | return interval<T, Policies>::empty(); |
| 56 | typename Policies::rounding rnd; |
| 57 | typedef interval<T, Policies> I; |
| 58 | typedef typename interval_lib::unprotect<I>::type R; |
| 59 | |
| 60 | // get lower bound within [0, pi] |
| 61 | const R pi2 = interval_lib::pi_twice<R>(); |
| 62 | R tmp = fmod((const R&)x, pi2); |
| 63 | if (width(tmp) >= pi2.lower()) |
| 64 | return I(static_cast<T>(-1), static_cast<T>(1), true); // we are covering a full period |
| 65 | if (tmp.lower() >= interval_lib::constants::pi_upper<T>()) |
| 66 | return -cos(tmp - interval_lib::pi<R>()); |
| 67 | T l = tmp.lower(); |
| 68 | T u = tmp.upper(); |
| 69 | |
| 70 | GECODE_BOOST_USING_STD_MIN(); |
| 71 | // separate into monotone subintervals |
| 72 | if (u <= interval_lib::constants::pi_lower<T>()) |
| 73 | return I(rnd.cos_down(u), rnd.cos_up(l), true); |
| 74 | else if (u <= pi2.lower()) |
| 75 | return I(static_cast<T>(-1), rnd.cos_up(min GECODE_BOOST_PREVENT_MACRO_SUBSTITUTION(rnd.sub_down(pi2.lower(), u), l)), true); |
| 76 | else |
| 77 | return I(static_cast<T>(-1), static_cast<T>(1), true); |
| 78 | } |
| 79 | |
| 80 | template<class T, class Policies> inline |
| 81 | interval<T, Policies> sin(const interval<T, Policies>& x) |
no test coverage detected