version 1.5, 2000/08/22 05:03:59 |
version 1.8, 2001/03/29 09:49:56 |
|
|
* 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.4 2000/08/21 08:31:21 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/builtin/poly.c,v 1.7 2001/03/14 06:04:52 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "parse.h" |
#include "parse.h" |
Line 63 void Pp_mag(),Pmaxblen(); |
|
Line 63 void Pp_mag(),Pmaxblen(); |
|
void Pmergelist(), Pch_mv(), Pre_mv(), Pdeglist(); |
void Pmergelist(), Pch_mv(), Pre_mv(), Pdeglist(); |
void Pptomp(),Pmptop(); |
void Pptomp(),Pmptop(); |
void Pptolmp(),Plmptop(); |
void Pptolmp(),Plmptop(); |
|
void Psfptop(); |
void Pptogf2n(),Pgf2ntop(),Pgf2ntovect(); |
void Pptogf2n(),Pgf2ntop(),Pgf2ntovect(); |
void Pptogfpn(),Pgfpntop(); |
void Pptogfpn(),Pgfpntop(); |
void Pfind_root_gf2n(); |
void Pfind_root_gf2n(); |
Line 143 struct ftab poly_tab[] = { |
|
Line 144 struct ftab poly_tab[] = { |
|
{"ptolmp",Pptolmp,1}, |
{"ptolmp",Pptolmp,1}, |
{"lmptop",Plmptop,1}, |
{"lmptop",Plmptop,1}, |
|
|
|
{"sfptop",Psfptop,1}, |
|
|
{"ptogf2n",Pptogf2n,1}, |
{"ptogf2n",Pptogf2n,1}, |
{"gf2ntop",Pgf2ntop,-2}, |
{"gf2ntop",Pgf2ntop,-2}, |
{"gf2ntovect",Pgf2ntovect,1}, |
{"gf2ntovect",Pgf2ntovect,1}, |
|
|
STOQ(ret,*rp); |
STOQ(ret,*rp); |
} |
} |
|
|
|
extern P current_gfs_ext; |
|
extern int current_gfs_p; |
|
extern int current_gfs_q; |
|
extern int current_gfs_q1; |
|
extern int *current_gfs_plus1; |
|
extern int *current_gfs_ntoi; |
|
extern int *current_gfs_iton; |
|
|
void Psetmod_ff(arg,rp) |
void Psetmod_ff(arg,rp) |
NODE arg; |
NODE arg; |
Obj *rp; |
Obj *rp; |
{ |
{ |
int ac; |
int ac; |
|
int d; |
Obj mod,defpoly; |
Obj mod,defpoly; |
N n; |
N n; |
UP up; |
UP up; |
UP2 up2; |
UP2 up2; |
Q q; |
Q q,r; |
P p; |
P p; |
NODE n0,n1; |
NODE n0,n1; |
LIST list; |
LIST list; |
|
|
switch ( OID(mod) ) { |
switch ( OID(mod) ) { |
case O_N: |
case O_N: |
current_ff = FF_GFP; |
current_ff = FF_GFP; |
setmod_lm(NM((Q)mod)); break; |
setmod_lm(NM((Q)mod)); |
|
break; |
case O_P: |
case O_P: |
current_ff = FF_GF2N; |
current_ff = FF_GF2N; |
setmod_gf2n((P)mod); break; |
setmod_gf2n((P)mod); break; |
|
|
error("setmod_ff : invalid argument"); |
error("setmod_ff : invalid argument"); |
} |
} |
} else if ( ac == 2 ) { |
} else if ( ac == 2 ) { |
current_ff = FF_GFPN; |
if ( OID(ARG0(arg)) == O_N ) { |
defpoly = (Obj)ARG0(arg); |
/* small finite field; primitive root representation */ |
mod = (Obj)ARG1(arg); |
current_ff = FF_GFS; |
if ( !mod || !defpoly ) |
setmod_sf(QTOS((Q)ARG0(arg)),QTOS((Q)ARG1(arg))); |
error("setmod_ff : invalid argument"); |
} else { |
setmod_lm(NM((Q)mod)); |
mod = (Obj)ARG1(arg); |
setmod_gfpn((P)defpoly); |
current_ff = FF_GFPN; |
|
defpoly = (Obj)ARG0(arg); |
|
if ( !mod || !defpoly ) |
|
error("setmod_ff : invalid argument"); |
|
setmod_lm(NM((Q)mod)); |
|
setmod_gfpn((P)defpoly); |
|
} |
} |
} |
switch ( current_ff ) { |
switch ( current_ff ) { |
case FF_GFP: |
case FF_GFP: |
|
|
MKNODE(n1,q,0); MKNODE(n0,p,n1); |
MKNODE(n1,q,0); MKNODE(n0,p,n1); |
MKLIST(list,n0); |
MKLIST(list,n0); |
*rp = (Obj)list; break; |
*rp = (Obj)list; break; |
|
case FF_GFS: |
|
STOQ(current_gfs_p,q); |
|
if ( current_gfs_ext ) { |
|
enc_to_p(current_gfs_p,current_gfs_iton[1], |
|
VR(current_gfs_ext),&p); |
|
n0 = mknode(3,q,current_gfs_ext,p); |
|
} else { |
|
STOQ(current_gfs_iton[1],r); |
|
n0 = mknode(3,q,current_gfs_ext,r); |
|
} |
|
MKLIST(list,n0); |
|
*rp = (Obj)list; break; |
default: |
default: |
*rp = 0; break; |
*rp = 0; break; |
} |
} |
|
|
LM l; |
LM l; |
GF2N g; |
GF2N g; |
GFPN p; |
GFPN p; |
|
GFS s; |
|
|
switch ( current_ff ) { |
switch ( current_ff ) { |
case FF_GFP: |
case FF_GFP: |
|
|
randomgf2n(&g); *rp = (Obj)g; break; |
randomgf2n(&g); *rp = (Obj)g; break; |
case FF_GFPN: |
case FF_GFPN: |
randomgfpn(&p); *rp = (Obj)p; break; |
randomgfpn(&p); *rp = (Obj)p; break; |
|
case FF_GFS: |
|
randomgfs(&s); *rp = (Obj)s; break; |
default: |
default: |
error("random_ff : current_ff is not set"); |
error("random_ff : current_ff is not set"); |
} |
} |
|
|
DCP dc,dcr0,dcr; |
DCP dc,dcr0,dcr; |
GF2N rg,sg; |
GF2N rg,sg; |
GFPN rpn,spn; |
GFPN rpn,spn; |
|
GFS rs; |
P t; |
P t; |
Obj obj; |
Obj obj; |
|
|
|
|
case FF_GFPN: |
case FF_GFPN: |
ntogfpn((Obj)p,&rpn); simpgfpn((GFPN)rpn,&spn); *rp = (Obj)spn; |
ntogfpn((Obj)p,&rpn); simpgfpn((GFPN)rpn,&spn); *rp = (Obj)spn; |
break; |
break; |
|
case FF_GFS: |
|
if ( NID((Num)p) == N_GFS ) |
|
*rp = p; |
|
else { |
|
ptomp(current_gfs_p,(P)p,&t); mqtogfs(t,&rs); |
|
*rp = (Obj)rs; |
|
} |
|
break; |
default: |
default: |
*rp = (Obj)p; |
*rp = (Obj)p; |
break; |
break; |
|
|
P *rp; |
P *rp; |
{ |
{ |
lmptop((P)ARG0(arg),rp); |
lmptop((P)ARG0(arg),rp); |
|
} |
|
|
|
void Psfptop(arg,rp) |
|
NODE arg; |
|
P *rp; |
|
{ |
|
sfptop((P)ARG0(arg),rp); |
} |
} |
|
|
void Pptogf2n(arg,rp) |
void Pptogf2n(arg,rp) |