本文整理汇总了C++中interval::upper方法的典型用法代码示例。如果您正苦于以下问题:C++ interval::upper方法的具体用法?C++ interval::upper怎么用?C++ interval::upper使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类interval
的用法示例。
在下文中一共展示了interval::upper方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: I
template<class T, class Policies> inline
interval<T, Policies> div_non_zero(const interval<T, Policies>& x,
const interval<T, Policies>& y)
{
// assert(!in_zero(y));
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();
if (is_neg(xu))
if (is_neg(yu))
return I(rnd.div_down(xu, yl), rnd.div_up(xl, yu), true);
else
return I(rnd.div_down(xl, yl), rnd.div_up(xu, yu), true);
else if (is_neg(xl))
if (is_neg(yu))
return I(rnd.div_down(xu, yu), rnd.div_up(xl, yu), true);
else
return I(rnd.div_down(xl, yl), rnd.div_up(xu, yl), true);
else if (is_neg(yu))
return I(rnd.div_down(xu, yu), rnd.div_up(xl, yl), true);
else
return I(rnd.div_down(xl, yu), rnd.div_up(xu, yl), true);
}
示例2:
template<class T, class Policies1, class Policies2> inline
bool operator>=(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
{
if (detail::test_input(x, y)) throw comparison_error();
const T& xl = x.lower();
const T& yl = y.lower();
return xl > yl || (xl == yl && x.upper() >= y.upper());
}
示例3:
template<class T, class Policies1, class Policies2> inline
logic::tribool operator==(const interval<T, Policies1>& x, const interval<T, Policies2>& y)
{
if (detail::test_input(x, y)) throw comparison_error();
if (x.upper() == y.lower() && x.lower() == y.upper()) return true;
if (x.upper() < y.lower() || x.lower() > y.upper()) return false;
return logic::indeterminate;
}
示例4: overlap
template<class T, class Policies1, class Policies2> inline
bool overlap(const interval<T, Policies1>& x,
const interval<T, Policies2>& y)
{
if (interval_lib::detail::test_input(x, y)) return false;
return x.lower() <= y.lower() && y.lower() <= x.upper() ||
y.lower() <= x.lower() && x.lower() <= y.upper();
}
示例5: proper_subset
template<class T, class Policies1, class Policies2> inline
bool proper_subset(const interval<T, Policies1>& x,
const interval<T, Policies2>& y)
{
if (empty(y)) return false;
if (empty(x)) return true;
return y.lower() <= x.lower() && x.upper() <= y.upper() &&
(y.lower() != x.lower() || x.upper() != y.upper());
}
示例6: empty
template<class T, class Policies> inline
interval<T, Policies> min(const interval<T, Policies>& x,
const interval<T, Policies>& y)
{
BOOST_NUMERIC_INTERVAL_using_max(min);
typedef interval<T, Policies> I;
if (interval_lib::detail::test_input(x, y))
return I::empty();
return I(min(x.lower(), y.lower()), min(x.upper(), y.upper()), true);
}
示例7: empty
template<class T, class Policies> inline
interval<T, Policies> acosh(const interval<T, Policies>& x)
{
typedef interval<T, Policies> I;
if (interval_lib::detail::test_input(x) || x.upper() < static_cast<T>(1))
return I::empty();
typename Policies::rounding rnd;
T l = x.lower() <= static_cast<T>(1) ? static_cast<T>(0) : rnd.acosh_down(x.lower());
return I(l, rnd.acosh_up(x.upper()), true);
}
示例8: 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);
}
示例9: empty
template<class T, class Policies> inline
interval<T, Policies> abs(const interval<T, Policies>& x)
{
typedef interval<T, Policies> I;
if (interval_lib::detail::test_input(x))
return I::empty();
if (!interval_lib::user::is_neg(x.lower())) return x;
if (!interval_lib::user::is_pos(x.upper())) return -x;
BOOST_USING_STD_MAX();
return I(static_cast<T>(0), max BOOST_PREVENT_MACRO_SUBSTITUTION(-x.lower(), x.upper()), true);
}
示例10: intersect
template<class T, class Policies> inline
interval<T, Policies> intersect(const interval<T, Policies>& x,
const interval<T, Policies>& y)
{
BOOST_NUMERIC_INTERVAL_using_max(min);
BOOST_NUMERIC_INTERVAL_using_max(max);
if (interval_lib::detail::test_input(x, y))
return interval<T, Policies>::empty();
const T& l = max(x.lower(), y.lower());
const T& u = min(x.upper(), y.upper());
if (l <= u) return interval<T, Policies>(l, u, true);
else return interval<T, Policies>::empty();
}
示例11: intersect
template<class T, class Policies> inline
interval<T, Policies> intersect(const interval<T, Policies>& x,
const interval<T, Policies>& y)
{
BOOST_USING_STD_MIN();
BOOST_USING_STD_MAX();
if (interval_lib::detail::test_input(x, y))
return interval<T, Policies>::empty();
const T& l = max BOOST_PREVENT_MACRO_SUBSTITUTION(x.lower(), y.lower());
const T& u = min BOOST_PREVENT_MACRO_SUBSTITUTION(x.upper(), y.upper());
if (l <= u) return interval<T, Policies>(l, u, true);
else return interval<T, Policies>::empty();
}
示例12: I
template<class T, class Policies> inline
interval<T, Policies> div_zero_part2(const interval<T, Policies>& x,
const interval<T, Policies>& y)
{
// assert(::boost::numeric::interval_lib::user::is_neg(y.lower()) && ::boost::numeric::interval_lib::user::is_pos(y.upper()) && (div_zero_part1(x, y, b), b));
typename Policies::rounding rnd;
typedef interval<T, Policies> I;
typedef typename Policies::checking checking;
if (::boost::numeric::interval_lib::user::is_neg(x.upper()))
return I(rnd.div_down(x.upper(), y.lower()), checking::pos_inf(), true);
else
return I(rnd.div_down(x.lower(), y.upper()), checking::pos_inf(), true);
}
示例13: zero_in
template<class T, class Policies> inline
bool zero_in(const interval<T, Policies>& x)
{
if (interval_lib::detail::test_input(x)) return false;
return (!interval_lib::user::is_pos(x.lower())) &&
(!interval_lib::user::is_neg(x.upper()));
}
示例14: hull
template<class T, class Policies> inline
interval<T, Policies> hull(const interval<T, Policies>& x,
const interval<T, Policies>& y)
{
BOOST_NUMERIC_INTERVAL_using_max(min);
BOOST_NUMERIC_INTERVAL_using_max(max);
bool bad_x = interval_lib::detail::test_input(x);
bool bad_y = interval_lib::detail::test_input(y);
if (bad_x)
if (bad_y) return interval<T, Policies>::empty();
else return y;
else
if (bad_y) return x;
return interval<T, Policies>(min(x.lower(), y.lower()),
max(x.upper(), y.upper()), true);
}
示例15: 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());
}