5 #include <boost/container/flat_set.hpp>
15 std::optional<PolyRef>
origin = std::nullopt;
31 using RootMap = boost::container::flat_map<RAN, std::vector<TaggedIndexedRoot>>;
32 using RootMapPlain = boost::container::flat_map<RAN, std::vector<IndexedRoot>>;
83 return sample ==
lower()->first;
95 os <<
"(" << *data.
lower();
99 os <<
"[" << *data.
lower();
103 os << *data.
upper() <<
")";
107 os << *data.
upper() <<
"]";
155 RootMap::const_iterator lower;
156 RootMap::const_iterator upper;
157 bool lower_strict =
false;
158 bool upper_strict =
false;
164 lower =
m_roots.lower_bound(sample);
165 if (lower ==
m_roots.end() || lower->first != sample) {
169 while(lower !=
m_roots.end() && std::find_if(lower->second.begin(), lower->second.end(), [&](
const auto& t_root) { return !t_root.is_optional; }) == lower->second.end()) {
173 upper =
m_roots.lower_bound(sample);
174 while(upper !=
m_roots.end() && std::find_if(upper->second.begin(), upper->second.end(), [&](
const auto& t_root) { return !t_root.is_optional; }) == upper->second.end()) {
194 if (lower != upper) {
196 lower_strict = std::find_if(lower->second.begin(), lower->second.end(), [&](
const auto& t_root) { return !t_root.is_inclusive; }) != lower->second.end();
199 upper_strict = std::find_if(upper->second.begin(), upper->second.end(), [&](
const auto& t_root) { return !t_root.is_inclusive; }) != upper->second.end();
209 irs =
m_roots.emplace(std::move(root), std::vector<TaggedIndexedRoot>()).first;
211 auto loc = std::find_if(irs->second.begin(), irs->second.end(), [&tagged_root](
const auto& current) { return current.root == tagged_root.root && current.origin == tagged_root.origin; });
212 if (loc == irs->second.end()) {
213 irs->second.push_back(std::move(tagged_root));
215 if (!tagged_root.
is_inclusive) loc->is_inclusive =
false;
216 if (!tagged_root.
is_optional) loc->is_optional =
false;
222 if (irs ==
m_roots.end())
return;
223 std::erase(irs->second, tagged_root);
228 if (irs ==
m_roots.end())
return;
229 std::erase_if(irs->second, [&origin, &only_optional](
const auto& current) {
230 return current.origin == origin && (!only_optional || current.is_optional);
243 for (
const auto& [k, v] : other.
m_roots) {
244 for (
const auto& r : v) {
259 os <<
"(roots: " << data.
roots() <<
"; nonzero: " << data.
nonzero() <<
"; nullified: " << data.
nullified() <<
")";
270 else return del1.
lower()->first < del2.
lower()->first;
290 else return del1.
upper()->first < del2.
upper()->first;
299 if (del1.
upper()->first < del2.
lower()->first)
return true;
312 else if (del1.
upper()->first == del2.
upper()->first)
An interval of a delineation.
bool upper_strict() const
bool lower_unbounded() const
bool lower_strict() const
DelineationInterval(RootMap::const_iterator &&lower, RootMap::const_iterator &&upper, RootMap::const_iterator &&end, bool lower_strict, bool upper_strict)
bool upper_unbounded() const
RootMap::const_iterator m_lower
RootMap::const_iterator m_upper
const auto & upper() const
RootMap::const_iterator m_end
bool contains(const RAN &sample) const
const auto & lower() const
Represents the delineation of a set of polynomials (at a sample), that is.
RootMap m_roots
A map from the actual roots to indexed root expressions. Note that this map is sorted.
void remove_roots_with_origin(RAN root, PolyRef origin, bool only_optional=false)
void add_poly_nonzero(PolyRef poly)
const auto & nonzero() const
The set of polynomials without roots.
void merge_with(const Delineation &other)
void add_poly_nullified(PolyRef poly)
void remove_root(RAN root, TaggedIndexedRoot tagged_root)
void add_root(RAN root, TaggedIndexedRoot tagged_root)
boost::container::flat_set< PolyRef > m_polys_nonzero
The set of all polynomials without a root.
const auto & roots() const
Returns the underlying root map, which is a set of real algebraic numbers to indexed root expressions...
const auto & nullified() const
The set of nullified polynomials.
auto delineate_cell(const RAN &sample) const
Computes the bounds of the interval around the given sample w.r.t.
friend class DelineationInterval
boost::container::flat_set< PolyRef > m_polys_nullified
The set of all nullified polynomials.
bool operator==(const TaggedIndexedRoot &lhs, const TaggedIndexedRoot &rhs)
bool upper_eq_upper(const DelineationInterval &del1, const DelineationInterval &del2)
Compares the upper bounds of two DelineationIntervals.
std::ostream & operator<<(std::ostream &os, const TaggedIndexedRoot &data)
bool upper_lt_upper(const DelineationInterval &del1, const DelineationInterval &del2)
Compares the upper bounds of two DelineationIntervals.
bool lower_lt_lower(const DelineationInterval &del1, const DelineationInterval &del2)
Compares the lower bounds of two DelineationIntervals.
boost::container::flat_map< RAN, std::vector< TaggedIndexedRoot > > RootMap
bool upper_lt_lower(const DelineationInterval &del1, const DelineationInterval &del2)
Compares an upper bound with a lower bound of DelineationIntervals.
bool lower_eq_lower(const DelineationInterval &del1, const DelineationInterval &del2)
Compares the lower bounds of two DelineationIntervals.
bool operator<(const TaggedIndexedRoot &lhs, const TaggedIndexedRoot &rhs)
boost::container::flat_map< RAN, std::vector< IndexedRoot > > RootMapPlain
Represents the i-th root of a multivariate polynomial at its main variable (given an appropriate samp...
std::optional< PolyRef > origin