PolyXY& PolyXY::operator%=(const PolyXY& v) { ZZn m,pq; int power, power2; termXY *rptr=start; termXY *vptr=v.start; termXY *ptr,*pos; if (degreeX(*this)<degreeX(v) && degreeY(*this)<degreeY(v)) return *this; m=((ZZn)1/vptr->an); while (rptr!=NULL && rptr->nx>=vptr->nx && rptr->ny>=vptr->ny) { pq=rptr->an*m; power=rptr->nx-vptr->nx; power2=rptr->ny-vptr->ny; pos=NULL; ptr=v.start; while (ptr!=NULL) { pos=addterm(ptr->an*pq,ptr->nx+power,ptr->ny+power2,pos); ptr=ptr->next; } rptr=start; } return *this; }
Poly2& Poly2::operator%=(const Poly2& v) { GF2m m,pq; int power; term2 *rptr=start; term2 *vptr=v.start; term2 *ptr,*pos; if (degree(*this)<degree(v)) return *this; m=((GF2m)1/vptr->an); while (rptr!=NULL && rptr->n>=vptr->n) { pq=rptr->an*m; power=rptr->n-vptr->n; pos=NULL; ptr=v.start; while (ptr!=NULL) { pos=addterm(ptr->an*pq,ptr->n+power,pos); ptr=ptr->next; } rptr=start; } return *this; }
Poly2::Poly2(const Poly2& p) { term2 *ptr=p.start; term2 *pos=NULL; start=NULL; while (ptr!=NULL) { pos=addterm(ptr->an,ptr->n,pos); ptr=ptr->next; } }
FPoly& FPoly::operator-=(const FPoly& p) { fterm *ptr,*pos=NULL; ptr=p.start; while (ptr!=NULL) { pos=addterm(-(ptr->an),ptr->n,pos); ptr=ptr->next; } return *this; }
FPoly::FPoly(const FPoly& p) { fterm *ptr=p.start; fterm *pos=NULL; start=NULL; while (ptr!=NULL) { pos=addterm(ptr->an,ptr->n,pos); ptr=ptr->next; } }
PolyXY::PolyXY(const Poly& p) { term *ptr=p.start; termXY *pos=NULL; start=NULL; while (ptr!=NULL) { pos=addterm(ptr->an,ptr->n,0,pos); ptr=ptr->next; } }
PolyXY& PolyXY::operator-=(const PolyXY& p) { termXY *ptr,*pos=NULL; ptr=p.start; while (ptr!=NULL) { pos=addterm(-(ptr->an),ptr->nx,ptr->ny,pos); ptr=ptr->next; } return *this; }
Poly2& Poly2::operator+=(const Poly2& p) { term2 *ptr,*pos=NULL; ptr=p.start; while (ptr!=NULL) { pos=addterm(ptr->an,ptr->n,pos); ptr=ptr->next; } return *this; }
Poly &Poly::operator=(const Poly& p) { term *ptr,*pos=NULL; clear(); ptr=p.start; while (ptr!=NULL) { pos=addterm(ptr->an,ptr->n,pos); ptr=ptr->next; } return *this; }
void Ps_ZZn::pad() { // insert any missing 0 coefficients int i=0; term_ps_zzn *ptr=start; term_ps_zzn *pos=NULL; while (ptr!=NULL) { while (i<ptr->n) { pos=addterm((ZZn)0,i*pwr-offset,pos); i++; } i++; ptr=ptr->next; } while (i<psN/pwr) { pos=addterm((ZZn)0,i*pwr-offset,pos); i++; } }
Ps_ZZn& Ps_ZZn::operator+=(const Ps_ZZn& p) { term_ps_zzn *ptr=p.start; term_ps_zzn *pos=NULL; int pw; while (ptr!=NULL) { pw=ptr->n*p.pwr-p.offset; // convert compressed to real if (pw>=psN) break; pos=addterm(ptr->an,pw,pos); ptr=ptr->next; } return *this; }
Ps_ZZn& Ps_ZZn::operator-=(const Ps_ZZn& p) { term_ps_zzn *ptr=p.start; term_ps_zzn *pos=NULL; int pw; while (ptr!=NULL) { pw=ptr->n*p.pwr-p.offset; if (pw>=psN) break; pos=addterm(-(ptr->an),pw,pos); ptr=ptr->next; } return *this; }
Ps_ZZn::Ps_ZZn(const Ps_ZZn& p) { term_ps_zzn *ptr=p.start; term_ps_zzn *pos=NULL; int pw; start=NULL; offset=p.offset; pwr=p.pwr; while (ptr!=NULL) { pw=ptr->n*p.pwr-p.offset; // conversion needed if (pw>=psN) break; pos=addterm(ptr->an,pw,pos); ptr=ptr->next; } }
Ps_Big& Ps_Big::operator=(const Ps_Big& p) { term_ps_big *ptr,*pos=NULL; clear(); int pw; pwr=p.pwr; offset=p.offset; ptr=p.start; while (ptr!=NULL) { pw=ptr->n*p.pwr-p.offset; if (pw>=psN) break; pos=addterm(ptr->an,pw,pos); ptr=ptr->next; } return *this; }
PolyXY& PolyXY::operator=(int p) { clear(); addterm((ZZn)p, 0, 0); return *this; }
Poly2::Poly2(const GF2m& c,int p) { start=NULL; addterm(c,p); }
Ps_ZZn& Ps_ZZn::operator=(int m) { clear(); if (m!=0) addterm((ZZn)m,0); return *this; }
Ps_Big& Ps_Big::operator=(int m) { clear(); if (m!=0) addterm((Big)m,0); return *this; }
Poly2::Poly2(Variable &x) { start=NULL; addterm((GF2m)1,1); }
Poly2& Poly2::operator=(int m) { clear(); if (m!=0) addterm((GF2m)m,0); return *this; }
PolyXY::PolyXY(const ZZn& c, int p, int y) { start=NULL; addterm(c,p,y); }
Poly2& Poly2::operator=(const GF2m& m) { clear(); if (!m.iszero()) addterm(m,0); return *this; }
PolyXY::PolyXY(int p) { start=NULL; addterm((ZZn)p,0,0); }