version 1.4, 2019/09/04 01:12:02 |
version 1.10, 2019/11/12 12:50:40 |
|
|
* 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/asir2018/builtin/dp-supp.c,v 1.3 2019/08/21 00:37:47 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2018/builtin/dp-supp.c,v 1.9 2019/11/12 07:47:45 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "base.h" |
#include "base.h" |
Line 904 void dpm_red(DPM p0,DPM p1,DPM p2,DPM *head,DPM *rest, |
|
Line 904 void dpm_red(DPM p0,DPM p1,DPM p2,DPM *head,DPM *rest, |
|
*head = h; *rest = r; *dnp = (P)c2; |
*head = h; *rest = r; *dnp = (P)c2; |
} |
} |
|
|
|
void dpm_red2(DPM p1,DPM p2,DPM *rest,P *dnp,DP *multp) |
|
{ |
|
int i,n,pos; |
|
DL d1,d2,d; |
|
MP m; |
|
DP s,ms; |
|
DPM t,r,h,u,w; |
|
Z c,c1,c2,gn; |
|
P g,a; |
|
P p[2]; |
|
|
|
n = p1->nv; d1 = BDY(p1)->dl; d2 = BDY(p2)->dl; pos = BDY(p1)->pos; |
|
if ( pos != BDY(p2)->pos ) |
|
error("dpm_red : cannot happen"); |
|
NEWDL(d,n); d->td = d1->td - d2->td; |
|
for ( i = 0; i < n; i++ ) |
|
d->d[i] = d1->d[i]-d2->d[i]; |
|
c1 = (Z)BDY(p1)->c; c2 = (Z)BDY(p2)->c; |
|
if ( dp_fcoeffs == N_GFS ) { |
|
p[0] = (P)c1; p[1] = (P)c2; |
|
gcdsf(CO,p,2,&g); |
|
divsp(CO,(P)c1,g,&a); c1 = (Z)a; divsp(CO,(P)c2,g,&a); c2 = (Z)a; |
|
} else if ( dp_fcoeffs ) { |
|
/* do nothing */ |
|
} else if ( INT(c1) && INT(c2) ) { |
|
gcdz(c1,c2,&gn); |
|
if ( !UNIQ(gn) ) { |
|
divsz(c1,gn,&c); c1 = c; |
|
divsz(c2,gn,&c); c2 = c; |
|
} |
|
} else { |
|
ezgcdpz(CO,(P)c1,(P)c2,&g); |
|
divsp(CO,(P)c1,g,&a); c1 = (Z)a; divsp(CO,(P)c2,g,&a); c2 = (Z)a; |
|
add_denomlist(g); |
|
} |
|
NEWMP(m); m->dl = d; m->c = (Obj)c1; NEXT(m) = 0; MKDP(n,m,s); s->sugar = d->td; |
|
*multp = s; |
|
chsgnd(s,&ms); mulobjdpm(CO,(Obj)ms,p2,&u); mulobjdpm(CO,(Obj)c2,p1,&w); adddpm(CO,w,u,&r); |
|
*rest = r; *dnp = (P)c2; |
|
} |
|
|
/* |
/* |
* m-reduction by a marked poly |
* m-reduction by a marked poly |
* do content reduction over Z or Q(x,...) |
* do content reduction over Z or Q(x,...) |
Line 1204 void dp_removecont2(DP p1,DP p2,DP *r1p,DP *r2p,Z *con |
|
Line 1244 void dp_removecont2(DP p1,DP p2,DP *r1p,DP *r2p,Z *con |
|
*r2p = 0; |
*r2p = 0; |
} |
} |
|
|
|
void dpm_removecont2(DPM p1,DPM p2,DPM *r1p,DPM *r2p,Z *contp) |
|
{ |
|
struct oVECT v; |
|
int i,n1,n2,n; |
|
DMM m,m0,t; |
|
Z *w; |
|
Z h; |
|
|
|
if ( p1 ) { |
|
for ( i = 0, m = BDY(p1); m; m = NEXT(m), i++ ); |
|
n1 = i; |
|
} else |
|
n1 = 0; |
|
if ( p2 ) { |
|
for ( i = 0, m = BDY(p2); m; m = NEXT(m), i++ ); |
|
n2 = i; |
|
} else |
|
n2 = 0; |
|
n = n1+n2; |
|
if ( !n ) { |
|
*r1p = 0; *r2p = 0; *contp = ONE; return; |
|
} |
|
w = (Z *)ALLOCA(n*sizeof(Q)); |
|
v.len = n; |
|
v.body = (pointer *)w; |
|
i = 0; |
|
if ( p1 ) |
|
for ( m = BDY(p1); i < n1; m = NEXT(m), i++ ) w[i] = (Z)m->c; |
|
if ( p2 ) |
|
for ( m = BDY(p2); i < n; m = NEXT(m), i++ ) w[i] = (Z)m->c; |
|
h = w[0]; removecont_array((P *)w,n,1); divsz(h,w[0],contp); |
|
i = 0; |
|
if ( p1 ) { |
|
for ( m0 = 0, t = BDY(p1); i < n1; i++, t = NEXT(t) ) { |
|
NEXTDMM(m0,m); m->c = (Obj)w[i]; m->dl = t->dl; m->pos = t->pos; |
|
} |
|
NEXT(m) = 0; |
|
MKDPM(p1->nv,m0,*r1p); (*r1p)->sugar = p1->sugar; |
|
} else |
|
*r1p = 0; |
|
if ( p2 ) { |
|
for ( m0 = 0, t = BDY(p2); i < n; i++, t = NEXT(t) ) { |
|
NEXTDMM(m0,m); m->c = (Obj)w[i]; m->dl = t->dl; m->pos = t->pos; |
|
} |
|
NEXT(m) = 0; |
|
MKDPM(p2->nv,m0,*r2p); (*r2p)->sugar = p2->sugar; |
|
} else |
|
*r2p = 0; |
|
} |
|
|
/* true nf by a marked GB */ |
/* true nf by a marked GB */ |
|
|
void dp_true_nf_marked(NODE b,DP g,DP *ps,DP *hps,DP *rp,P *nmp,P *dnp) |
void dp_true_nf_marked(NODE b,DP g,DP *ps,DP *hps,DP *rp,P *nmp,P *dnp) |
|
|
return q; |
return q; |
} |
} |
|
|
// struct oEGT egc; |
struct oEGT egred; |
|
|
|
void mulcmp(Obj c,MP m); |
|
void mulcdmm(Obj c,DMM m); |
|
|
|
DP appendd(DP d,DP m) |
|
{ |
|
MP t; |
|
|
|
if ( !d ) return m; |
|
for ( t = BDY(d); NEXT(t); t = NEXT(t) ); |
|
NEXT(t) = BDY(m); |
|
return d; |
|
} |
|
|
|
DPM appenddpm(DPM d,DPM m) |
|
{ |
|
DMM t; |
|
|
|
if ( !d ) return m; |
|
for ( t = BDY(d); NEXT(t); t = NEXT(t) ); |
|
NEXT(t) = BDY(m); |
|
return d; |
|
} |
|
|
DP *dpm_nf_and_quotient(NODE b,DPM g,VECT psv,DPM *rp,P *dnp) |
DP *dpm_nf_and_quotient(NODE b,DPM g,VECT psv,DPM *rp,P *dnp) |
{ |
{ |
DPM u,p,d,s,t; |
DPM u,p,s,t,d; |
DP dmy,mult; |
DP dmy,mult,zzz; |
DPM *ps; |
DPM *ps; |
DP *q; |
DP *q; |
NODE l; |
NODE l; |
DMM m,mr; |
DMM m,mr; |
int i,n,j,len; |
MP mp; |
|
int i,n,j,len,nv; |
int *wb; |
int *wb; |
int sugar,psugar,multiple; |
int sugar,psugar,multiple; |
P nm,tnm1,dn,tdn,tdn1; |
P nm,tnm1,dn,tdn,tdn1; |
Line 1401 DP *dpm_nf_and_quotient(NODE b,DPM g,VECT psv,DPM *rp, |
|
Line 1515 DP *dpm_nf_and_quotient(NODE b,DPM g,VECT psv,DPM *rp, |
|
if ( !g ) { |
if ( !g ) { |
*rp = 0; *dnp = dn; return 0; |
*rp = 0; *dnp = dn; return 0; |
} |
} |
|
nv = NV(g); |
ps = (DPM *)BDY(psv); |
ps = (DPM *)BDY(psv); |
len = psv->len; |
len = psv->len; |
if ( b ) { |
if ( b ) { |
Line 1421 DP *dpm_nf_and_quotient(NODE b,DPM g,VECT psv,DPM *rp, |
|
Line 1536 DP *dpm_nf_and_quotient(NODE b,DPM g,VECT psv,DPM *rp, |
|
for ( d = 0; g; ) { |
for ( d = 0; g; ) { |
for ( u = 0, i = 0; i < n; i++ ) { |
for ( u = 0, i = 0; i < n; i++ ) { |
if ( dpm_redble(g,p = ps[wb[i]]) ) { |
if ( dpm_redble(g,p = ps[wb[i]]) ) { |
dpm_red(d,g,p,&t,&u,&tdn,&mult); |
// get_eg(&eg0); |
|
dpm_red2(g,p,&u,&tdn,&mult); |
|
// get_eg(&eg1); add_eg(&egred,&eg0,&eg1); |
psugar = (BDY(g)->dl->td - BDY(p)->dl->td) + p->sugar; |
psugar = (BDY(g)->dl->td - BDY(p)->dl->td) + p->sugar; |
sugar = MAX(sugar,psugar); |
sugar = MAX(sugar,psugar); |
// get_eg(&eg0); |
|
for ( j = 0; j < len; j++ ) { |
for ( j = 0; j < len; j++ ) { |
muldc(CO,q[j],(Obj)tdn,&dmy); q[j] = dmy; |
if ( q[j] ) { mulcmp((Obj)tdn,BDY(q[j])); } |
} |
} |
addd(CO,q[wb[i]],mult,&dmy); q[wb[i]] = dmy; |
q[wb[i]] = appendd(q[wb[i]],mult); |
// get_eg(&eg1); add_eg(&egc,&eg0,&eg1); |
|
mulp(CO,dn,tdn,&tdn1); dn = tdn1; |
mulp(CO,dn,tdn,&tdn1); dn = tdn1; |
d = t; |
if ( d ) mulcdmm((Obj)tdn,BDY(d)); |
if ( !u ) goto last; |
if ( !u ) goto last; |
break; |
break; |
} |
} |
Line 1441 DP *dpm_nf_and_quotient(NODE b,DPM g,VECT psv,DPM *rp, |
|
Line 1556 DP *dpm_nf_and_quotient(NODE b,DPM g,VECT psv,DPM *rp, |
|
} else { |
} else { |
m = BDY(g); NEWDMM(mr); mr->dl = m->dl; mr->c = m->c; mr->pos = m->pos; |
m = BDY(g); NEWDMM(mr); mr->dl = m->dl; mr->c = m->c; mr->pos = m->pos; |
NEXT(mr) = 0; MKDPM(g->nv,mr,t); t->sugar = mr->dl->td; |
NEXT(mr) = 0; MKDPM(g->nv,mr,t); t->sugar = mr->dl->td; |
adddpm(CO,d,t,&s); d = s; |
d = appenddpm(d,t); |
dpm_rest(g,&t); g = t; |
dpm_rest(g,&t); g = t; |
} |
} |
} |
} |
|
|
return q; |
return q; |
} |
} |
|
|
|
DPM dpm_nf_and_quotient2(NODE b,DPM g,VECT psv,DPM *rp,P *dnp) |
|
{ |
|
DPM u,p,s,t,d,q; |
|
DP dmy,mult,zzz; |
|
DPM *ps; |
|
NODE l; |
|
DMM mr0,mq0,mr,mq,m; |
|
MP mp; |
|
int i,n,j,len,nv; |
|
int *wb; |
|
int sugar,psugar,multiple; |
|
P nm,tnm1,dn,tdn,tdn1; |
|
Q cont; |
|
Obj c1; |
|
struct oEGT eg0,eg1; |
|
|
|
dn = (P)ONE; |
|
if ( !g ) { |
|
*rp = 0; *dnp = dn; return 0; |
|
} |
|
nv = NV(g); |
|
ps = (DPM *)BDY(psv); |
|
len = psv->len; |
|
if ( b ) { |
|
for ( n = 0, l = b; l; l = NEXT(l), n++ ) |
|
; |
|
wb = (int *)ALLOCA(n*sizeof(int)); |
|
for ( i = 0, l = b; i < n; l = NEXT(l), i++ ) |
|
wb[i] = ZTOS((Q)BDY(l)); |
|
} else { |
|
wb = (int *)ALLOCA(len*sizeof(int)); |
|
for ( i = j = 0; i < len; i++ ) |
|
if ( ps[i] ) wb[j++] = i; |
|
n = j; |
|
} |
|
sugar = g->sugar; |
|
mq0 = 0; |
|
mr0 = 0; |
|
for ( ; g; ) { |
|
for ( u = 0, i = 0; i < n; i++ ) { |
|
if ( dpm_redble(g,p = ps[wb[i]]) ) { |
|
dpm_red2(g,p,&u,&tdn,&mult); |
|
psugar = (BDY(g)->dl->td - BDY(p)->dl->td) + p->sugar; |
|
sugar = MAX(sugar,psugar); |
|
for ( m = mq0; m; m = NEXT(m) ) { |
|
arf_mul(CO,(Obj)tdn,m->c,&c1); m->c = c1; |
|
} |
|
for ( m = mr0; m; m = NEXT(m) ) { |
|
arf_mul(CO,(Obj)tdn,m->c,&c1); m->c = c1; |
|
} |
|
NEXTDMM(mq0,mq); |
|
mq->c = BDY(mult)->c; mq->dl = BDY(mult)->dl; mq->pos = wb[i]+1; |
|
mulp(CO,dn,tdn,&tdn1); dn = tdn1; |
|
if ( !u ) goto last; |
|
break; |
|
} |
|
} |
|
if ( u ) { |
|
g = u; |
|
} else { |
|
m = BDY(g); |
|
NEXTDMM(mr0,mr); |
|
mr->dl = m->dl; mr->c = m->c; mr->pos = m->pos; |
|
dpm_rest(g,&t); g = t; |
|
} |
|
} |
|
last: |
|
if ( mr0 ) { |
|
NEXT(mr) = 0; |
|
MKDPM(nv,mr0,d); d->sugar = sugar; |
|
} else |
|
d = 0; |
|
if ( mq0 ) { |
|
NEXT(mq) = 0; |
|
MKDPM(nv,mq0,q); q->sugar = sugar; |
|
} else |
|
q = 0; |
|
*rp = d; *dnp = dn; |
|
return q; |
|
} |
|
|
|
DPM dpm_nf_and_quotient3(DPM g,VECT psv,DPM *rp,P *dnp) |
|
{ |
|
DPM u,p,s,t,d,q; |
|
DP dmy,mult,zzz; |
|
DPM *ps; |
|
NODE2 nd; |
|
DMM mr0,mq0,mr,mq,m; |
|
MP mp; |
|
int i,n,j,len,nv,pos,max; |
|
int *wb; |
|
int sugar,psugar,multiple; |
|
P nm,tnm1,dn,tdn,tdn1; |
|
Q cont; |
|
Obj c1; |
|
struct oEGT eg0,eg1; |
|
|
|
dn = (P)ONE; |
|
if ( !g ) { |
|
*rp = 0; *dnp = dn; return 0; |
|
} |
|
nv = NV(g); |
|
sugar = g->sugar; |
|
mq0 = 0; |
|
mr0 = 0; |
|
max = psv->len; |
|
for ( ; g; ) { |
|
pos = BDY(g)->pos; |
|
u = 0; |
|
if ( pos < max ) { |
|
nd = (NODE2)BDY(psv)[pos]; |
|
for ( u = 0; nd; nd = NEXT(nd) ) { |
|
if ( dpm_redble(g,p = (DPM)(nd->body1)) ) { |
|
dpm_red2(g,p,&u,&tdn,&mult); |
|
psugar = (BDY(g)->dl->td - BDY(p)->dl->td) + p->sugar; |
|
sugar = MAX(sugar,psugar); |
|
if ( !UNIZ(tdn) ) { |
|
for ( m = mq0; m; m = NEXT(m) ) { |
|
arf_mul(CO,(Obj)tdn,m->c,&c1); m->c = c1; |
|
} |
|
for ( m = mr0; m; m = NEXT(m) ) { |
|
arf_mul(CO,(Obj)tdn,m->c,&c1); m->c = c1; |
|
} |
|
} |
|
NEXTDMM(mq0,mq); |
|
mq->c = BDY(mult)->c; mq->dl = BDY(mult)->dl; mq->pos = (long)nd->body2; |
|
mulp(CO,dn,tdn,&tdn1); dn = tdn1; |
|
if ( !u ) goto last; |
|
break; |
|
} |
|
} |
|
} |
|
if ( u ) { |
|
g = u; |
|
} else { |
|
m = BDY(g); |
|
NEXTDMM(mr0,mr); |
|
mr->dl = m->dl; mr->c = m->c; mr->pos = m->pos; |
|
dpm_rest(g,&t); g = t; |
|
} |
|
} |
|
last: |
|
if ( mr0 ) { |
|
NEXT(mr) = 0; |
|
MKDPM(nv,mr0,d); d->sugar = sugar; |
|
} else |
|
d = 0; |
|
if ( mq0 ) { |
|
NEXT(mq) = 0; |
|
MKDPM(nv,mq0,q); q->sugar = sugar; |
|
} else |
|
q = 0; |
|
*rp = d; *dnp = dn; |
|
return q; |
|
} |
|
|
|
DPM dpm_nf_and_quotient4(DPM g,DPM *ps,VECT psiv,DPM head,DPM *rp,P *dnp) |
|
{ |
|
DPM u,p,s,t,d,q; |
|
DP dmy,mult,zzz; |
|
NODE nd; |
|
DMM mr0,mq0,mr,mq,m; |
|
MP mp; |
|
int i,n,j,len,nv,pos,max; |
|
int *wb; |
|
int sugar,psugar,multiple; |
|
P nm,tnm1,dn,tdn,tdn1,c; |
|
Q cont; |
|
Obj c1; |
|
struct oEGT eg0,eg1; |
|
|
|
dn = (P)ONE; |
|
if ( !g ) { |
|
*rp = 0; *dnp = dn; return 0; |
|
} |
|
nv = NV(g); |
|
sugar = g->sugar; |
|
mq0 = 0; |
|
if ( head ) { |
|
for ( m = BDY(head); m; m = NEXT(m) ) { |
|
NEXTDMM(mq0,mq); |
|
mq->c = m->c; mq->dl = m->dl; mq->pos = m->pos; |
|
} |
|
} |
|
mr0 = 0; |
|
max = psiv->len; |
|
for ( ; g; ) { |
|
pos = BDY(g)->pos; |
|
u = 0; |
|
if ( pos < max ) { |
|
nd = (NODE)BDY(psiv)[pos]; |
|
for ( u = 0; nd; nd = NEXT(nd) ) { |
|
if ( dpm_redble(g,p = ps[(long)(BDY(nd))-1]) ) { |
|
dpm_red2(g,p,&u,&tdn,&mult); |
|
psugar = (BDY(g)->dl->td - BDY(p)->dl->td) + p->sugar; |
|
sugar = MAX(sugar,psugar); |
|
if ( !UNIZ(tdn) ) { |
|
for ( m = mq0; m; m = NEXT(m) ) { |
|
arf_mul(CO,(Obj)tdn,m->c,&c1); m->c = c1; |
|
} |
|
for ( m = mr0; m; m = NEXT(m) ) { |
|
arf_mul(CO,(Obj)tdn,m->c,&c1); m->c = c1; |
|
} |
|
} |
|
NEXTDMM(mq0,mq); |
|
mq->c = BDY(mult)->c; |
|
mq->dl = BDY(mult)->dl; mq->pos = (long)BDY(nd); |
|
mulp(CO,dn,tdn,&tdn1); dn = tdn1; |
|
if ( !u ) goto last; |
|
break; |
|
} |
|
} |
|
} |
|
if ( u ) { |
|
g = u; |
|
} else { |
|
m = BDY(g); |
|
NEXTDMM(mr0,mr); |
|
mr->dl = m->dl; mr->c = m->c; mr->pos = m->pos; |
|
dpm_rest(g,&t); g = t; |
|
} |
|
} |
|
last: |
|
if ( mr0 ) { |
|
NEXT(mr) = 0; |
|
MKDPM(nv,mr0,d); d->sugar = sugar; |
|
} else |
|
d = 0; |
|
if ( mq0 ) { |
|
NEXT(mq) = 0; |
|
MKDPM(nv,mq0,q); q->sugar = sugar; |
|
} else |
|
q = 0; |
|
*rp = d; *dnp = dn; |
|
return q; |
|
} |
|
|
|
/* an intermediate version for calling from the user language */ |
|
|
|
DPM dpm_sp_nf_asir(VECT psv,int i,int j,DPM *nf) |
|
{ |
|
DPM *ps; |
|
int n,nv,s1,s2,sugar,max,pos,psugar; |
|
DPM g,u,p,d,q,t; |
|
DMM mq0,mq,mr0,mr,m; |
|
DP mult,t1,t2; |
|
P dn,tdn,tdn1; |
|
NODE nd; |
|
Obj c1; |
|
|
|
ps = (DPM *)BDY(psv); |
|
n = psv->len; |
|
nv = ps[1]->nv; |
|
dpm_sp(ps[i],ps[j],&g,&t1,&t2); |
|
mq0 = 0; |
|
NEXTDMM(mq0,mq); mq->c = BDY(t1)->c; mq->pos = i; mq->dl = BDY(t1)->dl; |
|
NEXTDMM(mq0,mq); chsgnp((P)BDY(t2)->c,(P *)&mq->c); mq->pos = j; mq->dl = BDY(t2)->dl; |
|
|
|
if ( !g ) { |
|
NEXT(mq) = 0; |
|
MKDPM(nv,mq0,d); |
|
s1 = BDY(t1)->dl->td + ps[i]->sugar; |
|
s2 = BDY(t2)->dl->td + ps[j]->sugar; |
|
d->sugar = MAX(s1,s2); |
|
*nf = 0; |
|
return d; |
|
} |
|
|
|
dn = (P)ONE; |
|
sugar = g->sugar; |
|
mr0 = 0; |
|
while ( g ) { |
|
for ( u = 0, i = 1; i < n; i++ ) { |
|
if ( (p=ps[i])!=0 && dpm_redble(g,p) ) { |
|
dpm_red2(g,p,&u,&tdn,&mult); |
|
psugar = (BDY(g)->dl->td - BDY(p)->dl->td) + p->sugar; |
|
sugar = MAX(sugar,psugar); |
|
if ( !UNIZ(tdn) ) { |
|
for ( m = mq0; m; m = NEXT(m) ) { |
|
arf_mul(CO,(Obj)tdn,m->c,&c1); m->c = c1; |
|
} |
|
for ( m = mr0; m; m = NEXT(m) ) { |
|
arf_mul(CO,(Obj)tdn,m->c,&c1); m->c = c1; |
|
} |
|
} |
|
NEXTDMM(mq0,mq); |
|
chsgnp((P)BDY(mult)->c,(P *)&mq->c); |
|
mq->dl = BDY(mult)->dl; mq->pos = i; |
|
mulp(CO,dn,tdn,&tdn1); dn = tdn1; |
|
if ( !u ) goto last; |
|
break; |
|
} |
|
} |
|
if ( u ) { |
|
g = u; |
|
} else { |
|
m = BDY(g); |
|
NEXTDMM(mr0,mr); |
|
mr->dl = m->dl; mr->c = m->c; mr->pos = m->pos; |
|
dpm_rest(g,&t); g = t; |
|
} |
|
} |
|
last: |
|
if ( mr0 ) { |
|
NEXT(mr) = 0; MKDPM(nv,mr0,d); d->sugar = sugar; |
|
} else |
|
d = 0; |
|
NEXT(mq) = 0; MKDPM(nv,mq0,q); q->sugar = sugar; |
|
*nf = d; |
|
return q; |
|
} |
|
|
|
DPM dpm_sp_nf(VECT psv,VECT psiv,int i,int j,DPM *nf) |
|
{ |
|
DPM *ps; |
|
int n,nv,s1,s2,sugar,max,pos,psugar; |
|
DPM g,u,p,d,q,t; |
|
DMM mq0,mq,mr0,mr,m; |
|
DP mult,t1,t2; |
|
P dn,tdn,tdn1; |
|
NODE nd; |
|
Obj c1; |
|
|
|
ps = (DPM *)BDY(psv); |
|
n = psv->len; |
|
nv = ps[1]->nv; |
|
dpm_sp(ps[i],ps[j],&g,&t1,&t2); |
|
mq0 = 0; |
|
NEXTDMM(mq0,mq); mq->c = BDY(t1)->c; mq->pos = i; mq->dl = BDY(t1)->dl; |
|
NEXTDMM(mq0,mq); chsgnp((P)BDY(t2)->c,(P *)&mq->c); mq->pos = j; mq->dl = BDY(t2)->dl; |
|
|
|
if ( !g ) { |
|
NEXT(mq) = 0; |
|
MKDPM(nv,mq0,d); |
|
s1 = BDY(t1)->dl->td + ps[i]->sugar; |
|
s2 = BDY(t2)->dl->td + ps[j]->sugar; |
|
d->sugar = MAX(s1,s2); |
|
*nf = 0; |
|
return d; |
|
} |
|
|
|
dn = (P)ONE; |
|
sugar = g->sugar; |
|
mr0 = 0; |
|
max = psiv->len; |
|
while ( g ) { |
|
pos = BDY(g)->pos; |
|
u = 0; |
|
if ( pos < max ) { |
|
nd = (NODE)BDY(psiv)[pos]; |
|
for ( u = 0; nd; nd = NEXT(nd) ) { |
|
if ( dpm_redble(g,p = ps[(long)(BDY(nd))]) ) { |
|
dpm_red2(g,p,&u,&tdn,&mult); |
|
psugar = (BDY(g)->dl->td - BDY(p)->dl->td) + p->sugar; |
|
sugar = MAX(sugar,psugar); |
|
if ( !UNIZ(tdn) ) { |
|
for ( m = mq0; m; m = NEXT(m) ) { |
|
arf_mul(CO,(Obj)tdn,m->c,&c1); m->c = c1; |
|
} |
|
for ( m = mr0; m; m = NEXT(m) ) { |
|
arf_mul(CO,(Obj)tdn,m->c,&c1); m->c = c1; |
|
} |
|
} |
|
NEXTDMM(mq0,mq); |
|
chsgnp((P)BDY(mult)->c,(P *)&mq->c); |
|
mq->dl = BDY(mult)->dl; mq->pos = (long)BDY(nd); |
|
mulp(CO,dn,tdn,&tdn1); dn = tdn1; |
|
if ( !u ) goto last; |
|
break; |
|
} |
|
} |
|
} |
|
if ( u ) { |
|
g = u; |
|
} else { |
|
m = BDY(g); |
|
NEXTDMM(mr0,mr); |
|
mr->dl = m->dl; mr->c = m->c; mr->pos = m->pos; |
|
dpm_rest(g,&t); g = t; |
|
} |
|
} |
|
last: |
|
if ( mr0 ) { |
|
NEXT(mr) = 0; MKDPM(nv,mr0,d); d->sugar = sugar; |
|
} else |
|
d = 0; |
|
NEXT(mq) = 0; MKDPM(nv,mq0,q); q->sugar = sugar; |
|
*nf = d; |
|
return q; |
|
} |
|
|
DP *dp_true_nf_and_quotient_marked_mod(NODE b,DP g,DP *ps,DP *hps,int mod,DP *rp,P *dnp) |
DP *dp_true_nf_and_quotient_marked_mod(NODE b,DP g,DP *ps,DP *hps,int mod,DP *rp,P *dnp) |
{ |
{ |
DP u,p,d,s,t,dmy,hp,mult; |
DP u,p,d,s,t,dmy,hp,mult; |
Line 1613 void dpm_nf_z(NODE b,DPM g,VECT psv,int full,int multi |
|
Line 2119 void dpm_nf_z(NODE b,DPM g,VECT psv,int full,int multi |
|
for ( d = 0; g; ) { |
for ( d = 0; g; ) { |
for ( u = 0, i = 0; i < n; i++ ) { |
for ( u = 0, i = 0; i < n; i++ ) { |
if ( (p=ps[wb[i]])!=0 && dpm_redble(g,p) ) { |
if ( (p=ps[wb[i]])!=0 && dpm_redble(g,p) ) { |
dpm_red(d,g,p,&t,&u,&dmy,&dmy1); |
dpm_red2(g,p,&u,&dmy,&dmy1); |
psugar = (BDY(g)->dl->td - BDY(p)->dl->td) + p->sugar; |
psugar = (BDY(g)->dl->td - BDY(p)->dl->td) + p->sugar; |
sugar = MAX(sugar,psugar); |
sugar = MAX(sugar,psugar); |
|
if ( d ) mulcdmm((Obj)dmy,BDY(d)); |
if ( !u ) { |
if ( !u ) { |
if ( d ) |
if ( d ) |
d->sugar = sugar; |
d->sugar = sugar; |
*rp = d; return; |
*rp = d; return; |
} |
} |
d = t; |
|
break; |
break; |
} |
} |
} |
} |
Line 1647 void dpm_nf_z(NODE b,DPM g,VECT psv,int full,int multi |
|
Line 2153 void dpm_nf_z(NODE b,DPM g,VECT psv,int full,int multi |
|
} else { |
} else { |
m = BDY(g); NEWDMM(mr); mr->dl = m->dl; mr->c = m->c; mr->pos = m->pos; |
m = BDY(g); NEWDMM(mr); mr->dl = m->dl; mr->c = m->c; mr->pos = m->pos; |
NEXT(mr) = 0; MKDPM(g->nv,mr,t); t->sugar = mr->dl->td; |
NEXT(mr) = 0; MKDPM(g->nv,mr,t); t->sugar = mr->dl->td; |
adddpm(CO,d,t,&s); d = s; |
d = appenddpm(d,t); |
dpm_rest(g,&t); g = t; |
dpm_rest(g,&t); g = t; |
} |
} |
} |
} |
Line 2110 int create_order_spec(VL vl,Obj obj,struct order_spec |
|
Line 2616 int create_order_spec(VL vl,Obj obj,struct order_spec |
|
spec->ord.simple = ZTOS((Q)obj); |
spec->ord.simple = ZTOS((Q)obj); |
return 1; |
return 1; |
} else if ( OID(obj) == O_LIST ) { |
} else if ( OID(obj) == O_LIST ) { |
/* module order; obj = [0|1,w,ord] or [0|1,ord] */ |
/* module order */ |
node = BDY((LIST)obj); |
node = BDY((LIST)obj); |
if ( !BDY(node) || NUM(BDY(node)) ) { |
if ( !BDY(node) || NUM(BDY(node)) ) { |
switch ( length(node) ) { |
switch ( length(node) ) { |
case 2: |
case 2: /* [n,ord] */ |
create_order_spec(0,(Obj)BDY(NEXT(node)),&spec); |
create_order_spec(0,(Obj)BDY(NEXT(node)),&spec); |
spec->id += 256; spec->obj = obj; |
spec->id += 256; spec->obj = obj; |
spec->top_weight = 0; |
spec->top_weight = 0; |
spec->module_rank = 0; |
spec->module_rank = 0; |
spec->module_top_weight = 0; |
spec->module_top_weight = 0; |
spec->ispot = (BDY(node)!=0); |
spec->module_ordtype = ZTOS((Z)BDY(node)); |
if ( spec->ispot ) { |
if ( spec->module_ordtype < 0 ) { |
n = ZTOS((Q)BDY(node)); |
spec->pot_nelim = -spec->module_ordtype; |
if ( n < 0 ) |
spec->module_ordtype = 1; |
spec->pot_nelim = -n; |
} else |
else |
|
spec->pot_nelim = 0; |
spec->pot_nelim = 0; |
} |
|
break; |
break; |
|
|
case 3: |
case 3: /* [n,[wv,wm],ord] */ |
create_order_spec(0,(Obj)BDY(NEXT(NEXT(node))),&spec); |
spec->module_ordtype = ZTOS((Z)BDY(node)); |
spec->id += 256; spec->obj = obj; |
if ( spec->module_ordtype < 0 ) { |
spec->ispot = (BDY(node)!=0); |
spec->pot_nelim = -spec->module_ordtype; |
node = NEXT(node); |
spec->module_ordtype = 1; |
if ( !BDY(node) || OID(BDY(node)) != O_LIST ) |
} else |
error("create_order_spec : [weight_for_poly,weight_for_modlue] must be specified as a module topweight"); |
spec->pot_nelim = 0; |
wpair = BDY((LIST)BDY(node)); |
|
if ( length(wpair) != 2 ) |
|
error("create_order_spec : [weight_for_poly,weight_for_modlue] must be specified as a module topweight"); |
|
|
|
wp = BDY(wpair); |
if ( spec->module_ordtype == 3 ) { /* schreyer order */ |
wm = BDY(NEXT(wpair)); |
Obj baseobj; |
if ( !wp || OID(wp) != O_LIST || !wm || OID(wm) != O_LIST ) |
struct order_spec *basespec; |
error("create_order_spec : [weight_for_poly,weight_for_modlue] must be specified as a module topweight"); |
int len; |
spec->nv = length(BDY((LIST)wp)); |
NODE in; |
spec->top_weight = (int *)MALLOC_ATOMIC(spec->nv*sizeof(int)); |
LIST *la; |
for ( i = 0, t = BDY((LIST)wp); i < spec->nv; t = NEXT(t), i++ ) |
DMMstack stack; |
spec->top_weight[i] = ZTOS((Q)BDY(t)); |
DMMstack push_schreyer_order(LIST l,DMMstack s); |
|
|
spec->module_rank = length(BDY((LIST)wm)); |
spec->id = 300; spec->obj = obj; |
spec->module_top_weight = (int *)MALLOC_ATOMIC(spec->module_rank*sizeof(int)); |
node = NEXT(node); |
for ( i = 0, t = BDY((LIST)wm); i < spec->module_rank; t = NEXT(t), i++ ) |
if ( !BDY(node) || OID(BDY(node)) != O_LIST ) |
spec->module_top_weight[i] = ZTOS((Q)BDY(t)); |
error("create_order_spec : [mlist1,mlist,...] must be specified for defining a schreyer order"); |
|
stack = 0; |
|
in = BDY((LIST)BDY(node)); |
|
len = length(in); |
|
la = (LIST *)MALLOC(len*sizeof(LIST)); |
|
for ( i = 0; i < len; i++, in = NEXT(in) ) la[i] = (LIST)(BDY(in)); |
|
for ( i = len-1; i >= 0; i-- ) stack = push_schreyer_order(la[i],stack); |
|
spec->dmmstack = stack; |
|
|
|
node = NEXT(node); |
|
baseobj = (Obj)BDY(node); |
|
create_order_spec(0,baseobj,&basespec); |
|
basespec->obj = baseobj; |
|
spec->base = basespec; |
|
} else { /* weighted order */ |
|
int ordtype; |
|
|
|
ordtype = spec->module_ordtype; |
|
create_order_spec(0,(Obj)BDY(NEXT(NEXT(node))),&spec); |
|
spec->module_ordtype = ordtype; |
|
spec->id += 256; spec->obj = obj; |
|
node = NEXT(node); |
|
if ( !BDY(node) || OID(BDY(node)) != O_LIST ) |
|
error("create_order_spec : [weight_for_poly,weight_for_modlue] must be specified as a module topweight"); |
|
wpair = BDY((LIST)BDY(node)); |
|
if ( length(wpair) != 2 ) |
|
error("create_order_spec : [weight_for_poly,weight_for_modlue] must be specified as a module topweight"); |
|
|
|
wp = BDY(wpair); |
|
wm = BDY(NEXT(wpair)); |
|
if ( !wp || OID(wp) != O_LIST || !wm || OID(wm) != O_LIST ) |
|
error("create_order_spec : [weight_for_poly,weight_for_modlue] must be specified as a module topweight"); |
|
spec->nv = length(BDY((LIST)wp)); |
|
spec->top_weight = (int *)MALLOC_ATOMIC(spec->nv*sizeof(int)); |
|
for ( i = 0, t = BDY((LIST)wp); i < spec->nv; t = NEXT(t), i++ ) |
|
spec->top_weight[i] = ZTOS((Q)BDY(t)); |
|
|
|
spec->module_rank = length(BDY((LIST)wm)); |
|
spec->module_top_weight = (int *)MALLOC_ATOMIC(spec->module_rank*sizeof(int)); |
|
for ( i = 0, t = BDY((LIST)wm); i < spec->module_rank; t = NEXT(t), i++ ) |
|
spec->module_top_weight[i] = ZTOS((Q)BDY(t)); |
|
} |
break; |
break; |
|
|
default: |
default: |
error("create_order_spec : invalid arguments for module order"); |
error("create_order_spec : invalid arguments for module order"); |
} |
} |
Line 2522 void create_modorder_spec(int id,LIST shift,struct mod |
|
Line 3065 void create_modorder_spec(int id,LIST shift,struct mod |
|
* |
* |
*/ |
*/ |
|
|
|
void dpm_homo(DPM p,DPM *rp) |
|
{ |
|
DMM m,mr,mr0,t; |
|
int i,n,nv,td; |
|
DL dl,dlh; |
|
|
|
if ( !p ) |
|
*rp = 0; |
|
else { |
|
n = p->nv; nv = n + 1; |
|
m = BDY(p); |
|
td = 0; |
|
for ( t = m; t; t = NEXT(t) ) |
|
if ( m->dl->td > td ) td = m->dl->td; |
|
for ( mr0 = 0; m; m = NEXT(m) ) { |
|
NEXTDMM(mr0,mr); mr->c = m->c; mr->pos = m->pos; |
|
dl = m->dl; |
|
mr->dl = dlh = (DL)MALLOC_ATOMIC((nv+1)*sizeof(int)); |
|
dlh->td = td; |
|
for ( i = 0; i < n; i++ ) |
|
dlh->d[i] = dl->d[i]; |
|
dlh->d[n] = td - dl->td; |
|
} |
|
NEXT(mr) = 0; MKDPM(nv,mr0,*rp); (*rp)->sugar = p->sugar; |
|
} |
|
} |
|
|
|
void dpm_dehomo(DPM p,DPM *rp) |
|
{ |
|
DMM m,mr,mr0; |
|
int i,n,nv; |
|
DL dl,dlh; |
|
|
|
if ( !p ) |
|
*rp = 0; |
|
else { |
|
n = p->nv; nv = n - 1; |
|
m = BDY(p); |
|
for ( mr0 = 0; m; m = NEXT(m) ) { |
|
NEXTDMM(mr0,mr); mr->c = m->c; mr->pos = m->pos; |
|
dlh = m->dl; |
|
mr->dl = dl = (DL)MALLOC_ATOMIC((nv+1)*sizeof(int)); |
|
dl->td = dlh->td - dlh->d[nv]; |
|
for ( i = 0; i < nv; i++ ) |
|
dl->d[i] = dlh->d[i]; |
|
} |
|
NEXT(mr) = 0; MKDPM(nv,mr0,*rp); (*rp)->sugar = p->sugar; |
|
} |
|
} |
|
|
void dp_homo(DP p,DP *rp) |
void dp_homo(DP p,DP *rp) |
{ |
{ |
MP m,mr,mr0; |
MP m,mr,mr0; |
Line 2569 void dp_dehomo(DP p,DP *rp) |
|
Line 3162 void dp_dehomo(DP p,DP *rp) |
|
} |
} |
} |
} |
|
|
|
|
void dp_mod(DP p,int mod,NODE subst,DP *rp) |
void dp_mod(DP p,int mod,NODE subst,DP *rp) |
{ |
{ |
MP m,mr,mr0; |
MP m,mr,mr0; |
Line 2624 void homogenize_order(struct order_spec *old,int n,str |
|
Line 3218 void homogenize_order(struct order_spec *old,int n,str |
|
struct weight_or_block *owb,*nwb; |
struct weight_or_block *owb,*nwb; |
|
|
*newp = new = (struct order_spec *)MALLOC(sizeof(struct order_spec)); |
*newp = new = (struct order_spec *)MALLOC(sizeof(struct order_spec)); |
|
bcopy((char *)old,(char *)new,sizeof(struct order_spec)); |
switch ( old->id ) { |
switch ( old->id ) { |
case 0: |
case 0: |
switch ( old->ord.simple ) { |
switch ( old->ord.simple ) { |
case 0: |
case 0: |
new->id = 0; new->ord.simple = 0; break; |
break; |
case 1: |
case 1: |
l = (struct order_pair *) |
l = (struct order_pair *) |
MALLOC_ATOMIC(2*sizeof(struct order_pair)); |
MALLOC_ATOMIC(2*sizeof(struct order_pair)); |
Line 2639 void homogenize_order(struct order_spec *old,int n,str |
|
Line 3234 void homogenize_order(struct order_spec *old,int n,str |
|
new->ord.block.length = 2; new->nv = n+1; |
new->ord.block.length = 2; new->nv = n+1; |
break; |
break; |
case 2: |
case 2: |
new->id = 0; new->ord.simple = 1; break; |
new->ord.simple = 1; break; |
case 3: case 4: case 5: |
case 3: case 4: case 5: |
new->id = 0; new->ord.simple = old->ord.simple+3; |
new->ord.simple = old->ord.simple+3; |
dp_nelim = n-1; break; |
dp_nelim = n-1; break; |
case 6: case 7: case 8: case 9: |
case 6: case 7: case 8: case 9: |
new->id = 0; new->ord.simple = old->ord.simple; break; |
break; |
default: |
default: |
error("homogenize_order : invalid input"); |
error("homogenize_order : invalid input"); |
} |
} |
Line 2655 void homogenize_order(struct order_spec *old,int n,str |
|
Line 3250 void homogenize_order(struct order_spec *old,int n,str |
|
MALLOC_ATOMIC((length+1)*sizeof(struct order_pair)); |
MALLOC_ATOMIC((length+1)*sizeof(struct order_pair)); |
bcopy((char *)old->ord.block.order_pair,(char *)l,length*sizeof(struct order_pair)); |
bcopy((char *)old->ord.block.order_pair,(char *)l,length*sizeof(struct order_pair)); |
l[length].order = 2; l[length].length = 1; |
l[length].order = 2; l[length].length = 1; |
new->id = old->id; new->nv = n+1; |
new->nv = n+1; |
new->ord.block.order_pair = l; |
new->ord.block.order_pair = l; |
new->ord.block.length = length+1; |
new->ord.block.length = length+1; |
new->ispot = old->ispot; |
|
break; |
break; |
case 2: case 258: |
case 2: case 258: |
nv = old->nv; row = old->ord.matrix.row; |
nv = old->nv; row = old->ord.matrix.row; |
Line 2670 void homogenize_order(struct order_spec *old,int n,str |
|
Line 3264 void homogenize_order(struct order_spec *old,int n,str |
|
newm[i+1][j] = oldm[i][j]; |
newm[i+1][j] = oldm[i][j]; |
newm[i+1][j] = 0; |
newm[i+1][j] = 0; |
} |
} |
new->id = old->id; new->nv = nv+1; |
new->nv = nv+1; |
new->ord.matrix.row = row+1; new->ord.matrix.matrix = newm; |
new->ord.matrix.row = row+1; new->ord.matrix.matrix = newm; |
new->ispot = old->ispot; |
|
break; |
break; |
case 3: case 259: |
case 3: case 259: |
onv = old->nv; |
onv = old->nv; |
Line 2708 void homogenize_order(struct order_spec *old,int n,str |
|
Line 3301 void homogenize_order(struct order_spec *old,int n,str |
|
(struct sparse_weight *)MALLOC(sizeof(struct sparse_weight)); |
(struct sparse_weight *)MALLOC(sizeof(struct sparse_weight)); |
nwb[i].body.sparse_weight[0].pos = onv; |
nwb[i].body.sparse_weight[0].pos = onv; |
nwb[i].body.sparse_weight[0].value = 1; |
nwb[i].body.sparse_weight[0].value = 1; |
new->id = old->id; |
|
new->nv = nnv; |
new->nv = nnv; |
new->ord.composite.length = nlen; |
new->ord.composite.length = nlen; |
new->ord.composite.w_or_b = nwb; |
new->ord.composite.w_or_b = nwb; |
new->ispot = old->ispot; |
|
print_composite_order_spec(new); |
print_composite_order_spec(new); |
break; |
break; |
case 256: /* simple module order */ |
case 256: /* simple module order */ |
switch ( old->ord.simple ) { |
switch ( old->ord.simple ) { |
case 0: |
case 0: |
new->id = 256; new->ord.simple = 0; break; |
break; |
case 1: |
case 1: |
l = (struct order_pair *) |
l = (struct order_pair *) |
MALLOC_ATOMIC(2*sizeof(struct order_pair)); |
MALLOC_ATOMIC(2*sizeof(struct order_pair)); |
Line 2729 void homogenize_order(struct order_spec *old,int n,str |
|
Line 3320 void homogenize_order(struct order_spec *old,int n,str |
|
new->ord.block.length = 2; new->nv = n+1; |
new->ord.block.length = 2; new->nv = n+1; |
break; |
break; |
case 2: |
case 2: |
new->id = 256; new->ord.simple = 1; break; |
new->ord.simple = 1; break; |
default: |
default: |
error("homogenize_order : invalid input"); |
error("homogenize_order : invalid input"); |
} |
} |
new->ispot = old->ispot; |
|
break; |
break; |
default: |
default: |
error("homogenize_order : invalid input"); |
error("homogenize_order : invalid input"); |