本文整理汇总了C++中interval类的典型用法代码示例。如果您正苦于以下问题:C++ interval类的具体用法?C++ interval怎么用?C++ interval使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了interval类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: r_search
void r_search(Node *root, const interval<T>& i, ivec& vec, int mode) {
if (root == NULL) return;
if (mode == OVERLAP && root->m_interval->overlaps(i)) vec.push_back(*(root->m_interval));
if (mode == CONTAIN && root->m_interval->contains(i)) vec.push_back(*(root->m_interval));
if (mode == CONTAINED && i.contains(*(root->m_interval))) vec.push_back(*(root->m_interval));
if (root->left != NULL && i.overlaps(root->left->min, root->left->max))
r_search(root->left, i, vec, mode);
if (root->right != NULL && i.overlaps(root->right->min, root->right->max))
r_search(root->right, i, vec, mode);
}
开发者ID:zoid,项目名称:zclib,代码行数:12,代码来源:interval_tree.cpp
示例2: fmod
template<class T, class Policies> inline
interval<T, Policies> fmod(const interval<T, Policies>& x,
const interval<T, Policies>& 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 const &yb = interval_lib::user::is_neg(x.lower()) ? y.lower() : y.upper();
T n = rnd.int_down(rnd.div_down(x.lower(), yb));
return (const I&)x - n * (const I&)y;
}
开发者ID:ngzHappy,项目名称:cpc2,代码行数:12,代码来源:arith2.hpp
示例3: diminish_interval_for_basic_var
void random_updater::diminish_interval_for_basic_var(numeric_pair<mpq>& nb_x, unsigned j,
mpq & a,
interval & r) {
SASSERT(m_core_solver.m_r_heading[j] >= 0);
numeric_pair<mpq> delta;
SASSERT(a != zero_of_type<mpq>());
switch (m_core_solver.get_column_type(j)) {
case column_type::free_column:
break;
case column_type::low_bound:
delta = m_core_solver.m_r_x[j] - m_core_solver.m_r_low_bounds[j];
SASSERT(delta >= zero_of_type<numeric_pair<mpq>>());
if (a > 0) {
r.set_upper_bound(nb_x + delta / a);
} else {
r.set_low_bound(nb_x + delta / a);
}
break;
case column_type::upper_bound:
delta = m_core_solver.m_r_upper_bounds()[j] - m_core_solver.m_r_x[j];
SASSERT(delta >= zero_of_type<numeric_pair<mpq>>());
if (a > 0) {
r.set_low_bound(nb_x - delta / a);
} else {
r.set_upper_bound(nb_x - delta / a);
}
break;
case column_type::boxed:
if (a > 0) {
delta = m_core_solver.m_r_x[j] - m_core_solver.m_r_low_bounds[j];
SASSERT(delta >= zero_of_type<numeric_pair<mpq>>());
r.set_upper_bound(nb_x + delta / a);
delta = m_core_solver.m_r_upper_bounds()[j] - m_core_solver.m_r_x[j];
SASSERT(delta >= zero_of_type<numeric_pair<mpq>>());
r.set_low_bound(nb_x - delta / a);
} else { // a < 0
delta = m_core_solver.m_r_upper_bounds()[j] - m_core_solver.m_r_x[j];
SASSERT(delta >= zero_of_type<numeric_pair<mpq>>());
r.set_upper_bound(nb_x - delta / a);
delta = m_core_solver.m_r_x[j] - m_core_solver.m_r_low_bounds[j];
SASSERT(delta >= zero_of_type<numeric_pair<mpq>>());
r.set_low_bound(nb_x + delta / a);
}
break;
case column_type::fixed:
r.set_low_bound(nb_x);
r.set_upper_bound(nb_x);
break;
default:
SASSERT(false);
}
}
开发者ID:chadbrewbaker,项目名称:z3,代码行数:52,代码来源:random_updater.hpp
示例4: 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();
}
开发者ID:AlexRa,项目名称:Kirstens-clone,代码行数:13,代码来源:utility.hpp
示例5: div_zero_part2
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);
}
开发者ID:ARK1988,项目名称:nupic.core,代码行数:13,代码来源:division.hpp
示例6: log
template<class T, class Policies> inline
interval<T, Policies> log(const interval<T, Policies>& x)
{
typedef interval<T, Policies> I;
if (interval_lib::detail::test_input(x) ||
!interval_lib::user::is_pos(x.upper()))
return I::empty();
typename Policies::rounding rnd;
typedef typename Policies::checking checking;
T l = !interval_lib::user::is_pos(x.lower())
? checking::neg_inf() : rnd.log_down(x.lower());
return I(l, rnd.log_up(x.upper()), true);
}
开发者ID:4eek,项目名称:xtractorfan,代码行数:13,代码来源:transc.hpp
示例7: div_non_zero
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
示例8: 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();
}
开发者ID:2asoft,项目名称:xray-16,代码行数:13,代码来源:utility.hpp
示例9: split
list<interval> split(interval const & i, unsigned n) {
list<interval> ret;
double lb = i.leftBound();
double const rb = i.rightBound();
double const width = rb - lb;
double const step = width / n;
for (unsigned i = 0; i < n - 1; i++) {
ret.emplace_back(lb, lb + step);
lb += step;
}
ret.emplace_back(lb, rb);
return ret;
}
开发者ID:rachelwang,项目名称:dreal,代码行数:13,代码来源:ode_solver.cpp
示例10: div_zero_part2
template<class T, class Policies> inline
interval<T, Policies> div_zero_part2(const interval<T, Policies>& x,
const interval<T, Policies>& y)
{
// assert(y.lower() < 0 && y.upper() > 0 && (div_zero_part1(x, y, b), b));
typename Policies::rounding rnd;
typedef interval<T, Policies> I;
typedef typename I::checking checking;
const T& inf = checking::inf();
if (is_neg(x.upper()))
return I(rnd.div_down(x.upper(), y.lower()), inf, true);
else
return I(rnd.div_down(x.lower(), y.upper()), inf, true);
}
开发者ID:Frankie-666,项目名称:xray-16,代码行数:14,代码来源:division.hpp
示例11: cosh
template<class T, class Policies> inline
interval<T, Policies> cosh(const interval<T, Policies>& x)
{
typedef interval<T, Policies> I;
if (interval_lib::detail::test_input(x))
return I::empty();
typename Policies::rounding rnd;
if (interval_lib::user::is_neg(x.upper()))
return I(rnd.cosh_down(x.upper()), rnd.cosh_up(x.lower()), true);
else if (!interval_lib::user::is_neg(x.lower()))
return I(rnd.cosh_down(x.lower()), rnd.cosh_up(x.upper()), true);
else
return I(static_cast<T>(0), rnd.cosh_up(-x.lower() > x.upper() ? x.lower() : x.upper()), true);
}
开发者ID:4eek,项目名称:xtractorfan,代码行数:14,代码来源:transc.hpp
示例12: hull
template<class T, class Policies> inline
interval<T, Policies> hull(const T& 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<T, Policies>(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 interval<T, Policies>(x, x, true);
return interval<T, Policies>(min(x, y.lower()),
max(x, y.upper()), true);
}
开发者ID:2asoft,项目名称:xray-16,代码行数:15,代码来源:utility.hpp
示例13: hull
template<class T, class Policies> inline
interval<T, Policies> hull(const T& x, const interval<T, Policies>& y)
{
BOOST_USING_STD_MIN();
BOOST_USING_STD_MAX();
bool bad_x = interval_lib::detail::test_input<T, Policies>(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 interval<T, Policies>(x, x, true);
return interval<T, Policies>(min BOOST_PREVENT_MACRO_SUBSTITUTION(x, y.lower()),
max BOOST_PREVENT_MACRO_SUBSTITUTION(x, y.upper()), true);
}
开发者ID:AlexRa,项目名称:Kirstens-clone,代码行数:15,代码来源:utility.hpp
示例14: 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();
}
开发者ID:AlexRa,项目名称:Kirstens-clone,代码行数:8,代码来源:utility.hpp
示例15: ext_numeral
interval interval_relation_plugin::widen(interval const& src1, interval const& src2) {
bool l_open = src1.is_lower_open();
bool r_open = src1.is_upper_open();
ext_numeral low = src1.inf();
ext_numeral high = src1.sup();
if (src2.inf() < low || (low == src2.inf() && l_open && !src2.is_lower_open())) {
low = ext_numeral(false);
l_open = true;
}
if (high < src2.sup() || (src2.sup() == high && !r_open && src2.is_upper_open())) {
high = ext_numeral(true);
r_open = true;
}
return interval(dep(), low, l_open, nullptr, high, r_open, nullptr);
}
开发者ID:NikolajBjorner,项目名称:z3,代码行数:16,代码来源:dl_interval_relation.cpp
示例16: 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());
}
开发者ID:AlexRa,项目名称:Kirstens-clone,代码行数:9,代码来源:utility.hpp
示例17: find_if
void ode_solver::prune_trajectory(interval& time, IVector& e) {
// Remove datapoints after time interval.
auto ite = find_if (m_trajectory.begin(),
m_trajectory.end(),
[&time](pair<interval, IVector>& item) {
return item.first.leftBound() > time.rightBound();
});
m_trajectory.erase(ite, m_trajectory.end());
// Update the datapoints in the time interval
ite = find_if (m_trajectory.begin(), m_trajectory.end(), [&time](pair<interval, IVector>& item) {
return item.first.leftBound()>= time.leftBound();
});
for_each(ite, m_trajectory.end(), [&e](pair<interval, IVector>& item) {
intersection(item.second, e, item.second);
});
}
开发者ID:rachelwang,项目名称:dreal,代码行数:17,代码来源:ode_solver.cpp
示例18: sqr_inverse
// FIXME It actually performs intersection which is inconsistent with intersect
bool sqr_inverse(interval& z, interval& x, interval& gap) {
bool has_gap = false;
const interval x_1 = sqrt(z);
const interval x_2 = -x_1;
interval x_image;
if (disjoint(x, x_2)) {
x_image = x_1;
}
else if (disjoint(x, x_1)) {
x_image = x_2;
}
else {
gap = interval(x_2.sup(), x_1.inf());
has_gap = gap.diameter() > IMPROVEMENT_TOL; // FIXME GAP_SQRT_TOL ?
x_image = hull_of(x_1, x_2);
}
x.intersect(x_image);
z.intersect(sqr(x));
return has_gap;
}
开发者ID:baharev,项目名称:old_sandbox,代码行数:34,代码来源:interval.cpp
示例19: checked_upper
template<class T, class Policies> inline
T checked_upper(const interval<T, Policies>& x)
{
if (empty(x)) {
typedef typename Policies::checking checking;
return checking::nan();
}
return x.upper();
}
开发者ID:AlexRa,项目名称:Kirstens-clone,代码行数:9,代码来源:utility.hpp
示例20: BOOST_PREVENT_MACRO_SUBSTITUTION
template<class T, class Policies> inline
interval<T, Policies> min BOOST_PREVENT_MACRO_SUBSTITUTION (const T& x, const interval<T, Policies>& y)
{
typedef interval<T, Policies> I;
if (interval_lib::detail::test_input(x, y))
return I::empty();
BOOST_USING_STD_MIN();
return I(min BOOST_PREVENT_MACRO_SUBSTITUTION(x, y.lower()), min BOOST_PREVENT_MACRO_SUBSTITUTION(x, y.upper()), true);
}
开发者ID:AlexRa,项目名称:Kirstens-clone,代码行数:9,代码来源:utility.hpp
注:本文中的interval类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论