version 1.6, 2019/09/05 08:49:43 |
version 1.9, 2019/09/19 06:29:47 |
|
|
* 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.5 2019/09/04 05:32:10 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2018/engine/dist.c,v 1.8 2019/09/13 02:04:42 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
|
|
Line 333 void nodetod(NODE node,DP *dp) |
|
Line 333 void nodetod(NODE node,DP *dp) |
|
void nodetodpm(NODE node,Obj pos,DPM *dp) |
void nodetodpm(NODE node,Obj pos,DPM *dp) |
{ |
{ |
NODE t; |
NODE t; |
int len,i,td; |
int len,i,td,p; |
Q e; |
Q e; |
DL d; |
DL d; |
DMM m; |
DMM m; |
Line 352 void nodetodpm(NODE node,Obj pos,DPM *dp) |
|
Line 352 void nodetodpm(NODE node,Obj pos,DPM *dp) |
|
} |
} |
} |
} |
d->td = td; |
d->td = td; |
NEWDMM(m); m->dl = d; m->pos = ZTOS((Q)pos); C(m) = (Obj)ONE; NEXT(m) = 0; |
p = ZTOS((Q)pos); |
|
if ( dp_current_spec->module_rank ) { |
|
if ( p > dp_current_spec->module_rank ) |
|
error("nodetodpm : inconsistent order spec"); |
|
d->td += dp_current_spec->module_top_weight[p-1]; |
|
} |
|
NEWDMM(m); m->dl = d; m->pos = p; C(m) = (Obj)ONE; NEXT(m) = 0; |
MKDPM(len,m,u); u->sugar = td; *dp = u; |
MKDPM(len,m,u); u->sugar = td; *dp = u; |
} |
} |
|
|
Line 360 void dtodpm(DP d,int pos,DPM *dp) |
|
Line 366 void dtodpm(DP d,int pos,DPM *dp) |
|
{ |
{ |
DMM mr0,mr; |
DMM mr0,mr; |
MP m; |
MP m; |
|
int shift; |
|
|
if ( !d ) *dp = 0; |
if ( !d ) *dp = 0; |
else { |
else { |
|
shift = 0; |
|
if ( dp_current_spec->module_rank ) { |
|
if ( pos > dp_current_spec->module_rank ) |
|
error("nodetodpm : inconsistent order spec"); |
|
shift = dp_current_spec->module_top_weight[pos-1]; |
|
} |
for ( m = BDY(d), mr0 = 0; m; m = NEXT(m) ) { |
for ( m = BDY(d), mr0 = 0; m; m = NEXT(m) ) { |
NEXTDMM(mr0,mr); |
NEXTDMM(mr0,mr); |
mr->dl = m->dl; |
mr->dl = m->dl; |
|
mr->dl->td += shift; |
mr->pos = pos; |
mr->pos = pos; |
C(mr) = C(m); |
C(mr) = C(m); |
} |
} |
Line 2635 NBP harmonic_mul_nbm(NBM a,NBM b) |
|
Line 2649 NBP harmonic_mul_nbm(NBM a,NBM b) |
|
/* DPM functions */ |
/* DPM functions */ |
|
|
DMMstack dmm_stack; |
DMMstack dmm_stack; |
|
int dpm_base_ordtype;; |
|
|
void push_schreyer_order(LIST data) |
DMMstack push_schreyer_order(LIST data,DMMstack stack) |
{ |
{ |
DMMstack t; |
DMMstack t; |
int len,i; |
int len,i; |
NODE in; |
NODE in,t1; |
|
LIST l; |
|
|
/* data = [DPM,...,DPM] */ |
/* data = [DPM,...,DPM] */ |
|
if ( !dmm_stack && ( !dp_current_spec || dp_current_spec->id < 256 ) ) |
|
error("push_schreyer_order : base module order is not set"); |
in = BDY(data); |
in = BDY(data); |
len = length(in); |
len = length(in); |
NEWDMMstack(t); |
NEWDMMstack(t); |
t->rank = len; |
t->rank = len; |
t->in = (DMM *)MALLOC((len+1)*sizeof(DMM)); |
t->in = (DMM *)MALLOC((len+1)*sizeof(DMM)); |
t->ordtype = 0; |
if ( stack ) { |
|
MKNODE(t1,data,BDY(stack->obj)); MKLIST(l,t1); t->obj = l; |
|
} else { |
|
MKNODE(t1,data,0); MKLIST(l,t1); t->obj = l; |
|
} |
for ( i = 1; i <= len; i++, in = NEXT(in) ) { |
for ( i = 1; i <= len; i++, in = NEXT(in) ) { |
t->in[i] = BDY((DPM)BDY(in)); |
t->in[i] = BDY((DPM)BDY(in)); |
} |
} |
t->next = dmm_stack; |
t->next = stack;; |
dmm_stack = t; |
dpm_ordtype = 3; |
dpm_ordtype = 2; |
return t; |
} |
} |
|
|
|
|
// data=[Ink,...,In0] |
// data=[Ink,...,In0] |
// Ini = a list of module monomials |
// Ini = a list of module monomials |
|
|
Line 2670 void set_schreyer_order(LIST data) |
|
Line 2691 void set_schreyer_order(LIST data) |
|
if ( !data ) { |
if ( !data ) { |
dmm_stack = 0; |
dmm_stack = 0; |
if ( dp_current_spec && dp_current_spec->id >= 256 ) |
if ( dp_current_spec && dp_current_spec->id >= 256 ) |
dpm_ordtype = dp_current_spec->ispot; |
dpm_ordtype = dp_current_spec->module_ordtype; |
else |
else |
dpm_ordtype = 0; |
dpm_ordtype = 0; |
return; |
return; |
} else { |
} else { |
|
if ( !dp_current_spec || dp_current_spec->id < 256 ) |
|
error("set_schreyer_order : base module order is not set"); |
dmm_stack = 0; |
dmm_stack = 0; |
|
dpm_base_ordtype = dp_current_spec->module_ordtype; |
in = BDY(data); |
in = BDY(data); |
len = length(in); |
len = length(in); |
w = (LIST *)MALLOC(len*sizeof(LIST)); |
w = (LIST *)MALLOC(len*sizeof(LIST)); |
for ( i = 0; i < len; i++, in = NEXT(in) ) w[i] = (LIST)BDY(in); |
for ( i = 0; i < len; i++, in = NEXT(in) ) w[i] = (LIST)BDY(in); |
for ( i = len-1; i >= 0; i-- ) push_schreyer_order(w[i]); |
for ( i = len-1; i >= 0; i-- ) dmm_stack = push_schreyer_order(w[i],dmm_stack); |
dpm_ordtype = 2; |
|
} |
} |
} |
} |
|
|
Line 2714 NODE dpm_reduceall(NODE in) |
|
Line 2737 NODE dpm_reduceall(NODE in) |
|
for ( i = 0, t = in; i < n; i++, t = NEXT(t) ) ps[i] = BDY(t); |
for ( i = 0, t = in; i < n; i++, t = NEXT(t) ) ps[i] = BDY(t); |
for ( i = 0; i < n; i++ ) { |
for ( i = 0; i < n; i++ ) { |
g = ps[i]; ps[i] = 0; |
g = ps[i]; ps[i] = 0; |
dpm_nf_z(0,g,psv,1,DP_Multiple,&r); |
// dpm_nf_z(0,g,psv,1,DP_Multiple,&ps[i]); |
ps[i] = r; |
dpm_nf_z(0,g,psv,1,0,&ps[i]); |
} |
} |
t = 0; |
t = 0; |
for ( i = n-1; i >= 0; i-- ) { |
for ( i = n-1; i >= 0; i-- ) { |
Line 2725 NODE dpm_reduceall(NODE in) |
|
Line 2748 NODE dpm_reduceall(NODE in) |
|
return t; |
return t; |
} |
} |
|
|
|
struct oEGT egra; |
|
|
|
void dpm_ht(DPM d,DPM *r); |
|
|
void dpm_schreyer_base(LIST g,LIST *s) |
void dpm_schreyer_base(LIST g,LIST *s) |
{ |
{ |
NODE nd,t,b0,b; |
NODE nd,t0,t,b0,b; |
int n,i,j,k,nv; |
int n,i,j,k,nv; |
|
LIST l; |
Z cont; |
Z cont; |
P dn,c; |
P dn,c; |
DP h,t1,t2; |
DP h,t1,t2; |
Line 2738 void dpm_schreyer_base(LIST g,LIST *s) |
|
Line 2766 void dpm_schreyer_base(LIST g,LIST *s) |
|
DPM *ps; |
DPM *ps; |
VECT psv; |
VECT psv; |
DP **m,*quo; |
DP **m,*quo; |
struct oEGT eg_nf,eg0,eg1; |
struct oEGT eg0,eg1; |
extern struct oEGT egc,egcomp; |
extern struct oEGT egred; |
|
|
// init_eg(&eg_nf); |
init_eg(&egra); |
// init_eg(&egcomp); |
|
nd = BDY(g); |
nd = BDY(g); |
n = length(nd); |
n = length(nd); |
MKVECT(psv,n); |
MKVECT(psv,n); |
Line 2751 void dpm_schreyer_base(LIST g,LIST *s) |
|
Line 2778 void dpm_schreyer_base(LIST g,LIST *s) |
|
nv = ps[0]->nv; |
nv = ps[0]->nv; |
m = (DP **)almat_pointer(n,n); |
m = (DP **)almat_pointer(n,n); |
b0 = 0; |
b0 = 0; |
// init_eg(&egc); |
|
for ( i = 0; i < n; i++ ) { |
for ( i = 0; i < n; i++ ) { |
// sp(ps[i],ps[j]) = ti*ps[i]-tj*ps[j] => m[i][j] = ti |
// sp(ps[i],ps[j]) = ti*ps[i]-tj*ps[j] => m[i][j] = ti |
for ( j = i+1; j < n; j++ ) m[i][j] = dpm_sp_hm(ps[i],ps[j]); |
for ( j = i+1; j < n; j++ ) m[i][j] = dpm_sp_hm(ps[i],ps[j]); |
for ( j = i+1; j < n; j++ ) { |
for ( j = i+1; j < n; j++ ) { |
// for ( j = n-1; j > i; j-- ) { |
|
if ( !m[i][j] ) continue; |
if ( !m[i][j] ) continue; |
for ( h = m[i][j], k = i+1; k < n; k++ ) |
for ( h = m[i][j], k = i+1; k < n; k++ ) |
if ( k != j && m[i][k] && dp_redble(m[i][k],h) ) m[i][k] = 0; |
if ( k != j && m[i][k] && dp_redble(m[i][k],h) ) m[i][k] = 0; |
Line 2764 void dpm_schreyer_base(LIST g,LIST *s) |
|
Line 2789 void dpm_schreyer_base(LIST g,LIST *s) |
|
for ( j = i+1; j < n; j++ ) { |
for ( j = i+1; j < n; j++ ) { |
if ( m[i][j] ) { |
if ( m[i][j] ) { |
dpm_sp(ps[i],ps[j],&sp,&t1,&t2); |
dpm_sp(ps[i],ps[j],&sp,&t1,&t2); |
// get_eg(&eg0); |
|
quo = dpm_nf_and_quotient(0,sp,psv,&nf,&dn); |
quo = dpm_nf_and_quotient(0,sp,psv,&nf,&dn); |
// get_eg(&eg1); add_eg(&eg_nf,&eg0,&eg1); |
|
if ( nf ) |
if ( nf ) |
error("dpm_schreyer_base : cannot happen"); |
error("dpm_schreyer_base : cannot happen"); |
NEWDMM(r0); r = r0; |
NEWDMM(r0); r = r0; |
Line 2789 void dpm_schreyer_base(LIST g,LIST *s) |
|
Line 2812 void dpm_schreyer_base(LIST g,LIST *s) |
|
} |
} |
if ( b0 ) NEXT(b) = 0; |
if ( b0 ) NEXT(b) = 0; |
} |
} |
push_schreyer_order(g); |
for ( t0 = t, 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); |
for ( t = b0; t; t = NEXT(t) ) { |
for ( t = b0; t; t = NEXT(t) ) { |
dpm_sort((DPM)BDY(t),&dpm); |
dpm_sort((DPM)BDY(t),&dpm); |
BDY(t) = (pointer)dpm; |
BDY(t) = (pointer)dpm; |
} |
} |
b0 = dpm_sort_list(b0); |
b0 = dpm_sort_list(b0); |
// b0 = dpm_reduceall(b0); |
// get_eg(&eg0); |
|
b0 = dpm_reduceall(b0); |
|
// get_eg(&eg1); add_eg(&egra,&eg0,&eg1); print_eg("RA",&egra); |
MKLIST(*s,b0); |
MKLIST(*s,b0); |
// print_eg("nf",&eg_nf); printf("\n"); |
// print_eg("red",&egred); printf("\n"); |
// print_eg("coef",&egc); printf("\n"); |
|
} |
} |
|
|
int compdmm_schreyer(int n,DMM m1,DMM m2) |
int compdmm_schreyer(int n,DMM m1,DMM m2) |
Line 2831 int compdmm_schreyer(int n,DMM m1,DMM m2) |
|
Line 2860 int compdmm_schreyer(int n,DMM m1,DMM m2) |
|
} |
} |
// comparison by the bottom order |
// comparison by the bottom order |
LAST: |
LAST: |
if ( dpm_ordtype == 1 ) { |
if ( dpm_base_ordtype == 1 ) { |
if ( pos1 < pos2 ) return 1; |
if ( pos1 < pos2 ) return 1; |
else if ( pos1 > pos2 ) return -1; |
else if ( pos1 > pos2 ) return -1; |
else return (*cmpdl)(n,d1,d2); |
else return (*cmpdl)(n,d1,d2); |
|
|
} |
} |
} |
} |
|
|
#if 1 |
|
int compdmm(int n,DMM m1,DMM m2) |
int compdmm(int n,DMM m1,DMM m2) |
{ |
{ |
int t; |
int t; |
|
|
switch ( dpm_ordtype ) { |
switch ( dpm_ordtype ) { |
case 0: |
case 0: /* TOP ord->pos */ |
t = (*cmpdl)(n,m1->dl,m2->dl); |
t = (*cmpdl)(n,m1->dl,m2->dl); |
if ( t ) return t; |
if ( t ) return t; |
else if ( m1->pos < m2->pos ) return 1; |
else if ( m1->pos < m2->pos ) return 1; |
else if ( m1->pos > m2->pos ) return -1; |
else if ( m1->pos > m2->pos ) return -1; |
else return 0; |
else return 0; |
case 1: |
case 1: /* POT : pos->ord */ |
if ( m1->pos < m2->pos ) return 1; |
if ( m1->pos < m2->pos ) return 1; |
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 2: |
case 2: /* wPOT: weight->pos->ord */ |
|
if ( m1->dl->td > m2->dl->td ) return 1; |
|
else if ( m1->dl->td < m2->dl->td ) return 1; |
|
else if ( m1->pos < m2->pos ) return 1; |
|
else if ( m1->pos > m2->pos ) return -1; |
|
else return (*cmpdl)(n,m1->dl,m2->dl); |
|
case 3: /* Schreyer */ |
return compdmm_schreyer(n,m1,m2); |
return compdmm_schreyer(n,m1,m2); |
default: |
default: |
error("compdmm : invalid dpm_ordtype"); |
error("compdmm : invalid dpm_ordtype"); |
} |
} |
} |
} |
#else |
|
int compdmm(int n,DMM m1,DMM m2) |
|
{ |
|
int t; |
|
|
|
if ( dpm_ordtype == 1 ) { |
|
if ( m1->pos < m2->pos ) return 1; |
|
else if ( m1->pos > m2->pos ) return -1; |
|
else return (*cmpdl)(n,m1->dl,m2->dl); |
|
} else if ( dpm_ordtype == 0 ) { |
|
t = (*cmpdl)(n,m1->dl,m2->dl); |
|
if ( t ) return t; |
|
else if ( m1->pos < m2->pos ) return 1; |
|
else if ( m1->pos > m2->pos ) return -1; |
|
else return 0; |
|
} else if ( dpm_ordtype == 2 ) { |
|
return compdmm_schreyer(n,m1,m2); |
|
} |
|
} |
|
#endif |
|
|
|
void adddpm(VL vl,DPM p1,DPM p2,DPM *pr) |
void adddpm(VL vl,DPM p1,DPM p2,DPM *pr) |
{ |
{ |
int n,s; |
int n,s; |
Line 2965 void chsgndpm(DPM p,DPM *pr) |
|
Line 2979 void chsgndpm(DPM p,DPM *pr) |
|
} |
} |
} |
} |
|
|
|
void mulcmp(Obj c,MP m) |
|
{ |
|
MP t; |
|
Obj c1; |
|
|
|
for ( t = m; t; t = NEXT(t) ) { |
|
arf_mul(CO,c,C(t),&c1); C(t) = c1; |
|
} |
|
} |
|
|
|
void mulcdmm(Obj c,DMM m) |
|
{ |
|
DMM t; |
|
Obj c1; |
|
|
|
for ( t = m; t; t = NEXT(t) ) { |
|
arf_mul(CO,c,C(t),&c1); C(t) = c1; |
|
} |
|
} |
|
|
void mulcdpm(VL vl,Obj c,DPM p,DPM *pr) |
void mulcdpm(VL vl,Obj c,DPM p,DPM *pr) |
{ |
{ |
DMM m,mr=0,mr0; |
DMM m,mr=0,mr0; |
Line 3166 DPM dpm_compress(DPM p,int *tab) |
|
Line 3200 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 |
void dpm_simplify_syz(LIST s,LIST m,LIST *s1,LIST *m1) |
void dpm_simplify_syz(LIST s,LIST m,LIST *s1,LIST *m1) |
{ |
{ |
int lm,ls,i,j,pos; |
int lm,ls,i,j,k,pos,nv; |
DPM *am,*as; |
DPM *am,*as; |
DPM p; |
DPM p; |
DMM d; |
DMM d; |
Obj c; |
Obj c; |
int *tab; |
int *tab,*dd; |
NODE t,t1; |
NODE t,t1; |
|
|
lm = length(BDY(m)); |
lm = length(BDY(m)); |
Line 3184 void dpm_simplify_syz(LIST s,LIST m,LIST *s1,LIST *m1) |
|
Line 3218 void dpm_simplify_syz(LIST s,LIST m,LIST *s1,LIST *m1) |
|
for ( i = 0; i < ls; i++ ) { |
for ( i = 0; i < ls; i++ ) { |
p = as[i]; |
p = as[i]; |
if ( p == 0 ) continue; |
if ( p == 0 ) continue; |
for ( d = BDY(p); d; d = NEXT(d) ) if ( d->dl->td == 0 ) break; |
nv = NV(p); |
|
for ( d = BDY(p); d; d = NEXT(d) ) { |
|
dd = d->dl->d; |
|
for ( k = 0; k < nv; k++ ) if ( dd[k] ) break; |
|
if ( k == nv ) break; |
|
} |
if ( d ) { |
if ( d ) { |
c = d->c; pos = d->pos; |
c = d->c; pos = d->pos; |
for ( j = 0; j < ls; j++ ) |
for ( j = 0; j < ls; j++ ) |