96 const Scalar& bound2);
107 bool operator==(
const Interval& in)
const;
108 bool operator!=(
const Interval& in)
const;
116 Scalar
width()
const;
126 Scalar& getLowerBoundRef();
127 const Scalar& getLowerBoundRef()
const;
131 Scalar& getUpperBoundRef();
132 const Scalar& getUpperBoundRef()
const;
168 std::ostream& operator<<(std::ostream& os,
179 bool isContained(
const Scalar& s,
183 bool isContained(
const Interval& in1,
212 const Scalar& bound2)
214 if (bound1 <= bound2)
229 inline bool Interval::operator==(
const Interval& in)
const
231 return (m_lb == in.m_lb && m_ub == in.m_ub);
235 inline bool Interval::operator!=(
const Interval& in)
const
237 return std::rel_ops::operator!=(*
this, in);
245 return (m_lb + m_ub) * Scalar(0.5);
271 inline Scalar& Interval::getLowerBoundRef()
277 inline const Scalar& Interval::getLowerBoundRef()
const
289 inline Scalar& Interval::getUpperBoundRef()
295 inline const Scalar& Interval::getUpperBoundRef()
const
319 inline Interval operator+(
const Scalar& s,
327 inline Interval operator+(
const Interval& in1,
330 return Interval(in1.getLowerBound() + in2.getLowerBound(),
331 in1.getUpperBound() + in2.getUpperBound());
335 inline Interval operator-(
const Scalar& s,
338 return Interval(in.getLowerBound() - s,
339 in.getUpperBound() - s);
343 inline Interval operator-(
const Interval& in1,
346 return Interval(in1.getLowerBound() - in2.getLowerBound(),
347 in1.getUpperBound() - in2.getUpperBound());
351 inline std::ostream& operator<<(std::ostream& os,
354 return os <<
'[' << in.getLowerBound() <<
", "
355 << in.getUpperBound() <<
']';
361 inline bool isOverlap(
const Interval& in1,
364 return (in1.getLowerBound() <= in2.getUpperBound()) &&
365 (in2.getLowerBound() <= in1.getUpperBound());
369 inline bool isContained(
const Scalar& s,
372 return s >= in.getLowerBound() &&
373 s <= in.getUpperBound();
377 inline bool isContained(
const Interval& in1,
380 return in1.getLowerBound() >= in2.getLowerBound() &&
381 in1.getUpperBound() <= in2.getUpperBound();
385 inline Interval widen(
const Interval& in,
393 inline Interval hull(
const Interval& in1,
396 return Interval(min(in1.getLowerBound(), in2.getLowerBound()),
397 max(in1.getUpperBound(), in2.getUpperBound()));
403 #endif // MT_INTERVAL_H