NextSpoly.h
Go to the documentation of this file.
// -*- c++ -*-
//*****************************************************************************
//*****************************************************************************
#ifndef polybori_groebner_NextSpoly_h_
#define polybori_groebner_NextSpoly_h_
// include basic definitions
#include "groebner_defs.h"
#include "ReductionStrategy.h"
BEGIN_NAMESPACE_PBORIGB
class NextSpoly {
public:
NextSpoly(ReductionStrategy& gen, PairStatusSet& status):
m_gen(gen), m_status(status) {}
Polynomial operator()(const Pair& act_pair) {
return compute(act_pair, act_pair.extract(m_gen));
}
protected:
Polynomial compute(const Pair& act_pair, const Polynomial& result) {
if (act_pair.getType() == IJ_PAIR)
return compute(act_pair.ijPair(), result);
else
if (act_pair.getType() == VARIABLE_PAIR)
return compute(act_pair.variablePair(), result);
return result;
}
Polynomial compute(const IJPairData& ij, const Polynomial& res) {
int i = ij.i, j = ij.j;
replacePair(i, j);
m_status.setToHasTRep(ij.i, ij.j);
if ((i != ij.i) || (ij.j != j)){
m_status.setToHasTRep(i,j);
return spoly(m_gen[i].p, m_gen[j].p);
}
return res;
}
Polynomial compute(const VariablePairData& vp, const Polynomial& res) {
m_gen(vp.i).vPairCalculated.insert(vp.v);
return (!res.isZero() && (res.lead() == m_gen[vp.i].lead)?
res + m_gen[vp.i].p: res);
}
void replacePair(int& first, int& second) {
MonomialSet m =
m_gen.leadingTerms.divisorsOf(m_gen[first].leadExp.LCM(m_gen[second].leadExp));
replacePair(m.expBegin(), m.expEnd(), first, second);
}
template <class Iterator>
void replacePair(Iterator start, Iterator finish, int& first, int& second) {
std::pair<int, int> original(first, second);
while(start != finish)
replaceGenerators(m_gen.index(*start++), original, first, second);
}
private:
void replaceGenerators(int index, std::pair<int, int> original,
int& first, int& second) const {
if ((index != original.first) && (index != original.second)) {
replaceGenerator(index, original.first, first);
replaceGenerator(index, original.second, second);
}
PBORI_ASSERT(first != second);
}
void replaceGenerator(int next, int original, int& current) const {
if (m_status.hasTRep(next, original) &&
(m_gen[current].weightedLength > m_gen[next].weightedLength) &&
(m_gen[next].ecart() <= m_gen[original].ecart()))
current = next;
}
ReductionStrategy& m_gen;
PairStatusSet& m_status;
};
END_NAMESPACE_PBORIGB
#endif /* polybori_groebner_NextSpoly_h_ */
polybori::groebner::NextSpoly::compute
Polynomial compute(const Pair &act_pair, const Polynomial &result)
Definition: NextSpoly.h:41
polybori::groebner::PairE::ijPair
const IJPairData & ijPair() const
Definition: PairE.h:85
polybori::groebner::VariablePairData::v
idx_type v
Definition: VariablePairData.h:31
polybori::BoolePolynomial::lead
monom_type lead() const
Get leading term.
Definition: BoolePolynomial.cc:225
polybori::spoly
BoolePolynomial spoly(const BoolePolynomial &first, const BoolePolynomial &second)
Compute spoly of two polynomials.
Definition: pbori_algorithms.h:42
END_NAMESPACE_PBORIGB
#define END_NAMESPACE_PBORIGB
Definition: groebner_defs.h:16
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
polybori::groebner::IJPairData
This class defines IJPairData.
Definition: IJPairData.h:28
polybori::BooleSet::divisorsOf
self divisorsOf(const term_type &rhs) const
Compute intersection with divisors of rhs.
Definition: BooleSet.cc:156
polybori::BooleSet::expEnd
exp_iterator expEnd() const
Finish of iteration over exponent vectors.
Definition: BooleSet.cc:109
polybori::groebner::VariablePairData::i
int i
Definition: VariablePairData.h:30
polybori::groebner::NextSpoly::replacePair
void replacePair(Iterator start, Iterator finish, int &first, int &second)
Definition: NextSpoly.h:76
polybori::groebner::VariablePairData
This class defines VariablePairData.
Definition: VariablePairData.h:28
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::PairE::variablePair
const VariablePairData & variablePair() const
Definition: PairE.h:90
polybori::BooleSet::expBegin
exp_iterator expBegin() const
Start of iteration over exponent vectors.
Definition: BooleSet.cc:101
polybori::groebner::NextSpoly::compute
Polynomial compute(const IJPairData &ij, const Polynomial &res)
Definition: NextSpoly.h:51
polybori::groebner::NextSpoly::NextSpoly
NextSpoly(ReductionStrategy &gen, PairStatusSet &status)
Definition: NextSpoly.h:33
polybori::BoolePolynomial
This class wraps the underlying decicion diagram type and defines the necessary operations.
Definition: BoolePolynomial.h:85
polybori::groebner::VARIABLE_PAIR
Definition: PairLS.h:28
polybori::groebner::NextSpoly::compute
Polynomial compute(const VariablePairData &vp, const Polynomial &res)
Definition: NextSpoly.h:62
polybori::groebner::NextSpoly::replacePair
void replacePair(int &first, int &second)
Definition: NextSpoly.h:68
groebner_defs.h
polybori::groebner::PairE::getType
int getType() const
Definition: PairE.h:32
PBORI_ASSERT
#define PBORI_ASSERT(arg)
Definition: pbori_defs.h:118
ReductionStrategy.h
polybori::BoolePolynomial::isZero
bool_type isZero() const
Check whether polynomial is constant zero.
Definition: BoolePolynomial.h:294
polybori::groebner::PairE::extract
Polynomial extract(const PolyEntryVector &v) const
Definition: PairE.h:47
polybori::groebner::IJPairData::i
int i
Definition: IJPairData.h:30
polybori::BooleSet
Definition: BooleSet.h:57
polybori::groebner::ReductionStrategy
This class defines ReductionStrategy.
Definition: ReductionStrategy.h:34
polybori::groebner::NextSpoly::operator()
Polynomial operator()(const Pair &act_pair)
Definition: NextSpoly.h:36
polybori::groebner::PairStatusSet
This class defines PairStatusSet.
Definition: PairStatusSet.h:30
polybori::groebner::IJPairData::j
int j
Definition: IJPairData.h:31