00001 template<typename mon, typename typB>
00002 int has_b_index(const mon m,int index,const typB b)
00003 {
00004 int res=0;
00005 list<mon> current_mon;
00006 current_mon.push_back(m);
00007
00008 for(int i=0;i<index-1;i++)
00009 {
00010 list<mon> tmp;
00011 for(typename list<mon>::iterator iter=current_mon.begin();
00012 iter!=current_mon.end();iter++)
00013 for(int j=0;j<b.nbvars;j++)
00014 {
00015 mon tmpmon=my_divmon(*iter,j,b);
00016 if(IsinB(tmpmon,b))
00017 return 0;
00018 if (!member(tmp,tmpmon))
00019 tmp.push_back(tmpmon);
00020 }
00021 current_mon.swap(tmp);
00022 }
00023 {
00024 list<mon> tmp;
00025 for(typename list<mon>::iterator iter=current_mon.begin();
00026 iter!=current_mon.end();iter++)
00027 for(int j=0;j<b.nbvars;j++)
00028 {
00029 mon tmpmon=my_divmon(*iter,j,b);
00030 if (!member(tmp,tmpmon))
00031 tmp.push_back(tmpmon);
00032 }
00033 current_mon.swap(tmp);
00034 }
00035
00036 for(typename list<mon>::iterator iter=current_mon.begin();
00037 iter!=current_mon.end();iter++)
00038 {
00039 if(IsinB(*iter,b))
00040 {
00041 res=1;
00042 break;
00043 }
00044 }
00045 return res;
00046 }
00047
00048 template<typename typB>
00049 int stop_degree(const typB &b)
00050 {
00051 typedef typename typB::mon mon;
00052 int max_deg=0;
00053 int comp_index=2;
00054 for(typename typB::const_iterator iter=b.begin();
00055 iter!=b.end();iter++)
00056 {
00057 list<typename typB::mon> listppcm;
00058 for(int i=0;i<iter->taille2;i++)
00059 listppcm.push_back(iter->refuse[i]);
00060 for(;!listppcm.empty();comp_index++)
00061 {
00062 list<mon> tmp;
00063 for(typename list<mon>::iterator iter1=listppcm.begin();
00064 iter1!=listppcm.end();
00065 iter1++)
00066 for(typename list<mon>::iterator iter2=(++iter1)--;
00067 iter2!=listppcm.end();
00068 iter2++)
00069 {
00070 mon tmpmon=lcm(*iter1,*iter2);
00071 if(!member(tmp,tmpmon))
00072 tmp.push_back(tmpmon);
00073 }
00074 listppcm.erase(listppcm.begin(),listppcm.end());
00075 for(typename list<mon>::iterator iter=tmp.begin();
00076 iter!=tmp.end();
00077 iter++)
00078 {
00079 if(has_b_index(*iter,comp_index,b))
00080 {
00081 listppcm.push_back(*iter);
00082 if(max_deg<iter->GetDegree()-comp_index+2)
00083 max_deg=iter->GetDegree()-comp_index+2;
00084 }
00085 }
00086 }
00087 }
00088 return max_deg;
00089 }