#include "ugly.cc"
Go to the source code of this file.
#define polter pol |
Definition at line 1 of file pol2ter.cc.
Referenced by convert().
void compress_ind | ( | ) |
Definition at line 196 of file pol2ter.cc.
References Iszero(), mon2int(), nbbits, and polter.
00197 { 00198 typedef typename polyalp::order_t ord; 00199 typedef typename polyalp::monom_t mon; 00200 typedef typename mon::coeff_t coeff; 00201 coeff *tmp; 00202 polter res; 00203 int i,maxind=-1,j,p=0; 00204 i=0; 00205 res.ind=mon(0); 00206 for(typename polyalp::const_iterator iter=P.begin();iter!=P.end();iter++) 00207 if ((IsinB(*iter,b))&&(mon2int(*iter)>maxind)) 00208 maxind=mon2int(*iter); 00209 maxind++; 00210 res.sizenf=(maxind/8)+1; 00211 res.nfind=(unsigned char*)malloc((maxind/8+1)); 00212 memset(res.nfind,0,res.sizenf); 00213 tmp=(coeff*)MAC_REV_MALLOC<coeff>((maxind)*sizeof(coeff)); 00214 for(int i=0;i<maxind;i++) 00215 tmp[i]=0; 00216 for(typename polyalp::const_iterator iter=P.begin();iter!=P.end();iter++) 00217 { 00218 if(IsinB(*iter,b)) 00219 { 00220 if(!Iszero(iter->GetCoeff())) 00221 { 00222 int stockind=mon2int(*iter); 00223 tmp[stockind]=iter->GetCoeff(); 00224 res.nfind[stockind/8]|=(unsigned char)(1<<(stockind%8)); 00225 p++; 00226 } 00227 } 00228 else 00229 res.ind=*iter; 00230 } 00231 res.size=p;//l'ind n'est pas comptabilise dans la nf 00232 res.nf=(coeff*)MAC_REV_MALLOC<coeff>(res.size*sizeof(coeff)); 00233 for( i=0;i<res.size;i++) 00234 res.nf[i]=0; 00235 00236 j=0; 00237 for(int i=0;i<maxind;i++) 00238 if(!Iszero(coeff(tmp[i]))) 00239 res.nf[j++]=tmp[i]; 00240 MAC_REV_FREE<coeff>(tmp,(maxind)*sizeof(coeff)); 00241 00242 p=0; 00243 for(int i=0;i<res.sizenf;i++) 00244 p+=nbbits[res.nfind[i]]; 00245 #ifdef DEB 00246 cout<<"pol.size "<<P.size()<<" kkk "<<p<<endl; 00247 #endif 00248 return res; 00249 }
Definition at line 252 of file pol2ter.cc.
References int2mon(), and Iszero().
00253 { 00254 int mmax=-1; 00255 for(int i=0;i<p.sizenf;i++) 00256 if(p.nfind[i]) 00257 { 00258 mon tmpmon; 00259 for(int j=0;j<8;j++) 00260 if((p.nfind[i]>>j)&1) 00261 { 00262 int2mon(8*i+j,tmpmon); 00263 mmax=(mmax<tmpmon.GetDegree())?tmpmon.GetDegree():mmax; 00264 } 00265 } 00266 if(!Iszero(p.ind.GetCoeff())) 00267 mmax=(mmax<p.ind.GetDegree())?p.ind.GetDegree():mmax; 00268 return mmax;//p.ind.GetDegree(); 00269 }
Definition at line 143 of file pol2ter.cc.
References int2mon(), Iszero(), and nbbits.
00144 { 00145 typedef typename polyalp::order_t ord; 00146 polyalp res(0); 00147 T *tmpptr=p.nf; 00148 int counter=0,decalage=0; 00149 mon tmp; 00150 for(int i=0;i<p.sizenf;i++) 00151 { 00152 unsigned char motif=p.nfind[i]&255; 00153 unsigned nb_repete=p.nfind[i]>>8; 00154 decalage=0; 00155 for(int j=0;j<8;j++) 00156 if ((p.nfind[i]>>j)&1) 00157 { 00158 for(int k=0;k<nb_repete;k++) 00159 { 00160 int2mon(counter+8*k+j,tmp); 00161 res+=tmp*(*(tmpptr+decalage+k*nbbits[motif])); 00162 } 00163 decalage++; 00164 } 00165 tmpptr+=nbbits[motif]*nb_repete; 00166 } 00167 if (!Iszero(p.ind.GetCoeff())) 00168 res+=p.ind; 00169 //cout<<"res dans invconv"<<endl<<res<<endl; 00170 return res; 00171 }
void MAC_REV_FREE | ( | void * | ptr, | |
int | size | |||
) | [inline] |
void* MAC_REV_MALLOC | ( | int | size | ) | [inline] |
void* MAC_REV_REALLOC | ( | void * | ptr, | |
int | , | |||
int | ||||
) | [inline] |
Definition at line 49 of file memory.cc.
Referenced by freeint2mon(), and putmon2().
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 }
int nbbits[256] = {0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8} |
Definition at line 4 of file pol2ter.cc.