PairManager.h
Go to the documentation of this file.
// -*- c++ -*-
//*****************************************************************************
//*****************************************************************************
#ifndef polybori_groebner_PairManager_h_
#define polybori_groebner_PairManager_h_
#include "PairStatusSet.h"
// include basic definitions
#include "groebner_defs.h"
#include "pairs.h"
#include "PolyEntry.h"
#include "NextSpoly.h"
#include "CheckChainCriterion.h"
#include <polybori/routines/pbori_algo.h>
#include <utility>
BEGIN_NAMESPACE_PBORIGB
class PairManager {
typedef PairManager self;
public:
typedef std::priority_queue<Pair, std::vector<PairE>, PairECompare>
queue_type;
PairManager(const BoolePolyRing& ring):
queue(ring) { }
void appendHiddenGenerators(std::vector<Polynomial>& vec) {
queue_type temp(queue);
while(!temp.empty()){
appendTo(vec, temp.top());
temp.pop();
}
}
void introducePair(const Pair& pair, bool isHFE) {
if (!skip(pair, isHFE)) queue.push(pair);
};
Polynomial nextSpoly(ReductionStrategy& gen) {
if (PBORI_UNLIKELY(pairSetEmpty()))
return gen.leadingTerms.ring().zero();
return NextSpoly(gen, status)(popped());
}
bool pairSetEmpty() const { return queue.empty(); }
template <class StrategyType>
void cleanTopByChainCriterion(StrategyType& strat) {
CheckChainCriterion<StrategyType> continuing(strat, status);
while(!pairSetEmpty() && continuing(queue.top()))
queue.pop();
}
PairStatusSet status;
queue_type queue;
protected:
Pair popped() {
Pair result = queue.top();
queue.pop();
return result;
}
private:
bool skip(const Pair& pair, bool isHFE) {
return isHFE && (pair.getType() == IJ_PAIR) && (pair.sugar > 4);
};
void appendTo(std::vector<Polynomial>& vec, const Pair& current) const {
if (current.getType() == DELAYED_PAIR)
appendTo(vec, current.delayedPair().p);
}
void appendTo(std::vector<Polynomial>& vec, const Polynomial& poly) const {
if (!poly.isZero())
vec.push_back(poly);
}
};
END_NAMESPACE_PBORIGB
#endif /* polybori_groebner_PairManager_h_ */
NextSpoly.h
END_NAMESPACE_PBORIGB
#define END_NAMESPACE_PBORIGB
Definition: groebner_defs.h:16
PolyEntry.h
polybori::groebner::IJ_PAIR
Definition: PairLS.h:29
polybori::groebner::NextSpoly
This class computes the next spoly for a generator pair.
Definition: NextSpoly.h:30
CheckChainCriterion.h
polybori::BoolePolyRing::zero
dd_type zero() const
Get empty decision diagram.
Definition: BoolePolyRing.cc:42
polybori::groebner::Pair
PairE Pair
Definition: pairs.h:40
polybori::BoolePolyRing
This class reinterprets decicion diagram managers as Boolean polynomial rings, adds an ordering and v...
Definition: BoolePolyRing.h:40
polybori::Polynomial
BoolePolynomial Polynomial
Definition: embed.h:51
BEGIN_NAMESPACE_PBORIGB
#define BEGIN_NAMESPACE_PBORIGB
Definition: groebner_defs.h:15
polybori::groebner::PairE
This class defines PairE.
Definition: PairE.h:28
polybori::groebner::PairManager::cleanTopByChainCriterion
void cleanTopByChainCriterion(StrategyType &strat)
Definition: PairManager.h:69
polybori::groebner::PairManager::status
PairStatusSet status
Definition: PairManager.h:75
polybori::BoolePolynomial
This class wraps the underlying decicion diagram type and defines the necessary operations.
Definition: BoolePolynomial.h:85
polybori::CCuddDDFacade::ring
const ring_type & ring() const
Get reference to ring.
Definition: CCuddDDFacade.h:250
polybori::groebner::PairManager::nextSpoly
Polynomial nextSpoly(ReductionStrategy &gen)
Definition: PairManager.h:59
pairs.h
polybori::groebner::CheckChainCriterion
This class defines CheckChainCriterion.
Definition: CheckChainCriterion.h:30
polybori::groebner::PairManager::appendHiddenGenerators
void appendHiddenGenerators(std::vector< Polynomial > &vec)
Definition: PairManager.h:47
groebner_defs.h
polybori::groebner::PairE::sugar
deg_type sugar
Definition: PairE.h:36
polybori::groebner::PairE::getType
int getType() const
Definition: PairE.h:32
polybori::groebner::PairManager::PairManager
PairManager(const BoolePolyRing &ring)
Definition: PairManager.h:44
polybori::groebner::PairManager
This class defines PairManager.
Definition: PairManager.h:37
polybori::groebner::PairManager::popped
Pair popped()
top() and pop() at once
Definition: PairManager.h:80
polybori::groebner::PairECompare
This class defines PairECompare.
Definition: PairECompare.h:28
polybori::groebner::PairManager::queue
queue_type queue
Definition: PairManager.h:76
polybori::groebner::PairManager::pairSetEmpty
bool pairSetEmpty() const
Definition: PairManager.h:66
PairStatusSet.h
polybori::groebner::PairManager::queue_type
std::priority_queue< Pair, std::vector< PairE >, PairECompare > queue_type
Definition: PairManager.h:42
polybori::groebner::ReductionTerms::leadingTerms
LeadingTerms leadingTerms
Definition: ReductionTerms.h:51
polybori::groebner::PairManager::introducePair
void introducePair(const Pair &pair, bool isHFE)
Definition: PairManager.h:55
polybori::groebner::ReductionStrategy
This class defines ReductionStrategy.
Definition: ReductionStrategy.h:34
pbori_algo.h
polybori::groebner::PairStatusSet
This class defines PairStatusSet.
Definition: PairStatusSet.h:30
PBORI_UNLIKELY
#define PBORI_UNLIKELY(expression)
Definition: pbori_defs.h:59
polybori::groebner::DELAYED_PAIR
Definition: PairLS.h:30