MCPcopy Create free account
hub / github.com/Gecode/gecode / cos

Function cos

gecode/third-party/boost/numeric/interval/transc.hpp:51–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49}
50
51template<class T, class Policies> inline
52interval<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
80template<class T, class Policies> inline
81interval<T, Policies> sin(const interval<T, Policies>& x)

Callers 1

sinFunction · 0.70

Calls 8

test_inputFunction · 0.85
widthFunction · 0.85
emptyFunction · 0.70
fmodFunction · 0.70
lowerMethod · 0.45
upperMethod · 0.45
sub_downMethod · 0.45

Tested by

no test coverage detected