00001 // -*- c++ -*- 00002 //***************************************************************************** 00014 //***************************************************************************** 00015 00016 #ifndef polybori_groebner_CountCriterion_h_ 00017 #define polybori_groebner_CountCriterion_h_ 00018 00019 // include basic definitions 00020 #include "groebner_defs.h" 00021 00022 #include "GroebnerStrategy.h" 00023 #include "interpolate.h" 00024 00025 BEGIN_NAMESPACE_PBORIGB 00026 00031 class CountCriterion{ 00032 public: 00033 GroebnerStrategy* strat; 00034 int j; 00035 CountCriterion(GroebnerStrategy& strat, int j){ 00036 this->strat=&strat; 00037 this->j=j; 00038 } 00039 bool operator() (int i){ 00040 const PolyEntry & e1=const_cast<const GroebnerStrategy*>(strat)->generators[i]; 00041 const PolyEntry & e2=const_cast<const GroebnerStrategy*>(strat)->generators[j]; 00042 const int USED_VARIABLES_BOUND=6; 00043 if ((e1.usedVariables.deg()>USED_VARIABLES_BOUND)|| 00044 (e2.usedVariables.deg()>USED_VARIABLES_BOUND)|| 00045 (e1.usedVariables.LCMDeg(e2.usedVariables) > USED_VARIABLES_BOUND) 00046 00047 00048 ||(e1.p.set().nNodes()>30)||(e2.p.set().nNodes()>30)) 00049 return false; 00050 00051 Exponent uv_exp=e1.usedVariables.LCM(e2.usedVariables); 00052 00053 MonomialSet space=uv_exp.divisors(e1.p.ring()); 00054 00055 Monomial lead_lcm=e1.lead.LCM(e2.lead); 00056 //I am sure, there exists combinatorial formulas 00057 MonomialSet common_lead_space=lead_lcm.divisors(); 00058 Monomial gcd=e1.lead.GCD(e2.lead); 00059 int gcd_deg = gcd_deg; 00060 int standard_monomials_in_common_lead= 00061 // common_lead_space.diff( 00062 // common_lead_space.multiplesOf(e1.lead)).diff( 00063 // common_lead_space.multiplesOf(e2.lead)).size(); 00064 (1<<gcd_deg)*((1<<(e1.leadDeg-gcd_deg))-1+(1<<(e1.leadDeg-gcd_deg) 00065 )-1) 00066 +((1<<gcd_deg)-1)*((1<<(e1.leadDeg-gcd_deg))+(1<<(e2.leadDeg-gcd_deg))); 00067 00068 MonomialSet::size_type standard_monomials = 00069 (standard_monomials_in_common_lead <<(uv_exp.size()-lead_lcm.deg())); 00070 00071 MonomialSet zeros1=zeros(e1.p, space); 00072 MonomialSet zeros2=zeros(e2.p, space); 00073 00074 MonomialSet my_zeros=zeros1.intersect(zeros2); 00075 00076 00077 // MonomialSet my_zeros=zeros(e1.p, space).intersect(zeros(e2.p, space)); 00078 00079 00080 if (PBORI_UNLIKELY(standard_monomials==my_zeros.size())) 00081 { 00082 strat->pairs.status.setToHasTRep(i,j); 00083 return true; 00084 00085 } 00086 else 00087 return false; 00088 } 00089 bool operator() (const Exponent &m){ 00090 int i = strat->generators.index(m); 00091 return (*this)(i); 00092 } 00093 00094 00095 }; 00096 00097 END_NAMESPACE_PBORIGB 00098 00099 #endif /* polybori_CountCriterion_h_ */