| version 1.1, 2018/09/19 05:45:06 |
version 1.4, 2020/10/06 06:31:19 |
|
|
| * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
| * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
| * |
* |
| * $OpenXM$ |
* $OpenXM: OpenXM_contrib2/asir2018/builtin/poly.c,v 1.3 2019/03/03 05:21:16 noro Exp $ |
| */ |
*/ |
| #include "ca.h" |
#include "ca.h" |
| #include "parse.h" |
#include "parse.h" |
| Line 235 void Pheadsgn(NODE arg,Z *rp) |
|
| Line 235 void Pheadsgn(NODE arg,Z *rp) |
|
| int s; |
int s; |
| |
|
| s = headsgn((P)ARG0(arg)); |
s = headsgn((P)ARG0(arg)); |
| STOQ(s,*rp); |
STOZ(s,*rp); |
| } |
} |
| |
|
| void Pmul_trunc(NODE arg,P *rp) |
void Pmul_trunc(NODE arg,P *rp) |
| Line 260 void Pmul_trunc(NODE arg,P *rp) |
|
| Line 260 void Pmul_trunc(NODE arg,P *rp) |
|
| vn[i].n = 0; |
vn[i].n = 0; |
| for ( h = p, i = 0; OID(h) == O_P; h = COEF(DC(h)) ) { |
for ( h = p, i = 0; OID(h) == O_P; h = COEF(DC(h)) ) { |
| for ( ; vn[i].v != VR(h); i++ ); |
for ( ; vn[i].v != VR(h); i++ ); |
| vn[i].n = QTOS(DEG(DC(h))); |
vn[i].n = ZTOS(DEG(DC(h))); |
| } |
} |
| mulp_trunc(vl,p1,p2,vn,rp); |
mulp_trunc(vl,p1,p2,vn,rp); |
| } |
} |
| Line 290 void Pquo_trunc(NODE arg,P *rp) |
|
| Line 290 void Pquo_trunc(NODE arg,P *rp) |
|
| vn[i].n = 0; |
vn[i].n = 0; |
| for ( h = p2, i = 0; OID(h) == O_P; h = COEF(DC(h)) ) { |
for ( h = p2, i = 0; OID(h) == O_P; h = COEF(DC(h)) ) { |
| for ( ; vn[i].v != VR(h); i++ ); |
for ( ; vn[i].v != VR(h); i++ ); |
| vn[i].n = QTOS(DEG(DC(h))); |
vn[i].n = ZTOS(DEG(DC(h))); |
| } |
} |
| quop_trunc(vl,p1,p2,vn,rp); |
quop_trunc(vl,p1,p2,vn,rp); |
| } |
} |
| Line 299 void Pquo_trunc(NODE arg,P *rp) |
|
| Line 299 void Pquo_trunc(NODE arg,P *rp) |
|
| void Phomogeneous_part(NODE arg,P *rp) |
void Phomogeneous_part(NODE arg,P *rp) |
| { |
{ |
| if ( argc(arg) == 2 ) |
if ( argc(arg) == 2 ) |
| exthp(CO,(P)ARG0(arg),QTOS((Q)ARG1(arg)),rp); |
exthp(CO,(P)ARG0(arg),ZTOS((Q)ARG1(arg)),rp); |
| else |
else |
| exthpc_generic(CO,(P)ARG0(arg),QTOS((Q)ARG2(arg)), |
exthpc_generic(CO,(P)ARG0(arg),ZTOS((Q)ARG2(arg)), |
| VR((P)ARG1(arg)),rp); |
VR((P)ARG1(arg)),rp); |
| } |
} |
| |
|
| Line 313 void Phomogeneous_deg(NODE arg,Z *rp) |
|
| Line 313 void Phomogeneous_deg(NODE arg,Z *rp) |
|
| d = homdeg((P)ARG0(arg)); |
d = homdeg((P)ARG0(arg)); |
| else |
else |
| d = getchomdeg(VR((P)ARG1(arg)),(P)ARG0(arg)); |
d = getchomdeg(VR((P)ARG1(arg)),(P)ARG0(arg)); |
| STOQ(d,*rp); |
STOZ(d,*rp); |
| } |
} |
| |
|
| /* |
/* |
| Line 379 void Pget_next_fft_prime(NODE arg,LIST *rp) |
|
| Line 379 void Pget_next_fft_prime(NODE arg,LIST *rp) |
|
| NODE n; |
NODE n; |
| Z q,ind; |
Z q,ind; |
| |
|
| start = QTOS((Q)ARG0(arg)); |
start = ZTOS((Q)ARG0(arg)); |
| bits = QTOS((Q)ARG1(arg)); |
bits = ZTOS((Q)ARG1(arg)); |
| for ( i = start; ; i++ ) { |
for ( i = start; ; i++ ) { |
| get_fft_prime(i,&mod,&d); |
get_fft_prime(i,(int *)&mod,(int *)&d); |
| if ( !mod ) { |
if ( !mod ) { |
| *rp = 0; return; |
*rp = 0; return; |
| } |
} |
| if ( bits <= (int)d ) { |
if ( bits <= (int)d ) { |
| UTOQ(mod,q); |
UTOZ(mod,q); |
| UTOQ(i,ind); |
UTOZ(i,ind); |
| n = mknode(2,ind,q); |
n = mknode(2,ind,q); |
| MKLIST(*rp,n); |
MKLIST(*rp,n); |
| return; |
return; |
| Line 401 void Pranp(NODE arg,P *rp) |
|
| Line 401 void Pranp(NODE arg,P *rp) |
|
| int n; |
int n; |
| UP c; |
UP c; |
| |
|
| n = QTOS((Q)ARG0(arg)); |
n = ZTOS((Q)ARG0(arg)); |
| ranp(n,&c); |
ranp(n,&c); |
| if ( c ) { |
if ( c ) { |
| up_var = VR((P)ARG1(arg)); |
up_var = VR((P)ARG1(arg)); |
| Line 420 void ranp(int n,UP *nr) |
|
| Line 420 void ranp(int n,UP *nr) |
|
| *nr = c = UPALLOC(n); |
*nr = c = UPALLOC(n); |
| for ( i = 0; i <= n; i++ ) { |
for ( i = 0; i <= n; i++ ) { |
| r = random(); |
r = random(); |
| UTOQ(r,q); |
UTOZ(r,q); |
| c->c[i] = (Num)q; |
c->c[i] = (Num)q; |
| } |
} |
| for ( i = n; i >= 0 && !c->c[i]; i-- ); |
for ( i = n; i >= 0 && !c->c[i]; i-- ); |
| Line 434 void Pmaxblen(NODE arg,Z *rp) |
|
| Line 434 void Pmaxblen(NODE arg,Z *rp) |
|
| { |
{ |
| int l; |
int l; |
| l = maxblenp(ARG0(arg)); |
l = maxblenp(ARG0(arg)); |
| STOQ(l,*rp); |
STOZ(l,*rp); |
| } |
} |
| |
|
| void Pp_mag(NODE arg,Z *rp) |
void Pp_mag(NODE arg,Z *rp) |
| { |
{ |
| int l; |
int l; |
| l = p_mag(ARG0(arg)); |
l = p_mag(ARG0(arg)); |
| STOQ(l,*rp); |
STOZ(l,*rp); |
| } |
} |
| |
|
| void Pord(NODE arg,LIST *listp) |
void Pord(NODE arg,LIST *listp) |
| Line 646 void Pcoef_gf2n(NODE arg,Obj *rp) |
|
| Line 646 void Pcoef_gf2n(NODE arg,Obj *rp) |
|
| else if ( (n = (Obj)ARG1(arg)) && (OID(n) > O_N) ) |
else if ( (n = (Obj)ARG1(arg)) && (OID(n) > O_N) ) |
| *rp = 0; |
*rp = 0; |
| else if ( id == O_N && NID((Num)t) == N_GF2N ) { |
else if ( id == O_N && NID((Num)t) == N_GF2N ) { |
| d = QTOS((Q)n); |
d = ZTOS((Q)n); |
| up2 = ((GF2N)t)->body; |
up2 = ((GF2N)t)->body; |
| if ( d > degup2(up2) ) |
if ( d > degup2(up2) ) |
| *rp = 0; |
*rp = 0; |
| Line 670 void Pdeg(NODE arg,Z *rp) |
|
| Line 670 void Pdeg(NODE arg,Z *rp) |
|
| *rp = (Obj)DEG(DC((P)t)); |
*rp = (Obj)DEG(DC((P)t)); |
| #endif |
#endif |
| if ( !(t = (Obj)ARG0(arg)) ) |
if ( !(t = (Obj)ARG0(arg)) ) |
| STOQ(-1,*rp); |
STOZ(-1,*rp); |
| else if ( OID(t) != O_P ) { |
else if ( OID(t) != O_P ) { |
| if ( OID(t) == O_N && NID(t) == N_GF2N |
if ( OID(t) == O_N && NID(t) == N_GF2N |
| && (v=(Obj)ARG1(arg)) && OID(v)== O_N && NID(v) == N_GF2N ) { |
&& (v=(Obj)ARG1(arg)) && OID(v)== O_N && NID(v) == N_GF2N ) { |
| d = degup2(((GF2N)t)->body); |
d = degup2(((GF2N)t)->body); |
| STOQ(d,*rp); |
STOZ(d,*rp); |
| } else |
} else |
| *rp = 0; |
*rp = 0; |
| } else |
} else |
| Line 696 void Psetmod(NODE arg,Z *rp) |
|
| Line 696 void Psetmod(NODE arg,Z *rp) |
|
| { |
{ |
| if ( arg ) { |
if ( arg ) { |
| asir_assert(ARG0(arg),O_N,"setmod"); |
asir_assert(ARG0(arg),O_N,"setmod"); |
| current_mod = QTOS((Q)ARG0(arg)); |
current_mod = ZTOS((Q)ARG0(arg)); |
| } |
} |
| STOQ(current_mod,*rp); |
STOZ(current_mod,*rp); |
| } |
} |
| |
|
| void Psparsemod_gf2n(NODE arg,Z *rp) |
void Psparsemod_gf2n(NODE arg,Z *rp) |
| Line 711 void Psparsemod_gf2n(NODE arg,Z *rp) |
|
| Line 711 void Psparsemod_gf2n(NODE arg,Z *rp) |
|
| id = -1; |
id = -1; |
| else |
else |
| id = current_mod_gf2n->id; |
id = current_mod_gf2n->id; |
| STOQ(id,*rp); |
STOZ(id,*rp); |
| } |
} |
| |
|
| void Pmultest_gf2n(NODE arg,GF2N *rp) |
void Pmultest_gf2n(NODE arg,GF2N *rp) |
| Line 753 void Pbininv_gf2n(NODE arg,GF2N *rp) |
|
| Line 753 void Pbininv_gf2n(NODE arg,GF2N *rp) |
|
| int n; |
int n; |
| |
|
| a = ((GF2N)ARG0(arg))->body; |
a = ((GF2N)ARG0(arg))->body; |
| n = QTOS((Q)ARG1(arg)); |
n = ZTOS((Q)ARG1(arg)); |
| type1_bin_invup2(a,n,&inv); |
type1_bin_invup2(a,n,&inv); |
| MKGF2N(inv,*rp); |
MKGF2N(inv,*rp); |
| } |
} |
| Line 809 void Pis_irred_ddd_gf2(NODE arg,Z *rp) |
|
| Line 809 void Pis_irred_ddd_gf2(NODE arg,Z *rp) |
|
| |
|
| ptoup2(ARG0(arg),&t); |
ptoup2(ARG0(arg),&t); |
| ret = irredcheck_dddup2(t); |
ret = irredcheck_dddup2(t); |
| STOQ(ret,*rp); |
STOZ(ret,*rp); |
| } |
} |
| |
|
| void Psetmod_ff(NODE arg,Obj *rp) |
void Psetmod_ff(NODE arg,Obj *rp) |
| Line 848 void Psetmod_ff(NODE arg,Obj *rp) |
|
| Line 848 void Psetmod_ff(NODE arg,Obj *rp) |
|
| if ( OID(ARG0(arg)) == O_N ) { |
if ( OID(ARG0(arg)) == O_N ) { |
| /* small finite field; primitive root representation */ |
/* small finite field; primitive root representation */ |
| current_ff = FF_GFS; |
current_ff = FF_GFS; |
| setmod_sf(QTOS((Q)ARG0(arg)),QTOS((Q)ARG1(arg))); |
setmod_sf(ZTOS((Q)ARG0(arg)),ZTOS((Q)ARG1(arg))); |
| } else { |
} else { |
| mod = (Obj)ARG1(arg); |
mod = (Obj)ARG1(arg); |
| current_ff = FF_GFPN; |
current_ff = FF_GFPN; |
| Line 861 void Psetmod_ff(NODE arg,Obj *rp) |
|
| Line 861 void Psetmod_ff(NODE arg,Obj *rp) |
|
| } else if ( ac == 3 ) { |
} else if ( ac == 3 ) { |
| /* finite extension of a small finite field */ |
/* finite extension of a small finite field */ |
| current_ff = FF_GFS; |
current_ff = FF_GFS; |
| setmod_sf(QTOS((Q)ARG0(arg)),QTOS((Q)ARG1(arg))); |
setmod_sf(ZTOS((Q)ARG0(arg)),ZTOS((Q)ARG1(arg))); |
| d = QTOS((Q)ARG2(arg)); |
d = ZTOS((Q)ARG2(arg)); |
| generate_defpoly_sfum(d,&dp); |
generate_defpoly_sfum(d,&dp); |
| setmod_gfsn(dp); |
setmod_gfsn(dp); |
| current_ff = FF_GFSN; |
current_ff = FF_GFSN; |
| Line 880 void Psetmod_ff(NODE arg,Obj *rp) |
|
| Line 880 void Psetmod_ff(NODE arg,Obj *rp) |
|
| *rp = (Obj)list; break; |
*rp = (Obj)list; break; |
| case FF_GFS: |
case FF_GFS: |
| case FF_GFSN: |
case FF_GFSN: |
| STOQ(current_gfs_p,q); |
STOZ(current_gfs_p,q); |
| if ( current_gfs_ext ) |
if ( current_gfs_ext ) |
| enc_to_p(current_gfs_p,current_gfs_iton[1], |
enc_to_p(current_gfs_p,current_gfs_iton[1], |
| VR(current_gfs_ext),&p); |
VR(current_gfs_ext),&p); |
| Line 890 void Psetmod_ff(NODE arg,Obj *rp) |
|
| Line 890 void Psetmod_ff(NODE arg,Obj *rp) |
|
| else if ( !current_gfs_ntoi ) |
else if ( !current_gfs_ntoi ) |
| r = 0; |
r = 0; |
| else |
else |
| STOQ(current_gfs_iton[1],r); |
STOZ(current_gfs_iton[1],r); |
| p = (P)r; |
p = (P)r; |
| } |
} |
| switch ( current_ff ) { |
switch ( current_ff ) { |
| Line 922 void Pextdeg_ff(Z *rp) |
|
| Line 922 void Pextdeg_ff(Z *rp) |
|
| case FF_GFP: |
case FF_GFP: |
| *rp = ONE; break; |
*rp = ONE; break; |
| case FF_GF2N: |
case FF_GF2N: |
| getmod_gf2n(&up2); d = degup2(up2); STOQ(d,*rp); break; |
getmod_gf2n(&up2); d = degup2(up2); STOZ(d,*rp); break; |
| case FF_GFPN: |
case FF_GFPN: |
| getmod_gfpn(&up); STOQ(up->d,*rp); break; |
getmod_gfpn(&up); STOZ(up->d,*rp); break; |
| case FF_GFS: |
case FF_GFS: |
| if ( !current_gfs_ext ) |
if ( !current_gfs_ext ) |
| *rp = ONE; |
*rp = ONE; |
| Line 933 void Pextdeg_ff(Z *rp) |
|
| Line 933 void Pextdeg_ff(Z *rp) |
|
| break; |
break; |
| case FF_GFSN: |
case FF_GFSN: |
| getmod_gfsn(&dp); |
getmod_gfsn(&dp); |
| STOQ(DEG(dp),*rp); |
STOZ(DEG(dp),*rp); |
| break; |
break; |
| default: |
default: |
| error("extdeg_ff : current_ff is not set"); |
error("extdeg_ff : current_ff is not set"); |
| Line 947 void Pcharacteristic_ff(Z *rp) |
|
| Line 947 void Pcharacteristic_ff(Z *rp) |
|
| case FF_GFPN: |
case FF_GFPN: |
| getmod_lm(rp); break; |
getmod_lm(rp); break; |
| case FF_GF2N: |
case FF_GF2N: |
| STOQ(2,*rp); break; |
STOZ(2,*rp); break; |
| case FF_GFS: |
case FF_GFS: |
| case FF_GFSN: |
case FF_GFSN: |
| STOQ(current_gfs_p,*rp); break; |
STOZ(current_gfs_p,*rp); break; |
| default: |
default: |
| error("characteristic_ff : current_ff is not set"); |
error("characteristic_ff : current_ff is not set"); |
| } |
} |
| Line 958 void Pcharacteristic_ff(Z *rp) |
|
| Line 958 void Pcharacteristic_ff(Z *rp) |
|
| |
|
| void Pfield_type_ff(Z *rp) |
void Pfield_type_ff(Z *rp) |
| { |
{ |
| STOQ(current_ff,*rp); |
STOZ(current_ff,*rp); |
| } |
} |
| |
|
| void Pfield_order_ff(Z *rp) |
void Pfield_order_ff(Z *rp) |
| Line 1146 void Pptomp(NODE arg,P *rp) |
|
| Line 1146 void Pptomp(NODE arg,P *rp) |
|
| else |
else |
| mod = current_mod; |
mod = current_mod; |
| } else |
} else |
| mod = QTOS((Q)ARG1(arg)); |
mod = ZTOS((Q)ARG1(arg)); |
| ptomp(mod,(P)ARG0(arg),rp); |
ptomp(mod,(P)ARG0(arg),rp); |
| } |
} |
| |
|
| Line 1183 void Psf_embed(NODE arg,P *rp) |
|
| Line 1183 void Psf_embed(NODE arg,P *rp) |
|
| |
|
| /* GF(pn)={0,1,a,a^2,...}->GF(pm)={0,1,b,b^2,...}; a->b^k */ |
/* GF(pn)={0,1,a,a^2,...}->GF(pm)={0,1,b,b^2,...}; a->b^k */ |
| k = CONT((GFS)ARG1(arg)); |
k = CONT((GFS)ARG1(arg)); |
| pm = QTOS((Q)ARG2(arg)); |
pm = ZTOS((Q)ARG2(arg)); |
| sf_embed((P)ARG0(arg),k,pm,rp); |
sf_embed((P)ARG0(arg),k,pm,rp); |
| } |
} |
| |
|
| Line 1194 void Psf_log(NODE arg,Z *rp) |
|
| Line 1194 void Psf_log(NODE arg,Z *rp) |
|
| if ( !ARG0(arg) ) |
if ( !ARG0(arg) ) |
| error("sf_log : invalid armument"); |
error("sf_log : invalid armument"); |
| k = CONT((GFS)ARG0(arg)); |
k = CONT((GFS)ARG0(arg)); |
| STOQ(k,*rp); |
STOZ(k,*rp); |
| } |
} |
| |
|
| void Psf_find_root(NODE arg,GFS *rp) |
void Psf_find_root(NODE arg,GFS *rp) |
| Line 1284 void Pureverse(NODE arg,P *rp) |
|
| Line 1284 void Pureverse(NODE arg,P *rp) |
|
| if ( argc(arg) == 1 ) |
if ( argc(arg) == 1 ) |
| reverseup(p,p->d,&r); |
reverseup(p,p->d,&r); |
| else |
else |
| reverseup(p,QTOS((Q)ARG1(arg)),&r); |
reverseup(p,ZTOS((Q)ARG1(arg)),&r); |
| uptop(r,rp); |
uptop(r,rp); |
| } |
} |
| |
|
| Line 1293 void Putrunc(NODE arg,P *rp) |
|
| Line 1293 void Putrunc(NODE arg,P *rp) |
|
| UP p,r; |
UP p,r; |
| |
|
| ptoup((P)ARG0(arg),&p); |
ptoup((P)ARG0(arg),&p); |
| truncup(p,QTOS((Q)ARG1(arg))+1,&r); |
truncup(p,ZTOS((Q)ARG1(arg))+1,&r); |
| uptop(r,rp); |
uptop(r,rp); |
| } |
} |
| |
|
| Line 1304 void Pudecomp(NODE arg,LIST *rp) |
|
| Line 1304 void Pudecomp(NODE arg,LIST *rp) |
|
| NODE n0,n1; |
NODE n0,n1; |
| |
|
| ptoup((P)ARG0(arg),&p); |
ptoup((P)ARG0(arg),&p); |
| decompup(p,QTOS((Q)ARG1(arg))+1,&low,&up); |
decompup(p,ZTOS((Q)ARG1(arg))+1,&low,&up); |
| uptop(low,&l); |
uptop(low,&l); |
| uptop(up,&u); |
uptop(up,&u); |
| MKNODE(n1,u,0); MKNODE(n0,l,n1); |
MKNODE(n1,u,0); MKNODE(n0,l,n1); |
| Line 1356 void Puinvmod(NODE arg,P *rp) |
|
| Line 1356 void Puinvmod(NODE arg,P *rp) |
|
| UP p,r; |
UP p,r; |
| |
|
| ptoup((P)ARG0(arg),&p); |
ptoup((P)ARG0(arg),&p); |
| invmodup(p,QTOS((Q)ARG1(arg)),&r); |
invmodup(p,ZTOS((Q)ARG1(arg)),&r); |
| uptop(r,rp); |
uptop(r,rp); |
| } |
} |
| |
|
| Line 1366 void Purevinvmod(NODE arg,P *rp) |
|
| Line 1366 void Purevinvmod(NODE arg,P *rp) |
|
| |
|
| ptoup((P)ARG0(arg),&p); |
ptoup((P)ARG0(arg),&p); |
| reverseup(p,p->d,&pr); |
reverseup(p,p->d,&pr); |
| invmodup(pr,QTOS((Q)ARG1(arg)),&r); |
invmodup(pr,ZTOS((Q)ARG1(arg)),&r); |
| uptop(r,rp); |
uptop(r,rp); |
| } |
} |
| |
|
| Line 1377 void Ppwrmod_ff(NODE arg,P *rp) |
|
| Line 1377 void Ppwrmod_ff(NODE arg,P *rp) |
|
| ptoup((P)ARG0(arg),&p1); |
ptoup((P)ARG0(arg),&p1); |
| switch ( current_ff ) { |
switch ( current_ff ) { |
| case FF_GFP: |
case FF_GFP: |
| |
/* XXX : hybrid version may not be useful ... */ |
| |
#if 1 |
| hybrid_powermodup(p1,&p2); break; |
hybrid_powermodup(p1,&p2); break; |
| |
#else |
| |
powermodup(p1,&p2); break; |
| |
#endif |
| case FF_GF2N: |
case FF_GF2N: |
| powermodup_gf2n(p1,&p2); break; |
powermodup_gf2n(p1,&p2); break; |
| case FF_GFPN: |
case FF_GFPN: |
| Line 1479 void Pkpwrtab_lm(NODE arg,VECT *rp) |
|
| Line 1484 void Pkpwrtab_lm(NODE arg,VECT *rp) |
|
| |
|
| void Plazy_lm(NODE arg,Q *rp) |
void Plazy_lm(NODE arg,Q *rp) |
| { |
{ |
| lm_lazy = QTOS((Q)ARG0(arg)); |
lm_lazy = ZTOS((Q)ARG0(arg)); |
| *rp = 0; |
*rp = 0; |
| } |
} |
| |
|
| Line 1508 void Pktmul(NODE arg,P *rp) |
|
| Line 1513 void Pktmul(NODE arg,P *rp) |
|
| |
|
| ptoup((P)ARG0(arg),&p1); |
ptoup((P)ARG0(arg),&p1); |
| ptoup((P)ARG1(arg),&p2); |
ptoup((P)ARG1(arg),&p2); |
| tkmulup(p1,p2,QTOS((Q)ARG2(arg))+1,&r); |
tkmulup(p1,p2,ZTOS((Q)ARG2(arg))+1,&r); |
| uptop(r,rp); |
uptop(r,rp); |
| } |
} |
| |
|
| Line 1545 void Putmul(NODE arg,P *rp) |
|
| Line 1550 void Putmul(NODE arg,P *rp) |
|
| |
|
| ptoup((P)ARG0(arg),&p1); |
ptoup((P)ARG0(arg),&p1); |
| ptoup((P)ARG1(arg),&p2); |
ptoup((P)ARG1(arg),&p2); |
| hybrid_tmulup(0,p1,p2,QTOS((Q)ARG2(arg))+1,&r); |
hybrid_tmulup(0,p1,p2,ZTOS((Q)ARG2(arg))+1,&r); |
| uptop(r,rp); |
uptop(r,rp); |
| } |
} |
| |
|
| Line 1581 void Putmul_ff(NODE arg,Obj *rp) |
|
| Line 1586 void Putmul_ff(NODE arg,Obj *rp) |
|
| |
|
| ptoup((P)ARG0(arg),&p1); |
ptoup((P)ARG0(arg),&p1); |
| ptoup((P)ARG1(arg),&p2); |
ptoup((P)ARG1(arg),&p2); |
| hybrid_tmulup(current_ff,p1,p2,QTOS((Q)ARG2(arg))+1,&r); |
hybrid_tmulup(current_ff,p1,p2,ZTOS((Q)ARG2(arg))+1,&r); |
| uptop(r,&p); |
uptop(r,&p); |
| simp_ff((Obj)p,rp); |
simp_ff((Obj)p,rp); |
| } |
} |
| Line 1638 void Pfmultest(NODE arg,LIST *rp) |
|
| Line 1643 void Pfmultest(NODE arg,LIST *rp) |
|
| Z prime; |
Z prime; |
| NODE n0,n1; |
NODE n0,n1; |
| |
|
| p1 = (P)ARG0(arg); p2 = (P)ARG1(arg); index = QTOS((Q)ARG2(arg)); |
p1 = (P)ARG0(arg); p2 = (P)ARG1(arg); index = ZTOS((Q)ARG2(arg)); |
| FFT_primes(index,&mod,&root,&d); |
FFT_primes(index,&mod,&root,&d); |
| maxint = 1<<d; |
maxint = 1<<d; |
| d1 = UDEG(p1); d2 = UDEG(p2); |
d1 = UDEG(p1); d2 = UDEG(p2); |
| Line 1665 void Pfmultest(NODE arg,LIST *rp) |
|
| Line 1670 void Pfmultest(NODE arg,LIST *rp) |
|
| for ( i = 0; i <= d1+d2; i++ ) |
for ( i = 0; i <= d1+d2; i++ ) |
| wr->c[i] = (unsigned int)fr[i]; |
wr->c[i] = (unsigned int)fr[i]; |
| umtop(VR(p1),wr,&r); |
umtop(VR(p1),wr,&r); |
| STOQ(mod,prime); |
STOZ(mod,prime); |
| MKNODE(n1,prime,0); |
MKNODE(n1,prime,0); |
| MKNODE(n0,r,n1); |
MKNODE(n0,r,n1); |
| MKLIST(*rp,n0); |
MKLIST(*rp,n0); |
| Line 1678 void Pkmulum(NODE arg,P *rp) |
|
| Line 1683 void Pkmulum(NODE arg,P *rp) |
|
| int d1,d2,mod; |
int d1,d2,mod; |
| UM w1,w2,wr; |
UM w1,w2,wr; |
| |
|
| p1 = (P)ARG0(arg); p2 = (P)ARG1(arg); mod = QTOS((Q)ARG2(arg)); |
p1 = (P)ARG0(arg); p2 = (P)ARG1(arg); mod = ZTOS((Q)ARG2(arg)); |
| d1 = UDEG(p1); d2 = UDEG(p2); |
d1 = UDEG(p1); d2 = UDEG(p2); |
| w1 = W_UMALLOC(d1); w2 = W_UMALLOC(d2); |
w1 = W_UMALLOC(d1); w2 = W_UMALLOC(d2); |
| wr = W_UMALLOC(d1+d2); |
wr = W_UMALLOC(d1+d2); |
| Line 1693 void Pksquareum(NODE arg,P *rp) |
|
| Line 1698 void Pksquareum(NODE arg,P *rp) |
|
| int d1,mod; |
int d1,mod; |
| UM w1,wr; |
UM w1,wr; |
| |
|
| p1 = (P)ARG0(arg); mod = QTOS((Q)ARG1(arg)); |
p1 = (P)ARG0(arg); mod = ZTOS((Q)ARG1(arg)); |
| d1 = UDEG(p1); |
d1 = UDEG(p1); |
| w1 = W_UMALLOC(d1); |
w1 = W_UMALLOC(d1); |
| wr = W_UMALLOC(2*d1); |
wr = W_UMALLOC(2*d1); |
| Line 1732 void Pumul_specialmod(NODE arg,P *rp) |
|
| Line 1737 void Pumul_specialmod(NODE arg,P *rp) |
|
| nmod = length(n); |
nmod = length(n); |
| modind = (int *)MALLOC_ATOMIC(nmod*sizeof(int)); |
modind = (int *)MALLOC_ATOMIC(nmod*sizeof(int)); |
| for ( i = 0, t = n; i < nmod; i++, t = NEXT(t) ) |
for ( i = 0, t = n; i < nmod; i++, t = NEXT(t) ) |
| modind[i] = QTOS((Q)BDY(t)); |
modind[i] = ZTOS((Q)BDY(t)); |
| fft_mulup_specialmod_main(p1,p2,0,modind,nmod,&r); |
fft_mulup_specialmod_main(p1,p2,0,modind,nmod,&r); |
| uptop(r,rp); |
uptop(r,rp); |
| } |
} |
| Line 1757 void Pusquare_specialmod(NODE arg,P *rp) |
|
| Line 1762 void Pusquare_specialmod(NODE arg,P *rp) |
|
| nmod = length(n); |
nmod = length(n); |
| modind = (int *)MALLOC_ATOMIC(nmod*sizeof(int)); |
modind = (int *)MALLOC_ATOMIC(nmod*sizeof(int)); |
| for ( i = 0, t = n; i < nmod; i++, t = NEXT(t) ) |
for ( i = 0, t = n; i < nmod; i++, t = NEXT(t) ) |
| modind[i] = QTOS((Q)BDY(t)); |
modind[i] = ZTOS((Q)BDY(t)); |
| fft_mulup_specialmod_main(p1,p1,0,modind,nmod,&r); |
fft_mulup_specialmod_main(p1,p1,0,modind,nmod,&r); |
| uptop(r,rp); |
uptop(r,rp); |
| } |
} |
| Line 1783 void Putmul_specialmod(NODE arg,P *rp) |
|
| Line 1788 void Putmul_specialmod(NODE arg,P *rp) |
|
| nmod = length(n); |
nmod = length(n); |
| modind = (int *)MALLOC_ATOMIC(nmod*sizeof(int)); |
modind = (int *)MALLOC_ATOMIC(nmod*sizeof(int)); |
| for ( i = 0, t = n; i < nmod; i++, t = NEXT(t) ) |
for ( i = 0, t = n; i < nmod; i++, t = NEXT(t) ) |
| modind[i] = QTOS((Q)BDY(t)); |
modind[i] = ZTOS((Q)BDY(t)); |
| fft_mulup_specialmod_main(p1,p2,QTOS((Q)ARG2(arg))+1,modind,nmod,&r); |
fft_mulup_specialmod_main(p1,p2,ZTOS((Q)ARG2(arg))+1,modind,nmod,&r); |
| uptop(r,rp); |
uptop(r,rp); |
| } |
} |
| } |
} |