PolyBoRi
LLReductor.h
Go to the documentation of this file.
00001 // -*- c++ -*-
00002 //*****************************************************************************
00014 //*****************************************************************************
00015 
00016 #ifndef polybori_groebner_LLReductor_h_
00017 #define polybori_groebner_LLReductor_h_
00018 
00019 #include "ll_red_nf.h"
00020 
00021 // include basic definitions
00022 #include "groebner_defs.h"
00023 
00024 BEGIN_NAMESPACE_PBORIGB
00025 
00026 // groebner_alg.h
00027 MonomialSet recursively_insert(MonomialSet::navigator p,
00028                                idx_type idx, MonomialSet mset);
00029 
00034 class LLReductor:
00035   public MonomialSet {
00036 
00037   typedef MonomialSet base;
00038   typedef LLReductor self;
00039 public:
00041   LLReductor(const BoolePolyRing& ring): base(ring.one()) {}
00042 
00044   template <class Type>
00045   LLReductor(const Type& value): base(value) { PBORI_ASSERT(!isZero()); }
00046 
00047 
00049   bool isCompatible(const PolyEntry& entry) {
00050 
00051     PBORI_ASSERT (!isZero());
00052     return  (entry.leadDeg == 1) && 
00053       (*(entry.p.navigation()) == entry.lead.firstIndex() ) &&
00054       (!expBegin()->reducibleBy(entry.lead.firstIndex()));
00055   }
00056 
00058   Polynomial update(const PolyEntry& entry) {
00059     return (isCompatible(entry)? insert(entry): entry.p);
00060   }
00061 
00062 private:
00063   self& operator=(const self& rhs) {
00064     return static_cast<self&>(static_cast<base&>(*this) = rhs);
00065   }
00066 
00067   Polynomial insert(const PolyEntry& entry) {
00068     
00069     Polynomial poly = ll_red_nf(entry.p, *this);
00070     PBORI_ASSERT(poly.lead() == entry.lead);
00071     
00072     operator=(recursively_insert(poly.navigation().elseBranch(),
00073                                  entry.lead.firstIndex(),
00074                                  ll_red_nf(*this, poly.set())));
00075     return poly;
00076   }
00077 
00078 };
00079 
00080 END_NAMESPACE_PBORIGB
00081 
00082 #endif /* polybori_groebner_LLReductor_h_ */