version 1.17, 2002/09/27 04:42:59 |
version 1.22, 2011/03/30 02:43:18 |
|
|
* 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.16 2001/10/09 01:36:06 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/builtin/poly.c,v 1.21 2003/06/24 09:49:35 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "parse.h" |
#include "parse.h" |
|
|
|
|
void Pranp(); |
void Pranp(); |
|
|
|
void Pheadsgn(); |
|
void Pmul_trunc(),Pquo_trunc(); |
void Pumul(),Pumul_ff(),Pusquare(),Pusquare_ff(),Putmul(),Putmul_ff(); |
void Pumul(),Pumul_ff(),Pusquare(),Pusquare_ff(),Putmul(),Putmul_ff(); |
void Pkmul(),Pksquare(),Pktmul(); |
void Pkmul(),Pksquare(),Pktmul(); |
void Pord(), Pcoef0(), Pcoef(), Pdeg(), Pmindeg(), Psetmod(); |
void Pord(), Premove_vars(), Pcoef0(), Pcoef(), Pdeg(), Pmindeg(), Psetmod(); |
void Pcoef_gf2n(); |
void Pcoef_gf2n(); |
void getcoef(), getdeglist(), mergedeglist(), change_mvar(), restore_mvar(); |
void getcoef(), getdeglist(), mergedeglist(), change_mvar(), restore_mvar(); |
|
|
Line 64 void Pmergelist(), Pch_mv(), Pre_mv(), Pdeglist(); |
|
Line 66 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(),Psf_log(); |
void Psf_minipoly(),Psf_log(),Psfptopsfp(); |
void Pptogf2n(),Pgf2ntop(),Pgf2ntovect(); |
void Pptogf2n(),Pgf2ntop(),Pgf2ntovect(); |
void Pptogfpn(),Pgfpntop(); |
void Pptogfpn(),Pgfpntop(); |
void Pfind_root_gf2n(); |
void Pfind_root_gf2n(); |
Line 111 void field_order_ff(N *); |
|
Line 113 void field_order_ff(N *); |
|
int current_ff; |
int current_ff; |
|
|
struct ftab poly_tab[] = { |
struct ftab poly_tab[] = { |
|
{"headsgn",Pheadsgn,1}, |
|
{"quo_trunc",Pquo_trunc,2}, |
|
{"mul_trunc",Pmul_trunc,3}, |
{"homogeneous_deg",Phomogeneous_deg,-2}, |
{"homogeneous_deg",Phomogeneous_deg,-2}, |
{"homogeneous_part",Phomogeneous_part,-3}, |
{"homogeneous_part",Phomogeneous_part,-3}, |
{"reorder",Preorder,3}, |
{"reorder",Preorder,3}, |
Line 119 struct ftab poly_tab[] = { |
|
Line 124 struct ftab poly_tab[] = { |
|
{"p_mag",Pp_mag,1}, |
{"p_mag",Pp_mag,1}, |
{"maxblen",Pmaxblen,1}, |
{"maxblen",Pmaxblen,1}, |
{"ord",Pord,-1}, |
{"ord",Pord,-1}, |
|
{"remove_vars",Premove_vars,1}, |
{"coef0",Pcoef0,-3}, |
{"coef0",Pcoef0,-3}, |
{"coef",Pcoef,-3}, |
{"coef",Pcoef,-3}, |
{"coef_gf2n",Pcoef_gf2n,2}, |
{"coef_gf2n",Pcoef_gf2n,2}, |
Line 155 struct ftab poly_tab[] = { |
|
Line 161 struct ftab poly_tab[] = { |
|
|
|
{"ptosfp",Pptosfp,1}, |
{"ptosfp",Pptosfp,1}, |
{"sfptop",Psfptop,1}, |
{"sfptop",Psfptop,1}, |
|
{"sfptopsfp",Psfptopsfp,2}, |
{"ptogf2n",Pptogf2n,1}, |
{"ptogf2n",Pptogf2n,1}, |
{"gf2ntop",Pgf2ntop,-2}, |
{"gf2ntop",Pgf2ntop,-2}, |
{"gf2ntovect",Pgf2ntovect,1}, |
{"gf2ntovect",Pgf2ntovect,1}, |
Line 222 struct ftab poly_tab[] = { |
|
Line 229 struct ftab poly_tab[] = { |
|
{0,0,0}, |
{0,0,0}, |
}; |
}; |
|
|
|
void Pheadsgn(NODE arg,Q *rp) |
|
{ |
|
int s; |
|
|
|
s = headsgn((P)ARG0(arg)); |
|
STOQ(s,*rp); |
|
} |
|
|
|
void Pmul_trunc(NODE arg,P *rp) |
|
{ |
|
P p1,p2,p,h; |
|
VL vl0,vl1,vl2,tvl,vl; |
|
VN vn; |
|
int i,n; |
|
|
|
p1 = (P)ARG0(arg); |
|
p2 = (P)ARG1(arg); |
|
get_vars((Obj)p1,&vl1); get_vars((Obj)p2,&vl2); mergev(CO,vl1,vl2,&tvl); |
|
p = (P)ARG2(arg); |
|
get_vars((Obj)p,&vl0); mergev(CO,tvl,vl0,&vl); |
|
for ( tvl = vl, n = 0; tvl; tvl = NEXT(tvl), n++ ); |
|
vn = (VN) ALLOCA((n+1)*sizeof(struct oVN)); |
|
for ( i = 0, tvl = vl; i < n; tvl = NEXT(tvl), i++ ) { |
|
vn[i].v = tvl->v; |
|
vn[i].n = 0; |
|
} |
|
vn[i].v = 0; |
|
vn[i].n = 0; |
|
for ( h = p, i = 0; OID(h) == O_P; h = COEF(DC(h)) ) { |
|
for ( ; vn[i].v != VR(h); i++ ); |
|
vn[i].n = QTOS(DEG(DC(h))); |
|
} |
|
mulp_trunc(vl,p1,p2,vn,rp); |
|
} |
|
|
|
void Pquo_trunc(NODE arg,P *rp) |
|
{ |
|
P p1,p2,p,h; |
|
VL vl0,vl1,vl2,tvl,vl; |
|
VN vn; |
|
int i,n; |
|
|
|
p1 = (P)ARG0(arg); |
|
p2 = (P)ARG1(arg); |
|
if ( !p1 ) |
|
*rp = 0; |
|
else if ( NUM(p2) ) |
|
divsp(CO,p1,p2,rp); |
|
else { |
|
get_vars((Obj)p1,&vl1); get_vars((Obj)p2,&vl2); mergev(CO,vl1,vl2,&vl); |
|
for ( tvl = vl, n = 0; tvl; tvl = NEXT(tvl), n++ ); |
|
vn = (VN) ALLOCA((n+1)*sizeof(struct oVN)); |
|
for ( i = 0, tvl = vl; i < n; tvl = NEXT(tvl), i++ ) { |
|
vn[i].v = tvl->v; |
|
vn[i].n = 0; |
|
} |
|
vn[i].v = 0; |
|
vn[i].n = 0; |
|
for ( h = p2, i = 0; OID(h) == O_P; h = COEF(DC(h)) ) { |
|
for ( ; vn[i].v != VR(h); i++ ); |
|
vn[i].n = QTOS(DEG(DC(h))); |
|
} |
|
quop_trunc(vl,p1,p2,vn,rp); |
|
} |
|
} |
|
|
void Phomogeneous_part(NODE arg,P *rp) |
void Phomogeneous_part(NODE arg,P *rp) |
{ |
{ |
if ( argc(arg) == 2 ) |
if ( argc(arg) == 2 ) |
Line 420 void Pord(NODE arg,LIST *listp) |
|
Line 493 void Pord(NODE arg,LIST *listp) |
|
NEXT(tn) = 0; MKLIST(l,n); *listp = l; |
NEXT(tn) = 0; MKLIST(l,n); *listp = l; |
} |
} |
|
|
|
void Premove_vars(NODE arg,LIST *listp) |
|
{ |
|
NODE l,nd,tnd; |
|
V *v,*va; |
|
int n,na,i,j; |
|
VL vl,vl1; |
|
P t; |
|
LIST list; |
|
|
|
asir_assert(ARG0(arg),O_LIST,"remove_vars"); |
|
l = BDY((LIST)ARG0(arg)); n = length(l); |
|
v = (V *)ALLOCA(n*sizeof(V)); |
|
for ( i = 0; i < n; i++, l = NEXT(l) ) |
|
if ( !(t = (P)BDY(l)) || (OID(t) != O_P) ) |
|
error("ord : invalid argument"); |
|
else v[i] = VR(t); |
|
|
|
for ( na = 0, vl = CO; vl; vl = NEXT(vl), na++ ); |
|
va = (V *)ALLOCA(na*sizeof(V)); |
|
for ( i = 0, vl = CO; i < na; i++, vl = NEXT(vl) ) va[i] = VR(vl); |
|
for ( i = 0; i < na; i++ ) |
|
for ( j = 0; j < n; j++ ) if ( va[i] == v[j] ) va[i] = 0; |
|
for ( vl = 0, i = na-1; i >= 0; i-- ) |
|
if ( va[i] ) { |
|
NEWVL(vl1); VR(vl1) = va[i]; NEXT(vl1) = vl; vl = vl1; |
|
} |
|
CO = vl; |
|
for ( nd = 0, vl = CO; vl; vl = NEXT(vl) ) { |
|
NEXTNODE(nd,tnd); MKV(VR(vl),t); BDY(tnd) = (pointer)t; |
|
} |
|
if ( nd ) NEXT(tnd) = 0; |
|
MKLIST(list,nd); *listp = list; |
|
} |
|
|
void Pcoef0(NODE arg,Obj *rp) |
void Pcoef0(NODE arg,Obj *rp) |
{ |
{ |
Obj t,n; |
Obj t,n; |
Line 1100 void Pptosfp(NODE arg,P *rp) |
|
Line 1207 void Pptosfp(NODE arg,P *rp) |
|
void Psfptop(NODE arg,P *rp) |
void Psfptop(NODE arg,P *rp) |
{ |
{ |
sfptop((P)ARG0(arg),rp); |
sfptop((P)ARG0(arg),rp); |
|
} |
|
|
|
void Psfptopsfp(NODE arg,P *rp) |
|
{ |
|
sfptopsfp((P)ARG0(arg),VR((P)ARG1(arg)),rp); |
} |
} |
|
|
void Pptogf2n(NODE arg,GF2N *rp) |
void Pptogf2n(NODE arg,GF2N *rp) |