本文整理汇总了C++中typenamepolicies::rounding类的典型用法代码示例。如果您正苦于以下问题:C++ rounding类的具体用法?C++ rounding怎么用?C++ rounding使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了rounding类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: width
template<class T, class Policies> inline
T width(const interval<T, Policies>& x)
{
if (interval_lib::detail::test_input(x)) return static_cast<T>(0);
typename Policies::rounding rnd;
return rnd.sub_up(x.upper(), x.lower());
}
开发者ID:AlexRa,项目名称:Kirstens-clone,代码行数:7,代码来源:utility.hpp
示例2: I
template<class T, class Policies> inline
interval<T, Policies> div_zero_part1(const interval<T, Policies>& x,
const interval<T, Policies>& y, bool& b)
{
// assert(y.lower() < 0 && y.upper() > 0);
if (is_zero(x.lower()) && is_zero(x.upper()))
{
b = false;
return x;
}
typename Policies::rounding rnd;
typedef interval<T, Policies> I;
const T& xl = x.lower();
const T& xu = x.upper();
const T& yl = y.lower();
const T& yu = y.upper();
typedef typename I::checking checking;
const T& inf = checking::inf();
if (is_neg(xu))
{
b = true;
return I(-inf, rnd.div_up(xu, yu), true);
}
else if (is_neg(xl))
{
b = false;
return I(-inf, inf, true);
}
else
{
b = true;
return I(-inf, rnd.div_up(xl, yl), true);
}
}
开发者ID:Frankie-666,项目名称:xray-16,代码行数:34,代码来源:division.hpp
示例3: 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);
}
开发者ID:4eek,项目名称:xtractorfan,代码行数:28,代码来源:transc.hpp
示例4: widen
template<class T, class Policies> inline
interval<T, Policies> widen(const interval<T, Policies>& x, const T& v)
{
if (interval_lib::detail::test_input(x))
return interval<T, Policies>::empty();
typename Policies::rounding rnd;
return interval<T, Policies>(rnd.sub_down(x.lower(), v),
rnd.add_up (x.upper(), v), true);
}
开发者ID:AlexRa,项目名称:Kirstens-clone,代码行数:9,代码来源:utility.hpp
示例5: empty
template<class T, class Policies> inline
interval<T, Policies> exp(const interval<T, Policies>& x)
{
typedef interval<T, Policies> I;
if (interval_lib::detail::test_input(x))
return I::empty();
typename Policies::rounding rnd;
return I(rnd.exp_down(x.lower()), rnd.exp_up(x.upper()), true);
}
开发者ID:4eek,项目名称:xtractorfan,代码行数:9,代码来源:transc.hpp
示例6: div
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);
}
开发者ID:ngzHappy,项目名称:cpc2,代码行数:9,代码来源:arith3.hpp
示例7: fmod
template<class T, class Policies> inline
interval<T, Policies> fmod(const interval<T, Policies>& x, const T& y)
{
if (interval_lib::detail::test_input(x, y))
return interval<T, Policies>::empty();
typename Policies::rounding rnd;
typedef typename interval_lib::unprotect<interval<T, Policies> >::type I;
T n = rnd.int_down(rnd.div_down(x.lower(), y));
return (const I&)x - n * I(y);
}
开发者ID:hackshields,项目名称:antivirus,代码行数:10,代码来源:arith2.hpp
示例8: median
template<class T, class Policies> inline
T median(const interval<T, Policies>& x)
{
if (interval_lib::detail::test_input(x)) {
typedef typename Policies::checking checking;
return checking::nan();
}
typename Policies::rounding rnd;
return rnd.median(x.lower(), x.upper());
}
开发者ID:AlexRa,项目名称:Kirstens-clone,代码行数:10,代码来源:utility.hpp
示例9: I
template<class T, class Policies> inline
interval<T, Policies> div_non_zero(const T& x, const interval<T, Policies>& y)
{
// assert(!in_zero(y));
typename Policies::rounding rnd;
typedef interval<T, Policies> I;
const T& yl = y.lower();
const T& yu = y.upper();
if (::boost::numeric::interval_lib::user::is_neg(x))
return I(rnd.div_down(x, yl), rnd.div_up(x, yu), true);
else
return I(rnd.div_down(x, yu), rnd.div_up(x, yl), true);
}
开发者ID:ARK1988,项目名称:nupic.core,代码行数:13,代码来源:division.hpp
示例10: if
template<class T, class Policies> inline
interval<T, Policies> div_zero_part1(const interval<T, Policies>& x,
const interval<T, Policies>& y, bool& b)
{
// assert(::boost::numeric::interval_lib::user::is_neg(y.lower()) && ::boost::numeric::interval_lib::user::is_pos(y.upper()));
if (::boost::numeric::interval_lib::user::is_zero(x.lower()) && ::boost::numeric::interval_lib::user::is_zero(x.upper()))
{ b = false; return x; }
typename Policies::rounding rnd;
typedef interval<T, Policies> I;
const T& xl = x.lower();
const T& xu = x.upper();
const T& yl = y.lower();
const T& yu = y.upper();
typedef typename Policies::checking checking;
if (::boost::numeric::interval_lib::user::is_neg(xu))
{ b = true; return I(checking::neg_inf(), rnd.div_up(xu, yu), true); }
else if (::boost::numeric::interval_lib::user::is_neg(xl))
{ b = false; return I(checking::neg_inf(), checking::pos_inf(), true); }
else
{ b = true; return I(checking::neg_inf(), rnd.div_up(xl, yl), true); }
}
开发者ID:ARK1988,项目名称:nupic.core,代码行数:21,代码来源:division.hpp
示例11: empty
template<class T, class Policies> inline
interval<T, Policies> multiplicative_inverse(const interval<T, Policies>& x)
{
typedef interval<T, Policies> I;
if (detail::test_input(x))
return I::empty();
T one = static_cast<T>(1);
typename Policies::rounding rnd;
if (in_zero(x)) {
typedef typename Policies::checking checking;
if (!detail::is_zero(x.lower()))
if (!detail::is_zero(x.upper()))
return I::whole();
else
return I(-checking::inf(), rnd.div_up(one, x.lower()), true);
else
if (!detail::is_zero(x.upper()))
return I(rnd.div_down(one, x.upper()), checking::inf(), true);
else
return I::empty();
} else
return I(rnd.div_down(one, x.upper()), rnd.div_up(one, x.lower()), true);
}
开发者ID:hackshields,项目名称:antivirus,代码行数:23,代码来源:arith2.hpp
示例12: empty
template<class T, class Policies> inline
interval<T, Policies> operator*(const interval<T, Policies>& x,
const interval<T, Policies>& y)
{
BOOST_NUMERIC_INTERVAL_using_max(min);
BOOST_NUMERIC_INTERVAL_using_max(max);
typedef interval<T, Policies> I;
if (interval_lib::detail::test_input(x, y))
return I::empty();
typename Policies::rounding rnd;
const T& xl = x.lower();
const T& xu = x.upper();
const T& yl = y.lower();
const T& yu = y.upper();
if (interval_lib::detail::is_neg(xl))
if (interval_lib::detail::is_pos(xu))
if (interval_lib::detail::is_neg(yl))
if (interval_lib::detail::is_pos(yu)) // M * M
return I(min(rnd.mul_down(xl, yu), rnd.mul_down(xu, yl)),
max(rnd.mul_up (xl, yl), rnd.mul_up (xu, yu)), true);
else // M * N
return I(rnd.mul_down(xu, yl), rnd.mul_up(xl, yl), true);
else
if (interval_lib::detail::is_pos(yu)) // M * P
return I(rnd.mul_down(xl, yu), rnd.mul_up(xu, yu), true);
else // M * Z
return I(0, 0, true);
else
if (interval_lib::detail::is_neg(yl))
if (interval_lib::detail::is_pos(yu)) // N * M
return I(rnd.mul_down(xl, yu), rnd.mul_up(xl, yl), true);
else // N * N
return I(rnd.mul_down(xu, yu), rnd.mul_up(xl, yl), true);
else
if (interval_lib::detail::is_pos(yu)) // N * P
return I(rnd.mul_down(xl, yu), rnd.mul_up(xu, yl), true);
else // N * Z
return I(0, 0, true);
else
if (interval_lib::detail::is_pos(xu))
if (interval_lib::detail::is_neg(yl))
if (interval_lib::detail::is_pos(yu)) // P * M
return I(rnd.mul_down(xu, yl), rnd.mul_up(xu, yu), true);
else // P * N
return I(rnd.mul_down(xu, yl), rnd.mul_up(xl, yu), true);
else
if (interval_lib::detail::is_pos(yu)) // P * P
return I(rnd.mul_down(xl, yl), rnd.mul_up(xu, yu), true);
else // P * Z
return I(0, 0, true);
else // Z * ?
return I(0, 0, true);
}
开发者ID:NeoAnomaly,项目名称:xray,代码行数:54,代码来源:arith.hpp
注:本文中的typenamepolicies::rounding类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论