include/borderbasix/pol.cc File Reference

#include "ugly.cc"

Go to the source code of this file.

Classes

Functions


Function Documentation

pol convert ( const polyalp &  P,
const Base b 
) [inline]

Definition at line 145 of file pol.cc.

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

00146 {
00147   typedef typename polyalp::order_t ord;
00148   typedef typename polyalp::monom_t mon;
00149   typedef typename mon::coeff_t coeff;
00150   pol res;
00151   int max=0;
00152   //  cout<<"entree de convert"<<endl;
00153   //cout<<"le pol que g ici c "<<P<<endl;
00154   for(typename polyalp::const_iterator iter=P.begin();iter!=P.end();iter++)
00155     {
00156       if(IsinB(*iter,b))
00157         {
00158           //int toto=mon2int(*iter),tutu=mon2int(*iter);
00159           max=(max<mon2int(*iter))?mon2int(*iter):max;
00160           //  cout<<"mon2int(*iter)"<<toto<<" "<<tutu<<endl;
00161         }
00162       else {/*cout<<*iter<<" n'est pas dans B "<<endl;*/};
00163     }
00164   res.size=max+1;
00165   res.nf=(coeff*)MAC_REV_MALLOC<coeff>(res.size*sizeof(coeff));
00166   for(int i=0;i<res.size;i++)
00167     res.nf[i]=0;
00168   //memset((void*)res.nf,0,res.size*sizeof(coeff));
00169   for(typename polyalp::const_iterator iter=P.begin();iter!=P.end();iter++)
00170     if(IsinB(*iter,b))
00171       {
00172         //cout<<"mon2int("<<*iter<<") "<<mon2int(*iter)<<" et size "<<res.size<<endl;
00173         res.nf[mon2int(*iter)]=iter->GetCoeff();
00174       }
00175   else 
00176     {
00177       //  cout<<"le monome "<<*iter<<" et le coeff "<<iter->GetCoeff()<<endl;
00178       //printf("le vrai nom est %.32f\n",iter->GetCoeff());
00179       if(!Iszero(coeff(iter->GetCoeff())))
00180         //le pol devrait NE PAS CONTENIR DE MONOME
00181         //EN DEHORS DU QUOTIENT AUTRE QUE x_i^{d_i}
00182         {
00183           // int i;
00184           //  cout<<"trouve monome correspondant a la description "<<*iter<<endl;
00185           res.ind=*iter;
00186           //res.size--;
00187           //res/=iter->GetCoeff();
00188         }
00189     }
00190   return res;
00191 }

int Degree ( const pol< mon, T > &  p  )  [inline]

Definition at line 194 of file pol.cc.

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

Referenced by choice_dlex(), choice_fall(), choice_grevlex(), choice_mac(), choice_mpq(), choice_naif(), choice_num(), choice_old(), Crochet(), minmaxdegP(), and newPkMkMatrixof().

00195 {
00196   int mmax=-1;
00197   for(int i=0;i<p.size;i++)
00198     if(!Iszero(p.nf[i]))
00199       {
00200         mon tmpmon;
00201         int2mon(i,tmpmon);
00202         mmax=(mmax<tmpmon.GetDegree())?tmpmon.GetDegree():mmax;
00203       }
00204   if(!Iszero(p.ind.GetCoeff()))
00205      mmax=(mmax<p.ind.GetDegree())?p.ind.GetDegree():mmax;
00206   return mmax;//p.ind.GetDegree();
00207 }

Mon divmon ( const Mon mon,
int  i,
const Base b 
) [inline]

Definition at line 128 of file pol.cc.

00129 {
00130   Mon res(1);
00131   for(int j=0;j<b.nvar();j++)
00132     if(i==j)
00133       {
00134         res*=Mon(j,mon.GetDegree(j)-1);
00135       }
00136   else 
00137     {
00138       res*=Mon(j,mon.GetDegree(j));
00139     }
00140   return res;
00141 }

polyalp invconv ( const poly &  p  )  [inline]

Definition at line 98 of file pol.cc.

References int2mon(), and Iszero().

00099 {
00100   typedef typename polyalp::monom_t mon;
00101   typedef typename polyalp::order_t ord;
00102   polyalp res(0);
00103   // cout<<"p.size "<<p.size<<endl;
00104   for(int i=0;i<p.size;i++)
00105     {
00106       if (!Iszero(p.nf[i]))
00107       {
00108         mon tmp;
00109         int2mon(i,tmp);
00110         //cout<<"i vaut"<<i<<endl;
00111         //cout<<"j'aoute le monome "<<tmp<<endl;
00112         //cout<<"LE COEFF EST "<<p.nf[i]<<endl;  
00113         //cout<<"res dans invconv"<<endl<<res<<endl;
00114         res+=tmp*p.nf[i];
00115       }
00116     }
00117   if (!Iszero(p.ind.GetCoeff()))
00118     res+=p.ind;
00119   //cout<<"res dans invconv"<<endl<<res<<endl;
00120   return res;
00121 }

void* MAC_REV_MALLOC ( int  size  )  [inline]

Definition at line 39 of file memory.cc.

00040 {
00041   //cout<<"c'est celui la "<<endl;
00042   void * res;
00043   res=malloc(size);
00044   INIT_ELEM<T>(res,size);
00045   return res;
00046 }

void* MAC_REV_REALLOC ( void *  ptr,
int  ,
int   
) [inline]

Definition at line 49 of file memory.cc.

00050 {
00051   void *res=ptr;
00052   if(size<newsize)
00053     {
00054       res=realloc(ptr,newsize);
00055       INIT_ELEM<T>((char*)res+size,newsize-size);
00056     }
00057   if(size>newsize)
00058     {
00059       CLEAR_ELEM<T>((char*)ptr+newsize,size-newsize);
00060       res=realloc(ptr,newsize);
00061     }
00062   return res;
00063 }

mon monofindex ( int  j,
pol< mon, T > &  p 
) [inline]

Definition at line 210 of file pol.cc.

References int2mon().

Referenced by printdump().

00211 {
00212   mon tmp;
00213   int2mon(j,tmp);
00214   return tmp;
00215 }


Generated on 6 Dec 2012 for borderbasix by  doxygen 1.6.1