version 1.12, 2001/06/29 09:08:52 |
version 1.15, 2001/09/03 07:01:05 |
|
|
* 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_contrib2/asir2000/builtin/poly.c,v 1.11 2001/05/28 08:22:00 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/builtin/poly.c,v 1.14 2001/09/03 01:04:25 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "parse.h" |
#include "parse.h" |
Line 64 void Pmergelist(), Pch_mv(), Pre_mv(), Pdeglist(); |
|
Line 64 void Pmergelist(), Pch_mv(), Pre_mv(), Pdeglist(); |
|
void Pptomp(),Pmptop(); |
void Pptomp(),Pmptop(); |
void Pptolmp(),Plmptop(); |
void Pptolmp(),Plmptop(); |
void Pptosfp(),Psfptop(),Psf_galois_action(),Psf_embed(),Psf_find_root(); |
void Pptosfp(),Psfptop(),Psf_galois_action(),Psf_embed(),Psf_find_root(); |
void Psf_minipoly(); |
void Psf_minipoly(),Psf_log(); |
void Pptogf2n(),Pgf2ntop(),Pgf2ntovect(); |
void Pptogf2n(),Pgf2ntop(),Pgf2ntovect(); |
void Pptogfpn(),Pgfpntop(); |
void Pptogfpn(),Pgfpntop(); |
void Pfind_root_gf2n(); |
void Pfind_root_gf2n(); |
Line 132 struct ftab poly_tab[] = { |
|
Line 132 struct ftab poly_tab[] = { |
|
|
|
{"sparsemod_gf2n",Psparsemod_gf2n,-1}, |
{"sparsemod_gf2n",Psparsemod_gf2n,-1}, |
|
|
{"setmod_ff",Psetmod_ff,-2}, |
{"setmod_ff",Psetmod_ff,-3}, |
{"simp_ff",Psimp_ff,1}, |
{"simp_ff",Psimp_ff,1}, |
{"extdeg_ff",Pextdeg_ff,0}, |
{"extdeg_ff",Pextdeg_ff,0}, |
{"characteristic_ff",Pcharacteristic_ff,0}, |
{"characteristic_ff",Pcharacteristic_ff,0}, |
Line 155 struct ftab poly_tab[] = { |
|
Line 155 struct ftab poly_tab[] = { |
|
{"sf_find_root",Psf_find_root,1}, |
{"sf_find_root",Psf_find_root,1}, |
{"sf_minipoly",Psf_minipoly,2}, |
{"sf_minipoly",Psf_minipoly,2}, |
{"sf_embed",Psf_embed,3}, |
{"sf_embed",Psf_embed,3}, |
|
{"sf_log",Psf_log,1}, |
|
|
{"ptosfp",Pptosfp,1}, |
{"ptosfp",Pptosfp,1}, |
{"sfptop",Psfptop,1}, |
{"sfptop",Psfptop,1}, |
{"ptogf2n",Pptogf2n,1}, |
{"ptogf2n",Pptogf2n,1}, |
|
|
N n; |
N n; |
UP up; |
UP up; |
UP2 up2; |
UP2 up2; |
|
UM dp; |
Q q,r; |
Q q,r; |
P p; |
P p,p1,y; |
NODE n0,n1; |
NODE n0,n1; |
LIST list; |
LIST list; |
|
|
|
|
setmod_lm(NM((Q)mod)); |
setmod_lm(NM((Q)mod)); |
setmod_gfpn((P)defpoly); |
setmod_gfpn((P)defpoly); |
} |
} |
|
} else if ( ac == 3 ) { |
|
/* finite extension of a small finite field */ |
|
current_ff = FF_GFS; |
|
setmod_sf(QTOS((Q)ARG0(arg)),QTOS((Q)ARG1(arg))); |
|
d = QTOS((Q)ARG2(arg)); |
|
generate_defpoly_sfum(d,&dp); |
|
setmod_gfsn(dp); |
|
current_ff = FF_GFSN; |
} |
} |
switch ( current_ff ) { |
switch ( current_ff ) { |
case FF_GFP: |
case FF_GFP: |
|
|
MKLIST(list,n0); |
MKLIST(list,n0); |
*rp = (Obj)list; break; |
*rp = (Obj)list; break; |
case FF_GFS: |
case FF_GFS: |
|
case FF_GFSN: |
STOQ(current_gfs_p,q); |
STOQ(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); |
n0 = mknode(3,q,current_gfs_ext,p); |
else { |
} else { |
|
if ( current_gfs_p == 2 ) |
if ( current_gfs_p == 2 ) |
r = ONE; |
r = ONE; |
else |
else |
STOQ(current_gfs_iton[1],r); |
STOQ(current_gfs_iton[1],r); |
n0 = mknode(3,q,current_gfs_ext,r); |
p = (P)r; |
} |
} |
|
switch ( current_ff ) { |
|
case FF_GFS: |
|
n0 = mknode(3,q,current_gfs_ext,p); |
|
break; |
|
case FF_GFSN: |
|
getmod_gfsn(&dp); |
|
makevar("y",&y); |
|
sfumtop(VR(y),dp,&p1); |
|
n0 = mknode(4,q,current_gfs_ext,p,p1); |
|
break; |
|
} |
MKLIST(list,n0); |
MKLIST(list,n0); |
*rp = (Obj)list; break; |
*rp = (Obj)list; break; |
default: |
default: |
|
|
int d; |
int d; |
UP2 up2; |
UP2 up2; |
UP up; |
UP up; |
|
UM dp; |
|
|
switch ( current_ff ) { |
switch ( current_ff ) { |
case FF_GFP: |
case FF_GFP: |
|
|
else |
else |
*rp = DEG(DC(current_gfs_ext)); |
*rp = DEG(DC(current_gfs_ext)); |
break; |
break; |
|
case FF_GFSN: |
|
getmod_gfsn(&dp); |
|
STOQ(DEG(dp),*rp); |
|
break; |
default: |
default: |
error("extdeg_ff : current_ff is not set"); |
error("extdeg_ff : current_ff is not set"); |
} |
} |
|
|
case FF_GF2N: |
case FF_GF2N: |
STOQ(2,*rp); break; |
STOQ(2,*rp); break; |
case FF_GFS: |
case FF_GFS: |
|
case FF_GFSN: |
STOQ(current_gfs_p,*rp); break; |
STOQ(current_gfs_p,*rp); break; |
default: |
default: |
error("characteristic_ff : current_ff is not set"); |
error("characteristic_ff : current_ff is not set"); |
|
|
{ |
{ |
UP2 up2; |
UP2 up2; |
UP up; |
UP up; |
|
UM dp; |
N m; |
N m; |
int d,w; |
int d,w; |
|
|
|
|
break; |
break; |
case FF_GFPN: |
case FF_GFPN: |
getmod_lm(&m); |
getmod_lm(&m); |
getmod_gfpn(&up); pwrn(m,up->d,order); break; |
getmod_gfpn(&up); pwrn(m,up->d,order); |
|
break; |
case FF_GFS: |
case FF_GFS: |
STON(current_gfs_q,*order); break; |
STON(current_gfs_q,*order); break; |
|
case FF_GFSN: |
|
STON(current_gfs_q,m); |
|
getmod_gfsn(&dp); pwrn(m,DEG(dp),order); |
|
break; |
default: |
default: |
error("field_order_ff : current_ff is not set"); |
error("field_order_ff : current_ff is not set"); |
} |
} |
|
|
GF2N g; |
GF2N g; |
GFPN p; |
GFPN p; |
GFS s; |
GFS s; |
|
GFSN spn; |
|
|
switch ( current_ff ) { |
switch ( current_ff ) { |
case FF_GFP: |
case FF_GFP: |
|
|
randomgfpn(&p); *rp = (Obj)p; break; |
randomgfpn(&p); *rp = (Obj)p; break; |
case FF_GFS: |
case FF_GFS: |
randomgfs(&s); *rp = (Obj)s; break; |
randomgfs(&s); *rp = (Obj)s; break; |
|
case FF_GFSN: |
|
randomgfsn(&spn); *rp = (Obj)spn; break; |
default: |
default: |
error("random_ff : current_ff is not set"); |
error("random_ff : current_ff is not set"); |
} |
} |
|
|
GF2N rg,sg; |
GF2N rg,sg; |
GFPN rpn,spn; |
GFPN rpn,spn; |
GFS rs; |
GFS rs; |
|
GFSN rspn,sspn; |
P t; |
P t; |
Obj obj; |
Obj obj; |
|
|
|
|
*rp = (Obj)rs; |
*rp = (Obj)rs; |
} |
} |
break; |
break; |
|
case FF_GFSN: |
|
ntogfsn((Obj)p,&rspn); simpgfsn((GFSN)rspn,&sspn); |
|
*rp = (Obj)sspn; |
|
break; |
default: |
default: |
*rp = (Obj)p; |
*rp = (Obj)p; |
break; |
break; |
|
|
sf_embed((P)ARG0(arg),k,pm,rp); |
sf_embed((P)ARG0(arg),k,pm,rp); |
} |
} |
|
|
|
void Psf_log(arg,rp) |
|
NODE arg; |
|
Q *rp; |
|
{ |
|
int k; |
|
|
|
if ( !ARG0(arg) ) |
|
error("sf_log : invalid armument"); |
|
k = CONT((GFS)ARG0(arg)); |
|
STOQ(k,*rp); |
|
} |
|
|
void Psf_find_root(arg,rp) |
void Psf_find_root(arg,rp) |
NODE arg; |
NODE arg; |
GFS *rp; |
GFS *rp; |
|
|
powermodup_gf2n(p1,&p2); break; |
powermodup_gf2n(p1,&p2); break; |
case FF_GFPN: |
case FF_GFPN: |
case FF_GFS: |
case FF_GFS: |
|
case FF_GFSN: |
powermodup(p1,&p2); break; |
powermodup(p1,&p2); break; |
default: |
default: |
error("pwrmod_ff : current_ff is not set"); |
error("pwrmod_ff : current_ff is not set"); |
|
|
generic_powermodup_gf2n(g,f,(Q)ARG2(arg),&r); break; |
generic_powermodup_gf2n(g,f,(Q)ARG2(arg),&r); break; |
case FF_GFPN: |
case FF_GFPN: |
case FF_GFS: |
case FF_GFS: |
|
case FF_GFSN: |
generic_powermodup(g,f,(Q)ARG2(arg),&r); break; |
generic_powermodup(g,f,(Q)ARG2(arg),&r); break; |
default: |
default: |
error("generic_pwrmod_ff : current_ff is not set"); |
error("generic_pwrmod_ff : current_ff is not set"); |
|
|
powertabup_gf2n(f,xp,tab); break; |
powertabup_gf2n(f,xp,tab); break; |
case FF_GFPN: |
case FF_GFPN: |
case FF_GFS: |
case FF_GFS: |
|
case FF_GFSN: |
powertabup(f,xp,tab); break; |
powertabup(f,xp,tab); break; |
default: |
default: |
error("pwrtab_ff : current_ff is not set"); |
error("pwrtab_ff : current_ff is not set"); |