Пример #1
0
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;
}
Пример #2
0
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;
}
Пример #3
0
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;
    }    
}
Пример #4
0
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;
}
Пример #5
0
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;
    }    
}
Пример #6
0
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;
    }
}
Пример #7
0
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;
}
Пример #8
0
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;
}
Пример #9
0
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;
}
Пример #10
0
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++;
    }
}
Пример #11
0
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;
}
Пример #12
0
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;
}
Пример #13
0
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;
    }
}
Пример #14
0
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;
}
Пример #15
0
PolyXY& PolyXY::operator=(int p)
{
    clear();
    addterm((ZZn)p, 0, 0);
    return *this;
}
Пример #16
0
Poly2::Poly2(const GF2m& c,int p)
{
    start=NULL;
    addterm(c,p);
}
Пример #17
0
Ps_ZZn& Ps_ZZn::operator=(int m)
{
    clear();
    if (m!=0) addterm((ZZn)m,0);
    return *this;
}
Пример #18
0
Ps_Big& Ps_Big::operator=(int m)
{
    clear();
    if (m!=0) addterm((Big)m,0);
    return *this;
}
Пример #19
0
Poly2::Poly2(Variable &x)
{
    start=NULL;
    addterm((GF2m)1,1);
}
Пример #20
0
Poly2& Poly2::operator=(int m)
{
    clear();
    if (m!=0) addterm((GF2m)m,0);
    return *this;
}
Пример #21
0
PolyXY::PolyXY(const ZZn& c, int p, int y)
{
    start=NULL;
    addterm(c,p,y);
}
Пример #22
0
Poly2& Poly2::operator=(const GF2m& m)
{
    clear();
    if (!m.iszero()) addterm(m,0);
    return *this;
}
Пример #23
0
PolyXY::PolyXY(int p)
{
    start=NULL;
    addterm((ZZn)p,0,0);
}