=================================================================== RCS file: /home/cvs/OpenXM_contrib2/asir2000/builtin/poly.c,v retrieving revision 1.22 retrieving revision 1.26 diff -u -p -r1.22 -r1.26 --- OpenXM_contrib2/asir2000/builtin/poly.c 2011/03/30 02:43:18 1.22 +++ OpenXM_contrib2/asir2000/builtin/poly.c 2017/02/28 07:06:28 1.26 @@ -45,7 +45,7 @@ * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. * - * $OpenXM: OpenXM_contrib2/asir2000/builtin/poly.c,v 1.21 2003/06/24 09:49:35 noro Exp $ + * $OpenXM: OpenXM_contrib2/asir2000/builtin/poly.c,v 1.25 2016/03/31 05:30:32 noro Exp $ */ #include "ca.h" #include "parse.h" @@ -125,6 +125,7 @@ struct ftab poly_tab[] = { {"maxblen",Pmaxblen,1}, {"ord",Pord,-1}, {"remove_vars",Premove_vars,1}, + {"delete_vars",Premove_vars,1}, {"coef0",Pcoef0,-3}, {"coef",Pcoef,-3}, {"coef_gf2n",Pcoef_gf2n,2}, @@ -445,7 +446,10 @@ void Pp_mag(NODE arg,Q *rp) void Pord(NODE arg,LIST *listp) { - NODE n,tn; + NODE n,tn,p,opt; + char *key; + Obj value; + int overwrite=0; LIST l; VL vl,tvl,svl; P t; @@ -453,6 +457,18 @@ void Pord(NODE arg,LIST *listp) V *va; V v; + if ( current_option ) { + for ( opt = current_option; opt; opt = NEXT(opt) ) { + p = BDY((LIST)BDY(opt)); + key = BDY((STRING)BDY(p)); + value = (Obj)BDY(NEXT(p)); + if ( !strcmp(key,"overwrite") && value ) { + overwrite = value ? 1 : 0; + break; + } + } + } + if ( argc(arg) ) { asir_assert(ARG0(arg),O_LIST,"ord"); for ( vl = 0, i = 0, n = BDY((LIST)ARG0(arg)); @@ -466,22 +482,29 @@ void Pord(NODE arg,LIST *listp) error("ord : invalid argument"); VR(tvl) = VR(t); } - va = (V *)ALLOCA(i*sizeof(V)); - for ( j = 0, svl = vl; j < i; j++, svl = NEXT(svl) ) - va[j] = VR(svl); - for ( svl = CO; svl; svl = NEXT(svl) ) { - v = VR(svl); - for ( j = 0; j < i; j++ ) - if ( v == va[j] ) - break; - if ( j == i ) { - if ( !vl ) { - NEWVL(vl); tvl = vl; - } else { - NEWVL(NEXT(tvl)); tvl = NEXT(tvl); + if ( !overwrite ) { + va = (V *)ALLOCA(i*sizeof(V)); + for ( j = 0, svl = vl; j < i; j++, svl = NEXT(svl) ) + va[j] = VR(svl); + for ( svl = CO; svl; svl = NEXT(svl) ) { + v = VR(svl); + for ( j = 0; j < i; j++ ) + if ( v == va[j] ) + break; + if ( j == i ) { + if ( !vl ) { + NEWVL(vl); tvl = vl; + } else { + NEWVL(NEXT(tvl)); tvl = NEXT(tvl); + } + VR(tvl) = v; } - VR(tvl) = v; } + } else { + for ( svl = vl; svl; svl = NEXT(svl) ) { + if ( svl->v->attr == (pointer)V_PF ) + ((PFINS)svl->v->priv)->pf->ins = 0; + } } if ( vl ) NEXT(tvl) = 0; @@ -803,8 +826,9 @@ void Psetmod_ff(NODE arg,Obj *rp) if ( ac == 1 ) { mod = (Obj)ARG0(arg); if ( !mod ) - error("setmod_ff : invalid argument"); - switch ( OID(mod) ) { + current_ff = FF_NOT_SET; + else { + switch ( OID(mod) ) { case O_N: current_ff = FF_GFP; setmod_lm(NM((Q)mod)); @@ -814,7 +838,8 @@ void Psetmod_ff(NODE arg,Obj *rp) setmod_gf2n((P)mod); break; default: error("setmod_ff : invalid argument"); - } + } + } } else if ( ac == 2 ) { if ( OID(ARG0(arg)) == O_N ) { /* small finite field; primitive root representation */