Lodestar
An integrated real-time control package in C++
EmptySet.hpp
1 //
2 // Created by Hamza El-Kebir on 6/24/21.
3 //
4 
5 #ifndef LODESTAR_EMPTYSET_HPP
6 #define LODESTAR_EMPTYSET_HPP
7 
8 #include <type_traits>
9 #include <limits>
10 #include "SetExpression.hpp"
11 #include "SetUnion.hpp"
12 #include "SetComplement.hpp"
13 
14 namespace ls {
15  namespace primitives {
16  namespace sets {
20  class EmptySet : public SetExpression<EmptySet> {
21  public:
23  using type = EmptySet;
24 
25  EmptySet() = default;
26 
36  template<typename TExpression>
37  bool operator==(const SetExpression <TExpression> &expr) const
38  {
39  return std::is_same<TExpression, type>::value || expr.isEmpty();
40  }
41 
51  template<typename TExpression>
52  bool operator!=(const SetExpression <TExpression> &expr) const
53  {
54  return !operator==(expr);
55  }
56 
67  template<typename TExpression>
68  bool contains(const SetExpression <TExpression> &expr) const
69  {
70  return std::is_same<type, TExpression>::value || expr.isEmpty();
71  }
72 
82  template<typename TElementType>
83  bool
84  contains(const TElementType &el) const
85  {
86  return std::is_same<type, TElementType>::value ||
87  std::is_same<SetExpression<type>, TElementType>::value;
88  }
89 
101  template<typename TElementType>
102  bool
103  isSubset(const TElementType &el) const
104  {
105  return true;
106  }
107 
117  template<typename TExpression>
118  bool isSuperset(const SetExpression <TExpression> &expr) const
119  {
120  return std::is_same<type, TExpression>::value || expr.isEmpty();
121  }
122 
123 // /**
124 // * @brief Checks if this expression is a superset of \c expr.
125 // *
126 // * @tparam TElementType Type of the other element.
127 // *
128 // * @param expr Element to check subsumption on.
129 // *
130 // * @return True if this \c el is an empty set object, false otherwise.
131 // */
132 // template<typename TElementType>
133 // bool
134 // isSuperset(const TElementType &el) const
135 // {
136 // return std::is_same<type, TElementType>::value || std::is_same<Base, TElementType>::value;
137 // }
138 
139 // /**
140 // * @brief Computes the relative complement of this expression and \c el.
141 // *
142 // * @tparam TElementType Type of the other element.
143 // *
144 // * @param el Element to take relative complement with.
145 // *
146 // * @return Emtpy set.
147 // */
148 // template<typename TElementType>
149 // SetExpression <EmptySet>
150 // relComplement(const TElementType &el) const
151 // {
152 // return *this;
153 // }
154 
156 // * @brief Computes the relative complement of this expression and \c el.
157 // *
158 // * @tparam TElementType Type of the other element.
159 // *
160 // * @param el Element to take relative complement with.
161 // *
162 // * @return Emtpy set.
163 // */
164 // template<typename TElementType>
165 // SetExpression <EmptySet>
166 // relComplement(const TElementType &el) const
167 // {
168 // return *this;
169 // }
170 
186  template<typename TExpression>
188  {
189  return SetComplement<type, TExpression>(*this, *static_cast<const TExpression *>(&expr),
190  expr.isEmpty());
191  }
192 
198  bool isEmpty() const
199  {
200  return true;
201  }
202 
212  template<typename TExpression>
214  {
215  return SetUnion<type, TExpression>(*this, *static_cast<const TExpression *>(&expr),
216  isEmpty() && expr.isEmpty());
217  }
218 
231  template<typename TDerived>
232  double sdf(Eigen::MatrixBase<TDerived> &p) const
233  {
234  return std::numeric_limits<double>::infinity();
235  }
236  };
237  }
238  }
239 }
240 
241 #endif //LODESTAR_EMPTYSET_HPP
ls::primitives::sets::EmptySet::contains
bool contains(const SetExpression< TExpression > &expr) const
Returns true if this expression contains expr.
Definition: EmptySet.hpp:68
ls::primitives::sets::EmptySet::isEmpty
bool isEmpty() const
Returns true if the expression is the empty set.
Definition: EmptySet.hpp:198
ls::primitives::sets::SetExpression
Definition: SetExpression.hpp:15
ls::primitives::sets::EmptySet
The empty set.
Definition: EmptySet.hpp:20
ls::primitives::sets::SetComplement
Relative complement of two SetExpressions.
Definition: SetComplement.hpp:28
ls
Main Lodestar code.
Definition: BilinearTransformation.hpp:12
ls::primitives::sets::EmptySet::operator==
bool operator==(const SetExpression< TExpression > &expr) const
Checks if this expression is equal to \expr.
Definition: EmptySet.hpp:37
ls::primitives::sets::EmptySet::relComplement
SetComplement< type, TExpression > relComplement(const SetExpression< TExpression > &expr)
‍**
Definition: EmptySet.hpp:187
ls::primitives::sets::SetUnion
Union of two SetExpressions.
Definition: SetUnion.hpp:28
ls::primitives::sets::EmptySet::contains
bool contains(const TElementType &el) const
Returns true if this expression contains expr.
Definition: EmptySet.hpp:84
ls::primitives::sets::EmptySet::isSubset
bool isSubset(const TElementType &el) const
Checks if this expression is a subset of expr.
Definition: EmptySet.hpp:103
ls::primitives::sets::EmptySet::operator!=
bool operator!=(const SetExpression< TExpression > &expr) const
Checks if this expression is not equal to \expr.
Definition: EmptySet.hpp:52
ls::primitives::sets::EmptySet::isSuperset
bool isSuperset(const SetExpression< TExpression > &expr) const
Checks if this expression is a superset of expr.
Definition: EmptySet.hpp:118
ls::primitives::sets::EmptySet::EmptySet
EmptySet()=default
Expression type.
ls::primitives::sets::EmptySet::unionize
SetUnion< type, TExpression > unionize(const SetExpression< TExpression > &expr)
Creates a union between this expression and another SetExpression.
Definition: EmptySet.hpp:213
ls::primitives::sets::EmptySet::sdf
double sdf(Eigen::MatrixBase< TDerived > &p) const
Returns signed distance to p.
Definition: EmptySet.hpp:232