本文整理匯總了C++中Interval::is_bounded方法的典型用法代碼示例。如果您正苦於以下問題:C++ Interval::is_bounded方法的具體用法?C++ Interval::is_bounded怎麽用?C++ Interval::is_bounded使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Interval
的用法示例。
在下文中一共展示了Interval::is_bounded方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: interval_test
void interval_test() {
Interval e = Interval::everything();
Interval n = Interval::nothing();
Expr x = Variable::make(Int(32), "x");
Interval xp{x, Interval::pos_inf};
Interval xn{Interval::neg_inf, x};
Interval xx{x, x};
internal_assert(e.is_everything());
internal_assert(!e.has_upper_bound());
internal_assert(!e.has_lower_bound());
internal_assert(!e.is_empty());
internal_assert(!e.is_bounded());
internal_assert(!e.is_single_point());
internal_assert(!n.is_everything());
internal_assert(!n.has_upper_bound());
internal_assert(!n.has_lower_bound());
internal_assert(n.is_empty());
internal_assert(!n.is_bounded());
internal_assert(!n.is_single_point());
internal_assert(!xp.is_everything());
internal_assert(!xp.has_upper_bound());
internal_assert(xp.has_lower_bound());
internal_assert(!xp.is_empty());
internal_assert(!xp.is_bounded());
internal_assert(!xp.is_single_point());
internal_assert(!xn.is_everything());
internal_assert(xn.has_upper_bound());
internal_assert(!xn.has_lower_bound());
internal_assert(!xn.is_empty());
internal_assert(!xn.is_bounded());
internal_assert(!xn.is_single_point());
internal_assert(!xx.is_everything());
internal_assert(xx.has_upper_bound());
internal_assert(xx.has_lower_bound());
internal_assert(!xx.is_empty());
internal_assert(xx.is_bounded());
internal_assert(xx.is_single_point());
check(Interval::make_union(xp, xn), e, __LINE__);
check(Interval::make_union(e, xn), e, __LINE__);
check(Interval::make_union(xn, e), e, __LINE__);
check(Interval::make_union(xn, n), xn, __LINE__);
check(Interval::make_union(n, xp), xp, __LINE__);
check(Interval::make_union(xp, xp), xp, __LINE__);
check(Interval::make_intersection(xp, xn), Interval::single_point(x), __LINE__);
check(Interval::make_intersection(e, xn), xn, __LINE__);
check(Interval::make_intersection(xn, e), xn, __LINE__);
check(Interval::make_intersection(xn, n), n, __LINE__);
check(Interval::make_intersection(n, xp), n, __LINE__);
check(Interval::make_intersection(xp, xp), xp, __LINE__);
check(Interval::make_union({3, Interval::pos_inf}, {5, Interval::pos_inf}), {3, Interval::pos_inf}, __LINE__);
check(Interval::make_intersection({3, Interval::pos_inf}, {5, Interval::pos_inf}), {5, Interval::pos_inf}, __LINE__);
check(Interval::make_union({Interval::neg_inf, 3}, {Interval::neg_inf, 5}), {Interval::neg_inf, 5}, __LINE__);
check(Interval::make_intersection({Interval::neg_inf, 3}, {Interval::neg_inf, 5}), {Interval::neg_inf, 3}, __LINE__);
check(Interval::make_union({3, 4}, {9, 10}), {3, 10}, __LINE__);
check(Interval::make_intersection({3, 4}, {9, 10}), {9, 4}, __LINE__);
check(Interval::make_union({3, 9}, {4, 10}), {3, 10}, __LINE__);
check(Interval::make_intersection({3, 9}, {4, 10}), {4, 9}, __LINE__);
std::cout << "Interval test passed" << std::endl;
}
示例2: get_extent
Expr get_extent(const Interval &i) {
if (!i.is_bounded()) {
return Expr();
}
return simplify(i.max - i.min + 1);
}