version 1.21, 2003/06/24 09:49:35 |
version 1.25, 2016/03/31 05:30:32 |
|
|
* 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.20 2003/06/21 02:09:16 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/builtin/poly.c,v 1.24 2011/07/21 04:43:26 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "parse.h" |
#include "parse.h" |
|
|
void Pmul_trunc(),Pquo_trunc(); |
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 124 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}, |
|
{"delete_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 444 void Pp_mag(NODE arg,Q *rp) |
|
Line 446 void Pp_mag(NODE arg,Q *rp) |
|
|
|
void Pord(NODE arg,LIST *listp) |
void Pord(NODE arg,LIST *listp) |
{ |
{ |
NODE n,tn; |
NODE n,tn,p,opt; |
|
char *key; |
|
Obj value; |
|
int overwrite=0; |
LIST l; |
LIST l; |
VL vl,tvl,svl; |
VL vl,tvl,svl; |
P t; |
P t; |
Line 452 void Pord(NODE arg,LIST *listp) |
|
Line 457 void Pord(NODE arg,LIST *listp) |
|
V *va; |
V *va; |
V v; |
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) ) { |
if ( argc(arg) ) { |
asir_assert(ARG0(arg),O_LIST,"ord"); |
asir_assert(ARG0(arg),O_LIST,"ord"); |
for ( vl = 0, i = 0, n = BDY((LIST)ARG0(arg)); |
for ( vl = 0, i = 0, n = BDY((LIST)ARG0(arg)); |
Line 465 void Pord(NODE arg,LIST *listp) |
|
Line 482 void Pord(NODE arg,LIST *listp) |
|
error("ord : invalid argument"); |
error("ord : invalid argument"); |
VR(tvl) = VR(t); |
VR(tvl) = VR(t); |
} |
} |
va = (V *)ALLOCA(i*sizeof(V)); |
if ( !overwrite ) { |
for ( j = 0, svl = vl; j < i; j++, svl = NEXT(svl) ) |
va = (V *)ALLOCA(i*sizeof(V)); |
va[j] = VR(svl); |
for ( j = 0, svl = vl; j < i; j++, svl = NEXT(svl) ) |
for ( svl = CO; svl; svl = NEXT(svl) ) { |
va[j] = VR(svl); |
v = VR(svl); |
for ( svl = CO; svl; svl = NEXT(svl) ) { |
for ( j = 0; j < i; j++ ) |
v = VR(svl); |
if ( v == va[j] ) |
for ( j = 0; j < i; j++ ) |
break; |
if ( v == va[j] ) |
if ( j == i ) { |
break; |
if ( !vl ) { |
if ( j == i ) { |
NEWVL(vl); tvl = vl; |
if ( !vl ) { |
} else { |
NEWVL(vl); tvl = vl; |
NEWVL(NEXT(tvl)); tvl = NEXT(tvl); |
} 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 ) |
if ( vl ) |
NEXT(tvl) = 0; |
NEXT(tvl) = 0; |
Line 490 void Pord(NODE arg,LIST *listp) |
|
Line 514 void Pord(NODE arg,LIST *listp) |
|
NEXTNODE(n,tn); MKV(VR(vl),t); BDY(tn) = (pointer)t; |
NEXTNODE(n,tn); MKV(VR(vl),t); BDY(tn) = (pointer)t; |
} |
} |
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) |