00001 #ifndef ALREADY_basisutil
00002 #define ALREADY_basisutil
00003
00004 template<typename Base,typename typdump, typename monomial_server>
00005 int countpoint(const Base &b,const typdump & dump, monomial_server &serv)
00006 {
00007 typedef typename typdump::value_type::pol_t pol;
00008 typedef typename pol::monom_t mon;
00009 int maxdeg=-1;
00010 list<mon> current;
00011 list<mon> stockmon;
00012 cout<<"countmon "<<endl;
00013 current.push_back(mon(1));
00014 stockmon.push_back(mon(1));
00015 #if 0
00016 {
00017 typename typdump::const_iterator iter;
00018 for(iter=dump.begin();
00019 iter!=dump.end();iter++);
00020 maxdeg=(--iter)->k;
00021 }
00022 #endif
00023
00024
00025
00026 for(int i=-2;i!=maxdeg;i=maxdeg,maxdeg=stockmon.size())
00027 {
00028
00029 list<mon> tmpcurrent=current;
00030
00031 current.erase(current.begin(),current.end());
00032 for(int i=0;i<b.nbvar();i++)
00033 {
00034 for(typename list<mon>::iterator iter=tmpcurrent.begin();
00035 iter!=tmpcurrent.end();iter++)
00036 current.push_back((*iter)*mon(i,1));
00037 }
00038
00039 for(typename list<mon>::iterator iter=current.begin();iter!=current.end();iter++)
00040 if((IsinB(*iter,b))&&(!member(stockmon,*iter)))
00041 {
00042 serv.mon2int(*iter);
00043
00044 stockmon.push_back(*iter);
00045 }
00046 else
00047 {
00048 current.erase(iter--);
00049 }
00050 }
00051 return stockmon.size();
00052 }
00053
00054 template<typename Base,typename typdump,typename typMk>
00055 void MonomialBase(const Base &b,const typdump & dump,typMk & res)
00056 {
00057 typedef typename typdump::value_type::pol_t pol;
00058 typedef typename pol::monom_t mon;
00059 int maxdeg=0;
00060 list<mon> current;
00061
00062 current.push_back(mon(1));
00063 res.push_back(mon(1));
00064 {
00065 typename typdump::const_iterator iter;
00066 for(iter=dump.begin();
00067 iter!=dump.end();iter++);
00068 maxdeg=(--iter)->k;
00069 }
00070
00071
00072
00073 for(int i=0;i<maxdeg;i++)
00074 {
00075 list<mon> tmpcurrent=current;
00076
00077 current.erase(current.begin(),current.end());
00078 for(int i=0;i<b.nbvar();i++)
00079 {
00080 for(typename list<mon>::iterator iter=tmpcurrent.begin();
00081 iter!=tmpcurrent.end();iter++)
00082 current.push_back((*iter)*mon(i,1));
00083 }
00084
00085 for(typename list<mon>::iterator iter=current.begin();iter!=current.end();iter++)
00086 if((IsinB(*iter,b))&&(!member(res,*iter)))
00087 {
00088 res.push_back(*iter);
00089 }
00090 else
00091 {
00092 current.erase(iter--);
00093 }
00094 }
00095 return;
00096 }
00097
00098 #ifdef DENSE
00099
00100 template<typename Base,typename typdump>
00101 int countpoint(const Base &b,const typdump & dump)
00102 {
00103 typedef typename typdump::value_type::pol_t pol;
00104 typedef typename pol::monom_t mon;
00105 int maxdeg=-1;
00106 list<mon> current;
00107 list<mon> stockmon;
00108 cout<<"countmon "<<endl;
00109 current.push_back(mon(1));
00110 stockmon.push_back(mon(1));
00111 #if 0
00112 {
00113 typename typdump::const_iterator iter;
00114 for(iter=dump.begin();
00115 iter!=dump.end();iter++);
00116 maxdeg=(--iter)->k;
00117 }
00118 #endif
00119
00120
00121
00122 for(int i=-2;i!=maxdeg;i=maxdeg,maxdeg=stockmon.size())
00123 {
00124
00125 list<mon> tmpcurrent=current;
00126
00127 current.erase(current.begin(),current.end());
00128 for(int i=0;i<b.nbvar();i++)
00129 {
00130 for(typename list<mon>::iterator iter=tmpcurrent.begin();
00131 iter!=tmpcurrent.end();iter++)
00132 current.push_back((*iter)*mon(i,1));
00133 }
00134
00135 for(typename list<mon>::iterator iter=current.begin();iter!=current.end();iter++)
00136 if((IsinB(*iter,b))&&(!member(stockmon,*iter)))
00137 {
00138 mon2int(*iter);
00139
00140 stockmon.push_back(*iter);
00141 }
00142 else
00143 {
00144 current.erase(iter--);
00145 }
00146 }
00147 return stockmon.size();
00148 }
00149
00150 #endif
00151
00152 #endif //ALREADY_basisutil