version 1.6, 2019/09/19 06:29:47 |
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.5 2019/09/13 02:04:42 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 1244 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; |
} |
} |
|
|
|
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 2228 int create_order_spec(VL vl,Obj obj,struct order_spec |
|
Line 2669 int create_order_spec(VL vl,Obj obj,struct order_spec |
|
basespec->obj = baseobj; |
basespec->obj = baseobj; |
spec->base = basespec; |
spec->base = basespec; |
} else { /* weighted order */ |
} else { /* weighted order */ |
|
int ordtype; |
|
|
|
ordtype = spec->module_ordtype; |
create_order_spec(0,(Obj)BDY(NEXT(NEXT(node))),&spec); |
create_order_spec(0,(Obj)BDY(NEXT(NEXT(node))),&spec); |
spec->id = 300; spec->obj = obj; |
spec->module_ordtype = ordtype; |
|
spec->id += 256; spec->obj = obj; |
node = NEXT(node); |
node = NEXT(node); |
if ( !BDY(node) || OID(BDY(node)) != O_LIST ) |
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"); |
error("create_order_spec : [weight_for_poly,weight_for_modlue] must be specified as a module topweight"); |
Line 2620 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 2666 void dp_dehomo(DP p,DP *rp) |
|
Line 3161 void dp_dehomo(DP p,DP *rp) |
|
NEXT(mr) = 0; MKDP(nv,mr0,*rp); (*rp)->sugar = p->sugar; |
NEXT(mr) = 0; MKDP(nv,mr0,*rp); (*rp)->sugar = p->sugar; |
} |
} |
} |
} |
|
|
|
|
void dp_mod(DP p,int mod,NODE subst,DP *rp) |
void dp_mod(DP p,int mod,NODE subst,DP *rp) |
{ |
{ |