PolynomialSugar.h
Go to the documentation of this file.
// -*- c++ -*-
//*****************************************************************************
//*****************************************************************************
#ifndef polybori_groebner_PolynomialSugar_h_
#define polybori_groebner_PolynomialSugar_h_
// include basic definitions
#include "groebner_defs.h"
BEGIN_NAMESPACE_PBORIGB
class PolynomialSugar{
public:
PolynomialSugar(const Polynomial& poly): lm(poly.ring()), p(poly), exp(){
sugar=p.deg();
if (!(p.isZero())){
this->lm=p.boundedLead(sugar);
this->exp=lm.exp();
PBORI_ASSERT(lm==p.lead());
PBORI_ASSERT(exp==p.leadExp());
}
length=p.length();
}
PolynomialSugar(const Polynomial& poly, int sugar, len_type length):
lm(poly.ring()), p(poly), exp() {
PBORI_ASSERT(length>=0);
//sugar=p.deg();
this->sugar=sugar;
this->length=length;
PBORI_ASSERT(sugar>=p.deg());
PBORI_ASSERT(length>=p.length());
if (!(p.isZero())){
this->lm=p.boundedLead(sugar);
this->exp=lm.exp();
PBORI_ASSERT(lm==p.lead());
PBORI_ASSERT(exp==p.leadExp());
}
}
const BooleMonomial& lead() const{
return this->lm;
}
const Exponent& leadExp() const{
return this->exp;
}
deg_type getSugar() const{
return sugar;
}
wlen_type getLengthEstimation() const {
return length;
}
bool isZero() const{
return p.isZero();
}
void add(const Polynomial p2, deg_type sugar2, wlen_type length){
PBORI_ASSERT(p2.leadExp()==exp);
PBORI_ASSERT(length>=0);
PBORI_ASSERT(length>=p2.length());
this->p=p+p2;
this->sugar=std::max(sugar2,this->sugar);
if (!(p.isZero())){
this->lm=this->p.boundedLead(sugar);
this->exp=this->lm.exp();
} else {
lm=Monomial(p2.ring());
exp=Exponent();
}
this->length+=length;
this->length-=2;
if (p2.ring().ordering().isTotalDegreeOrder()) this->sugar=this->lm.deg();
PBORI_ASSERT((p.isZero())|| (lm==p.lead()));
PBORI_ASSERT((p.isZero())||(exp==p.leadExp()));
}
void adjustSugar(){
sugar=p.deg();
}
bool isOne(){
return p.isOne();
}
Polynomial value() const{
return p;
}
wlen_type eliminationLength() const{
wlen_type res=1;
if (isZero()) return 0;
res=res+(sugar-exp.deg()+1)*(length-1);
PBORI_ASSERT(res>=p.eliminationLengthWithDegBound(sugar));
return res;
//return p.eliminationLengthWithDegBound(sugar);
}
void adjustLm(){
this->lm=this->p.lead();
exp=lm.exp();
PBORI_ASSERT(lm==p.lead());
PBORI_ASSERT(exp==p.leadExp());
}
protected:
Monomial lm;
len_type length;
deg_type sugar;
Polynomial p;
Exponent exp;
};
END_NAMESPACE_PBORIGB
#endif /* polybori_PolynomialSugar_h_ */
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::PolynomialSugar::getSugar
deg_type getSugar() const
Definition: PolynomialSugar.h:64
polybori::groebner::Exponent
polybori::BooleExponent Exponent
Definition: groebner_defs.h:33
END_NAMESPACE_PBORIGB
#define END_NAMESPACE_PBORIGB
Definition: groebner_defs.h:16
polybori::groebner::PolynomialSugar::p
Polynomial p
Definition: PolynomialSugar.h:122
polybori::groebner::deg_type
int deg_type
Definition: groebner_defs.h:42
polybori::groebner::PolynomialSugar::eliminationLength
wlen_type eliminationLength() const
Definition: PolynomialSugar.h:103
polybori::groebner::len_type
long len_type
Definition: groebner_defs.h:41
polybori::groebner::PolynomialSugar::lead
const BooleMonomial & lead() const
Definition: PolynomialSugar.h:58
polybori::groebner::PolynomialSugar::value
Polynomial value() const
Definition: PolynomialSugar.h:100
polybori::groebner::PolynomialSugar::length
len_type length
Definition: PolynomialSugar.h:120
polybori::groebner::PolynomialSugar::isOne
bool isOne()
Definition: PolynomialSugar.h:97
BEGIN_NAMESPACE_PBORIGB
#define BEGIN_NAMESPACE_PBORIGB
Definition: groebner_defs.h:15
polybori::groebner::PolynomialSugar::adjustSugar
void adjustSugar()
Definition: PolynomialSugar.h:94
polybori::groebner::PolynomialSugar::isZero
bool isZero() const
Definition: PolynomialSugar.h:70
polybori::BoolePolynomial
This class wraps the underlying decicion diagram type and defines the necessary operations.
Definition: BoolePolynomial.h:85
polybori::groebner::PolynomialSugar::sugar
deg_type sugar
Definition: PolynomialSugar.h:121
polybori::groebner::PolynomialSugar::add
void add(const Polynomial p2, deg_type sugar2, wlen_type length)
Definition: PolynomialSugar.h:73
polybori::groebner::PolynomialSugar::exp
Exponent exp
Definition: PolynomialSugar.h:123
groebner_defs.h
polybori::groebner::PolynomialSugar::PolynomialSugar
PolynomialSugar(const Polynomial &poly, int sugar, len_type length)
Definition: PolynomialSugar.h:41
polybori::BoolePolynomial::leadExp
exp_type leadExp() const
Get leading term.
Definition: BoolePolynomial.cc:258
PBORI_ASSERT
#define PBORI_ASSERT(arg)
Definition: pbori_defs.h:118
polybori::groebner::PolynomialSugar::lm
Monomial lm
Definition: PolynomialSugar.h:119
polybori::groebner::wlen_type
long wlen_type
Definition: groebner_defs.h:39
polybori::BoolePolynomial::length
size_type length() const
Returns number of terms.
Definition: BoolePolynomial.cc:414
polybori::groebner::PolynomialSugar
This class defines PolynomialSugar.
Definition: PolynomialSugar.h:28
polybori::groebner::PolynomialSugar::leadExp
const Exponent & leadExp() const
Definition: PolynomialSugar.h:61
polybori::groebner::PolynomialSugar::adjustLm
void adjustLm()
Definition: PolynomialSugar.h:112
polybori::BooleMonomial
This class is just a wrapper for using variables from cudd's decicion diagram.
Definition: BooleMonomial.h:50
polybori::Monomial
BooleMonomial Monomial
Definition: embed.h:53
polybori::groebner::PolynomialSugar::getLengthEstimation
wlen_type getLengthEstimation() const
Definition: PolynomialSugar.h:67
polybori::groebner::PolynomialSugar::PolynomialSugar
PolynomialSugar(const Polynomial &poly)
Definition: PolynomialSugar.h:30