carl  24.04
Computer ARithmetic Library
BoundType.h
Go to the documentation of this file.
1 /*
2  * File which contains the enum of the bound type for intervals as well as related functions.
3  * @file BoundType.h
4  * @author Stefan Schupp <stefan.schupp@cs.rwth-aachen.de>
5  *
6  * @since 2013-10-28
7  * @version 2014-01-07
8  */
9 
10 #pragma once
11 
12 namespace carl {
13 enum class BoundType {
14  /// the given bound is compared by a strict ordering relation
15  STRICT = 0,
16  /// the given bound is compared by a weak ordering relation
17  WEAK = 1,
18  /// the given bound is interpreted as minus or plus infinity depending on whether it is the left or the right bound
19  INFTY = 2
20 };
21 
22 inline std::ostream& operator<<(std::ostream& os, BoundType b) {
23  switch (b) {
24  case BoundType::STRICT: return os << "STRICT";
25  case BoundType::WEAK: return os << "WEAK";
26  case BoundType::INFTY: return os << "INFTY";
27  default: assert(false); return os;
28  }
29 }
30 
31 inline static BoundType get_weakest_bound_type(BoundType type1, BoundType type2) {
32  if (type1 == BoundType::INFTY || type2 == BoundType::INFTY) return BoundType::INFTY;
33  if (type1 == BoundType::WEAK || type2 == BoundType::WEAK) return BoundType::WEAK;
34  return BoundType::STRICT;
35 }
37  if (type1 == BoundType::INFTY || type2 == BoundType::INFTY) return BoundType::INFTY;
38  if (type1 == BoundType::STRICT || type2 == BoundType::STRICT) return BoundType::STRICT;
39  return BoundType::WEAK;
40 }
41 
43  if (type == BoundType::INFTY) return BoundType::INFTY;
44  if (type == BoundType::WEAK) return BoundType::STRICT;
45  return BoundType::WEAK;
46 }
47 
48 } // namespace carl
49 
50 namespace std {
51 /// Specialization of `std::hash` for BoundType.
52 template<>
53 struct hash<carl::BoundType> {
54  /// Calculates the hash of a BoundType.
55  std::size_t operator()(carl::BoundType bt) const {
56  return static_cast<std::size_t>(bt);
57  }
58 };
59 } // namespace std
carl is the main namespace for the library.
static BoundType get_strictest_bound_type(BoundType type1, BoundType type2)
Definition: BoundType.h:36
std::ostream & operator<<(std::ostream &os, const BasicConstraint< Poly > &c)
Prints the given constraint on the given stream.
static BoundType get_other_bound_type(BoundType type)
Definition: BoundType.h:42
static BoundType get_weakest_bound_type(BoundType type1, BoundType type2)
Definition: BoundType.h:31
BoundType
Definition: BoundType.h:13
@ WEAK
the given bound is compared by a weak ordering relation
@ STRICT
the given bound is compared by a strict ordering relation
@ INFTY
the given bound is interpreted as minus or plus infinity depending on whether it is the left or the r...
std::size_t operator()(carl::BoundType bt) const
Calculates the hash of a BoundType.
Definition: BoundType.h:55