version 1.4, 2019/09/04 01:12:02 |
version 1.7, 2019/09/06 00:11: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.3 2019/08/21 00:37:47 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2018/engine/dist.c,v 1.6 2019/09/05 08:49:43 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
|
|
Line 2635 NBP harmonic_mul_nbm(NBM a,NBM b) |
|
Line 2635 NBP harmonic_mul_nbm(NBM a,NBM b) |
|
/* DPM functions */ |
/* DPM functions */ |
|
|
DMMstack dmm_stack; |
DMMstack dmm_stack; |
|
extern LIST schreyer_obj; |
|
|
void push_schreyer_order(LIST data) |
void push_schreyer_order(LIST data) |
{ |
{ |
DMMstack t; |
DMMstack t; |
int len,i; |
int len,i; |
NODE in; |
NODE in,t1; |
|
|
/* data = [DPM,...,DPM] */ |
/* data = [DPM,...,DPM] */ |
in = BDY(data); |
in = BDY(data); |
Line 2655 void push_schreyer_order(LIST data) |
|
Line 2656 void push_schreyer_order(LIST data) |
|
t->next = dmm_stack; |
t->next = dmm_stack; |
dmm_stack = t; |
dmm_stack = t; |
dpm_ordtype = 2; |
dpm_ordtype = 2; |
|
MKNODE(t1,data,schreyer_obj?BDY(schreyer_obj):0); |
|
MKLIST(schreyer_obj,t1); |
} |
} |
|
|
|
|
// data=[Ink,...,In0] |
// data=[Ink,...,In0] |
// Ini = a list of module monomials |
// Ini = a list of module monomials |
|
|
Line 3119 int compdpm(VL vl,DPM p1,DPM p2) |
|
Line 3121 int compdpm(VL vl,DPM p1,DPM p2) |
|
} |
} |
} |
} |
|
|
|
// p = ...+c*<<0,...0:pos>>+... |
|
DPM dpm_eliminate_term(DPM a,DPM p,Obj c,int pos) |
|
{ |
|
MP d0,d; |
|
DMM m; |
|
DP f; |
|
DPM a1,p1,r; |
|
|
|
if ( !a ) return 0; |
|
d0 = 0; |
|
for ( m = BDY(a); m; m = NEXT(m) ) |
|
if ( m->pos == pos ) { |
|
NEXTMP(d0,d); d->dl = m->dl; arf_chsgn(m->c,&d->c); |
|
} |
|
if ( d0 ) { |
|
NEXT(d) = 0; MKDP(NV(a),d0,f); |
|
mulcdpm(CO,c,a,&a1); |
|
mulobjdpm(CO,(Obj)f,p,&p1); |
|
adddpm(CO,a1,p1,&r); |
|
return r; |
|
} else |
|
return a; |
|
} |
|
|
|
// <<...:i>> -> <<...:tab[i]>> |
|
DPM dpm_compress(DPM p,int *tab) |
|
{ |
|
DMM m,mr0,mr; |
|
DPM t; |
|
|
|
if ( !p ) return 0; |
|
else { |
|
for ( m = BDY(p), mr0 = 0; m; m = NEXT(m) ) { |
|
NEXTDMM(mr0,mr); |
|
mr->dl = m->dl; mr->c = m->c; mr->pos = tab[m->pos]; |
|
if ( mr->pos <= 0 ) |
|
error("dpm_compress : invalid position"); |
|
} |
|
NEXT(mr) = 0; |
|
MKDPM(p->nv,mr0,t); t->sugar = p->sugar; |
|
return t; |
|
} |
|
} |
|
|
|
// input : s, s = syz(m) output simplified s, m |
|
void dpm_simplify_syz(LIST s,LIST m,LIST *s1,LIST *m1) |
|
{ |
|
int lm,ls,i,j,pos; |
|
DPM *am,*as; |
|
DPM p; |
|
DMM d; |
|
Obj c; |
|
int *tab; |
|
NODE t,t1; |
|
|
|
lm = length(BDY(m)); |
|
am = (DPM *)MALLOC((lm+1)*sizeof(DPM)); |
|
ls = length(BDY(s)); |
|
as = (DPM *)MALLOC(ls*sizeof(DPM)); |
|
for ( i = 1, t = BDY(m); i <= lm; i++, t = NEXT(t) ) am[i] = (DPM)BDY(t); |
|
for ( i = 0, t = BDY(s); i < ls; i++, t = NEXT(t) ) as[i] = (DPM)BDY(t); |
|
|
|
for ( i = 0; i < ls; i++ ) { |
|
p = as[i]; |
|
if ( p == 0 ) continue; |
|
for ( d = BDY(p); d; d = NEXT(d) ) if ( d->dl->td == 0 ) break; |
|
if ( d ) { |
|
c = d->c; pos = d->pos; |
|
for ( j = 0; j < ls; j++ ) |
|
if ( j != i ) { |
|
as[j] = dpm_eliminate_term(as[j],p,c,pos); |
|
} |
|
// remove m[i] |
|
am[pos] = 0; |
|
as[i] = 0; |
|
} |
|
} |
|
// compress s |
|
// create index table from am[] |
|
// (0 0 * 0 * ...) -> (0 0 1 0 2 ... ) which means 2->1, 4->2, ... |
|
tab = (int *)MALLOC((lm+1)*sizeof(int)); |
|
for ( j = 0, i = 1; i <= lm; i++ ) { |
|
if ( am[i] ) { j++; tab[i] = j; } |
|
else tab[i] = 0; |
|
} |
|
t = 0; |
|
for ( i = ls-1; i >= 0; i-- ) |
|
if ( as[i] ) { |
|
p = dpm_compress(as[i],tab); |
|
MKNODE(t1,(pointer)p,t); t = t1; |
|
} |
|
MKLIST(*s1,t); |
|
t = 0; |
|
for ( i = lm; i >= 1; i-- ) |
|
if ( am[i] ) { |
|
MKNODE(t1,(pointer)am[i],t); t = t1; |
|
} |
|
MKLIST(*m1,t); |
|
} |