本文整理汇总了C++中typenamepolicies::rounding::cos_down方法的典型用法代码示例。如果您正苦于以下问题:C++ rounding::cos_down方法的具体用法?C++ rounding::cos_down怎么用?C++ rounding::cos_down使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类typenamepolicies::rounding
的用法示例。
在下文中一共展示了rounding::cos_down方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: I
template<class T, class Policies> inline
interval<T, Policies> cos(const interval<T, Policies>& x)
{
if (interval_lib::detail::test_input(x))
return interval<T, Policies>::empty();
typename Policies::rounding rnd;
typedef interval<T, Policies> I;
typedef typename interval_lib::unprotect<I>::type R;
// get lower bound within [0, pi]
const R pi2 = interval_lib::pi_twice<R>();
R tmp = fmod((const R&)x, pi2);
if (width(tmp) >= pi2.lower())
return I(static_cast<T>(-1), static_cast<T>(1), true); // we are covering a full period
if (tmp.lower() >= interval_lib::constants::pi_upper<T>())
return -cos(tmp - interval_lib::pi<R>());
T l = tmp.lower();
T u = tmp.upper();
BOOST_USING_STD_MIN();
// separate into monotone subintervals
if (u <= interval_lib::constants::pi_lower<T>())
return I(rnd.cos_down(u), rnd.cos_up(l), true);
else if (u <= pi2.lower())
return I(static_cast<T>(-1), rnd.cos_up(min BOOST_PREVENT_MACRO_SUBSTITUTION(rnd.sub_down(pi2.lower(), u), l)), true);
else
return I(static_cast<T>(-1), static_cast<T>(1), true);
}