version 1.10, 2005/01/23 14:03:47 |
version 1.15, 2017/08/31 02:36:20 |
|
|
* 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/algnum.c,v 1.9 2004/12/06 09:29:34 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/builtin/algnum.c,v 1.14 2013/11/17 17:34:59 ohara Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "parse.h" |
#include "parse.h" |
Line 55 void Palg(), Palgv(), Pgetalgtree(); |
|
Line 55 void Palg(), Palgv(), Pgetalgtree(); |
|
void Pinvalg_le(); |
void Pinvalg_le(); |
void Pset_field(),Palgtodalg(),Pdalgtoalg(); |
void Pset_field(),Palgtodalg(),Pdalgtoalg(); |
void Pinv_or_split_dalg(); |
void Pinv_or_split_dalg(); |
|
void Pdalgtoup(); |
|
void Pget_field_defpoly(); |
|
void Pget_field_generator(); |
|
|
void mkalg(P,Alg *); |
void mkalg(P,Alg *); |
int cmpalgp(P,P); |
int cmpalgp(P,P); |
Line 64 void rattoalg(Obj,Alg *); |
|
Line 67 void rattoalg(Obj,Alg *); |
|
void ptoalgp(P,P *); |
void ptoalgp(P,P *); |
void clctalg(P,VL *); |
void clctalg(P,VL *); |
void get_algtree(Obj f,VL *r); |
void get_algtree(Obj f,VL *r); |
|
void Pinvalg_chrem(); |
|
void Pdalgtodp(); |
|
void Pdptodalg(); |
|
|
struct ftab alg_tab[] = { |
struct ftab alg_tab[] = { |
{"set_field",Pset_field,1}, |
{"set_field",Pset_field,-3}, |
|
{"get_field_defpoly",Pget_field_defpoly,1}, |
|
{"get_field_generator",Pget_field_generator,1}, |
{"algtodalg",Palgtodalg,1}, |
{"algtodalg",Palgtodalg,1}, |
{"dalgtoalg",Pdalgtoalg,1}, |
{"dalgtoalg",Pdalgtoalg,1}, |
|
{"dalgtodp",Pdalgtodp,1}, |
|
{"dalgtoup",Pdalgtoup,1}, |
|
{"dptodalg",Pdptodalg,1}, |
{"inv_or_split_dalg",Pinv_or_split_dalg,1}, |
{"inv_or_split_dalg",Pinv_or_split_dalg,1}, |
|
{"invalg_chrem",Pinvalg_chrem,2}, |
{"invalg_le",Pinvalg_le,1}, |
{"invalg_le",Pinvalg_le,1}, |
{"defpoly",Pdefpoly,1}, |
{"defpoly",Pdefpoly,1}, |
{"newalg",Pnewalg,1}, |
{"newalg",Pnewalg,1}, |
Line 87 static int UCN,ACNT; |
|
Line 99 static int UCN,ACNT; |
|
|
|
void Pset_field(NODE arg,Q *rp) |
void Pset_field(NODE arg,Q *rp) |
{ |
{ |
setfield_dalg(BDY((LIST)ARG0(arg))); |
int ac; |
|
NODE a0,a1; |
|
VL vl0,vl; |
|
struct order_spec *spec; |
|
|
|
if ( (ac = argc(arg)) == 1 ) |
|
setfield_dalg(BDY((LIST)ARG0(arg))); |
|
else if ( ac == 3 ) { |
|
a0 = BDY((LIST)ARG0(arg)); |
|
a1 = BDY((LIST)ARG1(arg)); |
|
for ( vl0 = 0; a1; a1 = NEXT(a1) ) { |
|
NEXTVL(vl0,vl); |
|
vl->v = VR((P)BDY(a1)); |
|
} |
|
if ( vl0 ) NEXT(vl) = 0; |
|
create_order_spec(0,ARG2(arg),&spec); |
|
setfield_gb(a0,vl0,spec); |
|
} |
*rp = 0; |
*rp = 0; |
} |
} |
|
|
Line 101 void Pdalgtoalg(NODE arg,Alg *rp) |
|
Line 130 void Pdalgtoalg(NODE arg,Alg *rp) |
|
dalgtoalg((DAlg)ARG0(arg),rp); |
dalgtoalg((DAlg)ARG0(arg),rp); |
} |
} |
|
|
|
void Pdalgtodp(NODE arg,LIST *r) |
|
{ |
|
NODE b; |
|
DP nm; |
|
Q dn; |
|
DAlg da; |
|
|
|
da = (DAlg)ARG0(arg); |
|
nm = da->nm; |
|
dn = da->dn; |
|
b = mknode(2,nm,dn); |
|
MKLIST(*r,b); |
|
} |
|
|
|
void Pdptodalg(NODE arg,DAlg *r) |
|
{ |
|
DP d,nm,nm1; |
|
MP m; |
|
Q c,a; |
|
DAlg t; |
|
|
|
d = (DP)ARG0(arg); |
|
if ( !d ) *r = 0; |
|
else { |
|
for ( m = BDY(d); m; m = NEXT(m) ) |
|
if ( !INT((Q)m->c) ) break; |
|
if ( !m ) { |
|
MKDAlg(d,(Q)ONE,t); |
|
} else { |
|
dp_ptozp(d,&nm); |
|
divq((Q)BDY(d)->c,(Q)BDY(nm)->c,&c); |
|
NTOQ(NM(c),SGN(c),a); |
|
muldc(CO,nm,(Obj)a,&nm1); |
|
NTOQ(DN(c),1,a); |
|
MKDAlg(nm1,a,t); |
|
} |
|
simpdalg(t,r); |
|
} |
|
} |
|
|
|
void Pdalgtoup(NODE arg,LIST *r) |
|
{ |
|
NODE b; |
|
int pos; |
|
P up; |
|
DP nm; |
|
Q dn,q; |
|
|
|
pos = dalgtoup((DAlg)ARG0(arg),&up,&dn); |
|
STOQ(pos,q); |
|
b = mknode(3,up,dn,q); |
|
MKLIST(*r,b); |
|
} |
|
|
NODE inv_or_split_dalg(DAlg,DAlg *); |
NODE inv_or_split_dalg(DAlg,DAlg *); |
NumberField get_numberfield(); |
NumberField get_numberfield(); |
|
|
|
void Pget_field_defpoly(NODE arg,DAlg *r) |
|
{ |
|
NumberField nf; |
|
DP d; |
|
|
|
nf = get_numberfield(); |
|
d = nf->ps[QTOS((Q)ARG0(arg))]; |
|
MKDAlg(d,ONE,*r); |
|
} |
|
|
|
void Pget_field_generator(NODE arg,DAlg *r) |
|
{ |
|
int index,n,i; |
|
DL dl; |
|
MP m; |
|
DP d; |
|
|
|
index = QTOS((Q)ARG0(arg)); |
|
n = get_numberfield()->n; |
|
NEWDL(dl,n); |
|
for ( i = 0; i < n; i++ ) dl->d[i] = 0; |
|
dl->d[index] = 1; dl->td = 1; |
|
NEWMP(m); m->dl = dl; m->c = (Obj)ONE; NEXT(m) = 0; |
|
MKDP(n,m,d); |
|
MKDAlg(d,ONE,*r); |
|
} |
|
|
|
|
void Pinv_or_split_dalg(NODE arg,Obj *rp) |
void Pinv_or_split_dalg(NODE arg,Obj *rp) |
{ |
{ |
NODE gen,t,nd0,nd; |
NODE gen,t,nd0,nd; |
LIST list; |
LIST list; |
int l,i,j,k,n; |
int l,i,j,n; |
DP *ps,*ps1,*psw; |
DP *ps,*ps1,*psw; |
NumberField nf; |
NumberField nf; |
DAlg inv; |
DAlg inv; |
Line 144 void Pinv_or_split_dalg(NODE arg,Obj *rp) |
|
Line 255 void Pinv_or_split_dalg(NODE arg,Obj *rp) |
|
for ( ; i >= 0; i-- ) { |
for ( ; i >= 0; i-- ) { |
NEXTNODE(nd0,nd); BDY(nd) = (pointer)psw[i]; |
NEXTNODE(nd0,nd); BDY(nd) = (pointer)psw[i]; |
} |
} |
for ( ; t; t = NEXT(t), k++ ) { |
for ( ; t; t = NEXT(t) ) { |
NEXTNODE(nd0,nd); BDY(nd) = BDY(t); |
NEXTNODE(nd0,nd); BDY(nd) = BDY(t); |
} |
} |
NEXT(nd) = 0; |
NEXT(nd) = 0; |
|
|
} |
} |
} |
} |
|
|
|
void Pinvalg_chrem(NODE arg,LIST *r) |
|
{ |
|
NODE n; |
|
|
|
inva_chrem((P)ARG0(arg),(P)ARG1(arg),&n); |
|
MKLIST(*r,n); |
|
} |
|
|
void invalg_le(Alg a,LIST *r); |
void invalg_le(Alg a,LIST *r); |
|
|
void Pinvalg_le(NODE arg,LIST *r) |
void Pinvalg_le(NODE arg,LIST *r) |
Line 623 void invalg_le(Alg a,LIST *r) |
|
Line 742 void invalg_le(Alg a,LIST *r) |
|
for ( i = 0, t = rev0, mp0 = 0; i < len; i++, t = NEXT(t) ) |
for ( i = 0, t = rev0, mp0 = 0; i < len; i++, t = NEXT(t) ) |
if ( solmat[i][0] ) { |
if ( solmat[i][0] ) { |
NEXTMP(mp0,mp); |
NEXTMP(mp0,mp); |
mp->c = (P)solmat[i][0]; |
mp->c = (Obj)solmat[i][0]; |
mp->dl = BDY((DP)BDY(t))->dl; |
mp->dl = BDY((DP)BDY(t))->dl; |
} |
} |
NEXT(mp) = 0; MKDP(n,mp0,u); |
NEXT(mp) = 0; MKDP(n,mp0,u); |
dp_ptozp(u,&u1); |
dp_ptozp(u,&u1); |
divq((Q)BDY(u)->c,(Q)BDY(u1)->c,&cont); |
divq((Q)BDY(u)->c,(Q)BDY(u1)->c,&cont); |
dtop(ALG,vl,u1,&ap); |
dtop(ALG,vl,u1,(Obj *)&ap); |
MKAlg(ap,inv); |
MKAlg(ap,inv); |
mulq(dnsol,(Q)dn,&c1); |
mulq(dnsol,(Q)dn,&c1); |
mulq(c1,c,&c2); |
mulq(c1,c,&c2); |