PolyBoRi
HasTRepOrExtendedProductCriterion.h
Go to the documentation of this file.
00001 // -*- c++ -*-
00002 //*****************************************************************************
00014 //*****************************************************************************
00015 
00016 #ifndef polybori_groebner_HasTRepOrExtendedProductCriterion_h_
00017 #define polybori_groebner_HasTRepOrExtendedProductCriterion_h_
00018 
00019 // include basic definitions
00020 #include "groebner_defs.h"
00021 #include "GroebnerStrategy.h"
00022 
00023 BEGIN_NAMESPACE_PBORIGB
00024 
00025 
00026 inline bool
00027 extended_product_criterion(const PolyEntry& m, const PolyEntry& m2){
00028   //BooleMonomial m;
00030   
00031   bool res=(m.lead.GCD(m2.lead).deg()==common_literal_factors_deg(m.literal_factors, m2.literal_factors));
00032   //if (res)
00033   //  cout<<"EXTENDED PRODUCT_CRIT";
00034   return res;
00035 }
00036 
00037 
00042 class HasTRepOrExtendedProductCriterion{
00043 public:
00044   GroebnerStrategy* strat;
00045   int j;
00046   HasTRepOrExtendedProductCriterion(GroebnerStrategy& strat, int j){
00047     this->strat=&strat;
00048     this->j=j;
00049   }
00050   bool operator() (const Monomial &m){
00051     int i = strat->generators.index(m);
00052     
00053     if (strat->pairs.status.hasTRep(i,j))
00054       return true;
00055     
00056     if (extended_product_criterion(const_cast<const GroebnerStrategy*>(strat)->generators[i],const_cast<const GroebnerStrategy*>(strat)->generators[j])){
00057       strat->pairs.status.setToHasTRep(i,j);
00058       strat->extendedProductCriterions++;
00059       return true;
00060     }
00061     return false;
00062   }
00063   bool operator() (const Exponent &m){
00064     int i;
00065     i=strat->generators.index(m);
00066     
00067     if (strat->pairs.status.hasTRep(i,j))
00068       return true;
00069     
00070     if (extended_product_criterion(const_cast<const GroebnerStrategy*>(strat)->generators[i],const_cast<const GroebnerStrategy*>(strat)->generators[j])){
00071       strat->pairs.status.setToHasTRep(i,j);
00072       strat->extendedProductCriterions++;
00073       return true;
00074     }
00075     return false;
00076   }
00077 
00078 };
00079 
00080 END_NAMESPACE_PBORIGB
00081 
00082 #endif /* polybori_HasTRepOrExtendedProductCriterion_h_ */