- 注册时间
- 2007-12-27
- 最后登录
- 1970-1-1
- 威望
- 星
- 金币
- 枚
- 贡献
- 分
- 经验
- 点
- 鲜花
- 朵
- 魅力
- 点
- 上传
- 次
- 下载
- 次
- 积分
- 40285
- 在线时间
- 小时
|
楼主 |
发表于 2014-4-23 14:19:21
|
显示全部楼层
- qcov_num_add_poly(a,b,P, tn, tm)={
- local(r);r=0;
- if(tn==P&&tm==P,
- r=Mod(1,P)*x^2,
- if(tm==P, tm=tn;tn=P );
- if(tn==P,
- if(tm==0, r=Mod(0,P),
- r=( Mod(1,P)*x-1/Mod(a*b*tm,P) )^2
- ),
- if(tn==0, r=(Mod(1,P)*x-Mod(tm,P))^2,
- r=Mod((a*b*tm*tn-1),P)^2/Mod(tn,P)^2*x^2+
- Mod(-2*a*b*tm^2+(-2*a*b*tn^2+4*a*tn+4*b*tn-2)*tm/tn-2,P)/Mod(tn,P)*x
- +Mod((tm/tn-1)^2,P)
- )
- )
- );
- r
- }
- get_other_root(r1,r2,P)={
- local(d1,d2,r,t,t2);
- r=P+1;
- d1=poldegree(r1);d2=poldegree(r2);
- if(d2<1&&r2==0&&d1==1,
- r=-polcoeff(r1,0)/polcoeff(r1,1);
- r=component(r,2)
- );
- if(d2==2&&d1==1,
- t=-polcoeff(r1,0)/polcoeff(r1,1);
- t2=subst(r2,x,t);
- if(t2==0, r=P)
- );
- if(d2==2&&d1==2,
- r1=r1/polcoeff(r1,2);
- r2=r2/polcoeff(r2,2);
- r2=r2-r1;
- if(poldegree(r2)==1,
- t=-polcoeff(r2,0)/polcoeff(r2,1);
- t2=subst(r1,x,t);
- if(t2==0,
- r=component(polcoeff(r1,0)/t,2)
- )
- )
- );
- r
- }
- get_common_root(r1,r2,P)={
- local(d1,d2,r,t,t2);
- r=P+1;
- d1=poldegree(r1);d2=poldegree(r2);
- if(d1<=1&&d2<=1, r=P,
- if(d2<=1,t=r2;r2=r1;r1=t;t=d2;d2=d1;d1=t);
- if(d1==1,
- t=-polcoeff(r1,0)/polcoeff(r1,1);
- t2=subst(r2,x,t);
- if(t2==0, r=component(t,2), r=P+1),
- if(d1==0, r=P+1,
- r1=r1/polcoeff(r1,2);r2=r2/polcoeff(r2,2);
- r1=r1-r2;
- if(poldegree(r1)<1, if(r1==0, r=P+2,r=P+1),
- r1=r1/polcoeff(r1,1);
- t=-polcoeff(r1,0)/polcoeff(r1,1);
- t2=subst(r2,x,t);
- if(t2==0, r=component(t,2), r=P+1)
- )
- )
- )
- );
- r
- }
- qcov_group_add(a,b,P,tn,tn_p,tm,tm_p)={
- local(tmp1,tmp2,r1,r2);
- r1=r2=P+1;
- if(tm==tn&&tn_p==tm_p,
- r1=tn_p;r2=if(tn_p==P, tn, component(Mod(tn-1,P)^2/Mod(tn*a*b-1,P)^2,2)),
- tmp1=qcov_num_add_poly(a,b,P, tn, tm_p);
- tmp2=qcov_num_add_poly(a,b,P,tn_p,tm);
- r2=get_common_root(tmp1,tmp2,P);
- if(r2==P+1, print("invalid r2"),
- tmp1=qcov_num_add_poly(a,b,P, 1, r2);
- tmp2=qcov_num_add_poly(a,b,P, tn, tm);
- r1=get_common_root(tmp1,tmp2,P);
- if(r1==P+2, tmp2=qcov_num_add_poly(a,b,P,tn_p,tm_p);
- r1=get_other_root(tmp1,tmp2,P));
- if(r1==P+1, print("invalid r1"))
- )
- );
- [r1,r2]
- }
复制代码 |
|