version 1.16, 2019/11/21 01:54:01 |
version 1.19, 2019/12/27 08:13:59 |
|
|
* 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.18 2019/12/12 04:44:59 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
|
|
Line 353 void nodetodpm(NODE node,Obj pos,DPM *dp) |
|
Line 353 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 371 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 2750 void dpm_sp(DPM p1,DPM p2,DPM *sp,DP *t1,DP *t2); |
|
Line 2750 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); |
|
|
Line 2861 void dpm_schreyer_base(LIST g,LIST *s) |
|
Line 2862 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 2877 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; |
|
|
|
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; |
|
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) |
DMMstack_array dpm_schreyer_frame(NODE g) |
{ |
{ |
LIST l; |
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 3079 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++; |
Line 2938 DMMstack_array dpm_schreyer_frame(NODE g) |
|
Line 3102 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 3122 DMMstack_array dpm_schreyer_frame(NODE g) |
|
} |
} |
if ( h ) m[p2] = h; |
if ( h ) m[p2] = h; |
} |
} |
|
#if 0 |
|
// compress m to m2 |
|
for ( j = 0, n2 = NEXT(n1); n2; n2 = NEXT(n2) ) { |
|
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); |
|
NEXTNODE(b0,b); BDY(b) = (pointer)dpm; |
|
} |
|
#else |
for ( n2 = NEXT(n1); n2; n2 = NEXT(n2) ) { |
for ( n2 = NEXT(n1); n2; n2 = NEXT(n2) ) { |
p2 = (long)BDY(n2); |
p2 = (long)BDY(n2); |
if ( m[p2] ) { |
if ( m[p2] ) { |
Line 2965 DMMstack_array dpm_schreyer_frame(NODE g) |
|
Line 3143 DMMstack_array dpm_schreyer_frame(NODE g) |
|
NEXTNODE(b0,b); BDY(b) = (pointer)dpm; |
NEXTNODE(b0,b); BDY(b) = (pointer)dpm; |
} |
} |
} |
} |
|
#endif |
} |
} |
} |
} |
if ( !b0 ) { |
if ( !b0 ) { |
Line 3036 int compdmm_schreyer(int n,DMM m1,DMM m2) |
|
Line 3215 int compdmm_schreyer(int n,DMM m1,DMM m2) |
|
int compdmm(int n,DMM m1,DMM m2) |
int compdmm(int n,DMM m1,DMM m2) |
{ |
{ |
int t; |
int t; |
|
int *base_ord; |
|
|
switch ( dpm_ordtype ) { |
switch ( dpm_ordtype ) { |
case 0: /* TOP ord->pos */ |
case 0: /* TOP ord->pos */ |
Line 3056 int compdmm(int n,DMM m1,DMM m2) |
|
Line 3236 int compdmm(int n,DMM m1,DMM m2) |
|
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); |
return compdmm_schreyer(n,m1,m2); |
|
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"); |
} |
} |
Line 3331 DPM dpm_eliminate_term(DPM a,DPM p,Obj c,int pos) |
|
Line 3516 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 3426 void dpm_simplify_syz(LIST s,LIST m,LIST *s1,LIST *m1, |
|
Line 3611 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]; } |