14 #include <boost/intrusive/unordered_set.hpp>
20 return monomial.
hash();
57 #define MONOMIAL_POOL_LOCK_GUARD std::lock_guard<std::recursive_mutex> lock(mMutex);
58 #define MONOMIAL_POOL_LOCK mMutex.lock();
59 #define MONOMIAL_POOL_UNLOCK mMutex.unlock();
61 #define MONOMIAL_POOL_LOCK_GUARD
62 #define MONOMIAL_POOL_LOCK
63 #define MONOMIAL_POOL_UNLOCK
90 auto new_buckets =
new underlying_set::bucket_type[rehash.second];
91 mPool.rehash(underlying_set::bucket_traits(new_buckets, rehash.second));
105 template<
typename Number>
107 return create(_var,
static_cast<exponent>(std::forward<Number>(_exp)));
125 Monomial::Arg create(
const std::initializer_list<std::pair<Variable, exponent>>& _exponents);
137 if (m ==
nullptr)
return;
138 if (m->
id() == 0)
return;
141 auto it =
mPool.find(*m);
142 if (it !=
mPool.end()) {
160 os <<
"MonomialPool of size " << mp.
size() << std::endl;
161 for (
const auto& entry : mp.
mPool) {
162 os <<
"\t" << entry << std::endl;
167 template<
typename... T>
#define MONOMIAL_POOL_LOCK_GUARD
#define CARL_LOG_TRACE(channel, msg)
#define CARL_LOG_DEBUG(channel, msg)
carl is the main namespace for the library.
Coeff content(const UnivariatePolynomial< Coeff > &p)
The content of a polynomial is the gcd of the coefficients of the normal part of a polynomial.
Monomial::Arg createMonomial(T &&... t)
std::size_t exponent
Type of an exponent.
std::ostream & operator<<(std::ostream &os, const BasicConstraint< Poly > &c)
Prints the given constraint on the given stream.
std::size_t hash_value(const carl::Monomial &monomial)
auto & get(const std::string &name)
A Variable represents an algebraic variable that can be used throughout carl.
The general-purpose monomials.
std::shared_ptr< const Monomial > Arg
Content mExponents
A vector of variable exponent pairs (v_i^e_i) with nonzero exponents.
std::size_t hash() const
Returns the hash of this monomial.
std::vector< std::pair< Variable, std::size_t > > Content
std::size_t id() const
Return the id of this monomial.
static std::size_t hashContent(const Monomial::Content &c)
Calculate the hash of a monomial based on its content.
Monomial::Arg create(Variable _var, Number &&_exp)
Creates a monomial from a variable and an exponent.
boost::intrusive::unordered_set< Monomial > underlying_set
std::unique_ptr< underlying_set::bucket_type[]> mPoolBuckets
underlying_set mPool
The pool.
std::size_t largestID() const
friend std::ostream & operator<<(std::ostream &os, const MonomialPool &mp)
Monomial::Arg create(Variable _var, exponent _exp)
Creates a monomial from a variable and an exponent.
void free(const Monomial *m)
std::recursive_mutex mMutex
Mutex to avoid multiple access to the pool.
MonomialPool(std::size_t _capacity=1000)
Constructor of the pool.
pool::RehashPolicy mRehashPolicy
Monomial::Arg add(Monomial::Content &&c, exponent totalDegree=0)
bool operator()(const Monomial &monomial, const Monomial::Content &content) const
bool operator()(const Monomial::Content &content, const Monomial &monomial) const
std::size_t operator()(const Monomial::Content &content) const
std::size_t largestID() const
void free(std::size_t id)
Mimics stdlibs default rehash policy for hashtables.
std::pair< bool, std::size_t > needRehash(std::size_t numBuckets, std::size_t numElements) const
Base class that implements a singleton.
static VariablePool & getInstance()
Returns the single instance of this class by reference.