include/borderbasix/proj.cc File Reference

Go to the source code of this file.

Functions


Function Documentation

void proj ( T &  Crochet,
const typdump &  dump,
const Base b 
) [inline]

Definition at line 51 of file proj.cc.

References int2mon(), Iszero(), mult(), Base< predicat >::nbvar(), pol< mon, T >::nf, rewrite(), and pol< mon, T >::size.

Referenced by newPkMkMatrixof(), and putingoodshape().

00052 {
00053   typedef typename typdump::value_type::pol_t pol;
00054   typedef typename T::value_type polyalp;
00055   typedef typename polyalp::monom_t mon;
00056   typedef typename mon::coeff_t coeff;
00057   typename T::iterator iter=Crochet.begin();
00058 #ifdef unimul 
00059   reinit_multiple();
00060 #endif
00061 #ifdef uninf
00062   reinit_nf<pol>();
00063 #endif
00064   for(;iter!=Crochet.end();iter++)
00065     {
00066       list<mon> monared;
00067       //cout<<"le pol que je vais reduire"<<endl;
00068       //cout<<*iter<<endl;
00069       for(typename polyalp::iterator iterpol=iter->begin();iterpol!=iter->end();iterpol++)
00070         {
00071           if (!IsinB(*iterpol,b)) monared.push_back(*iterpol);
00072           //cout<<"mon dans proj "<<*iterpol<<" b? "<<IsinB(*iterpol,b)<<endl;
00073         }
00074       for(typename list<mon>::iterator itermon=monared.begin();itermon!=monared.end();itermon++)
00075         {
00076           //  cout<<"dans le for sur monared "<<b.nbvar()<<endl;
00077 #ifdef projfast
00078           polyalp result(0);
00079           pol accumul;
00080           mon *exce;
00081           int sizeex;
00082           accumul.size=1;
00083           accumul.nf=(coeff*)MAC_REV_MALLOC<coeff>(sizeof(coeff));
00084           accumul.nf[0]=1;
00085           for(int i=0;i<b.nbvar();i++)
00086             for(int j=0;j<itermon->GetDegree(i);j++)
00087               {
00088                 pol tmp;
00089                 //if(result.size()!=0)
00090                 result*=mon(i,1);
00091                 tmp=mult(i,accumul,dump,b,&exce,sizeex);
00092                 MAC_REV_FREE<coeff>(accumul.nf,accumul.size*sizeof(coeff));
00093                 accumul=tmp;
00094                 for(int k=0;k<sizeex-1;k++)
00095                   result+=exce[k];
00096                 MAC_REV_FREE<mon>(exce,sizeex*sizeof(mon));
00097               }
00098           for(int k=0;k<accumul.size;k++)
00099             if(!Iszero(accumul.nf[k]))
00100               {
00101                 mon tmpmon;
00102                 int2mon(k,tmpmon);
00103                 //      cout<<"tmpmon "<<tmpmon<<endl;
00104                 result+=tmpmon*accumul.nf[k];
00105               }
00106           MAC_REV_FREE<coeff>(accumul.nf,accumul.size*sizeof(coeff));
00107 #else
00108           polyalp result(1);
00109           for(int i=0;i<b.nbvar();i++)
00110             for(int j=0;j<itermon->GetDegree(i);j++)
00111               {
00112                 result*=mon(i,1);
00113                 int flag=0;
00114                 //cout<<"nbtour dans la boucle "<<itermon->GetDegree(i)<<"J"<<j<<endl;
00115                 for (typename polyalp::iterator iterres=result.begin();
00116                      iterres!=result.end();iterres++)
00117                  {
00118                    if (!IsinB(*iterres,b)) flag=1;
00119                    // cout<<"IsinB("<<*iterres<<") "<<IsinB(*iterres,b)<<endl;
00120                  }
00121                 if (flag)
00122                   {
00123                     T tmp;
00124                     tmp.push_back(result);
00125                     //cout<<"rewrite"<<endl;
00126                     rewrite(tmp,dump,b);
00127                     //cout<<"sortie rewrite"<<endl;
00128                     result=tmp.front();
00129                   }
00130               }
00131 #endif
00132           coeff Coeff;
00133           for(typename polyalp::iterator iterpol=iter->begin();
00134               iterpol!=iter->end();iterpol++)
00135             if ((itermon->rep)==(iterpol->rep))
00136               {
00137                 Coeff=iterpol->GetCoeff();
00138                 break;
00139               }
00140           //cout<<"iter avant reecriture "<<*iter<<endl;
00141           *iter+=result*mon(Coeff);
00142           *iter-=polyalp(mon((*itermon)*(coeff)(Coeff/itermon->GetCoeff())));
00143           //cout<<"iter apres reecriture "<<*iter<<endl<<endl;
00144         }
00145     }
00146   //stab(Crochet);
00147   return;
00148 
00149 }

void rewrite ( typPk &  Pk,
const typdump &  dump,
const Base b 
) [inline]

Definition at line 2 of file proj.cc.

References findcorresppol(), pol< mon, T >::ind, pol< mon, T >::nf, and pol< mon, T >::size.

Referenced by proj().

00003 {
00004   typedef typename typPk::value_type polyalp;
00005   typedef typename polyalp::monom_t mon;
00006   typedef typename typdump::value_type dumpstruct;
00007   typedef typename dumpstruct::pol_t pol;
00008   typename typPk::iterator iter=Pk.begin();
00009   //cout<<"Pk.size dans rewrite "<<Pk.size()<<endl;
00010   for(;iter!=Pk.end();iter++)
00011     //pour chaque poly de Pk
00012     { 
00013       polyalp tmp(mon(0));
00014       for(typename polyalp::iterator itermon=iter->begin();
00015           itermon!=iter->end();itermon++)
00016       //pour chaque mon du polynome *iter
00017       {
00018           if (!IsinB(*itermon,b))
00019             {
00020               pol ttmp;
00021               ttmp.size=-1;
00022               ttmp.nf=NULL;
00023               //cout<<"findcorresppol "<<*itermon<<endl;
00024               findcorresppol(*itermon,dump,ttmp);
00025               //cout<<"invconv"<<endl;
00026               //fincorresppol ne touche pas son parametre de sortie qd 
00027               //le monome recherche n'existe pas
00028               //il existe ce monome?
00029               if(ttmp.size!=-1)
00030                 {
00031                   //  cout<<"trouve "<<endl;
00032                   //tmp*=mon(ttmp.ind.GetCoeff());
00033                   tmp+=invconv<polyalp>(ttmp)*mon(itermon->GetCoeff()/ttmp.ind.GetCoeff());
00034                 }
00035                 }
00036         
00037       }
00038       //cout<<"le pol que je vais enlever"<<endl;
00039       //cout<<tmp<<endl;
00040       //cout<<"fin du pol"<<endl;
00041       //cout<<"le poly avant reecriture "<<*iter<<endl;
00042       (*iter)-=tmp;
00043       //cout<<"poly apres reecriture!!\n"<<(*iter)<<endl;
00044     }
00045   return;
00046 }


Generated on 6 Dec 2012 for borderbasix by  doxygen 1.6.1