PolyBoRi
ReductionStrategy.h
Go to the documentation of this file.
00001 // -*- c++ -*-
00002 //*****************************************************************************
00014 //*****************************************************************************
00015 
00016 #ifndef polybori_groebner_ReductionStrategy_h_
00017 #define polybori_groebner_ReductionStrategy_h_
00018 
00019 // include basic definitions
00020 #include "groebner_defs.h"
00021 #include "polynomial_properties.h"
00022 #include "PolyEntryVector.h"
00023 #include "ReductionOptions.h"
00024 #include "ReductionTerms.h"
00025 #include "SetAssociatedMinimal.h"
00026 
00027 BEGIN_NAMESPACE_PBORIGB
00028 
00034 class ReductionStrategy:
00035   public PolyEntryVector, public ReductionOptions, public ReductionTerms {
00036   typedef ReductionStrategy self;
00037 public:
00038 
00039     ReductionStrategy(const BoolePolyRing& ring):
00040       PolyEntryVector(), ReductionOptions(),
00041       ReductionTerms(ring)  { }
00042 
00044     void addGenerator(const PolyEntry& entry) {
00045       PolyEntryVector::append(entry);
00046       setupSetsForElement(back());
00047     }
00048 
00051     void append(const PolyEntry& entry) { addGenerator(entry); }
00052 
00053     Polynomial nf(const Polynomial& p) const {
00054       return (optRedTail? reducedNormalForm(p): headNormalForm(p));
00055     }
00056 
00057     bool canRewrite(const Polynomial& p) const {
00058       return is_rewriteable(p, minimalLeadingTerms);
00059     }
00060 
00061     int select1(const Polynomial& p) const;
00062     int select1(const Monomial& m) const;
00063 
00064     int select_short(const Polynomial& p) const {
00065       return select_short_by_terms(p.leadDivisors());
00066     }
00067     int select_short(const Monomial& m) const {
00068       return select_short_by_terms(m.divisors());
00069     }
00070 
00071     Polynomial headNormalForm(const Polynomial& p) const;
00072     Polynomial reducedNormalForm(const Polynomial& p) const;
00073 
00074     void llReduceAll();
00075 
00076     operator const PolyEntryVector&() const {
00077       return static_cast<const PolyEntryVector&>(*this);
00078     }
00079 
00080 protected:
00081   void llReduce(const PolyEntry& entry, const Exponent& ll_e);
00082 
00083   int select_short_by_terms(const MonomialSet&) const;
00084 
00085   void unmarkNonMinimalLeadingTerms(MonomialSet removed) {
00086     std::for_each(removed.expBegin(), removed.expEnd(),
00087                   SetAssociatedMinimal<Exponent, false>(*this));
00088   }
00089  
00090   void setupSetsForElement(const PolyEntry& entry);
00091 
00092 
00093   template <class Iterator, class CompareType>
00094   size_type minimum(Iterator start, Iterator finish, const CompareType& comp)
00095     const {
00096     start = std::min_element(start, finish, comp);
00097     if PBORI_UNLIKELY(start == finish)
00098       return size_type(-1);
00099     
00100     return index(*start);
00101   }
00102 
00103 };
00104 
00105 
00106 inline bool
00107 irreducible_lead(Monomial lm, const ReductionStrategy& strat){
00108 
00109   return (!(strat.minimalLeadingTerms.hasTermOfVariables(lm)));//
00110   //        strat.generators.minimalLeadingTerms.intersect(lm.divisors()).isZero();
00111 }
00112 
00113 
00114 
00115 
00116 END_NAMESPACE_PBORIGB
00117 
00118 #endif /* polybori_ReductionStrategy_h_ */