31 explicit Interval(
const mpq_class &val) : lb_(val), ub_(val) {}
32 Interval(
const mpq_class &lb,
const mpq_class &ub);
37 [[nodiscard]]
bool is_empty()
const {
return lb_ == 1 && ub_ == 0; }
38 [[nodiscard]]
bool is_degenerated()
const {
return lb_ == ub_; }
39 [[nodiscard]]
bool is_bisectable()
const {
return lb_ < ub_; }
40 [[nodiscard]]
const mpq_class &lb()
const {
return lb_; }
41 [[nodiscard]]
const mpq_class &ub()
const {
return ub_; }
42 [[nodiscard]] mpq_class mid()
const {
return (lb_ + ub_) / 2; }
43 [[nodiscard]] mpq_class diam()
const {
return is_empty() ? mpq_class(0) : mpq_class(ub_ - lb_); }
44 [[nodiscard]] std::pair<Interval, Interval> bisect(
const mpq_class &p)
const;
46 bool operator==(
const Interval &other)
const {
return lb_ == other.lb_ && ub_ == other.ub_; }
47 Interval &operator=(
const mpq_t &val) {
48 mpq_set(lb_.get_mpq_t(), val);
49 mpq_set(ub_.get_mpq_t(), val);
52 Interval &operator=(
const mpq_class &val) {
63 GENERIC_ARITHMETIC_OPERATORS(
Interval, mpq_class &)
65 std::ostream &PrintToStream(std::ostream &os,
const mpq_class &ninfinity,
const mpq_class &infinity)
const;