version 1.1, 2018/09/19 05:45:05 |
version 1.4, 2019/09/04 01:12:02 |
|
|
* 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: OpenXM_contrib2/asir2018/builtin/dp-supp.c,v 1.3 2019/08/21 00:37:47 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "base.h" |
#include "base.h" |
Line 147 void dp_ptozp2(DP p0,DP p1,DP *hp,DP *rp) |
|
Line 147 void dp_ptozp2(DP p0,DP p1,DP *hp,DP *rp) |
|
*hp = h; *rp = r; |
*hp = h; *rp = r; |
} |
} |
|
|
void dpm_ptozp(DPM p,DPM *rp) |
void dpm_ptozp(DPM p,Z *cont,DPM *rp) |
{ |
{ |
DMM m,mr,mr0; |
DMM m,mr,mr0; |
int i,n; |
int i,n; |
Line 155 void dpm_ptozp(DPM p,DPM *rp) |
|
Line 155 void dpm_ptozp(DPM p,DPM *rp) |
|
Z dvr; |
Z dvr; |
P t; |
P t; |
|
|
if ( !p ) |
if ( !p ) { |
*rp = 0; |
*rp = 0; *cont = ONE; |
else { |
} else { |
for ( m =BDY(p), n = 0; m; m = NEXT(m), n++ ); |
for ( m =BDY(p), n = 0; m; m = NEXT(m), n++ ); |
w = (Q *)ALLOCA(n*sizeof(Q)); |
w = (Q *)ALLOCA(n*sizeof(Q)); |
for ( m =BDY(p), i = 0; i < n; m = NEXT(m), i++ ) |
for ( m =BDY(p), i = 0; i < n; m = NEXT(m), i++ ) |
Line 171 void dpm_ptozp(DPM p,DPM *rp) |
|
Line 171 void dpm_ptozp(DPM p,DPM *rp) |
|
NEXTDMM(mr0,mr); divsp(CO,(P)m->c,(P)dvr,(P *)&mr->c); mr->dl = m->dl; mr->pos = m->pos; |
NEXTDMM(mr0,mr); divsp(CO,(P)m->c,(P)dvr,(P *)&mr->c); mr->dl = m->dl; mr->pos = m->pos; |
} |
} |
NEXT(mr) = 0; MKDPM(p->nv,mr0,*rp); (*rp)->sugar = p->sugar; |
NEXT(mr) = 0; MKDPM(p->nv,mr0,*rp); (*rp)->sugar = p->sugar; |
|
*cont = dvr; |
} |
} |
} |
} |
|
|
Line 178 void dpm_ptozp2(DPM p0,DPM p1,DPM *hp,DPM *rp) |
|
Line 179 void dpm_ptozp2(DPM p0,DPM p1,DPM *hp,DPM *rp) |
|
{ |
{ |
DPM t,s,h,r; |
DPM t,s,h,r; |
DMM m,mr,mr0,m0; |
DMM m,mr,mr0,m0; |
|
Z cont; |
|
|
adddpm(CO,p0,p1,&t); dpm_ptozp(t,&s); |
adddpm(CO,p0,p1,&t); dpm_ptozp(t,&cont,&s); |
if ( !p0 ) { |
if ( !p0 ) { |
h = 0; r = s; |
h = 0; r = s; |
} else if ( !p1 ) { |
} else if ( !p1 ) { |
Line 238 void dp_idiv(DP p,Z c,DP *rp) |
|
Line 240 void dp_idiv(DP p,Z c,DP *rp) |
|
else { |
else { |
for ( mr0 = 0, m = BDY(p); m; m = NEXT(m) ) { |
for ( mr0 = 0, m = BDY(p); m; m = NEXT(m) ) { |
NEXTMP(mr0,mr); |
NEXTMP(mr0,mr); |
divz((Z)(m->c),c,(Z *)&mr->c); |
divsz((Z)(m->c),c,(Z *)&mr->c); |
mr->dl = m->dl; |
mr->dl = m->dl; |
} |
} |
NEXT(mr) = 0; MKDP(p->nv,mr0,*rp); |
NEXT(mr) = 0; MKDP(p->nv,mr0,*rp); |
Line 475 void heu_nezgcdnpz(VL vl,P *pl,int m,P *pr) |
|
Line 477 void heu_nezgcdnpz(VL vl,P *pl,int m,P *pr) |
|
|
|
while ( 1 ) { |
while ( 1 ) { |
for ( i = 0, s1 = 0; i < m; i++ ) { |
for ( i = 0, s1 = 0; i < m; i++ ) { |
r = random(); UTOQ(r,rq); |
r = random(); UTOZ(r,rq); |
mulp(vl,pl[i],(P)rq,&t); addp(vl,s1,t,&u); s1 = u; |
mulp(vl,pl[i],(P)rq,&t); addp(vl,s1,t,&u); s1 = u; |
} |
} |
for ( i = 0, s2 = 0; i < m; i++ ) { |
for ( i = 0, s2 = 0; i < m; i++ ) { |
r = random(); UTOQ(r,rq); |
r = random(); UTOZ(r,rq); |
mulp(vl,pl[i],(P)rq,&t); addp(vl,s2,t,&u); s2 = u; |
mulp(vl,pl[i],(P)rq,&t); addp(vl,s2,t,&u); s2 = u; |
} |
} |
ezgcdp(vl,s1,s2,&gcd); |
ezgcdp(vl,s1,s2,&gcd); |
Line 565 void dp_sp(DP p1,DP p2,DP *rp) |
|
Line 567 void dp_sp(DP p1,DP p2,DP *rp) |
|
if ( INT(c1) && INT(c2) ) { |
if ( INT(c1) && INT(c2) ) { |
gcdz(c1,c2,&gn); |
gcdz(c1,c2,&gn); |
if ( !UNIQ(gn) ) { |
if ( !UNIQ(gn) ) { |
divz(c1,gn,&c); c1 = c; |
divsz(c1,gn,&c); c1 = c; |
divz(c2,gn,&c);c2 = c; |
divsz(c2,gn,&c);c2 = c; |
} |
} |
} |
} |
|
|
Line 595 void dp_sp(DP p1,DP p2,DP *rp) |
|
Line 597 void dp_sp(DP p1,DP p2,DP *rp) |
|
} |
} |
} |
} |
|
|
void dpm_sp(DPM p1,DPM p2,DPM *rp) |
void dpm_sp(DPM p1,DPM p2,DPM *rp,DP *mul1,DP *mul2) |
{ |
{ |
int i,n,td; |
int i,n,td; |
int *w; |
int *w; |
Line 608 void dpm_sp(DPM p1,DPM p2,DPM *rp) |
|
Line 610 void dpm_sp(DPM p1,DPM p2,DPM *rp) |
|
|
|
n = p1->nv; d1 = BDY(p1)->dl; d2 = BDY(p2)->dl; |
n = p1->nv; d1 = BDY(p1)->dl; d2 = BDY(p2)->dl; |
if ( BDY(p1)->pos != BDY(p2)->pos ) { |
if ( BDY(p1)->pos != BDY(p2)->pos ) { |
*rp = 0; |
*mul1 = 0; *mul2 = 0; *rp = 0; |
return; |
return; |
} |
} |
w = (int *)ALLOCA(n*sizeof(int)); |
w = (int *)ALLOCA(n*sizeof(int)); |
Line 623 void dpm_sp(DPM p1,DPM p2,DPM *rp) |
|
Line 625 void dpm_sp(DPM p1,DPM p2,DPM *rp) |
|
if ( INT(c1) && INT(c2) ) { |
if ( INT(c1) && INT(c2) ) { |
gcdz(c1,c2,&gn); |
gcdz(c1,c2,&gn); |
if ( !UNIQ(gn) ) { |
if ( !UNIQ(gn) ) { |
divz(c1,gn,&c); c1 = c; |
divsz(c1,gn,&c); c1 = c; |
divz(c2,gn,&c);c2 = c; |
divsz(c2,gn,&c);c2 = c; |
} |
} |
} |
} |
|
|
NEWMP(m); m->dl = d; m->c = (Obj)c2; NEXT(m) = 0; |
NEWMP(m); m->dl = d; m->c = (Obj)c2; NEXT(m) = 0; |
MKDP(n,m,s1); s1->sugar = d->td; mulobjdpm(CO,(Obj)s1,p1,&t); |
MKDP(n,m,s1); s1->sugar = d->td; mulobjdpm(CO,(Obj)s1,p1,&t); |
|
*mul1 = s1; |
|
|
NEWDL(d,n); d->td = td - d2->td; |
NEWDL(d,n); d->td = td - d2->td; |
for ( i = 0; i < n; i++ ) |
for ( i = 0; i < n; i++ ) |
d->d[i] = w[i] - d2->d[i]; |
d->d[i] = w[i] - d2->d[i]; |
NEWMP(m); m->dl = d; m->c = (Obj)c1; NEXT(m) = 0; |
NEWMP(m); m->dl = d; m->c = (Obj)c1; NEXT(m) = 0; |
MKDP(n,m,s2); s2->sugar = d->td; mulobjdpm(CO,(Obj)s2,p2,&u); |
MKDP(n,m,s2); s2->sugar = d->td; mulobjdpm(CO,(Obj)s2,p2,&u); |
|
*mul2 = s2; |
|
|
subdpm(CO,t,u,rp); |
subdpm(CO,t,u,rp); |
if ( GenTrace ) { |
if ( GenTrace ) { |
Line 653 void dpm_sp(DPM p1,DPM p2,DPM *rp) |
|
Line 657 void dpm_sp(DPM p1,DPM p2,DPM *rp) |
|
} |
} |
} |
} |
|
|
|
DP dpm_sp_hm(DPM p1,DPM p2) |
|
{ |
|
int i,n,td; |
|
int *w; |
|
DL d1,d2,d; |
|
MP m; |
|
DP s1; |
|
|
|
n = p1->nv; d1 = BDY(p1)->dl; d2 = BDY(p2)->dl; |
|
if ( BDY(p1)->pos != BDY(p2)->pos ) { |
|
return 0; |
|
} |
|
w = (int *)ALLOCA(n*sizeof(int)); |
|
for ( i = 0, td = 0; i < n; i++ ) { |
|
w[i] = MAX(d1->d[i],d2->d[i]); td += MUL_WEIGHT(w[i],i); |
|
} |
|
|
|
NEWDL(d,n); d->td = td - d1->td; |
|
for ( i = 0; i < n; i++ ) |
|
d->d[i] = w[i] - d1->d[i]; |
|
|
|
NEWMP(m); m->dl = d; m->c = (Obj)ONE; NEXT(m) = 0; |
|
MKDP(n,m,s1); s1->sugar = d->td; |
|
return s1; |
|
} |
|
|
void _dp_sp_dup(DP p1,DP p2,DP *rp) |
void _dp_sp_dup(DP p1,DP p2,DP *rp) |
{ |
{ |
int i,n,td; |
int i,n,td; |
Line 676 void _dp_sp_dup(DP p1,DP p2,DP *rp) |
|
Line 706 void _dp_sp_dup(DP p1,DP p2,DP *rp) |
|
if ( INT(c1) && INT(c2) ) { |
if ( INT(c1) && INT(c2) ) { |
gcdz(c1,c2,&gn); |
gcdz(c1,c2,&gn); |
if ( !UNIQ(gn) ) { |
if ( !UNIQ(gn) ) { |
divz(c1,gn,&c); c1 = c; |
divsz(c1,gn,&c); c1 = c; |
divz(c2,gn,&c);c2 = c; |
divsz(c2,gn,&c);c2 = c; |
} |
} |
} |
} |
|
|
Line 789 void _dp_sp_mod(DP p1,DP p2,int mod,DP *rp) |
|
Line 819 void _dp_sp_mod(DP p1,DP p2,int mod,DP *rp) |
|
* do content reduction over Z or Q(x,...) |
* do content reduction over Z or Q(x,...) |
* do nothing over finite fields |
* do nothing over finite fields |
* |
* |
|
* head+rest = dn*(p0+p1)+mult*p2 |
*/ |
*/ |
|
|
void dp_red(DP p0,DP p1,DP p2,DP *head,DP *rest,P *dnp,DP *multp) |
void dp_red(DP p0,DP p1,DP p2,DP *head,DP *rest,P *dnp,DP *multp) |
Line 815 void dp_red(DP p0,DP p1,DP p2,DP *head,DP *rest,P *dnp |
|
Line 846 void dp_red(DP p0,DP p1,DP p2,DP *head,DP *rest,P *dnp |
|
} else if ( INT(c1) && INT(c2) ) { |
} else if ( INT(c1) && INT(c2) ) { |
gcdz(c1,c2,&gn); |
gcdz(c1,c2,&gn); |
if ( !UNIQ(gn) ) { |
if ( !UNIQ(gn) ) { |
divz(c1,gn,&c); c1 = c; |
divsz(c1,gn,&c); c1 = c; |
divz(c2,gn,&c); c2 = c; |
divsz(c2,gn,&c); c2 = c; |
} |
} |
} else { |
} else { |
ezgcdpz(CO,(P)c1,(P)c2,&g); |
ezgcdpz(CO,(P)c1,(P)c2,&g); |
Line 830 void dp_red(DP p0,DP p1,DP p2,DP *head,DP *rest,P *dnp |
|
Line 861 void dp_red(DP p0,DP p1,DP p2,DP *head,DP *rest,P *dnp |
|
*head = h; *rest = r; *dnp = (P)c2; |
*head = h; *rest = r; *dnp = (P)c2; |
} |
} |
|
|
|
// head+rest = dn*(p0+p1)-mult*p2 |
void dpm_red(DPM p0,DPM p1,DPM p2,DPM *head,DPM *rest,P *dnp,DP *multp) |
void dpm_red(DPM p0,DPM p1,DPM p2,DPM *head,DPM *rest,P *dnp,DP *multp) |
{ |
{ |
int i,n,pos; |
int i,n,pos; |
DL d1,d2,d; |
DL d1,d2,d; |
MP m; |
MP m; |
DP s; |
DP s,ms; |
DPM t,r,h,u,w; |
DPM t,r,h,u,w; |
Z c,c1,c2,gn; |
Z c,c1,c2,gn; |
P g,a; |
P g,a; |
Line 857 void dpm_red(DPM p0,DPM p1,DPM p2,DPM *head,DPM *rest, |
|
Line 889 void dpm_red(DPM p0,DPM p1,DPM p2,DPM *head,DPM *rest, |
|
} else if ( INT(c1) && INT(c2) ) { |
} else if ( INT(c1) && INT(c2) ) { |
gcdz(c1,c2,&gn); |
gcdz(c1,c2,&gn); |
if ( !UNIQ(gn) ) { |
if ( !UNIQ(gn) ) { |
divz(c1,gn,&c); c1 = c; |
divsz(c1,gn,&c); c1 = c; |
divz(c2,gn,&c); c2 = c; |
divsz(c2,gn,&c); c2 = c; |
} |
} |
} else { |
} else { |
ezgcdpz(CO,(P)c1,(P)c2,&g); |
ezgcdpz(CO,(P)c1,(P)c2,&g); |
divsp(CO,(P)c1,g,&a); c1 = (Z)a; divsp(CO,(P)c2,g,&a); c2 = (Z)a; |
divsp(CO,(P)c1,g,&a); c1 = (Z)a; divsp(CO,(P)c2,g,&a); c2 = (Z)a; |
add_denomlist(g); |
add_denomlist(g); |
} |
} |
NEWMP(m); m->dl = d; chsgnp((P)c1,(P *)&m->c); NEXT(m) = 0; MKDP(n,m,s); s->sugar = d->td; |
NEWMP(m); m->dl = d; m->c = (Obj)c1; NEXT(m) = 0; MKDP(n,m,s); s->sugar = d->td; |
*multp = s; |
*multp = s; |
mulobjdpm(CO,(Obj)s,p2,&u); mulobjdpm(CO,(Obj)c2,p1,&w); adddpm(CO,u,w,&r); |
chsgnd(s,&ms); mulobjdpm(CO,(Obj)ms,p2,&u); mulobjdpm(CO,(Obj)c2,p1,&w); adddpm(CO,w,u,&r); |
mulobjdpm(CO,(Obj)c2,p0,&h); |
mulobjdpm(CO,(Obj)c2,p0,&h); |
*head = h; *rest = r; *dnp = (P)c2; |
*head = h; *rest = r; *dnp = (P)c2; |
} |
} |
Line 905 void dp_red_marked(DP p0,DP p1,DP p2,DP hp2,DP *head,D |
|
Line 937 void dp_red_marked(DP p0,DP p1,DP p2,DP hp2,DP *head,D |
|
} else if ( INT(c1) && INT(c2) ) { |
} else if ( INT(c1) && INT(c2) ) { |
gcdz(c1,c2,&gn); |
gcdz(c1,c2,&gn); |
if ( !UNIQ(gn) ) { |
if ( !UNIQ(gn) ) { |
divz(c1,gn,&c); c1 = c; |
divsz(c1,gn,&c); c1 = c; |
divz(c2,gn,&c); c2 = c; |
divsz(c2,gn,&c); c2 = c; |
} |
} |
} else { |
} else { |
ezgcdpz(CO,(P)c1,(P)c2,&g); |
ezgcdpz(CO,(P)c1,(P)c2,&g); |
Line 1084 void dp_true_nf(NODE b,DP g,DP *ps,int full,DP *rp,P * |
|
Line 1116 void dp_true_nf(NODE b,DP g,DP *ps,int full,DP *rp,P * |
|
for ( n = 0, l = b; l; l = NEXT(l), n++ ); |
for ( n = 0, l = b; l; l = NEXT(l), n++ ); |
wb = (int *)ALLOCA(n*sizeof(int)); |
wb = (int *)ALLOCA(n*sizeof(int)); |
for ( i = 0, l = b; i < n; l = NEXT(l), i++ ) |
for ( i = 0, l = b; i < n; l = NEXT(l), i++ ) |
wb[i] = QTOS((Q)BDY(l)); |
wb[i] = ZTOS((Q)BDY(l)); |
sugar = g->sugar; |
sugar = g->sugar; |
for ( d = 0; g; ) { |
for ( d = 0; g; ) { |
for ( u = 0, i = 0; i < n; i++ ) { |
for ( u = 0, i = 0; i < n; i++ ) { |
Line 1152 void dp_removecont2(DP p1,DP p2,DP *r1p,DP *r2p,Z *con |
|
Line 1184 void dp_removecont2(DP p1,DP p2,DP *r1p,DP *r2p,Z *con |
|
for ( m = BDY(p1); i < n1; m = NEXT(m), i++ ) w[i] = (Z)m->c; |
for ( m = BDY(p1); i < n1; m = NEXT(m), i++ ) w[i] = (Z)m->c; |
if ( p2 ) |
if ( p2 ) |
for ( m = BDY(p2); i < n; m = NEXT(m), i++ ) w[i] = (Z)m->c; |
for ( m = BDY(p2); i < n; m = NEXT(m), i++ ) w[i] = (Z)m->c; |
h = w[0]; removecont_array((P *)w,n,1); divz(h,w[0],contp); |
h = w[0]; removecont_array((P *)w,n,1); divsz(h,w[0],contp); |
i = 0; |
i = 0; |
if ( p1 ) { |
if ( p1 ) { |
for ( m0 = 0, t = BDY(p1); i < n1; i++, t = NEXT(t) ) { |
for ( m0 = 0, t = BDY(p1); i < n1; i++, t = NEXT(t) ) { |
Line 1195 void dp_true_nf_marked(NODE b,DP g,DP *ps,DP *hps,DP * |
|
Line 1227 void dp_true_nf_marked(NODE b,DP g,DP *ps,DP *hps,DP * |
|
for ( n = 0, l = b; l; l = NEXT(l), n++ ); |
for ( n = 0, l = b; l; l = NEXT(l), n++ ); |
wb = (int *)ALLOCA(n*sizeof(int)); |
wb = (int *)ALLOCA(n*sizeof(int)); |
for ( i = 0, l = b; i < n; l = NEXT(l), i++ ) |
for ( i = 0, l = b; i < n; l = NEXT(l), i++ ) |
wb[i] = QTOS((Z)BDY(l)); |
wb[i] = ZTOS((Z)BDY(l)); |
sugar = g->sugar; |
sugar = g->sugar; |
for ( d = 0; g; ) { |
for ( d = 0; g; ) { |
for ( u = 0, i = 0; i < n; i++ ) { |
for ( u = 0, i = 0; i < n; i++ ) { |
Line 1253 void dp_true_nf_marked_mod(NODE b,DP g,DP *ps,DP *hps, |
|
Line 1285 void dp_true_nf_marked_mod(NODE b,DP g,DP *ps,DP *hps, |
|
if ( !g ) { |
if ( !g ) { |
*rp = 0; *dnp = dn; return; |
*rp = 0; *dnp = dn; return; |
} |
} |
for ( n = 0, l = b; l; l = NEXT(l), n++ ); |
for ( n = 0, l = b; l; l = NEXT(l), n++ ) |
wb = (int *)ALLOCA(n*sizeof(int)); |
; |
|
wb = (int *)ALLOCA(n*sizeof(int)); |
for ( i = 0, l = b; i < n; l = NEXT(l), i++ ) |
for ( i = 0, l = b; i < n; l = NEXT(l), i++ ) |
wb[i] = QTOS((Q)BDY(l)); |
wb[i] = ZTOS((Q)BDY(l)); |
sugar = g->sugar; |
sugar = g->sugar; |
for ( d = 0; g; ) { |
for ( d = 0; g; ) { |
for ( u = 0, i = 0; i < n; i++ ) { |
for ( u = 0, i = 0; i < n; i++ ) { |
Line 1311 DP *dp_true_nf_and_quotient_marked (NODE b,DP g,DP *ps |
|
Line 1344 DP *dp_true_nf_and_quotient_marked (NODE b,DP g,DP *ps |
|
for ( n = 0, l = b; l; l = NEXT(l), n++ ); |
for ( n = 0, l = b; l; l = NEXT(l), n++ ); |
wb = (int *)ALLOCA(n*sizeof(int)); |
wb = (int *)ALLOCA(n*sizeof(int)); |
for ( i = 0, l = b; i < n; l = NEXT(l), i++ ) |
for ( i = 0, l = b; i < n; l = NEXT(l), i++ ) |
wb[i] = QTOS((Q)BDY(l)); |
wb[i] = ZTOS((Q)BDY(l)); |
q = (DP *)MALLOC(n*sizeof(DP)); |
q = (DP *)MALLOC(n*sizeof(DP)); |
for ( i = 0; i < n; i++ ) q[i] = 0; |
for ( i = 0; i < n; i++ ) q[i] = 0; |
sugar = g->sugar; |
sugar = g->sugar; |
|
|
return q; |
return q; |
} |
} |
|
|
|
// struct oEGT egc; |
|
|
|
DP *dpm_nf_and_quotient(NODE b,DPM g,VECT psv,DPM *rp,P *dnp) |
|
{ |
|
DPM u,p,d,s,t; |
|
DP dmy,mult; |
|
DPM *ps; |
|
DP *q; |
|
NODE l; |
|
DMM m,mr; |
|
int i,n,j,len; |
|
int *wb; |
|
int sugar,psugar,multiple; |
|
P nm,tnm1,dn,tdn,tdn1; |
|
Q cont; |
|
struct oEGT eg0,eg1; |
|
|
|
dn = (P)ONE; |
|
if ( !g ) { |
|
*rp = 0; *dnp = dn; return 0; |
|
} |
|
ps = (DPM *)BDY(psv); |
|
len = psv->len; |
|
if ( b ) { |
|
for ( n = 0, l = b; l; l = NEXT(l), n++ ) |
|
; |
|
wb = (int *)ALLOCA(n*sizeof(int)); |
|
for ( i = 0, l = b; i < n; l = NEXT(l), i++ ) |
|
wb[i] = ZTOS((Q)BDY(l)); |
|
} else { |
|
wb = (int *)ALLOCA(len*sizeof(int)); |
|
for ( i = j = 0; i < len; i++ ) |
|
if ( ps[i] ) wb[j++] = i; |
|
n = j; |
|
} |
|
q = (DP *)MALLOC(len*sizeof(DP)); |
|
for ( i = 0; i < len; i++ ) q[i] = 0; |
|
sugar = g->sugar; |
|
for ( d = 0; g; ) { |
|
for ( u = 0, i = 0; i < n; i++ ) { |
|
if ( dpm_redble(g,p = ps[wb[i]]) ) { |
|
dpm_red(d,g,p,&t,&u,&tdn,&mult); |
|
psugar = (BDY(g)->dl->td - BDY(p)->dl->td) + p->sugar; |
|
sugar = MAX(sugar,psugar); |
|
// get_eg(&eg0); |
|
for ( j = 0; j < len; j++ ) { |
|
muldc(CO,q[j],(Obj)tdn,&dmy); q[j] = dmy; |
|
} |
|
addd(CO,q[wb[i]],mult,&dmy); q[wb[i]] = dmy; |
|
// get_eg(&eg1); add_eg(&egc,&eg0,&eg1); |
|
mulp(CO,dn,tdn,&tdn1); dn = tdn1; |
|
d = t; |
|
if ( !u ) goto last; |
|
break; |
|
} |
|
} |
|
if ( u ) { |
|
g = u; |
|
} else { |
|
m = BDY(g); NEWDMM(mr); mr->dl = m->dl; mr->c = m->c; mr->pos = m->pos; |
|
NEXT(mr) = 0; MKDPM(g->nv,mr,t); t->sugar = mr->dl->td; |
|
adddpm(CO,d,t,&s); d = s; |
|
dpm_rest(g,&t); g = t; |
|
} |
|
} |
|
last: |
|
if ( d ) d->sugar = sugar; |
|
*rp = d; *dnp = dn; |
|
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 1367 DP *dp_true_nf_and_quotient_marked_mod(NODE b,DP g,DP |
|
Line 1471 DP *dp_true_nf_and_quotient_marked_mod(NODE b,DP g,DP |
|
} |
} |
wb = (int *)ALLOCA(n*sizeof(int)); |
wb = (int *)ALLOCA(n*sizeof(int)); |
for ( i = 0, l = b; i < n; l = NEXT(l), i++ ) |
for ( i = 0, l = b; i < n; l = NEXT(l), i++ ) |
wb[i] = QTOS((Q)BDY(l)); |
wb[i] = ZTOS((Q)BDY(l)); |
sugar = g->sugar; |
sugar = g->sugar; |
for ( d = 0; g; ) { |
for ( d = 0; g; ) { |
for ( u = 0, i = 0; i < n; i++ ) { |
for ( u = 0, i = 0; i < n; i++ ) { |
Line 1421 void dp_nf_z(NODE b,DP g,DP *ps,int full,int multiple, |
|
Line 1525 void dp_nf_z(NODE b,DP g,DP *ps,int full,int multiple, |
|
for ( n = 0, l = b; l; l = NEXT(l), n++ ); |
for ( n = 0, l = b; l; l = NEXT(l), n++ ); |
wb = (int *)ALLOCA(n*sizeof(int)); |
wb = (int *)ALLOCA(n*sizeof(int)); |
for ( i = 0, l = b; i < n; l = NEXT(l), i++ ) |
for ( i = 0, l = b; i < n; l = NEXT(l), i++ ) |
wb[i] = QTOS((Q)BDY(l)); |
wb[i] = ZTOS((Q)BDY(l)); |
|
|
hmag = multiple*HMAG(g); |
hmag = multiple*HMAG(g); |
sugar = g->sugar; |
sugar = g->sugar; |
Line 1473 void dp_nf_z(NODE b,DP g,DP *ps,int full,int multiple, |
|
Line 1577 void dp_nf_z(NODE b,DP g,DP *ps,int full,int multiple, |
|
*rp = d; |
*rp = d; |
} |
} |
|
|
void dpm_nf_z(NODE b,DPM g,DPM *ps,int full,int multiple,DPM *rp) |
void dpm_nf_z(NODE b,DPM g,VECT psv,int full,int multiple,DPM *rp) |
{ |
{ |
|
DPM *ps; |
DPM u,p,d,s,t; |
DPM u,p,d,s,t; |
DP dmy1; |
DP dmy1; |
P dmy; |
P dmy; |
|
Z cont; |
NODE l; |
NODE l; |
DMM m,mr; |
DMM m,mr; |
int i,n; |
int i,n; |
Line 1488 void dpm_nf_z(NODE b,DPM g,DPM *ps,int full,int multip |
|
Line 1594 void dpm_nf_z(NODE b,DPM g,DPM *ps,int full,int multip |
|
if ( !g ) { |
if ( !g ) { |
*rp = 0; return; |
*rp = 0; return; |
} |
} |
for ( n = 0, l = b; l; l = NEXT(l), n++ ); |
if ( b ) { |
wb = (int *)ALLOCA(n*sizeof(int)); |
for ( n = 0, l = b; l; l = NEXT(l), n++ ); |
for ( i = 0, l = b; i < n; l = NEXT(l), i++ ) |
wb = (int *)ALLOCA(n*sizeof(int)); |
wb[i] = QTOS((Q)BDY(l)); |
for ( i = 0, l = b; i < n; l = NEXT(l), i++ ) |
|
wb[i] = ZTOS((Q)BDY(l)); |
|
ps = (DPM *)BDY(psv); |
|
} else { |
|
n = psv->len; |
|
wb = (int *)MALLOC(n*sizeof(int)); |
|
for ( i = 0; i < n; i++ ) wb[i] = i; |
|
ps = (DPM *)BDY(psv); |
|
} |
|
|
hmag = multiple*HMAG(g); |
hmag = multiple*HMAG(g); |
sugar = g->sugar; |
sugar = g->sugar; |
|
|
for ( d = 0; g; ) { |
for ( d = 0; g; ) { |
for ( u = 0, i = 0; i < n; i++ ) { |
for ( u = 0, i = 0; i < n; i++ ) { |
if ( dpm_redble(g,p = ps[wb[i]]) ) { |
if ( (p=ps[wb[i]])!=0 && dpm_redble(g,p) ) { |
dpm_red(d,g,p,&t,&u,&dmy,&dmy1); |
dpm_red(d,g,p,&t,&u,&dmy,&dmy1); |
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 1520 void dpm_nf_z(NODE b,DPM g,DPM *ps,int full,int multip |
|
Line 1634 void dpm_nf_z(NODE b,DPM g,DPM *ps,int full,int multip |
|
} |
} |
} else { |
} else { |
if ( multiple && HMAG(g) > hmag ) { |
if ( multiple && HMAG(g) > hmag ) { |
dpm_ptozp(g,&t); g = t; |
dpm_ptozp(g,&cont,&t); g = t; |
hmag = multiple*HMAG(g); |
hmag = multiple*HMAG(g); |
} |
} |
} |
} |
Line 1542 void dpm_nf_z(NODE b,DPM g,DPM *ps,int full,int multip |
|
Line 1656 void dpm_nf_z(NODE b,DPM g,DPM *ps,int full,int multip |
|
*rp = d; |
*rp = d; |
} |
} |
|
|
|
void dpm_shift(DPM p,int s,DPM *r) |
|
{ |
|
DMM m,mr0,mr; |
|
DPM t; |
|
|
|
if ( !p ) *r = 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 = m->pos-s; |
|
if ( mr->pos <= 0 ) |
|
error("dpm_shift : too large shift value"); |
|
} |
|
NEXT(mr) = 0; |
|
MKDPM(p->nv,mr0,t); t->sugar = p->sugar; |
|
*r = t; |
|
} |
|
} |
|
|
|
// up=sum{c*<<...:i>>|i<=s}, lo=sum{c*<<...:i>>|i>s} |
|
|
|
void dpm_split(DPM p,int s,DPM *up,DPM *lo) |
|
{ |
|
DMM m,mu0,mu,ml0,ml; |
|
DPM t; |
|
|
|
if ( !p ) { |
|
*up = 0; *lo = 0; |
|
} else { |
|
for ( m = BDY(p), mu0 = ml0 = 0; m; m = NEXT(m) ) { |
|
if ( m->pos <= s ) { |
|
NEXTDMM(mu0,mu); |
|
mu->dl = m->dl; mu->c = m->c; mu->pos = m->pos; |
|
} else { |
|
NEXTDMM(ml0,ml); |
|
ml->dl = m->dl; ml->c = m->c; ml->pos = m->pos; |
|
} |
|
} |
|
if ( mu0 ) { |
|
NEXT(mu) = 0; MKDPM(p->nv,mu0,t); t->sugar = p->sugar; |
|
*up = t; |
|
} else |
|
*up = 0; |
|
if ( ml0 ) { |
|
NEXT(ml) = 0; MKDPM(p->nv,ml0,t); t->sugar = p->sugar; |
|
*lo = t; |
|
} else |
|
*lo = 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 1559 void dp_nf_f(NODE b,DP g,DP *ps,int full,DP *rp) |
|
Line 1724 void dp_nf_f(NODE b,DP g,DP *ps,int full,DP *rp) |
|
for ( n = 0, l = b; l; l = NEXT(l), n++ ); |
for ( n = 0, l = b; l; l = NEXT(l), n++ ); |
wb = (int *)ALLOCA(n*sizeof(int)); |
wb = (int *)ALLOCA(n*sizeof(int)); |
for ( i = 0, l = b; i < n; l = NEXT(l), i++ ) |
for ( i = 0, l = b; i < n; l = NEXT(l), i++ ) |
wb[i] = QTOS((Q)BDY(l)); |
wb[i] = ZTOS((Q)BDY(l)); |
|
|
sugar = g->sugar; |
sugar = g->sugar; |
for ( d = 0; g; ) { |
for ( d = 0; g; ) { |
Line 1595 void dp_nf_f(NODE b,DP g,DP *ps,int full,DP *rp) |
|
Line 1760 void dp_nf_f(NODE b,DP g,DP *ps,int full,DP *rp) |
|
*rp = d; |
*rp = d; |
} |
} |
|
|
void dpm_nf_f(NODE b,DPM g,DPM *ps,int full,DPM *rp) |
void dpm_nf_f(NODE b,DPM g,VECT psv,int full,DPM *rp) |
{ |
{ |
|
DPM *ps; |
DPM u,p,d,s,t; |
DPM u,p,d,s,t; |
NODE l; |
NODE l; |
DMM m,mr; |
DMM m,mr; |
Line 1607 void dpm_nf_f(NODE b,DPM g,DPM *ps,int full,DPM *rp) |
|
Line 1773 void dpm_nf_f(NODE b,DPM g,DPM *ps,int full,DPM *rp) |
|
if ( !g ) { |
if ( !g ) { |
*rp = 0; return; |
*rp = 0; return; |
} |
} |
for ( n = 0, l = b; l; l = NEXT(l), n++ ); |
if ( b ) { |
wb = (int *)ALLOCA(n*sizeof(int)); |
for ( n = 0, l = b; l; l = NEXT(l), n++ ); |
for ( i = 0, l = b; i < n; l = NEXT(l), i++ ) |
wb = (int *)ALLOCA(n*sizeof(int)); |
wb[i] = QTOS((Q)BDY(l)); |
for ( i = 0, l = b; i < n; l = NEXT(l), i++ ) |
|
wb[i] = ZTOS((Q)BDY(l)); |
|
ps = (DPM *)BDY(psv); |
|
} else { |
|
n = psv->len; |
|
wb = (int *)MALLOC(n*sizeof(int)); |
|
for ( i = 0; i < n; i++ ) wb[i] = i; |
|
ps = (DPM *)BDY(psv); |
|
} |
|
|
sugar = g->sugar; |
sugar = g->sugar; |
for ( d = 0; g; ) { |
for ( d = 0; g; ) { |
for ( u = 0, i = 0; i < n; i++ ) { |
for ( u = 0, i = 0; i < n; i++ ) { |
if ( dpm_redble(g,p = ps[wb[i]]) ) { |
if ( ( (p=ps[wb[i]]) != 0 ) && dpm_redble(g,p) ) { |
dpm_red_f(g,p,&u); |
dpm_red_f(g,p,&u); |
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 1708 void dp_true_nf_mod(NODE b,DP g,DP *ps,int mod,int ful |
|
Line 1882 void dp_true_nf_mod(NODE b,DP g,DP *ps,int mod,int ful |
|
if ( !g ) { |
if ( !g ) { |
*rp = 0; *dnp = dn; return; |
*rp = 0; *dnp = dn; return; |
} |
} |
for ( n = 0, l = b; l; l = NEXT(l), n++ ); |
for ( n = 0, l = b; l; l = NEXT(l), n++ ) |
wb = (int *)ALLOCA(n*sizeof(int)); |
; |
|
wb = (int *)ALLOCA(n*sizeof(int)); |
for ( i = 0, l = b; i < n; l = NEXT(l), i++ ) |
for ( i = 0, l = b; i < n; l = NEXT(l), i++ ) |
wb[i] = QTOS((Q)BDY(l)); |
wb[i] = ZTOS((Q)BDY(l)); |
sugar = g->sugar; |
sugar = g->sugar; |
for ( d = 0; g; ) { |
for ( d = 0; g; ) { |
for ( u = 0, i = 0; i < n; i++ ) { |
for ( u = 0, i = 0; i < n; i++ ) { |
Line 1932 int create_order_spec(VL vl,Obj obj,struct order_spec |
|
Line 2107 int create_order_spec(VL vl,Obj obj,struct order_spec |
|
*specp = spec = (struct order_spec *)MALLOC(sizeof(struct order_spec)); |
*specp = spec = (struct order_spec *)MALLOC(sizeof(struct order_spec)); |
if ( !obj || NUM(obj) ) { |
if ( !obj || NUM(obj) ) { |
spec->id = 0; spec->obj = obj; |
spec->id = 0; spec->obj = obj; |
spec->ord.simple = QTOS((Q)obj); |
spec->ord.simple = ZTOS((Q)obj); |
return 1; |
return 1; |
} else if ( OID(obj) == O_LIST ) { |
} else if ( OID(obj) == O_LIST ) { |
/* module order; obj = [0|1,w,ord] or [0|1,ord] */ |
/* module order; obj = [0|1,w,ord] or [0|1,ord] */ |
Line 1947 int create_order_spec(VL vl,Obj obj,struct order_spec |
|
Line 2122 int create_order_spec(VL vl,Obj obj,struct order_spec |
|
spec->module_top_weight = 0; |
spec->module_top_weight = 0; |
spec->ispot = (BDY(node)!=0); |
spec->ispot = (BDY(node)!=0); |
if ( spec->ispot ) { |
if ( spec->ispot ) { |
n = QTOS((Q)BDY(node)); |
n = ZTOS((Q)BDY(node)); |
if ( n < 0 ) |
if ( n < 0 ) |
spec->pot_nelim = -n; |
spec->pot_nelim = -n; |
else |
else |
Line 1973 int create_order_spec(VL vl,Obj obj,struct order_spec |
|
Line 2148 int create_order_spec(VL vl,Obj obj,struct order_spec |
|
spec->nv = length(BDY((LIST)wp)); |
spec->nv = length(BDY((LIST)wp)); |
spec->top_weight = (int *)MALLOC_ATOMIC(spec->nv*sizeof(int)); |
spec->top_weight = (int *)MALLOC_ATOMIC(spec->nv*sizeof(int)); |
for ( i = 0, t = BDY((LIST)wp); i < spec->nv; t = NEXT(t), i++ ) |
for ( i = 0, t = BDY((LIST)wp); i < spec->nv; t = NEXT(t), i++ ) |
spec->top_weight[i] = QTOS((Q)BDY(t)); |
spec->top_weight[i] = ZTOS((Q)BDY(t)); |
|
|
spec->module_rank = length(BDY((LIST)wm)); |
spec->module_rank = length(BDY((LIST)wm)); |
spec->module_top_weight = (int *)MALLOC_ATOMIC(spec->module_rank*sizeof(int)); |
spec->module_top_weight = (int *)MALLOC_ATOMIC(spec->module_rank*sizeof(int)); |
for ( i = 0, t = BDY((LIST)wm); i < spec->module_rank; t = NEXT(t), i++ ) |
for ( i = 0, t = BDY((LIST)wm); i < spec->module_rank; t = NEXT(t), i++ ) |
spec->module_top_weight[i] = QTOS((Q)BDY(t)); |
spec->module_top_weight[i] = ZTOS((Q)BDY(t)); |
break; |
break; |
default: |
default: |
error("create_order_spec : invalid arguments for module order"); |
error("create_order_spec : invalid arguments for module order"); |
Line 1991 int create_order_spec(VL vl,Obj obj,struct order_spec |
|
Line 2166 int create_order_spec(VL vl,Obj obj,struct order_spec |
|
for ( n = 0, t = node; t; t = NEXT(t), n++ ); |
for ( n = 0, t = node; t; t = NEXT(t), n++ ); |
l = (struct order_pair *)MALLOC_ATOMIC(n*sizeof(struct order_pair)); |
l = (struct order_pair *)MALLOC_ATOMIC(n*sizeof(struct order_pair)); |
for ( i = 0, t = node, s = 0; i < n; t = NEXT(t), i++ ) { |
for ( i = 0, t = node, s = 0; i < n; t = NEXT(t), i++ ) { |
tn = BDY((LIST)BDY(t)); l[i].order = QTOS((Q)BDY(tn)); |
tn = BDY((LIST)BDY(t)); l[i].order = ZTOS((Q)BDY(tn)); |
tn = NEXT(tn); l[i].length = QTOS((Q)BDY(tn)); |
tn = NEXT(tn); l[i].length = ZTOS((Q)BDY(tn)); |
s += l[i].length; |
s += l[i].length; |
} |
} |
spec->id = 1; spec->obj = obj; |
spec->id = 1; spec->obj = obj; |
Line 2005 int create_order_spec(VL vl,Obj obj,struct order_spec |
|
Line 2180 int create_order_spec(VL vl,Obj obj,struct order_spec |
|
w = almat(row,col); |
w = almat(row,col); |
for ( i = 0; i < row; i++ ) |
for ( i = 0; i < row; i++ ) |
for ( j = 0; j < col; j++ ) |
for ( j = 0; j < col; j++ ) |
w[i][j] = QTOS((Q)b[i][j]); |
w[i][j] = ZTOS((Q)b[i][j]); |
spec->id = 2; spec->obj = obj; |
spec->id = 2; spec->obj = obj; |
spec->nv = col; spec->ord.matrix.row = row; |
spec->nv = col; spec->ord.matrix.row = row; |
spec->ord.matrix.matrix = w; |
spec->ord.matrix.matrix = w; |
Line 2077 struct order_spec *append_block(struct order_spec *spe |
|
Line 2252 struct order_spec *append_block(struct order_spec *spe |
|
r = (struct order_spec *)MALLOC(sizeof(struct order_spec)); |
r = (struct order_spec *)MALLOC(sizeof(struct order_spec)); |
switch ( spec->id ) { |
switch ( spec->id ) { |
case 0: |
case 0: |
STOQ(spec->ord.simple,oq); STOQ(nv,nq); |
STOZ(spec->ord.simple,oq); STOZ(nv,nq); |
t = mknode(2,oq,nq); MKLIST(list0,t); |
t = mknode(2,oq,nq); MKLIST(list0,t); |
STOQ(ord,oq); STOQ(nalg,nq); |
STOZ(ord,oq); STOZ(nalg,nq); |
t = mknode(2,oq,nq); MKLIST(list1,t); |
t = mknode(2,oq,nq); MKLIST(list1,t); |
t = mknode(2,list0,list1); MKLIST(list,t); |
t = mknode(2,list0,list1); MKLIST(list,t); |
l = (struct order_pair *)MALLOC_ATOMIC(2*sizeof(struct order_pair)); |
l = (struct order_pair *)MALLOC_ATOMIC(2*sizeof(struct order_pair)); |
Line 2105 struct order_spec *append_block(struct order_spec *spe |
|
Line 2280 struct order_spec *append_block(struct order_spec *spe |
|
for ( t = BDY(list0), s0 = 0; t; t = NEXT(t) ) { |
for ( t = BDY(list0), s0 = 0; t; t = NEXT(t) ) { |
NEXTNODE(s0,s); BDY(s) = BDY(t); |
NEXTNODE(s0,s); BDY(s) = BDY(t); |
} |
} |
STOQ(ord,oq); STOQ(nalg,nq); |
STOZ(ord,oq); STOZ(nalg,nq); |
t = mknode(2,oq,nq); MKLIST(list,t); |
t = mknode(2,oq,nq); MKLIST(list,t); |
NEXTNODE(s0,s); BDY(s) = (pointer)list; NEXT(s) = 0; |
NEXTNODE(s0,s); BDY(s) = (pointer)list; NEXT(s) = 0; |
MKLIST(list,s0); |
MKLIST(list,s0); |
Line 2123 struct order_spec *append_block(struct order_spec *spe |
|
Line 2298 struct order_spec *append_block(struct order_spec *spe |
|
MKMAT(mat,row+nalg,col+nalg); wp = (Z **)BDY(mat); |
MKMAT(mat,row+nalg,col+nalg); wp = (Z **)BDY(mat); |
for ( i = 0; i < row; i++ ) |
for ( i = 0; i < row; i++ ) |
for ( j = 0; j < col; j++ ) { |
for ( j = 0; j < col; j++ ) { |
w[i][j] = QTOS(b[i][j]); |
w[i][j] = ZTOS(b[i][j]); |
wp[i][j] = b[i][j]; |
wp[i][j] = b[i][j]; |
} |
} |
for ( i = 0; i < nalg; i++ ) { |
for ( i = 0; i < nalg; i++ ) { |
Line 2198 int create_composite_order_spec(VL vl,LIST order,struc |
|
Line 2373 int create_composite_order_spec(VL vl,LIST order,struc |
|
for ( j = 0, p = a; j < len; p = NEXT(p), j++ ) { |
for ( j = 0, p = a; j < len; p = NEXT(p), j++ ) { |
if ( !INT((Q)BDY(p)) ) |
if ( !INT((Q)BDY(p)) ) |
error("a dense weight vector must be specified as a list of integers"); |
error("a dense weight vector must be specified as a list of integers"); |
dw[j] = QTOS((Q)BDY(p)); |
dw[j] = ZTOS((Q)BDY(p)); |
} |
} |
w_or_b[i].type = IS_DENSE_WEIGHT; |
w_or_b[i].type = IS_DENSE_WEIGHT; |
w_or_b[i].length = len; |
w_or_b[i].length = len; |
Line 2224 int create_composite_order_spec(VL vl,LIST order,struc |
|
Line 2399 int create_composite_order_spec(VL vl,LIST order,struc |
|
sw[j].pos = k; |
sw[j].pos = k; |
if ( !INT((Q)BDY(p)) ) |
if ( !INT((Q)BDY(p)) ) |
error("a sparse weight vector must be specified as [var1,weight1,...]"); |
error("a sparse weight vector must be specified as [var1,weight1,...]"); |
sw[j].value = QTOS((Q)BDY(p)); p = NEXT(p); |
sw[j].value = ZTOS((Q)BDY(p)); p = NEXT(p); |
} |
} |
qsort(sw,len,sizeof(struct sparse_weight), |
qsort(sw,len,sizeof(struct sparse_weight), |
(int (*)(const void *,const void *))comp_sw); |
(int (*)(const void *,const void *))comp_sw); |
Line 2248 int create_composite_order_spec(VL vl,LIST order,struc |
|
Line 2423 int create_composite_order_spec(VL vl,LIST order,struc |
|
len = end-start+1; |
len = end-start+1; |
sw = (struct sparse_weight *) |
sw = (struct sparse_weight *) |
MALLOC(sizeof(struct sparse_weight)*len); |
MALLOC(sizeof(struct sparse_weight)*len); |
w = QTOS((Q)BDY(NEXT(a))); |
w = ZTOS((Q)BDY(NEXT(a))); |
for ( tvl = vl, k = 0; k < start; k++, tvl = NEXT(tvl) ); |
for ( tvl = vl, k = 0; k < start; k++, tvl = NEXT(tvl) ); |
for ( j = 0 ; k <= end; k++, tvl = NEXT(tvl), j++ ) { |
for ( j = 0 ; k <= end; k++, tvl = NEXT(tvl), j++ ) { |
sw[j].pos = k; |
sw[j].pos = k; |
Line 2310 int create_composite_order_spec(VL vl,LIST order,struc |
|
Line 2485 int create_composite_order_spec(VL vl,LIST order,struc |
|
w_or_b[n].body.block.order = 0; |
w_or_b[n].body.block.order = 0; |
spec->ord.composite.length = n+1; |
spec->ord.composite.length = n+1; |
} |
} |
|
return 1; |
} |
} |
|
|
/* module order spec */ |
/* module order spec */ |
Line 2330 void create_modorder_spec(int id,LIST shift,struct mod |
|
Line 2506 void create_modorder_spec(int id,LIST shift,struct mod |
|
spec->len = l = length(n); |
spec->len = l = length(n); |
spec->degree_shift = ds = (int *)MALLOC_ATOMIC(l*sizeof(int)); |
spec->degree_shift = ds = (int *)MALLOC_ATOMIC(l*sizeof(int)); |
for ( t = n, i = 0; t; t = NEXT(t), i++ ) |
for ( t = n, i = 0; t; t = NEXT(t), i++ ) |
ds[i] = QTOS((Q)BDY(t)); |
ds[i] = ZTOS((Q)BDY(t)); |
} else { |
} else { |
spec->len = 0; |
spec->len = 0; |
spec->degree_shift = 0; |
spec->degree_shift = 0; |
} |
} |
STOQ(id,q); |
STOZ(id,q); |
n = mknode(2,q,shift); |
n = mknode(2,q,shift); |
MKLIST(list,n); |
MKLIST(list,n); |
spec->obj = (Obj)list; |
spec->obj = (Obj)list; |
Line 2725 void dpm_rest(DPM p,DPM *rp) |
|
Line 2901 void dpm_rest(DPM p,DPM *rp) |
|
} |
} |
} |
} |
|
|
|
int dpm_getdeg(DPM p,int *r) |
|
{ |
|
int max,n,i,rank; |
|
DMM m; |
|
int *d; |
|
|
|
if ( !p ) return 0; |
|
n = p->nv; |
|
max = 0; |
|
rank = 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]; |
|
rank = MAX(rank,m->pos); |
|
} |
|
*r = rank; |
|
return max; |
|
} |
|
|
DL lcm_of_DL(int nv,DL dl1,DL dl2,DL dl) |
DL lcm_of_DL(int nv,DL dl1,DL dl2,DL dl) |
{ |
{ |
register int i, *d1, *d2, *d, td; |
register int i, *d1, *d2, *d, td; |
Line 2788 void _print_mp(int nv,MP m) |
|
Line 2984 void _print_mp(int nv,MP m) |
|
if ( !m ) |
if ( !m ) |
return; |
return; |
for ( ; m; m = NEXT(m) ) { |
for ( ; m; m = NEXT(m) ) { |
fprintf(stderr,"%d<",ITOS(C(m))); |
fprintf(stderr,"%ld<",ITOS(C(m))); |
for ( i = 0; i < nv; i++ ) { |
for ( i = 0; i < nv; i++ ) { |
fprintf(stderr,"%d",m->dl->d[i]); |
fprintf(stderr,"%d",m->dl->d[i]); |
if ( i != nv-1 ) |
if ( i != nv-1 ) |
fprintf(stderr," "); |
fprintf(stderr," "); |
} |
} |
fprintf(stderr,">",C(m)); |
fprintf(stderr,">"); |
} |
} |
fprintf(stderr,"\n"); |
fprintf(stderr,"\n"); |
} |
} |
Line 2915 LIST dp_initial_term(LIST f,struct order_spec *ord) |
|
Line 3111 LIST dp_initial_term(LIST f,struct order_spec *ord) |
|
default: |
default: |
error("dp_initial_term : unsupported order"); |
error("dp_initial_term : unsupported order"); |
} |
} |
|
return 0; |
} |
} |
|
|
int highest_order_dp(DP p,int *weight,int n); |
int highest_order_dp(DP p,int *weight,int n); |
Line 2951 LIST highest_order(LIST f,int *weight,int n) |
|
Line 3148 LIST highest_order(LIST f,int *weight,int n) |
|
NEXTNODE(r0,r); |
NEXTNODE(r0,r); |
p = (Obj)BDY(nd); |
p = (Obj)BDY(nd); |
h = highest_order_dp((DP)p,weight,n); |
h = highest_order_dp((DP)p,weight,n); |
STOQ(h,q); |
STOZ(h,q); |
BDY(r) = (pointer)q; |
BDY(r) = (pointer)q; |
} |
} |
if ( r0 ) NEXT(r) = 0; |
if ( r0 ) NEXT(r) = 0; |
Line 2994 LIST dp_order(LIST f,struct order_spec *ord) |
|
Line 3191 LIST dp_order(LIST f,struct order_spec *ord) |
|
default: |
default: |
error("dp_initial_term : unsupported order"); |
error("dp_initial_term : unsupported order"); |
} |
} |
|
return 0; |
} |
} |
|
|
int dpv_ht(DPV p,DP *h) |
int dpv_ht(DPV p,DP *h) |
Line 3064 int compare_facet_preorder(int n,int *u,int *v, |
|
Line 3262 int compare_facet_preorder(int n,int *u,int *v, |
|
for ( i = 0; i < row2; i++ ) { |
for ( i = 0; i < row2; i++ ) { |
w2i = w2[i]; |
w2i = w2[i]; |
for ( j = 0, tu = tv = 0; j < n; j++ ) |
for ( j = 0, tu = tv = 0; j < n; j++ ) |
if ( s = w2i[j] ) { |
if ( (s = w2i[j]) != 0 ) { |
tu += s*u[j]; tv += s*v[j]; |
tu += s*u[j]; tv += s*v[j]; |
} |
} |
for ( j = 0; j < n; j++ ) uv[j] = u[j]*tv-v[j]*tu; |
for ( j = 0; j < n; j++ ) uv[j] = u[j]*tv-v[j]*tu; |
Line 3084 Q inner_product_with_small_vector(VECT w,int *v) |
|
Line 3282 Q inner_product_with_small_vector(VECT w,int *v) |
|
n = w->len; |
n = w->len; |
s = 0; |
s = 0; |
for ( i = 0; i < n; i++ ) { |
for ( i = 0; i < n; i++ ) { |
STOQ(v[i],q); mulq((Q)w->body[i],(Q)q,&t); addq(t,s,&u); s = u; |
STOZ(v[i],q); mulq((Q)w->body[i],(Q)q,&t); addq(t,s,&u); s = u; |
} |
} |
return s; |
return s; |
} |
} |
Line 3278 NODE compute_essential_df(DP *g,DP *gh,int ng) |
|
Line 3476 NODE compute_essential_df(DP *g,DP *gh,int ng) |
|
dl = (DL)BDY(rt); d = dl->d; |
dl = (DL)BDY(rt); d = dl->d; |
ri = 0; |
ri = 0; |
for ( k = nv-1; k >= 0; k-- ) { |
for ( k = nv-1; k >= 0; k-- ) { |
STOQ(d[k],q); |
STOZ(d[k],q); |
MKNODE(r1,q,ri); ri = r1; |
MKNODE(r1,q,ri); ri = r1; |
} |
} |
MKNODE(r1,0,ri); MKLIST(l,r1); |
MKNODE(r1,0,ri); MKLIST(l,r1); |