PolyEntryIndices.h
Go to the documentation of this file.
// -*- c++ -*-
//*****************************************************************************
//*****************************************************************************
#ifndef polybori_groebner_PolyEntryIndices_h_
#define polybori_groebner_PolyEntryIndices_h_
// include basic definitions
#include "groebner_defs.h"
#include "PolyEntry.h"
BEGIN_NAMESPACE_PBORIGB
typedef Monomial::idx_map_type lm2Index_map_type;
typedef Exponent::idx_map_type exp2Index_map_type;
class PolyEntryIndices {
class check {};
class uncheck {};
public:
typedef Monomial::idx_map_type lm2Index_map_type;
typedef Exponent::idx_map_type exp2Index_map_type;
typedef lm2Index_map_type::value_type value_type;
typedef value_type::second_type data_type;
PolyEntryIndices():
lm2Index(), exp2Index() {}
void insert(const PolyEntry& entry, const data_type& rhs) {
exp2Index[entry.leadExp] = rhs;
lm2Index[entry.lead] = rhs;
}
void update(const Monomial& key, const PolyEntry& entry) {
if PBORI_UNLIKELY(entry.lead != key) {
lm2Index_map_type::iterator lm_pos = lm2Index.find(key);
PBORI_ASSERT(lm_pos != lm2Index.end());
lm2Index[entry.lead] = lm_pos->second;
exp2Index[entry.leadExp] = lm_pos->second;
lm2Index.erase(lm_pos);
exp2Index.erase(exp2Index.find(key.exp()));
}
}
template <class KeyType>
data_type operator()(const KeyType& key) const {
return get(key, uncheck());
}
template <class KeyType>
data_type checked(const KeyType& key) const {
return get(key, check());
}
protected:
template <class CheckType>
data_type get(data_type key, CheckType) const { return key; }
template <class CheckType>
data_type get(const Exponent& key, CheckType dummy) const {
return get(exp2Index, key, dummy);
}
template <class CheckType>
data_type get(const Monomial& key, CheckType dummy) const {
return get(lm2Index, key, dummy);
}
template <class CheckType>
data_type get(const PolyEntry& key, CheckType dummy) const {
return get(lm2Index, key.lead, dummy);
}
template <class MapType, class KeyType>
data_type get(const MapType& map, const KeyType& key, check) const {
typename MapType::const_iterator result(map.find(key));
if (result == map.end())
return (data_type)-1;
PBORI_ASSERT(result->second != data_type(-1));
return result->second;
}
template <class MapType, class KeyType>
data_type get(const MapType& map, const KeyType& key, uncheck) const {
typename MapType::const_iterator result(map.find(key));
PBORI_ASSERT(result != map.end());
return result->second;
}
private:
lm2Index_map_type lm2Index;
exp2Index_map_type exp2Index;
};
END_NAMESPACE_PBORIGB
#endif /* polybori_groebner_PolyEntryIndices_h_ */
polybori::groebner::lm2Index_map_type
Monomial::idx_map_type lm2Index_map_type
Definition: PolyEntryIndices.h:25
polybori::BooleExponent
This class is just a wrapper for using variables for storing indices as interim data structure for Bo...
Definition: BooleExponent.h:34
polybori::groebner::PolyEntryIndices::data_type
value_type::second_type data_type
Definition: PolyEntryIndices.h:42
polybori::BooleMonomial::idx_map_type
std::map< self, idx_type, symmetric_composition< std::less< poly_type::navigator >, navigates< poly_type > > > idx_map_type
Type for index maps.
Definition: BooleMonomial.h:98
END_NAMESPACE_PBORIGB
#define END_NAMESPACE_PBORIGB
Definition: groebner_defs.h:16
PolyEntry.h
polybori::groebner::PolyEntryIndices::lm2Index_map_type
Monomial::idx_map_type lm2Index_map_type
Definition: PolyEntryIndices.h:39
polybori::groebner::PolyEntryIndices::exp2Index_map_type
Exponent::idx_map_type exp2Index_map_type
Definition: PolyEntryIndices.h:40
BEGIN_NAMESPACE_PBORIGB
#define BEGIN_NAMESPACE_PBORIGB
Definition: groebner_defs.h:15
polybori::groebner::PolyEntryIndices::update
void update(const Monomial &key, const PolyEntry &entry)
Consistently replacing keys.
Definition: PolyEntryIndices.h:54
polybori::groebner::PolyEntry
This class defines PolyEntry.
Definition: PolyEntry.h:32
polybori::groebner::PolyEntryIndices::value_type
lm2Index_map_type::value_type value_type
Definition: PolyEntryIndices.h:41
groebner_defs.h
polybori::groebner::exp2Index_map_type
Exponent::idx_map_type exp2Index_map_type
Definition: PolyEntryIndices.h:26
polybori::groebner::PolyEntryIndices
This class defines PolyEntryIndices.
Definition: PolyEntryIndices.h:33
polybori::BooleExponent::idx_map_type
generate_index_map< self >::type idx_map_type
Type for index maps.
Definition: BooleExponent.h:76
polybori::groebner::PolyEntryIndices::checked
data_type checked(const KeyType &key) const
Savely looking up indices, returns -1 if key is invalid.
Definition: PolyEntryIndices.h:74
PBORI_ASSERT
#define PBORI_ASSERT(arg)
Definition: pbori_defs.h:118
polybori::groebner::PolyEntryBase::leadExp
Exponent leadExp
Definition: PolyEntryBase.h:60
polybori::groebner::PolyEntryIndices::operator()
data_type operator()(const KeyType &key) const
Lookup indices.
Definition: PolyEntryIndices.h:68
polybori::groebner::PolyEntryIndices::PolyEntryIndices
PolyEntryIndices()
Definition: PolyEntryIndices.h:44
polybori::BooleMonomial::exp
exp_type exp() const
Get exponent vector.
Definition: BooleMonomial.cc:256
polybori::groebner::PolyEntryIndices::insert
void insert(const PolyEntry &entry, const data_type &rhs)
Consistently inserting element.
Definition: PolyEntryIndices.h:48
polybori::groebner::PolyEntryBase::lead
Monomial lead
Definition: PolyEntryBase.h:55
polybori::BooleMonomial
This class is just a wrapper for using variables from cudd's decicion diagram.
Definition: BooleMonomial.h:50
PBORI_UNLIKELY
#define PBORI_UNLIKELY(expression)
Definition: pbori_defs.h:59