version 1.16, 2019/11/21 01:54:01 |
version 1.26, 2021/12/23 08:55:33 |
|
|
* 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/engine/dist.c,v 1.15 2019/11/19 10:50:31 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2018/engine/dist.c,v 1.25 2021/01/11 08:37:44 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
|
|
Line 210 void initd(struct order_spec *spec) |
|
Line 210 void initd(struct order_spec *spec) |
|
|
|
int dpm_ordtype; |
int dpm_ordtype; |
|
|
|
#if 0 |
void ptod(VL vl,VL dvl,P p,DP *pr) |
void ptod(VL vl,VL dvl,P p,DP *pr) |
{ |
{ |
int n,i,j,k; |
int n,i,j,k; |
Line 267 void ptod(VL vl,VL dvl,P p,DP *pr) |
|
Line 268 void ptod(VL vl,VL dvl,P p,DP *pr) |
|
dp_fcoeffs = N_GFS; |
dp_fcoeffs = N_GFS; |
#endif |
#endif |
} |
} |
|
#else |
|
void ptod(VL vl,VL dvl,P p,DP *pr) |
|
{ |
|
int n,i,j,k; |
|
VL tvl; |
|
V v; |
|
DL d; |
|
MP m; |
|
DCP dc; |
|
DP *y; |
|
DP r,s,t,u; |
|
P x,c; |
|
|
|
if ( !p ) |
|
*pr = 0; |
|
else if ( OID(p) > O_P ) |
|
error("ptod : only polynomials can be converted."); |
|
else { |
|
for ( n = 0, tvl = dvl; tvl; tvl = NEXT(tvl), n++ ); |
|
if ( NUM(p) ) { |
|
NEWDL(d,n); |
|
NEWMP(m); m->dl = d; C(m) = (Obj)p; NEXT(m) = 0; MKDP(n,m,*pr); (*pr)->sugar = 0; |
|
} else { |
|
for ( i = 0, tvl = dvl, v = VR(p); tvl && tvl->v != v; tvl = NEXT(tvl), i++ ); |
|
for ( dc = DC(p), k = 0; dc; dc = NEXT(dc), k++ ); |
|
y = (DP *)ALLOCA(k*sizeof(DP)); |
|
if ( !tvl ) { |
|
MKV(v,x); |
|
for ( dc = DC(p), j = 0; dc; dc = NEXT(dc), j++ ) { |
|
ptod(vl,dvl,COEF(dc),&t); pwrp(vl,x,DEG(dc),&c); |
|
muldc(vl,t,(Obj)c,&y[j]); |
|
} |
|
} else { |
|
for ( dc = DC(p), j = 0; dc; dc = NEXT(dc), j++ ) { |
|
ptod(vl,dvl,COEF(dc),&t); |
|
NEWDL(d,n); |
|
d->d[i] = ZTOS(DEG(dc)); |
|
d->td = MUL_WEIGHT(d->d[i],i); |
|
NEWMP(m); m->dl = d; C(m) = (Obj)ONE; NEXT(m) = 0; MKDP(n,m,u); u->sugar = d->td; |
|
comm_muld(vl,t,u,&y[j]); |
|
} |
|
} |
|
for ( j = k-1, s = 0; j >= 0; j-- ) { |
|
addd(vl,y[j],s,&t); s = t; |
|
} |
|
*pr = s; |
|
} |
|
} |
|
#if 0 |
|
if ( !dp_fcoeffs && has_sfcoef(*pr) ) |
|
dp_fcoeffs = N_GFS; |
|
#endif |
|
} |
|
#endif |
|
|
void dtop(VL vl,VL dvl,DP p,Obj *pr) |
void dtop(VL vl,VL dvl,DP p,Obj *pr) |
{ |
{ |
int n,i,j,k; |
int n,i,j,k; |
Line 353 void nodetodpm(NODE node,Obj pos,DPM *dp) |
|
Line 408 void nodetodpm(NODE node,Obj pos,DPM *dp) |
|
} |
} |
d->td = td; |
d->td = td; |
p = ZTOS((Q)pos); |
p = ZTOS((Q)pos); |
if ( dp_current_spec->module_rank ) { |
if ( dp_current_spec->module_top_weight ) { |
if ( p > dp_current_spec->module_rank ) |
if ( p > dp_current_spec->module_rank ) |
error("nodetodpm : inconsistent order spec"); |
error("nodetodpm : inconsistent order spec"); |
d->td += dp_current_spec->module_top_weight[p-1]; |
d->td += dp_current_spec->module_top_weight[p-1]; |
Line 371 void dtodpm(DP d,int pos,DPM *dp) |
|
Line 426 void dtodpm(DP d,int pos,DPM *dp) |
|
if ( !d ) *dp = 0; |
if ( !d ) *dp = 0; |
else { |
else { |
shift = 0; |
shift = 0; |
if ( dp_current_spec->module_rank ) { |
if ( dp_current_spec->module_top_weight ) { |
if ( pos > dp_current_spec->module_rank ) |
if ( pos > dp_current_spec->module_rank ) |
error("nodetodpm : inconsistent order spec"); |
error("nodetodpm : inconsistent order spec"); |
shift = dp_current_spec->module_top_weight[pos-1]; |
shift = dp_current_spec->module_top_weight[pos-1]; |
Line 582 void _adddl(int n,DL d1,DL d2,DL d3) |
|
Line 637 void _adddl(int n,DL d1,DL d2,DL d3) |
|
d3->d[i] = d1->d[i]+d2->d[i]; |
d3->d[i] = d1->d[i]+d2->d[i]; |
} |
} |
|
|
|
void _subdl(int n,DL d1,DL d2,DL d3) |
|
{ |
|
int i; |
|
|
|
d3->td = d1->td-d2->td; |
|
for ( i = 0; i < n; i++ ) |
|
d3->d[i] = d1->d[i]-d2->d[i]; |
|
} |
|
|
|
|
void _addtodl(int n,DL d1,DL d2) |
void _addtodl(int n,DL d1,DL d2) |
{ |
{ |
int i; |
int i; |
Line 591 void _addtodl(int n,DL d1,DL d2) |
|
Line 656 void _addtodl(int n,DL d1,DL d2) |
|
d2->d[i] += d1->d[i]; |
d2->d[i] += d1->d[i]; |
} |
} |
|
|
|
void _subfromdl(int n,DL d1,DL d2) |
|
{ |
|
int i; |
|
|
|
d2->td -= d1->td; |
|
for ( i = 0; i < n; i++ ) |
|
d2->d[i] -= d1->d[i]; |
|
} |
|
|
void _copydl(int n,DL d1,DL d2) |
void _copydl(int n,DL d1,DL d2) |
{ |
{ |
int i; |
int i; |
Line 2750 void dpm_sp(DPM p1,DPM p2,DPM *sp,DP *t1,DP *t2); |
|
Line 2824 void dpm_sp(DPM p1,DPM p2,DPM *sp,DP *t1,DP *t2); |
|
DPM dpm_nf_and_quotient3(DPM sp,VECT psv,DPM *nf,P *dn); |
DPM dpm_nf_and_quotient3(DPM sp,VECT psv,DPM *nf,P *dn); |
DPM dpm_nf_and_quotient4(DPM sp,DPM *ps,VECT psiv,DPM head,DPM *nf,P *dn); |
DPM dpm_nf_and_quotient4(DPM sp,DPM *ps,VECT psiv,DPM head,DPM *nf,P *dn); |
DPM dpm_sp_nf(VECT psv,VECT psiv,int i,int j,DPM *nf); |
DPM dpm_sp_nf(VECT psv,VECT psiv,int i,int j,DPM *nf); |
|
DPM dpm_sp_nf_zlist(VECT psv,VECT psiv,int i,int j,int top,DPM *nf); |
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); |
void dpm_sort(DPM p,DPM *r); |
void dpm_sort(DPM p,DPM *r); |
|
|
extern int DP_Multiple; |
extern int DP_Multiple; |
|
extern int DP_Print; |
|
|
void dpm_nf_z(NODE b,DPM g,VECT psv,int full,int multiple,DPM *rp); |
void dpm_nf_z(NODE b,DPM g,VECT psv,int full,int multiple,DPM *rp); |
NODE dpm_sort_list(NODE l); |
NODE dpm_sort_list(NODE l); |
Line 2861 void dpm_schreyer_base(LIST g,LIST *s) |
|
Line 2937 void dpm_schreyer_base(LIST g,LIST *s) |
|
get_eg(&eg0); |
get_eg(&eg0); |
get_eg(&eg1); add_eg(&egnf,&eg0,&eg1); print_eg("NF",&egnf); printf("\n"); |
get_eg(&eg1); add_eg(&egnf,&eg0,&eg1); print_eg("NF",&egnf); printf("\n"); |
if ( b0 ) NEXT(b) = 0; |
if ( b0 ) NEXT(b) = 0; |
for ( t0 = t, nd = BDY(g); nd; nd = NEXT(nd) ) { |
for ( t0 = 0, nd = BDY(g); nd; nd = NEXT(nd) ) { |
dpm_ht((DPM)BDY(nd),&dpm); NEXTNODE(t0,t); BDY(t) = (pointer)dpm; |
dpm_ht((DPM)BDY(nd),&dpm); NEXTNODE(t0,t); BDY(t) = (pointer)dpm; |
} |
} |
if ( t0 ) NEXT(t) = 0; |
if ( t0 ) NEXT(t) = 0; |
Line 2876 void dpm_schreyer_base(LIST g,LIST *s) |
|
Line 2952 void dpm_schreyer_base(LIST g,LIST *s) |
|
printf("sch_count=%d, schlast_count=%d\n",sch_count,schlast_count); |
printf("sch_count=%d, schlast_count=%d\n",sch_count,schlast_count); |
} |
} |
|
|
|
void dpm_list_to_array(LIST g,VECT *psvect,VECT *psindvect) |
|
{ |
|
NODE nd,t; |
|
int n; |
|
VECT psv,psiv; |
|
DPM *ps; |
|
int i,max,pos; |
|
LIST *psi; |
|
LIST l; |
|
Z iz; |
|
|
DMMstack_array dpm_schreyer_frame(NODE g) |
nd = BDY(g); |
|
n = length(nd); |
|
MKVECT(psv,n+1); |
|
ps = (DPM *)BDY(psv); |
|
for ( i = 1, t = nd; i <= n; i++, t = NEXT(t) ) ps[i] = (DPM)BDY(t); |
|
for ( i = 1, max = 0; i <= n; i++ ) |
|
if ( (pos=BDY(ps[i])->pos) > max ) max = pos; |
|
MKVECT(psiv,max+1); |
|
psi = (LIST *)BDY(psiv); |
|
for ( i = 0; i <= max; i++ ) { |
|
MKLIST(l,0); psi[i] = l; |
|
} |
|
for ( i = n; i >= 1; i-- ) { |
|
pos = BDY(ps[i])->pos; |
|
STOZ(i,iz); MKNODE(nd,iz,BDY(psi[pos])); BDY(psi[pos]) = nd; |
|
} |
|
*psvect = psv; *psindvect = psiv; |
|
} |
|
|
|
#if 0 |
|
void dpm_insert_to_zlist(VECT psiv,int pos,int i) |
{ |
{ |
LIST l; |
LIST l; |
|
NODE prev,cur,nd; |
|
int curi; |
|
Z iz; |
|
|
|
l = (LIST)BDY(psiv)[pos]; |
|
for ( prev = 0, cur = BDY(l); cur; cur = NEXT(cur) ) { |
|
curi = ZTOS((Q)BDY(cur)); |
|
if ( curi == i ) |
|
error("dpm_insert_to_list : invalid index"); |
|
if ( i < curi ) break; |
|
prev = cur; |
|
} |
|
STOZ(i,iz); MKNODE(nd,iz,cur); |
|
if ( prev == 0 ) BDY(l) = nd; |
|
else NEXT(prev) = nd; |
|
} |
|
#else |
|
void dpm_insert_to_zlist(VECT psiv,int pos,int i) |
|
{ |
|
LIST l; |
|
NODE prev,cur,nd; |
|
int curi; |
|
Z iz; |
|
|
|
l = (LIST)BDY(psiv)[pos]; |
|
for ( prev = 0, cur = BDY(l); cur; cur = NEXT(cur) ) { |
|
curi = ZTOS((Q)BDY(cur)); |
|
if ( curi == i ) |
|
error("dpm_insert_to_list : invalid index"); |
|
prev = cur; |
|
} |
|
STOZ(i,iz); MKNODE(nd,iz,cur); |
|
if ( prev == 0 ) BDY(l) = nd; |
|
else NEXT(prev) = nd; |
|
} |
|
#endif |
|
|
|
void dpm_schreyer_base_zlist(LIST g,LIST *s) |
|
{ |
|
NODE nd,t0,t,b0,b; |
|
int n,i,j,k,nv,max,pos; |
|
LIST l; |
|
DP h,t1,t2; |
|
MP d; |
|
DMM r0,r,r1; |
|
DPM sp,nf,dpm; |
|
DPM *ps; |
|
VECT psv,psiv; |
|
DPM quo; |
|
DP *mm; |
|
LIST *psi; |
|
NODE n1,n2,n3; |
|
int p1,p2,p3; |
|
Z iz; |
|
struct oEGT eg0,eg1,egsp,egnf; |
|
extern struct oEGT egred; |
|
extern int sch_count,schrec_count,schlast_count; |
|
|
|
sch_count = schlast_count= 0; |
|
init_eg(&egra); |
|
init_eg(&egsp); |
|
init_eg(&egnf); |
|
dpm_list_to_array(g,&psv,&psiv); |
|
ps = (DPM *)BDY(psv); |
|
psi = (LIST *)BDY(psiv); |
|
nv = ps[1]->nv; |
|
n = psv->len-1; |
|
max = psiv->len-1; |
|
mm = (DP *)MALLOC((n+1)*sizeof(DP)); |
|
b0 = 0; |
|
get_eg(&eg0); |
|
for ( i = 1; i <= max; i++ ) { |
|
memset(mm,0,(n+1)*sizeof(DP)); |
|
for ( n1 = BDY((LIST)psi[i]); n1; n1 = NEXT(n1) ) { |
|
p1 = ZTOS((Q)BDY(n1)); |
|
for ( n2 = NEXT(n1); n2; n2 = NEXT(n2) ) { |
|
p2 = ZTOS((Q)BDY(n2)); |
|
mm[p2] = dpm_sp_hm(ps[p1],ps[p2]); |
|
} |
|
for ( n2 = NEXT(n1); n2; n2 = NEXT(n2) ) { |
|
p2 = ZTOS((Q)BDY(n2)); |
|
if ( !mm[p2] ) continue; |
|
for ( h = mm[p2], n3 = NEXT(n1); n3; n3 = NEXT(n3) ) { |
|
p3 = ZTOS((Q)BDY(n3)); |
|
if ( n3 != n2 && mm[p3] && dp_redble(mm[p3],h) ) mm[p3] = 0; |
|
} |
|
} |
|
for ( j = p1+1; j <= n; j++ ) { |
|
if ( mm[j] ) { |
|
quo = dpm_sp_nf_zlist(psv,psiv,p1,j,0,&nf); |
|
if ( nf ) |
|
error("dpm_schreyer_base : cannot happen"); |
|
NEXTNODE(b0,b); BDY(b) = (pointer)quo; |
|
} |
|
} |
|
} |
|
} |
|
get_eg(&eg1); add_eg(&egsp,&eg0,&eg1); print_eg("SP",&egsp); |
|
get_eg(&eg0); |
|
get_eg(&eg1); add_eg(&egnf,&eg0,&eg1); print_eg("NF",&egnf); printf("\n"); |
|
if ( b0 ) NEXT(b) = 0; |
|
for ( t0 = 0, nd = BDY(g); nd; nd = NEXT(nd) ) { |
|
dpm_ht((DPM)BDY(nd),&dpm); NEXTNODE(t0,t); BDY(t) = (pointer)dpm; |
|
} |
|
if ( t0 ) NEXT(t) = 0; |
|
MKLIST(l,t0); |
|
dmm_stack = push_schreyer_order(l,dmm_stack); |
|
// b0 = dpm_sort_list(b0); |
|
// get_eg(&eg0); |
|
// b0 = dpm_reduceall(b0); |
|
// get_eg(&eg1); add_eg(&egra,&eg0,&eg1); print_eg("RA",&egra); |
|
MKLIST(*s,b0); |
|
// print_eg("red",&egred); printf("\n"); |
|
printf("sch_count=%d, schlast_count=%d\n",sch_count,schlast_count); |
|
} |
|
|
|
static int compdp_nv; |
|
|
|
int compdp_revgradlex(DP *a,DP *b) |
|
{ |
|
return -cmpdl_revgradlex(compdp_nv,BDY(*a)->dl,BDY(*b)->dl); |
|
} |
|
|
|
int compdp_lex(DP *a,DP *b) |
|
{ |
|
return -cmpdl_lex(compdp_nv,BDY(*a)->dl,BDY(*b)->dl); |
|
} |
|
|
|
DMMstack_array dpm_schreyer_frame(NODE g,int lex) |
|
{ |
|
LIST l; |
NODE nd,in,b0,b,n1,n2,n3,t; |
NODE nd,in,b0,b,n1,n2,n3,t; |
NODE *psi; |
NODE *psi; |
long p1,p2,p3; |
long p1,p2,p3; |
int nv,n,i,max,pos,level; |
int nv,n,i,j,k,max,pos,level; |
DMMstack s,s1; |
DMMstack s,s1; |
DMM m1,m0,dmm; |
DMM m1,m0,dmm; |
MP mp; |
MP mp; |
DP dp,h; |
DP dp,h; |
DP *m; |
DP *m,*m2; |
DPM dpm,dpm0,dpm1; |
DPM dpm,dpm0,dpm1; |
VECT psv,psiv; |
VECT psv,psiv; |
DPM *ps; |
DPM *ps; |
DMMstack_array dmmstack_array; |
DMMstack_array dmmstack_array; |
|
|
nd = g; |
nd = g; |
nv = ((DPM)BDY(nd))->nv; |
compdp_nv = nv = ((DPM)BDY(nd))->nv; |
s = 0; |
s = 0; |
level = 0; |
level = 0; |
while ( 1 ) { |
while ( 1 ) { |
Line 2917 DMMstack_array dpm_schreyer_frame(NODE g) |
|
Line 3154 DMMstack_array dpm_schreyer_frame(NODE g) |
|
s1->sum[i] = BDY(dpm1); |
s1->sum[i] = BDY(dpm1); |
} |
} |
} else { |
} else { |
for ( i = 1, in = nd; i <= n; i++, in = NEXT(in) ) |
for ( i = 1, in = nd; i <= n; i++, in = NEXT(in) ) { |
s1->sum[i] = s1->in[i] = BDY((DPM)BDY(in)); |
m0 = BDY((DPM)BDY(in)); |
|
NEWDMM(m1); *m1 = *m0; m1->c = (Obj)ONE; NEXT(m1) = 0; |
|
s1->sum[i] = s1->in[i] = m1; |
|
} |
} |
} |
s = s1; |
s = s1; |
level++; |
level++; |
|
if ( DP_Print ) printf("level=%d,len=%d\n",level,n); |
|
|
|
|
/* create new list */ |
/* create new list */ |
MKVECT(psv,n+1); |
MKVECT(psv,n+1); |
ps = (DPM *)BDY(psv); |
ps = (DPM *)BDY(psv); |
Line 2938 DMMstack_array dpm_schreyer_frame(NODE g) |
|
Line 3177 DMMstack_array dpm_schreyer_frame(NODE g) |
|
MKNODE(nd,(long)i,psi[pos]); psi[pos] = nd; |
MKNODE(nd,(long)i,psi[pos]); psi[pos] = nd; |
} |
} |
m = (DP *)MALLOC((n+1)*sizeof(DP)); |
m = (DP *)MALLOC((n+1)*sizeof(DP)); |
|
m2 = (DP *)MALLOC((n+1)*sizeof(DP)); |
b0 = 0; |
b0 = 0; |
for ( i = 1; i <= max; i++ ) { |
for ( i = 1; i <= max; i++ ) { |
for ( n1 = psi[i]; n1; n1 = NEXT(n1) ) { |
for ( n1 = psi[i]; n1; n1 = NEXT(n1) ) { |
Line 2957 DMMstack_array dpm_schreyer_frame(NODE g) |
|
Line 3197 DMMstack_array dpm_schreyer_frame(NODE g) |
|
} |
} |
if ( h ) m[p2] = h; |
if ( h ) m[p2] = h; |
} |
} |
for ( n2 = NEXT(n1); n2; n2 = NEXT(n2) ) { |
if ( lex ) { |
p2 = (long)BDY(n2); |
// compress m to m2 |
if ( m[p2] ) { |
for ( j = 0, n2 = NEXT(n1); n2; n2 = NEXT(n2) ) { |
NEWDMM(dmm); dmm->dl = BDY(m[p2])->dl; dmm->pos = p1; dmm->c = (Obj)ONE; |
p2 = (long)BDY(n2); |
|
if ( m[p2] ) m2[j++] = m[p2]; |
|
} |
|
qsort(m2,j,sizeof(DP),(int (*)(const void *,const void *))compdp_lex); |
|
for ( k = 0; k < j; k++ ) { |
|
NEWDMM(dmm); dmm->dl = BDY(m2[k])->dl; dmm->pos = p1; dmm->c = (Obj)ONE; |
MKDPM(nv,dmm,dpm); |
MKDPM(nv,dmm,dpm); |
NEXTNODE(b0,b); BDY(b) = (pointer)dpm; |
NEXTNODE(b0,b); BDY(b) = (pointer)dpm; |
} |
} |
|
} else { |
|
for ( n2 = NEXT(n1); n2; n2 = NEXT(n2) ) { |
|
p2 = (long)BDY(n2); |
|
if ( m[p2] ) { |
|
NEWDMM(dmm); dmm->dl = BDY(m[p2])->dl; dmm->pos = p1; dmm->c = (Obj)ONE; |
|
MKDPM(nv,dmm,dpm); |
|
NEXTNODE(b0,b); BDY(b) = (pointer)dpm; |
|
} |
|
} |
} |
} |
} |
} |
} |
} |
Line 3031 int compdmm_schreyer(int n,DMM m1,DMM m2) |
|
Line 3285 int compdmm_schreyer(int n,DMM m1,DMM m2) |
|
else return 0; |
else return 0; |
} |
} |
} |
} |
|
/* XXX */ |
|
return 0; |
} |
} |
|
|
|
int compdmm_schreyer_old(int n,DMM m1,DMM m2) |
|
{ |
|
int pos1,pos2,t,npos1,npos2; |
|
DMM *in,*sum; |
|
DMMstack s; |
|
static DL d1=0,d2=0; |
|
static int dlen=0; |
|
|
|
sch_count++; |
|
pos1 = m1->pos; pos2 = m2->pos; |
|
if ( pos1 == pos2 ) return (*cmpdl)(n,m1->dl,m2->dl); |
|
if ( n > dlen ) { |
|
NEWDL(d1,n); NEWDL(d2,n); dlen = n; |
|
} |
|
sum = dmm_stack->sum; |
|
_copydl(n,m1->dl,d1); |
|
_copydl(n,m2->dl,d2); |
|
for ( s = dmm_stack; s; s = NEXT(s) ) { |
|
in = s->in; |
|
_addtodl(n,in[pos1]->dl,d1); |
|
_addtodl(n,in[pos2]->dl,d2); |
|
if ( in[pos1]->pos == in[pos2]->pos && _eqdl(n,d1,d2)) { |
|
if ( pos1 < pos2 ) return 1; |
|
else if ( pos1 > pos2 ) return -1; |
|
else return 0; |
|
} |
|
pos1 = in[pos1]->pos; |
|
pos2 = in[pos2]->pos; |
|
if ( pos1 == pos2 ) return (*cmpdl)(n,d1,d2); |
|
} |
|
if ( dpm_base_ordtype == 1 ) { |
|
if ( pos1 < pos2 ) return 1; |
|
else if ( pos1 > pos2 ) return -1; |
|
else return (*cmpdl)(n,d1,d2); |
|
} else { |
|
t = (*cmpdl)(n,d1,d2); |
|
if ( t ) return t; |
|
else if ( pos1 < pos2 ) return 1; |
|
else if ( pos1 > pos2 ) return -1; |
|
else return 0; |
|
} |
|
} |
|
|
|
extern int NaiveSchreyer; |
|
|
int compdmm(int n,DMM m1,DMM m2) |
int compdmm(int n,DMM m1,DMM m2) |
{ |
{ |
int t; |
int t,t1; |
|
int *base_ord; |
|
|
switch ( dpm_ordtype ) { |
switch ( dpm_ordtype ) { |
case 0: /* TOP ord->pos */ |
case 0: /* TOP ord->pos */ |
Line 3055 int compdmm(int n,DMM m1,DMM m2) |
|
Line 3357 int compdmm(int n,DMM m1,DMM m2) |
|
else if ( m1->pos > m2->pos ) return -1; |
else if ( m1->pos > m2->pos ) return -1; |
else return (*cmpdl)(n,m1->dl,m2->dl); |
else return (*cmpdl)(n,m1->dl,m2->dl); |
case 3: /* Schreyer */ |
case 3: /* Schreyer */ |
return compdmm_schreyer(n,m1,m2); |
if ( NaiveSchreyer ) |
|
t = compdmm_schreyer_old(n,m1,m2); |
|
else |
|
t = compdmm_schreyer(n,m1,m2); |
|
return t; |
|
case 4: /* POT with base_ord */ |
|
base_ord = dp_current_spec->module_base_ord; |
|
if ( base_ord[m1->pos] < base_ord[m2->pos] ) return 1; |
|
else if ( base_ord[m1->pos] > base_ord[m2->pos] ) return -1; |
|
else return (*cmpdl)(n,m1->dl,m2->dl); |
default: |
default: |
error("compdmm : invalid dpm_ordtype"); |
error("compdmm : invalid dpm_ordtype"); |
|
return 0; |
} |
} |
} |
} |
|
|
Line 3331 DPM dpm_eliminate_term(DPM a,DPM p,Obj c,int pos) |
|
Line 3643 DPM dpm_eliminate_term(DPM a,DPM p,Obj c,int pos) |
|
if ( m->pos == pos ) { |
if ( m->pos == pos ) { |
NEXTMP(d0,d); |
NEXTMP(d0,d); |
arf_chsgn(m->c,&d->c); |
arf_chsgn(m->c,&d->c); |
if ( !dp_current_spec || !dp_current_spec->module_rank ) |
if ( !dp_current_spec || !dp_current_spec->module_top_weight ) |
d->dl = m->dl; |
d->dl = m->dl; |
else { |
else { |
NEWDL(dl,NV(a)); |
NEWDL(dl,NV(a)); |
Line 3372 DPM dpm_compress(DPM p,int *tab) |
|
Line 3684 DPM dpm_compress(DPM p,int *tab) |
|
} |
} |
|
|
// input : s, s = syz(m) output simplified s, m |
// input : s, s = syz(m) output simplified s, m |
|
// assuming the term order is POT |
void dpm_simplify_syz(LIST s,LIST m,LIST *s1,LIST *m1,LIST *w1) |
void dpm_simplify_syz(LIST s,LIST m,LIST *s1,LIST *m1,LIST *w1) |
{ |
{ |
int lm,ls,i,j,k,pos,nv; |
int lm,ls,i,j,k,pos,nv; |
Line 3394 void dpm_simplify_syz(LIST s,LIST m,LIST *s1,LIST *m1, |
|
Line 3707 void dpm_simplify_syz(LIST s,LIST m,LIST *s1,LIST *m1, |
|
p = as[i]; |
p = as[i]; |
if ( p == 0 ) continue; |
if ( p == 0 ) continue; |
nv = NV(p); |
nv = NV(p); |
for ( d = BDY(p); d; d = NEXT(d) ) { |
for ( d = BDY(p); d; ) { |
dd = d->dl->d; |
dd = d->dl->d; |
for ( k = 0; k < nv; k++ ) if ( dd[k] ) break; |
for ( k = 0; k < nv; k++ ) if ( dd[k] ) break; |
if ( k == nv ) break; |
if ( k == nv ) break; |
|
pos = d->pos; |
|
while ( d && d->pos == pos ) d = NEXT(d); |
} |
} |
if ( d ) { |
if ( d ) { |
c = d->c; pos = d->pos; |
c = d->c; pos = d->pos; |
Line 3426 void dpm_simplify_syz(LIST s,LIST m,LIST *s1,LIST *m1, |
|
Line 3741 void dpm_simplify_syz(LIST s,LIST m,LIST *s1,LIST *m1, |
|
} |
} |
MKLIST(*s1,t); |
MKLIST(*s1,t); |
|
|
if ( dp_current_spec && dp_current_spec->module_rank ) { |
if ( dp_current_spec && dp_current_spec->module_top_weight ) { |
new_w = (int *)MALLOC(j*sizeof(int)); |
new_w = (int *)MALLOC(j*sizeof(int)); |
for ( j = 0, i = 1; i <= lm; i++ ) |
for ( j = 0, i = 1; i <= lm; i++ ) |
if ( tab[i] ) { new_w[j++] = dp_current_spec->module_top_weight[i-1]; } |
if ( tab[i] ) { new_w[j++] = dp_current_spec->module_top_weight[i-1]; } |