PolyBoRi
LLReductor.h
Go to the documentation of this file.
1 // -*- c++ -*-
2 //*****************************************************************************
14 //*****************************************************************************
15 
16 #ifndef polybori_groebner_LLReductor_h_
17 #define polybori_groebner_LLReductor_h_
18 
19 #include "ll_red_nf.h"
20 
21 // include basic definitions
22 #include "groebner_defs.h"
23 
25 
26 // groebner_alg.h
27 MonomialSet recursively_insert(MonomialSet::navigator p,
28  idx_type idx, MonomialSet mset);
29 
34 class LLReductor:
35  public MonomialSet {
36 
37  typedef MonomialSet base;
38  typedef LLReductor self;
39 public:
41  LLReductor(const BoolePolyRing& ring): base(ring.one()) {}
42 
44  template <class Type>
45  LLReductor(const Type& value): base(value) { PBORI_ASSERT(!isZero()); }
46 
47 
49  bool isCompatible(const PolyEntry& entry) {
50 
51  PBORI_ASSERT (!isZero());
52  return (entry.leadDeg == 1) &&
53  (*(entry.p.navigation()) == entry.lead.firstIndex() ) &&
54  (!expBegin()->reducibleBy(entry.lead.firstIndex()));
55  }
56 
58  Polynomial update(const PolyEntry& entry) {
59  return (isCompatible(entry)? insert(entry): entry.p);
60  }
61 
62 private:
63  self& operator=(const self& rhs) {
64  return static_cast<self&>(static_cast<base&>(*this) = rhs);
65  }
66 
67  Polynomial insert(const PolyEntry& entry) {
68 
69  Polynomial poly = ll_red_nf(entry.p, *this);
70  PBORI_ASSERT(poly.lead() == entry.lead);
71 
72  operator=(recursively_insert(poly.navigation().elseBranch(),
73  entry.lead.firstIndex(),
74  ll_red_nf(*this, poly.set())));
75  return poly;
76  }
77 
78 };
79 
81 
82 #endif /* polybori_groebner_LLReductor_h_ */