version 1.10, 2019/11/12 12:50:40 |
version 1.16, 2020/12/05 03:27: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/asir2018/builtin/dp-supp.c,v 1.9 2019/11/12 07:47:45 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2018/builtin/dp-supp.c,v 1.15 2020/10/26 02:41:05 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "base.h" |
#include "base.h" |
Line 315 int _dl_redble(DL d1,DL d2,int nvar) |
|
Line 315 int _dl_redble(DL d1,DL d2,int nvar) |
|
return 1; |
return 1; |
} |
} |
|
|
|
int _dl_redble_ext(DL d1,DL d2,DL quo,int nvar) |
|
{ |
|
int i; |
|
|
|
if ( (quo->td = d2->td-d1->td) < 0 ) |
|
return 0; |
|
for ( i = 0; i < nvar; i++ ) |
|
if ( (quo->d[i] = d2->d[i]-d1->d[i]) < 0 ) |
|
break; |
|
if ( i < nvar ) |
|
return 0; |
|
else |
|
return 1; |
|
} |
|
|
void insert_to_node(DL d,NODE *n,int nvar) |
void insert_to_node(DL d,NODE *n,int nvar) |
{ |
{ |
DL d1; |
DL d1; |
|
|
} |
} |
|
|
/* an intermediate version for calling from the user language */ |
/* an intermediate version for calling from the user language */ |
|
/* XXX : i, j must be positive */ |
|
|
DPM dpm_sp_nf_asir(VECT psv,int i,int j,DPM *nf) |
DPM dpm_sp_nf_asir(VECT psv,int i,int j,DPM *nf) |
{ |
{ |
DPM *ps; |
DPM *ps; |
int n,nv,s1,s2,sugar,max,pos,psugar; |
int n,k,nv,s1,s2,sugar,max,pos,psugar; |
DPM g,u,p,d,q,t; |
DPM g,u,p,d,q,t; |
DMM mq0,mq,mr0,mr,m; |
DMM mq0,mq,mr0,mr,m; |
DP mult,t1,t2; |
DP mult,t1,t2; |
Line 1838 DPM dpm_sp_nf_asir(VECT psv,int i,int j,DPM *nf) |
|
Line 1854 DPM dpm_sp_nf_asir(VECT psv,int i,int j,DPM *nf) |
|
sugar = g->sugar; |
sugar = g->sugar; |
mr0 = 0; |
mr0 = 0; |
while ( g ) { |
while ( g ) { |
for ( u = 0, i = 1; i < n; i++ ) { |
pos = BDY(g)->pos; |
if ( (p=ps[i])!=0 && dpm_redble(g,p) ) { |
for ( u = 0, k = 1; k < n; k++ ) { |
|
if ( (p=ps[k])!=0 && pos == BDY(p)->pos && dpm_redble(g,p) ) { |
dpm_red2(g,p,&u,&tdn,&mult); |
dpm_red2(g,p,&u,&tdn,&mult); |
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); |
Line 1853 DPM dpm_sp_nf_asir(VECT psv,int i,int j,DPM *nf) |
|
Line 1870 DPM dpm_sp_nf_asir(VECT psv,int i,int j,DPM *nf) |
|
} |
} |
NEXTDMM(mq0,mq); |
NEXTDMM(mq0,mq); |
chsgnp((P)BDY(mult)->c,(P *)&mq->c); |
chsgnp((P)BDY(mult)->c,(P *)&mq->c); |
mq->dl = BDY(mult)->dl; mq->pos = i; |
mq->dl = BDY(mult)->dl; mq->pos = k; |
mulp(CO,dn,tdn,&tdn1); dn = tdn1; |
mulp(CO,dn,tdn,&tdn1); dn = tdn1; |
if ( !u ) goto last; |
if ( !u ) goto last; |
break; |
break; |
Line 1891 DPM dpm_sp_nf(VECT psv,VECT psiv,int i,int j,DPM *nf) |
|
Line 1908 DPM dpm_sp_nf(VECT psv,VECT psiv,int i,int j,DPM *nf) |
|
|
|
ps = (DPM *)BDY(psv); |
ps = (DPM *)BDY(psv); |
n = psv->len; |
n = psv->len; |
nv = ps[1]->nv; |
nv = ps[i]->nv; |
dpm_sp(ps[i],ps[j],&g,&t1,&t2); |
dpm_sp(ps[i],ps[j],&g,&t1,&t2); |
mq0 = 0; |
mq0 = 0; |
NEXTDMM(mq0,mq); mq->c = BDY(t1)->c; mq->pos = i; mq->dl = BDY(t1)->dl; |
NEXTDMM(mq0,mq); mq->c = BDY(t1)->c; mq->pos = i; mq->dl = BDY(t1)->dl; |
|
|
return q; |
return q; |
} |
} |
|
|
|
/* psiv is a vector of lists of Z */ |
|
|
|
DPM dpm_sp_nf_zlist(VECT psv,VECT psiv,int i,int j,int top,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[i]->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 = BDY((LIST)BDY(psiv)[pos]); |
|
for ( u = 0; nd; nd = NEXT(nd) ) { |
|
if ( dpm_redble(g,p = ps[ZTOS((Q)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 = ZTOS((Q)BDY(nd)); |
|
mulp(CO,dn,tdn,&tdn1); dn = tdn1; |
|
if ( !u ) goto last; |
|
break; |
|
} |
|
} |
|
} |
|
if ( u ) { |
|
g = u; |
|
} else if ( !top ) { |
|
m = BDY(g); |
|
NEXTDMM(mr0,mr); |
|
mr->dl = m->dl; mr->c = m->c; mr->pos = m->pos; |
|
dpm_rest(g,&t); g = t; |
|
} else { |
|
*nf = g; |
|
if ( mq0 ) { |
|
NEXT(mq) = 0; MKDPM(nv,mq0,q); q->sugar = sugar; |
|
} else |
|
q = 0; |
|
return q; |
|
} |
|
} |
|
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 2213 void dpm_split(DPM p,int s,DPM *up,DPM *lo) |
|
Line 2318 void dpm_split(DPM p,int s,DPM *up,DPM *lo) |
|
} |
} |
} |
} |
|
|
|
/* extract the component in DP of position s */ |
|
void dpm_extract(DPM p,int s,DP *r) |
|
{ |
|
DMM m; |
|
MP mu0,mu; |
|
DP t; |
|
|
|
if ( !p ) { |
|
*r = 0; return; |
|
} |
|
for ( m = BDY(p), mu0 = 0; m; m = NEXT(m) ) { |
|
if ( m->pos == s ) { |
|
NEXTMP(mu0,mu); |
|
mu->dl = m->dl; mu->c = m->c; |
|
} |
|
} |
|
if ( mu0 ) { |
|
NEXT(mu) = 0; MKDP(p->nv,mu0,t); t->sugar = p->sugar; |
|
*r = t; |
|
} else |
|
*r = 0; |
|
} |
|
|
/* nf computation over a field */ |
/* nf computation over a field */ |
|
|
void dp_nf_f(NODE b,DP g,DP *ps,int full,DP *rp) |
void dp_nf_f(NODE b,DP g,DP *ps,int full,DP *rp) |
Line 2668 int create_order_spec(VL vl,Obj obj,struct order_spec |
|
Line 2796 int create_order_spec(VL vl,Obj obj,struct order_spec |
|
create_order_spec(0,baseobj,&basespec); |
create_order_spec(0,baseobj,&basespec); |
basespec->obj = baseobj; |
basespec->obj = baseobj; |
spec->base = basespec; |
spec->base = basespec; |
} else { /* weighted order */ |
} else if ( spec->module_ordtype == 4 ) { /* POT with base order [n,bord,ord] */ |
|
NODE base_ord; |
|
int rank; |
|
|
|
create_order_spec(0,(Obj)BDY(NEXT(NEXT(node))),&spec); |
|
spec->id += 256; spec->obj = obj; |
|
spec->top_weight = 0; |
|
spec->module_rank = 0; |
|
spec->module_top_weight = 0; |
|
spec->pot_nelim = 0; |
|
spec->module_ordtype = 4; |
|
node = NEXT(node); |
|
if ( !BDY(node) || OID(BDY(node)) != O_LIST ) |
|
error("create_order_spec : a permitation list must be specified"); |
|
base_ord = BDY((LIST)BDY(node)); |
|
spec->module_rank = rank = length(base_ord); |
|
spec->module_base_ord = (int *)MALLOC_ATOMIC((rank+1)*sizeof(int)); |
|
for ( i = 1, t = base_ord; i <= rank; i++, t = NEXT(t) ) |
|
spec->module_base_ord[ZTOS((Q)BDY(t))] = i; |
|
break; |
|
} else { /* weighted order * [n,[wv,wm],ord] */ |
int ordtype; |
int ordtype; |
|
|
ordtype = spec->module_ordtype; |
ordtype = spec->module_ordtype; |
Line 3190 void dp_mod(DP p,int mod,NODE subst,DP *rp) |
|
Line 3338 void dp_mod(DP p,int mod,NODE subst,DP *rp) |
|
} |
} |
} |
} |
|
|
|
void dpm_mod(DPM p,int mod,DPM *rp) |
|
{ |
|
DMM m,mr,mr0; |
|
P t; |
|
V v; |
|
NODE tn; |
|
|
|
if ( !p ) |
|
*rp = 0; |
|
else { |
|
for ( mr0 = 0, m = BDY(p); m; m = NEXT(m) ) { |
|
ptomp(mod,(P)m->c,&t); |
|
if ( t ) { |
|
NEXTDMM(mr0,mr); mr->c = (Obj)t; mr->dl = m->dl; |
|
} |
|
} |
|
if ( mr0 ) { |
|
NEXT(mr) = 0; MKDPM(p->nv,mr0,*rp); (*rp)->sugar = p->sugar; |
|
} else |
|
*rp = 0; |
|
} |
|
} |
|
|
void dp_rat(DP p,DP *rp) |
void dp_rat(DP p,DP *rp) |
{ |
{ |
MP m,mr,mr0; |
MP m,mr,mr0; |
Line 3489 void dpm_rest(DPM p,DPM *rp) |
|
Line 3660 void dpm_rest(DPM p,DPM *rp) |
|
if ( *rp ) |
if ( *rp ) |
(*rp)->sugar = p->sugar; |
(*rp)->sugar = p->sugar; |
} |
} |
|
} |
|
|
|
int dp_getdeg(DP p) |
|
{ |
|
int max,n,i; |
|
MP m; |
|
int *d; |
|
|
|
if ( !p ) return 0; |
|
n = p->nv; |
|
max = 0; |
|
for ( m = BDY(p); m; m = NEXT(m) ) { |
|
d = m->dl->d; |
|
for ( i = 0; i < n; i++ ) |
|
if ( d[i] > max ) max = d[i]; |
|
} |
|
return max; |
} |
} |
|
|
int dpm_getdeg(DPM p,int *r) |
int dpm_getdeg(DPM p,int *r) |