version 1.38, 2001/11/16 10:35:07 |
version 1.74, 2018/03/29 01:32:50 |
|
|
* 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/asir2000/builtin/gr.c,v 1.37 2001/10/09 01:36:06 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/builtin/gr.c,v 1.73 2017/08/31 02:36:20 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "parse.h" |
#include "parse.h" |
|
|
#include "ox.h" |
#include "ox.h" |
|
|
#if defined(__GNUC__) |
#if defined(__GNUC__) |
#define INLINE inline |
#define INLINE static inline |
#elif defined(VISUAL) |
#elif defined(VISUAL) || defined(__MINGW32__) |
#define INLINE __inline |
#define INLINE __inline |
#else |
#else |
#define INLINE |
#define INLINE |
#endif |
#endif |
|
|
#define HMAG(p) (p_mag(BDY(p)->c)) |
#define HMAG(p) (p_mag((P)BDY(p)->c)) |
|
|
#define NEWDP_pairs ((DP_pairs)MALLOC(sizeof(struct dp_pairs))) |
#define NEWDP_pairs ((DP_pairs)MALLOC(sizeof(struct dp_pairs))) |
|
|
static DP_pairs collect_pairs_of_hdlcm( DP_pairs d1, DP_pairs *prest ); |
static DP_pairs collect_pairs_of_hdlcm( DP_pairs d1, DP_pairs *prest ); |
double get_rtime(); |
double get_rtime(); |
|
|
struct oEGT eg_nf,eg_nfm; |
struct oEGT eg_nf,eg_nfm; |
struct oEGT eg_znfm,eg_pz,eg_np,eg_ra,eg_mc,eg_gc; |
struct oEGT eg_znfm,eg_pz,eg_np,eg_ra,eg_mc,eg_gc; |
int TP,NBP,NMP,NFP,NDP,ZR,NZR; |
int TP,N_BP,NMP,NFP,NDP,ZR,NZR; |
|
|
extern int (*cmpdl)(); |
extern int (*cmpdl)(); |
extern int do_weyl; |
extern int do_weyl; |
|
|
|
|
int PCoeffs; |
int PCoeffs; |
int DP_Print = 0; |
int DP_Print = 0; |
|
int DP_PrintShort = 0; |
int DP_Multiple = 0; |
int DP_Multiple = 0; |
int DP_NFStat = 0; |
int DP_NFStat = 0; |
LIST Dist = 0; |
LIST Dist = 0; |
int NoGCD = 0; |
int NoGCD = 0; |
int GenTrace = 0; |
int GenTrace = 0; |
|
int GenSyz = 0; |
int OXCheck = -1; |
int OXCheck = -1; |
|
int OneZeroHomo = 0; |
|
int MaxDeg = 0; |
|
|
static int NoSugar = 0; |
int NoSugar = 0; |
static int NoCriB = 0; |
static int NoCriB = 0; |
static int NoGC = 0; |
static int NoGC = 0; |
static int NoMC = 0; |
static int NoMC = 0; |
static int NoRA = 0; |
static int NoRA = 0; |
static int DP_PrintShort = 0; |
|
static int ShowMag = 0; |
static int ShowMag = 0; |
static int Stat = 0; |
static int Stat = 0; |
static int Denominator = 1; |
int Denominator = 1; |
static int Top = 0; |
int Top = 0; |
static int Reverse = 0; |
int Reverse = 0; |
static int Max_mag = 0; |
static int Max_mag = 0; |
static char *Demand = 0; |
static int Max_coef = 0; |
|
char *Demand = 0; |
static int PtozpRA = 0; |
static int PtozpRA = 0; |
|
|
int doing_f4; |
int doing_f4; |
Line 121 void Pox_pop_local(NODE,Obj *); |
|
Line 125 void Pox_pop_local(NODE,Obj *); |
|
|
|
INLINE int eqdl(int nv,DL dl1,DL dl2) |
INLINE int eqdl(int nv,DL dl1,DL dl2) |
{ |
{ |
int i; |
int i; |
int *b1,*b2; |
int *p1,*p2; |
|
|
if ( dl1->td != dl2->td ) |
if ( dl1->td != dl2->td ) |
return 0; |
return 0; |
for ( i = 0, b1 = dl1->d, b2 = dl2->d; i < nv; i++ ) |
i = nv-1; |
if ( b1[i] != b2[i] ) |
p1 = dl1->d; |
break; |
p2 = dl2->d; |
if ( i == nv ) |
while ( i >= 7 ) { |
return 1; |
if ( *p1++ != *p2++ ) return 0; |
else |
if ( *p1++ != *p2++ ) return 0; |
return 0; |
if ( *p1++ != *p2++ ) return 0; |
|
if ( *p1++ != *p2++ ) return 0; |
|
if ( *p1++ != *p2++ ) return 0; |
|
if ( *p1++ != *p2++ ) return 0; |
|
if ( *p1++ != *p2++ ) return 0; |
|
if ( *p1++ != *p2++ ) return 0; |
|
i -= 8; |
|
} |
|
switch ( i ) { |
|
case 6: |
|
if ( *p1++ != *p2++ ) return 0; |
|
if ( *p1++ != *p2++ ) return 0; |
|
if ( *p1++ != *p2++ ) return 0; |
|
if ( *p1++ != *p2++ ) return 0; |
|
if ( *p1++ != *p2++ ) return 0; |
|
if ( *p1++ != *p2++ ) return 0; |
|
if ( *p1++ != *p2++ ) return 0; |
|
return 1; |
|
case 5: |
|
if ( *p1++ != *p2++ ) return 0; |
|
if ( *p1++ != *p2++ ) return 0; |
|
if ( *p1++ != *p2++ ) return 0; |
|
if ( *p1++ != *p2++ ) return 0; |
|
if ( *p1++ != *p2++ ) return 0; |
|
if ( *p1++ != *p2++ ) return 0; |
|
return 1; |
|
case 4: |
|
if ( *p1++ != *p2++ ) return 0; |
|
if ( *p1++ != *p2++ ) return 0; |
|
if ( *p1++ != *p2++ ) return 0; |
|
if ( *p1++ != *p2++ ) return 0; |
|
if ( *p1++ != *p2++ ) return 0; |
|
return 1; |
|
case 3: |
|
if ( *p1++ != *p2++ ) return 0; |
|
if ( *p1++ != *p2++ ) return 0; |
|
if ( *p1++ != *p2++ ) return 0; |
|
if ( *p1++ != *p2++ ) return 0; |
|
return 1; |
|
case 2: |
|
if ( *p1++ != *p2++ ) return 0; |
|
if ( *p1++ != *p2++ ) return 0; |
|
if ( *p1++ != *p2++ ) return 0; |
|
return 1; |
|
case 1: |
|
if ( *p1++ != *p2++ ) return 0; |
|
if ( *p1++ != *p2++ ) return 0; |
|
return 1; |
|
case 0: |
|
if ( *p1++ != *p2++ ) return 0; |
|
return 1; |
|
default: |
|
return 1; |
|
} |
} |
} |
|
|
/* b[] should be cleared */ |
/* b[] should be cleared */ |
|
|
void _dpmod_to_vect(DP f,DL *at,int *b) |
void _dpmod_to_vect(DP f,DL *at,int *b) |
{ |
{ |
int i,nv; |
int i,nv; |
MP m; |
MP m; |
|
|
nv = f->nv; |
nv = f->nv; |
for ( m = BDY(f), i = 0; m; m = NEXT(m), i++ ) { |
for ( m = BDY(f), i = 0; m; m = NEXT(m), i++ ) { |
for ( ; !eqdl(nv,m->dl,at[i]); i++ ); |
for ( ; !eqdl(nv,m->dl,at[i]); i++ ); |
b[i] = ITOS(m->c); |
b[i] = ITOS(m->c); |
} |
} |
} |
} |
|
|
/* [t,findex] -> tf -> compressed vector */ |
/* [t,findex] -> tf -> compressed vector */ |
|
|
void _tf_to_vect_compress(NODE tf,DL *at,CDP *b) |
void _tf_to_vect_compress(NODE tf,DL *at,CDP *b) |
{ |
{ |
int i,j,k,nv,len; |
int i,j,k,nv,len; |
DL t,s,d1; |
DL t,s,d1; |
DP f; |
DP f; |
MP m; |
MP m; |
CDP r; |
CDP r; |
|
|
t = (DL)BDY(tf); |
t = (DL)BDY(tf); |
f = ps[(int)BDY(NEXT(tf))]; |
f = ps[(int)BDY(NEXT(tf))]; |
|
|
nv = f->nv; |
nv = f->nv; |
for ( m = BDY(f), len = 0; m; m = NEXT(m), len++ ); |
for ( m = BDY(f), len = 0; m; m = NEXT(m), len++ ); |
r = (CDP)MALLOC(sizeof(struct oCDP)); |
r = (CDP)MALLOC(sizeof(struct oCDP)); |
r->len = len; |
r->len = len; |
r->psindex = (int)BDY(NEXT(tf)); |
r->psindex = (int)BDY(NEXT(tf)); |
r->body = (unsigned int *)MALLOC_ATOMIC(sizeof(unsigned int)*len); |
r->body = (unsigned int *)MALLOC_ATOMIC(sizeof(unsigned int)*len); |
|
|
NEWDL_NOINIT(s,nv); |
NEWDL_NOINIT(s,nv); |
for ( m = BDY(f), i = j = 0; m; m = NEXT(m), j++ ) { |
for ( m = BDY(f), i = j = 0; m; m = NEXT(m), j++ ) { |
d1 = m->dl; |
d1 = m->dl; |
s->td = t->td+d1->td; |
s->td = t->td+d1->td; |
for ( k = 0; k < nv; k++ ) |
for ( k = 0; k < nv; k++ ) |
s->d[k] = t->d[k]+d1->d[k]; |
s->d[k] = t->d[k]+d1->d[k]; |
for ( ; !eqdl(nv,s,at[i]); i++ ); |
for ( ; !eqdl(nv,s,at[i]); i++ ); |
r->body[j] = i; |
r->body[j] = i; |
} |
} |
*b = r; |
*b = r; |
} |
} |
|
|
void dp_to_vect(DP f,DL *at,Q *b) |
void dp_to_vect(DP f,DL *at,Q *b) |
{ |
{ |
int i,nv; |
int i,nv; |
MP m; |
MP m; |
|
|
nv = f->nv; |
nv = f->nv; |
for ( m = BDY(f), i = 0; m; m = NEXT(m), i++ ) { |
for ( m = BDY(f), i = 0; m; m = NEXT(m), i++ ) { |
for ( ; !eqdl(nv,m->dl,at[i]); i++ ); |
for ( ; !eqdl(nv,m->dl,at[i]); i++ ); |
b[i] =(Q)m->c; |
b[i] =(Q)m->c; |
} |
} |
} |
} |
|
|
NODE dp_dllist(DP f) |
NODE dp_dllist(DP f) |
{ |
{ |
MP m; |
MP m; |
NODE mp,mp0; |
NODE mp,mp0; |
|
|
if ( !f ) |
if ( !f ) |
return 0; |
return 0; |
mp0 = 0; |
mp0 = 0; |
for ( m = BDY(f); m; m = NEXT(m) ) { |
for ( m = BDY(f); m; m = NEXT(m) ) { |
NEXTNODE(mp0,mp); BDY(mp) = (pointer)m->dl; |
NEXTNODE(mp0,mp); BDY(mp) = (pointer)m->dl; |
} |
} |
NEXT(mp) = 0; |
NEXT(mp) = 0; |
return mp0; |
return mp0; |
} |
} |
|
|
NODE mul_dllist(DL d,DP f) |
NODE mul_dllist(DL d,DP f) |
{ |
{ |
MP m; |
MP m; |
NODE mp,mp0; |
NODE mp,mp0; |
DL t,d1; |
DL t,d1; |
int i,nv; |
int i,nv; |
|
|
if ( !f ) |
if ( !f ) |
return 0; |
return 0; |
nv = NV(f); |
nv = NV(f); |
mp0 = 0; |
mp0 = 0; |
for ( m = BDY(f); m; m = NEXT(m) ) { |
for ( m = BDY(f); m; m = NEXT(m) ) { |
NEXTNODE(mp0,mp); |
NEXTNODE(mp0,mp); |
NEWDL_NOINIT(t,nv); |
NEWDL_NOINIT(t,nv); |
d1 = m->dl; |
d1 = m->dl; |
t->td = d->td+d1->td; |
t->td = d->td+d1->td; |
for ( i = 0; i < nv; i++ ) |
for ( i = 0; i < nv; i++ ) |
t->d[i] = d->d[i]+d1->d[i]; |
t->d[i] = d->d[i]+d1->d[i]; |
BDY(mp) = (pointer)t; |
BDY(mp) = (pointer)t; |
} |
} |
NEXT(mp) = 0; |
NEXT(mp) = 0; |
return mp0; |
return mp0; |
} |
} |
|
|
void pdl(NODE f) |
void pdl(NODE f) |
{ |
{ |
while ( f ) { |
while ( f ) { |
printdl(BDY(f)); f = NEXT(f); |
printdl(BDY(f)); f = NEXT(f); |
} |
} |
fflush(stdout); |
fflush(stdout); |
printf("\n"); |
printf("\n"); |
} |
} |
|
|
void dp_gr_main(LIST f,LIST v,Num homo,int modular,int field,struct order_spec *ord,LIST *rp) |
void dp_gr_main(LIST f,LIST v,Num homo,int modular,int field,struct order_spec *ord,LIST *rp) |
{ |
{ |
int i,mindex,m,nochk; |
int i,mindex,m,nochk; |
struct order_spec ord1; |
struct order_spec *ord1; |
Q q; |
Q q; |
VL fv,vv,vc; |
VL fv,vv,vc; |
NODE fd,fd0,fi,fi0,r,r0,t,subst,x,s,xx; |
NODE fd,fd0,fi,fi0,r,r0,t,subst,x,s,xx; |
NODE ind,ind0; |
NODE ind,ind0; |
LIST trace,gbindex; |
LIST trace,gbindex; |
|
int input_is_dp = 0; |
|
|
mindex = 0; nochk = 0; dp_fcoeffs = field; |
mindex = 0; nochk = 0; dp_fcoeffs = field; |
get_vars((Obj)f,&fv); pltovl(v,&vv); vlminus(fv,vv,&vc); |
get_vars((Obj)f,&fv); pltovl(v,&vv); vlminus(fv,vv,&vc); |
NVars = length((NODE)vv); PCoeffs = vc ? 1 : 0; VC = vc; |
NVars = length((NODE)vv); PCoeffs = vc ? 1 : 0; VC = vc; |
CNVars = homo ? NVars+1 : NVars; |
CNVars = homo ? NVars+1 : NVars; |
if ( ord->id && NVars != ord->nv ) |
if ( ord->id && NVars != ord->nv ) |
error("dp_gr_main : invalid order specification"); |
error("dp_gr_main : invalid order specification"); |
initd(ord); |
initd(ord); |
if ( homo ) { |
if ( homo ) { |
homogenize_order(ord,NVars,&ord1); |
homogenize_order(ord,NVars,&ord1); |
for ( fd0 = fi0 = 0, t = BDY(f); t; t = NEXT(t) ) { |
for ( fd0 = fi0 = 0, t = BDY(f); t; t = NEXT(t) ) { |
NEXTNODE(fd0,fd); NEXTNODE(fi0,fi); |
NEXTNODE(fd0,fd); NEXTNODE(fi0,fi); |
ptod(CO,vv,(P)BDY(t),(DP *)&BDY(fi)); dp_homo((DP)BDY(fi),(DP *)&BDY(fd)); |
if ( BDY(t) && OID(BDY(t)) == O_DP ) { |
} |
dp_sort((DP)BDY(t),(DP *)&BDY(fi)); input_is_dp = 1; |
if ( fd0 ) NEXT(fd) = 0; |
} else |
if ( fi0 ) NEXT(fi) = 0; |
ptod(CO,vv,(P)BDY(t),(DP *)&BDY(fi)); |
initd(&ord1); |
dp_homo((DP)BDY(fi),(DP *)&BDY(fd)); |
} else { |
} |
for ( fd0 = 0, t = BDY(f); t; t = NEXT(t) ) { |
if ( fd0 ) NEXT(fd) = 0; |
NEXTNODE(fd0,fd); ptod(CO,vv,(P)BDY(t),(DP *)&BDY(fd)); |
if ( fi0 ) NEXT(fi) = 0; |
} |
initd(ord1); |
if ( fd0 ) NEXT(fd) = 0; |
} else { |
fi0 = fd0; |
for ( fd0 = 0, t = BDY(f); t; t = NEXT(t) ) { |
} |
NEXTNODE(fd0,fd); |
if ( modular < 0 ) { |
if ( BDY(t) && OID(BDY(t)) == O_DP ) { |
modular = -modular; nochk = 1; |
dp_sort((DP)BDY(t),(DP *)&BDY(fd)); input_is_dp = 1; |
} |
} else |
if ( modular ) |
ptod(CO,vv,(P)BDY(t),(DP *)&BDY(fd)); |
m = modular > 1 ? modular : get_lprime(mindex); |
} |
else |
if ( fd0 ) NEXT(fd) = 0; |
m = 0; |
fi0 = fd0; |
makesubst(vc,&subst); |
} |
setup_arrays(fd0,0,&s); |
if ( modular < 0 ) { |
init_stat(); |
modular = -modular; nochk = 1; |
while ( 1 ) { |
} |
if ( homo ) { |
if ( modular ) |
initd(&ord1); CNVars = NVars+1; |
m = modular > 1 ? modular : get_lprime(mindex); |
} |
else |
if ( DP_Print && modular ) { |
m = 0; |
fprintf(asir_out,"mod= %d, eval = ",m); printsubst(subst); |
makesubst(vc,&subst); |
} |
setup_arrays(fd0,0,&s); |
x = gb(s,m,subst); |
init_stat(); |
if ( x ) { |
while ( 1 ) { |
if ( homo ) { |
if ( homo ) { |
reducebase_dehomo(x,&xx); x = xx; |
initd(ord1); CNVars = NVars+1; |
initd(ord); CNVars = NVars; |
} |
} |
if ( DP_Print && modular ) { |
reduceall(x,&xx); x = xx; |
fprintf(asir_out,"mod= %d, eval = ",m); printsubst(subst); |
if ( modular ) { |
} |
if ( nochk || (membercheck(fi0,x) && gbcheck(x)) ) |
x = gb(s,m,subst); |
break; |
if ( x ) { |
} else |
if ( homo ) { |
break; |
reducebase_dehomo(x,&xx); x = xx; |
} |
initd(ord); CNVars = NVars; |
if ( modular ) |
} |
if ( modular > 1 ) { |
reduceall(x,&xx); x = xx; |
*rp = 0; return; |
if ( modular ) { |
} else |
if ( nochk || (membercheck(fi0,x) && gbcheck(x)) ) |
m = get_lprime(++mindex); |
break; |
makesubst(vc,&subst); |
} else |
psn = length(s); |
break; |
for ( i = psn; i < pslen; i++ ) { |
} |
pss[i] = 0; psh[i] = 0; psc[i] = 0; ps[i] = 0; |
if ( modular ) |
} |
if ( modular > 1 ) { |
} |
*rp = 0; return; |
for ( r0 = 0, ind0 = 0; x; x = NEXT(x) ) { |
} else |
NEXTNODE(r0,r); dp_load((int)BDY(x),&ps[(int)BDY(x)]); |
m = get_lprime(++mindex); |
dtop(CO,vv,ps[(int)BDY(x)],(P *)&BDY(r)); |
makesubst(vc,&subst); |
NEXTNODE(ind0,ind); |
psn = length(s); |
STOQ((int)BDY(x),q); BDY(ind) = q; |
for ( i = psn; i < pslen; i++ ) { |
} |
pss[i] = 0; psh[i] = 0; psc[i] = 0; ps[i] = 0; |
if ( r0 ) NEXT(r) = 0; |
} |
if ( ind0 ) NEXT(ind) = 0; |
} |
MKLIST(*rp,r0); |
for ( r0 = 0, ind0 = 0; x; x = NEXT(x) ) { |
MKLIST(gbindex,ind0); |
NEXTNODE(r0,r); dp_load((int)BDY(x),&ps[(int)BDY(x)]); |
|
if ( input_is_dp ) |
|
BDY(r) = (pointer)ps[(int)BDY(x)]; |
|
else |
|
dtop(CO,vv,ps[(int)BDY(x)],(Obj *)&BDY(r)); |
|
NEXTNODE(ind0,ind); |
|
STOQ((int)BDY(x),q); BDY(ind) = q; |
|
} |
|
if ( r0 ) NEXT(r) = 0; |
|
if ( ind0 ) NEXT(ind) = 0; |
|
MKLIST(*rp,r0); |
|
MKLIST(gbindex,ind0); |
|
|
if ( GenTrace && OXCheck < 0 ) { |
if ( GenTrace && OXCheck < 0 ) { |
|
|
x = AllTraceList; |
x = AllTraceList; |
for ( r = 0; x; x = NEXT(x) ) { |
for ( r = 0; x; x = NEXT(x) ) { |
MKNODE(r0,BDY(x),r); r = r0; |
MKNODE(r0,BDY(x),r); r = r0; |
} |
} |
MKLIST(trace,r); |
MKLIST(trace,r); |
r0 = mknode(3,*rp,gbindex,trace); |
r0 = mknode(3,*rp,gbindex,trace); |
MKLIST(*rp,r0); |
MKLIST(*rp,r0); |
} |
} |
print_stat(); |
print_stat(); |
if ( ShowMag ) |
if ( ShowMag ) |
fprintf(asir_out,"\nMax_mag=%d\n",Max_mag); |
fprintf(asir_out,"\nMax_mag=%d, Max_coef=%d\n",Max_mag, Max_coef); |
} |
} |
|
|
|
void dp_interreduce(LIST f,LIST v,int field,struct order_spec *ord,LIST *rp) |
|
{ |
|
int i,mindex,m,nochk; |
|
struct order_spec *ord1; |
|
Q q; |
|
VL fv,vv,vc; |
|
NODE fd,fd0,fi,fi0,r,r0,t,subst,x,s,xx; |
|
NODE ind,ind0; |
|
LIST trace,gbindex; |
|
int input_is_dp = 0; |
|
|
|
mindex = 0; nochk = 0; dp_fcoeffs = field; |
|
get_vars((Obj)f,&fv); pltovl(v,&vv); vlminus(fv,vv,&vc); |
|
NVars = length((NODE)vv); PCoeffs = vc ? 1 : 0; VC = vc; |
|
CNVars = NVars; |
|
if ( ord->id && NVars != ord->nv ) |
|
error("dp_interreduce : invalid order specification"); |
|
initd(ord); |
|
for ( fd0 = 0, t = BDY(f); t; t = NEXT(t) ) { |
|
NEXTNODE(fd0,fd); |
|
if ( BDY(t) && OID(BDY(t)) == O_DP ) { |
|
dp_sort((DP)BDY(t),(DP *)&BDY(fd)); input_is_dp = 1; |
|
} else |
|
ptod(CO,vv,(P)BDY(t),(DP *)&BDY(fd)); |
|
} |
|
if ( fd0 ) NEXT(fd) = 0; |
|
fi0 = fd0; |
|
setup_arrays(fd0,0,&s); |
|
init_stat(); |
|
x = s; |
|
reduceall(x,&xx); x = xx; |
|
for ( r0 = 0, ind0 = 0; x; x = NEXT(x) ) { |
|
NEXTNODE(r0,r); dp_load((int)BDY(x),&ps[(int)BDY(x)]); |
|
if ( input_is_dp ) |
|
BDY(r) = (pointer)ps[(int)BDY(x)]; |
|
else |
|
dtop(CO,vv,ps[(int)BDY(x)],(Obj *)&BDY(r)); |
|
NEXTNODE(ind0,ind); |
|
STOQ((int)BDY(x),q); BDY(ind) = q; |
|
} |
|
if ( r0 ) NEXT(r) = 0; |
|
if ( ind0 ) NEXT(ind) = 0; |
|
MKLIST(*rp,r0); |
|
MKLIST(gbindex,ind0); |
|
} |
|
|
void dp_gr_mod_main(LIST f,LIST v,Num homo,int m,struct order_spec *ord,LIST *rp) |
void dp_gr_mod_main(LIST f,LIST v,Num homo,int m,struct order_spec *ord,LIST *rp) |
{ |
{ |
struct order_spec ord1; |
struct order_spec *ord1; |
VL fv,vv,vc; |
VL fv,vv,vc; |
NODE fd,fd0,r,r0,t,x,s,xx; |
NODE fd,fd0,r,r0,t,x,s,xx; |
DP a,b,c; |
DP a,b,c; |
extern struct oEGT eg_red_mod; |
extern struct oEGT eg_red_mod; |
|
int input_is_dp = 0; |
|
|
get_vars((Obj)f,&fv); pltovl(v,&vv); vlminus(fv,vv,&vc); |
get_vars((Obj)f,&fv); pltovl(v,&vv); vlminus(fv,vv,&vc); |
NVars = length((NODE)vv); PCoeffs = vc ? 1 : 0; VC = vc; |
NVars = length((NODE)vv); PCoeffs = vc ? 1 : 0; VC = vc; |
CNVars = homo ? NVars+1 : NVars; |
CNVars = homo ? NVars+1 : NVars; |
if ( ord->id && NVars != ord->nv ) |
if ( ord->id && NVars != ord->nv ) |
error("dp_gr_mod_main : invalid order specification"); |
error("dp_gr_mod_main : invalid order specification"); |
initd(ord); |
initd(ord); |
if ( homo ) { |
if ( homo ) { |
for ( fd0 = 0, t = BDY(f); t; t = NEXT(t) ) { |
for ( fd0 = 0, t = BDY(f); t; t = NEXT(t) ) { |
ptod(CO,vv,(P)BDY(t),&a); dp_homo(a,&b); |
if ( BDY(t) && OID(BDY(t)) == O_DP ) { |
if ( PCoeffs ) |
dp_sort((DP)BDY(t),&a); input_is_dp = 1; |
dp_mod(b,m,0,&c); |
} else |
else |
ptod(CO,vv,(P)BDY(t),&a); |
_dp_mod(b,m,(NODE)0,&c); |
dp_homo(a,&b); |
if ( c ) { |
if ( PCoeffs ) |
NEXTNODE(fd0,fd); BDY(fd) = (pointer)c; |
dp_mod(b,m,0,&c); |
} |
else |
} |
_dp_mod(b,m,(NODE)0,&c); |
homogenize_order(ord,NVars,&ord1); initd(&ord1); |
if ( c ) { |
} else { |
NEXTNODE(fd0,fd); BDY(fd) = (pointer)c; |
for ( fd0 = 0, t = BDY(f); t; t = NEXT(t) ) { |
} |
ptod(CO,vv,(P)BDY(t),&b); |
} |
if ( PCoeffs ) |
homogenize_order(ord,NVars,&ord1); initd(ord1); |
dp_mod(b,m,0,&c); |
} else { |
else |
for ( fd0 = 0, t = BDY(f); t; t = NEXT(t) ) { |
_dp_mod(b,m,0,&c); |
if ( BDY(t) && OID(BDY(t)) == O_DP ) { |
if ( c ) { |
dp_sort((DP)BDY(t),&b); input_is_dp = 1; |
NEXTNODE(fd0,fd); BDY(fd) = (pointer)c; |
} else |
} |
ptod(CO,vv,(P)BDY(t),&b); |
} |
if ( PCoeffs ) |
} |
dp_mod(b,m,0,&c); |
if ( fd0 ) NEXT(fd) = 0; |
else |
setup_arrays(fd0,m,&s); |
_dp_mod(b,m,0,&c); |
init_stat(); |
if ( c ) { |
if ( homo ) { |
NEXTNODE(fd0,fd); BDY(fd) = (pointer)c; |
initd(&ord1); CNVars = NVars+1; |
} |
} |
} |
|
} |
|
if ( fd0 ) NEXT(fd) = 0; |
|
setup_arrays(fd0,m,&s); |
|
init_stat(); |
|
if ( homo ) { |
|
initd(ord1); CNVars = NVars+1; |
|
} |
/* init_eg(&eg_red_mod); */ |
/* init_eg(&eg_red_mod); */ |
x = gb_mod(s,m); |
x = gb_mod(s,m); |
/* print_eg("Red_mod",&eg_red_mod); */ |
/* print_eg("Red_mod",&eg_red_mod); */ |
if ( homo ) { |
if ( homo ) { |
reducebase_dehomo(x,&xx); x = xx; |
reducebase_dehomo(x,&xx); x = xx; |
initd(ord); CNVars = NVars; |
initd(ord); CNVars = NVars; |
} |
} |
reduceall_mod(x,m,&xx); x = xx; |
reduceall_mod(x,m,&xx); x = xx; |
if ( PCoeffs ) |
if ( PCoeffs ) |
for ( r0 = 0; x; x = NEXT(x) ) { |
for ( r0 = 0; x; x = NEXT(x) ) { |
NEXTNODE(r0,r); mdtop(CO,m,vv,ps[(int)BDY(x)],(P *)&BDY(r)); |
NEXTNODE(r0,r); |
} |
if ( input_is_dp ) |
else |
mdtodp(ps[(int)BDY(x)],(DP *)&BDY(r)); |
for ( r0 = 0; x; x = NEXT(x) ) { |
else |
NEXTNODE(r0,r); _dtop_mod(CO,vv,ps[(int)BDY(x)],(P *)&BDY(r)); |
mdtop(CO,m,vv,ps[(int)BDY(x)],(P *)&BDY(r)); |
} |
} |
print_stat(); |
else |
if ( r0 ) NEXT(r) = 0; |
for ( r0 = 0; x; x = NEXT(x) ) { |
MKLIST(*rp,r0); |
NEXTNODE(r0,r); |
|
if ( input_is_dp ) |
|
_mdtodp(ps[(int)BDY(x)],(DP *)&BDY(r)); |
|
else |
|
_dtop_mod(CO,vv,ps[(int)BDY(x)],(P *)&BDY(r)); |
|
} |
|
print_stat(); |
|
if ( r0 ) NEXT(r) = 0; |
|
MKLIST(*rp,r0); |
} |
} |
|
|
void dp_f4_main(LIST f,LIST v,struct order_spec *ord,LIST *rp) |
void dp_f4_main(LIST f,LIST v,struct order_spec *ord,LIST *rp) |
{ |
{ |
int homogen; |
int homogen; |
VL fv,vv,vc; |
VL fv,vv,vc; |
NODE fd,fd0,r,r0,t,x,s,xx; |
NODE fd,fd0,r,r0,t,x,s,xx; |
|
int input_is_dp = 0; |
|
|
dp_fcoeffs = 0; |
dp_fcoeffs = 0; |
get_vars((Obj)f,&fv); pltovl(v,&vv); vlminus(fv,vv,&vc); |
get_vars((Obj)f,&fv); pltovl(v,&vv); vlminus(fv,vv,&vc); |
NVars = length((NODE)vv); PCoeffs = vc ? 1 : 0; VC = vc; |
NVars = length((NODE)vv); PCoeffs = vc ? 1 : 0; VC = vc; |
CNVars = NVars; |
CNVars = NVars; |
if ( ord->id && NVars != ord->nv ) |
if ( ord->id && NVars != ord->nv ) |
error("dp_f4_main : invalid order specification"); |
error("dp_f4_main : invalid order specification"); |
initd(ord); |
initd(ord); |
for ( fd0 = 0, t = BDY(f), homogen = 1; t; t = NEXT(t) ) { |
for ( fd0 = 0, t = BDY(f), homogen = 1; t; t = NEXT(t) ) { |
NEXTNODE(fd0,fd); ptod(CO,vv,(P)BDY(t),(DP *)&BDY(fd)); |
NEXTNODE(fd0,fd); |
if ( homogen ) |
if ( BDY(t) && OID(BDY(t)) == O_DP ) { |
homogen = dp_homogeneous(BDY(fd)); |
dp_sort((DP)BDY(t),(DP *)&BDY(fd)); input_is_dp = 1; |
} |
} else |
if ( fd0 ) NEXT(fd) = 0; |
ptod(CO,vv,(P)BDY(t),(DP *)&BDY(fd)); |
setup_arrays(fd0,0,&s); |
if ( homogen ) |
x = gb_f4(s); |
homogen = dp_homogeneous(BDY(fd)); |
if ( !homogen ) { |
} |
reduceall(x,&xx); x = xx; |
if ( fd0 ) NEXT(fd) = 0; |
} |
setup_arrays(fd0,0,&s); |
for ( r0 = 0; x; x = NEXT(x) ) { |
x = gb_f4(s); |
NEXTNODE(r0,r); dp_load((int)BDY(x),&ps[(int)BDY(x)]); |
if ( !homogen ) { |
dtop(CO,vv,ps[(int)BDY(x)],(P *)&BDY(r)); |
reduceall(x,&xx); x = xx; |
} |
} |
if ( r0 ) NEXT(r) = 0; |
for ( r0 = 0; x; x = NEXT(x) ) { |
MKLIST(*rp,r0); |
NEXTNODE(r0,r); dp_load((int)BDY(x),&ps[(int)BDY(x)]); |
|
if ( input_is_dp ) |
|
BDY(r) = (pointer)ps[(int)BDY(x)]; |
|
else |
|
dtop(CO,vv,ps[(int)BDY(x)],(Obj *)&BDY(r)); |
|
} |
|
if ( r0 ) NEXT(r) = 0; |
|
MKLIST(*rp,r0); |
} |
} |
|
|
void dp_f4_mod_main(LIST f,LIST v,int m,struct order_spec *ord,LIST *rp) |
void dp_f4_mod_main(LIST f,LIST v,int m,struct order_spec *ord,LIST *rp) |
{ |
{ |
int homogen; |
int homogen; |
VL fv,vv,vc; |
VL fv,vv,vc; |
DP b,c,c1; |
DP b,c,c1; |
NODE fd,fd0,r,r0,t,x,s,xx; |
NODE fd,fd0,r,r0,t,x,s,xx; |
|
int input_is_dp = 0; |
|
|
dp_fcoeffs = 0; |
dp_fcoeffs = 0; |
get_vars((Obj)f,&fv); pltovl(v,&vv); vlminus(fv,vv,&vc); |
get_vars((Obj)f,&fv); pltovl(v,&vv); vlminus(fv,vv,&vc); |
NVars = length((NODE)vv); PCoeffs = vc ? 1 : 0; VC = vc; |
NVars = length((NODE)vv); PCoeffs = vc ? 1 : 0; VC = vc; |
CNVars = NVars; |
CNVars = NVars; |
if ( ord->id && NVars != ord->nv ) |
if ( ord->id && NVars != ord->nv ) |
error("dp_f4_mod_main : invalid order specification"); |
error("dp_f4_mod_main : invalid order specification"); |
initd(ord); |
initd(ord); |
for ( fd0 = 0, t = BDY(f), homogen = 1; t; t = NEXT(t) ) { |
for ( fd0 = 0, t = BDY(f), homogen = 1; t; t = NEXT(t) ) { |
ptod(CO,vv,(P)BDY(t),&b); |
if ( BDY(t) && OID(BDY(t)) == O_DP ) { |
if ( homogen ) |
dp_sort((DP)BDY(t),&b); input_is_dp = 1; |
homogen = dp_homogeneous(b); |
} else |
_dp_mod(b,m,0,&c); |
ptod(CO,vv,(P)BDY(t),&b); |
_dp_monic(c,m,&c1); |
if ( homogen ) |
if ( c ) { |
homogen = dp_homogeneous(b); |
NEXTNODE(fd0,fd); BDY(fd) = (pointer)c1; |
_dp_mod(b,m,0,&c); |
} |
_dp_monic(c,m,&c1); |
} |
if ( c ) { |
if ( fd0 ) NEXT(fd) = 0; |
NEXTNODE(fd0,fd); BDY(fd) = (pointer)c1; |
setup_arrays(fd0,m,&s); |
} |
init_stat(); |
} |
if ( do_weyl ) |
if ( fd0 ) NEXT(fd) = 0; |
x = gb_f4_mod_old(s,m); |
setup_arrays(fd0,m,&s); |
else |
init_stat(); |
x = gb_f4_mod(s,m); |
if ( do_weyl ) |
if ( !homogen ) { |
x = gb_f4_mod_old(s,m); |
reduceall_mod(x,m,&xx); x = xx; |
else |
} |
x = gb_f4_mod(s,m); |
for ( r0 = 0; x; x = NEXT(x) ) { |
if ( !homogen ) { |
NEXTNODE(r0,r); _dtop_mod(CO,vv,ps[(int)BDY(x)],(P *)&BDY(r)); |
reduceall_mod(x,m,&xx); x = xx; |
} |
} |
if ( r0 ) NEXT(r) = 0; |
for ( r0 = 0; x; x = NEXT(x) ) { |
MKLIST(*rp,r0); |
NEXTNODE(r0,r); |
print_stat(); |
if ( input_is_dp ) |
|
_mdtodp(ps[(int)BDY(x)],(DP *)&BDY(r)); |
|
else |
|
_dtop_mod(CO,vv,ps[(int)BDY(x)],(P *)&BDY(r)); |
|
} |
|
if ( r0 ) NEXT(r) = 0; |
|
MKLIST(*rp,r0); |
|
print_stat(); |
} |
} |
|
|
NODE gb_f4(NODE f) |
NODE gb_f4(NODE f) |
{ |
{ |
int i,k,nh,row,col,nv; |
int i,k,nh,row,col,nv; |
NODE r,g,gall; |
NODE r,g,gall; |
NODE s,s0; |
NODE s,s0; |
DP_pairs d,dm,dr,t; |
DP_pairs d,dm,dr,t; |
DP nf,nf1,f2,sp,sd,tdp; |
DP nf,nf1,f2,sp,sd,tdp; |
MP mp,mp0; |
MP mp,mp0; |
NODE blist,bt; |
NODE blist,bt; |
DL *ht,*at; |
DL *ht,*at; |
MAT mat,nm; |
MAT mat,nm; |
int *rind,*cind; |
int *rind,*cind; |
int rank,nred; |
int rank,nred; |
Q dn; |
Q dn; |
struct oEGT tmp0,tmp1,eg_split_symb; |
struct oEGT tmp0,tmp1,eg_split_symb; |
extern struct oEGT eg_mod,eg_elim,eg_chrem,eg_gschk,eg_intrat,eg_symb; |
extern struct oEGT eg_mod,eg_elim,eg_chrem,eg_gschk,eg_intrat,eg_symb; |
|
|
init_eg(&eg_mod); init_eg(&eg_elim); init_eg(&eg_chrem); |
init_eg(&eg_mod); init_eg(&eg_elim); init_eg(&eg_chrem); |
init_eg(&eg_gschk); init_eg(&eg_intrat); init_eg(&eg_symb); |
init_eg(&eg_gschk); init_eg(&eg_intrat); init_eg(&eg_symb); |
|
|
doing_f4 = 1; |
doing_f4 = 1; |
for ( gall = g = 0, d = 0, r = f; r; r = NEXT(r) ) { |
for ( gall = g = 0, d = 0, r = f; r; r = NEXT(r) ) { |
i = (int)BDY(r); |
i = (int)BDY(r); |
d = updpairs(d,g,i); |
d = updpairs(d,g,i); |
g = updbase(g,i); |
g = updbase(g,i); |
gall = append_one(gall,i); |
gall = append_one(gall,i); |
} |
} |
if ( gall ) |
if ( gall ) |
nv = ((DP)ps[(int)BDY(gall)])->nv; |
nv = ((DP)ps[(int)BDY(gall)])->nv; |
while ( d ) { |
while ( d ) { |
get_eg(&tmp0); |
get_eg(&tmp0); |
minsugar(d,&dm,&dr); d = dr; |
minsugar(d,&dm,&dr); d = dr; |
if ( DP_Print ) |
if ( DP_Print ) |
fprintf(asir_out,"sugar=%d\n",dm->sugar); |
fprintf(asir_out,"sugar=%d\n",dm->sugar); |
blist = 0; s0 = 0; |
blist = 0; s0 = 0; |
/* asph : sum of all head terms of spoly */ |
/* asph : sum of all head terms of spoly */ |
for ( t = dm; t; t = NEXT(t) ) { |
for ( t = dm; t; t = NEXT(t) ) { |
dp_sp(ps[t->dp1],ps[t->dp2],&sp); |
dp_sp(ps[t->dp1],ps[t->dp2],&sp); |
if ( sp ) { |
if ( sp ) { |
MKNODE(bt,sp,blist); blist = bt; |
MKNODE(bt,sp,blist); blist = bt; |
s0 = symb_merge(s0,dp_dllist(sp),nv); |
s0 = symb_merge(s0,dp_dllist(sp),nv); |
} |
} |
} |
} |
/* s0 : all the terms appeared in symbolic redunction */ |
/* s0 : all the terms appeared in symbolic redunction */ |
for ( s = s0, nred = 0; s; s = NEXT(s) ) { |
for ( s = s0, nred = 0; s; s = NEXT(s) ) { |
for ( r = gall; r; r = NEXT(r) ) |
for ( r = gall; r; r = NEXT(r) ) |
if ( _dl_redble(BDY(ps[(int)BDY(r)])->dl,BDY(s),nv) ) |
if ( _dl_redble(BDY(ps[(int)BDY(r)])->dl,BDY(s),nv) ) |
break; |
break; |
if ( r ) { |
if ( r ) { |
dltod(BDY(s),nv,&tdp); |
dltod(BDY(s),nv,&tdp); |
dp_subd(tdp,ps[(int)BDY(r)],&sd); |
dp_subd(tdp,ps[(int)BDY(r)],&sd); |
muld(CO,sd,ps[(int)BDY(r)],&f2); |
muld(CO,sd,ps[(int)BDY(r)],&f2); |
MKNODE(bt,f2,blist); blist = bt; |
MKNODE(bt,f2,blist); blist = bt; |
s = symb_merge(s,dp_dllist(f2),nv); |
s = symb_merge(s,dp_dllist(f2),nv); |
nred++; |
nred++; |
} |
} |
} |
} |
|
|
/* the first nred polys in blist are reducers */ |
/* the first nred polys in blist are reducers */ |
/* row = the number of all the polys */ |
/* row = the number of all the polys */ |
for ( r = blist, row = 0; r; r = NEXT(r), row++ ); |
for ( r = blist, row = 0; r; r = NEXT(r), row++ ); |
ht = (DL *)MALLOC(nred*sizeof(DL)); |
ht = (DL *)MALLOC(nred*sizeof(DL)); |
for ( r = blist, i = 0; i < nred; r = NEXT(r), i++ ) |
for ( r = blist, i = 0; i < nred; r = NEXT(r), i++ ) |
ht[i] = BDY((DP)BDY(r))->dl; |
ht[i] = BDY((DP)BDY(r))->dl; |
for ( s = s0, col = 0; s; s = NEXT(s), col++ ); |
for ( s = s0, col = 0; s; s = NEXT(s), col++ ); |
at = (DL *)MALLOC(col*sizeof(DL)); |
at = (DL *)MALLOC(col*sizeof(DL)); |
for ( s = s0, i = 0; i < col; s = NEXT(s), i++ ) |
for ( s = s0, i = 0; i < col; s = NEXT(s), i++ ) |
at[i] = (DL)BDY(s); |
at[i] = (DL)BDY(s); |
MKMAT(mat,row,col); |
MKMAT(mat,row,col); |
for ( i = 0, r = blist; i < row; r = NEXT(r), i++ ) |
for ( i = 0, r = blist; i < row; r = NEXT(r), i++ ) |
dp_to_vect(BDY(r),at,(Q *)mat->body[i]); |
dp_to_vect(BDY(r),at,(Q *)mat->body[i]); |
get_eg(&tmp1); add_eg(&eg_symb,&tmp0,&tmp1); |
get_eg(&tmp1); add_eg(&eg_symb,&tmp0,&tmp1); |
init_eg(&eg_split_symb); add_eg(&eg_split_symb,&tmp0,&tmp1); |
init_eg(&eg_split_symb); add_eg(&eg_split_symb,&tmp0,&tmp1); |
if ( DP_Print ) { |
if ( DP_Print ) { |
print_eg("Symb",&eg_split_symb); |
print_eg("Symb",&eg_split_symb); |
fprintf(asir_out,"mat : %d x %d",row,col); |
fprintf(asir_out,"mat : %d x %d",row,col); |
fflush(asir_out); |
fflush(asir_out); |
} |
} |
#if 0 |
#if 0 |
rank = generic_gauss_elim_hensel(mat,&nm,&dn,&rind,&cind); |
rank = generic_gauss_elim_hensel(mat,&nm,&dn,&rind,&cind); |
#else |
#else |
rank = generic_gauss_elim(mat,&nm,&dn,&rind,&cind); |
rank = generic_gauss_elim(mat,&nm,&dn,&rind,&cind); |
#endif |
#endif |
if ( DP_Print ) |
if ( DP_Print ) |
fprintf(asir_out,"done rank = %d\n",rank,row,col); |
fprintf(asir_out,"done rank = %d\n",rank,row,col); |
for ( i = 0; i < rank; i++ ) { |
for ( i = 0; i < rank; i++ ) { |
for ( k = 0; k < nred; k++ ) |
for ( k = 0; k < nred; k++ ) |
if ( !cmpdl(nv,at[rind[i]],ht[k]) ) |
if ( !cmpdl(nv,at[rind[i]],ht[k]) ) |
break; |
break; |
if ( k == nred ) { |
if ( k == nred ) { |
/* this is a new base */ |
/* this is a new base */ |
mp0 = 0; |
mp0 = 0; |
NEXTMP(mp0,mp); mp->dl = at[rind[i]]; mp->c = (P)dn; |
NEXTMP(mp0,mp); mp->dl = at[rind[i]]; mp->c = (Obj)dn; |
for ( k = 0; k < col-rank; k++ ) |
for ( k = 0; k < col-rank; k++ ) |
if ( nm->body[i][k] ) { |
if ( nm->body[i][k] ) { |
NEXTMP(mp0,mp); mp->dl = at[cind[k]]; |
NEXTMP(mp0,mp); mp->dl = at[cind[k]]; |
mp->c = (P)nm->body[i][k]; |
mp->c = (Obj)nm->body[i][k]; |
} |
} |
NEXT(mp) = 0; |
NEXT(mp) = 0; |
MKDP(nv,mp0,nf); nf->sugar = dm->sugar; |
MKDP(nv,mp0,nf); nf->sugar = dm->sugar; |
dp_ptozp(nf,&nf1); |
dp_ptozp(nf,&nf1); |
nh = newps(nf1,0,0); |
nh = newps(nf1,0,0); |
d = updpairs(d,g,nh); |
d = updpairs(d,g,nh); |
g = updbase(g,nh); |
g = updbase(g,nh); |
gall = append_one(gall,nh); |
gall = append_one(gall,nh); |
} |
} |
} |
} |
} |
} |
if ( DP_Print ) { |
if ( DP_Print ) { |
print_eg("Symb",&eg_symb); |
print_eg("Symb",&eg_symb); |
print_eg("Mod",&eg_mod); print_eg("GaussElim",&eg_elim); |
print_eg("Mod",&eg_mod); print_eg("GaussElim",&eg_elim); |
print_eg("ChRem",&eg_chrem); print_eg("IntToRat",&eg_intrat); |
print_eg("ChRem",&eg_chrem); print_eg("IntToRat",&eg_intrat); |
print_eg("Check",&eg_gschk); |
print_eg("Check",&eg_gschk); |
} |
} |
return g; |
return g; |
} |
} |
|
|
/* initial bases are monic */ |
/* initial bases are monic */ |
|
|
unsigned int **psca; |
unsigned int **psca; |
|
GeoBucket create_bucket(); |
|
DL remove_head_bucket(GeoBucket,int); |
|
|
NODE gb_f4_mod(NODE f,int m) |
NODE gb_f4_mod(NODE f,int m) |
{ |
{ |
int i,j,k,nh,row,col,nv; |
int i,j,k,nh,row,col,nv; |
NODE r,g,gall; |
NODE r,g,gall; |
NODE s,s0; |
NODE s,s0; |
DP_pairs d,dm,dr,t; |
DP_pairs d,dm,dr,t; |
DP nf,sp,sd,tdp; |
DP nf,sp,sd,tdp; |
MP mp,mp0; |
MP mp,mp0; |
NODE blist,bt,bt1,dt; |
NODE blist,bt,bt1,dt; |
DL *at,*st; |
DL *at,*st; |
int **spmat; |
int **spmat; |
CDP *redmat; |
CDP *redmat; |
int *colstat,*w,*w1; |
int *colstat,*w,*w1; |
int rank,nred,nsp,nsp0,nonzero,spcol; |
int rank,nred,nsp,nsp0,nonzero,spcol; |
int *indred,*isred; |
int *indred,*isred; |
CDP ri; |
CDP ri; |
int pscalen; |
int pscalen; |
struct oEGT tmp0,tmp1,eg_split_symb,eg_split_elim1,eg_split_elim2; |
GeoBucket bucket; |
extern struct oEGT eg_symb,eg_elim1,eg_elim2; |
DL head; |
|
struct oEGT tmp0,tmp1,eg_split_symb,eg_split_conv,eg_split_elim1,eg_split_elim2; |
|
extern struct oEGT eg_symb,eg_conv,eg_elim1,eg_elim2; |
|
|
/* initialize coeffcient array list of ps[] */ |
/* initialize coeffcient array list of ps[] */ |
pscalen = pslen; |
pscalen = pslen; |
psca = (unsigned int **)MALLOC(pscalen*sizeof(unsigned int *)); |
psca = (unsigned int **)MALLOC(pscalen*sizeof(unsigned int *)); |
|
|
init_eg(&eg_symb); init_eg(&eg_elim1); init_eg(&eg_elim2); |
init_eg(&eg_symb); init_eg(&eg_conv); init_eg(&eg_elim1); init_eg(&eg_elim2); |
for ( gall = g = 0, d = 0, r = f; r; r = NEXT(r) ) { |
for ( gall = g = 0, d = 0, r = f; r; r = NEXT(r) ) { |
i = (int)BDY(r); |
i = (int)BDY(r); |
d = updpairs(d,g,i); |
d = updpairs(d,g,i); |
g = updbase(g,i); |
g = updbase(g,i); |
gall = append_one(gall,i); |
gall = append_one(gall,i); |
dptoca(ps[i],&psca[i]); |
dptoca(ps[i],&psca[i]); |
} |
} |
if ( gall ) |
if ( gall ) |
nv = ((DP)ps[(int)BDY(gall)])->nv; |
nv = ((DP)ps[(int)BDY(gall)])->nv; |
while ( d ) { |
while ( d ) { |
get_eg(&tmp0); |
get_eg(&tmp0); |
minsugar(d,&dm,&dr); d = dr; |
minsugar(d,&dm,&dr); d = dr; |
if ( DP_Print ) |
if ( DP_Print ) |
fprintf(asir_out,"sugar=%d\n",dm->sugar); |
fprintf(asir_out,"sugar=%d\n",dm->sugar); |
blist = 0; s0 = 0; |
blist = 0; |
/* asph : sum of all head terms of spoly */ |
bucket = create_bucket(); |
for ( t = dm; t; t = NEXT(t) ) { |
/* asph : sum of all head terms of spoly */ |
_dp_sp_mod(ps[t->dp1],ps[t->dp2],m,&sp); |
for ( t = dm; t; t = NEXT(t) ) { |
/* fprintf(stderr,"splen=%d-",dp_nt(sp)); */ |
_dp_sp_mod(ps[t->dp1],ps[t->dp2],m,&sp); |
if ( sp ) { |
/* fprintf(stderr,"splen=%d-",dp_nt(sp)); */ |
MKNODE(bt,sp,blist); blist = bt; |
if ( sp ) { |
s0 = symb_merge(s0,dp_dllist(sp),nv); |
MKNODE(bt,sp,blist); blist = bt; |
/* fprintf(stderr,"%d-",length(s0)); */ |
add_bucket(bucket,dp_dllist(sp),nv); |
} |
/* fprintf(stderr,"%d-",length(s0)); */ |
} |
} |
if ( DP_Print ) |
} |
fprintf(asir_out,"initial spmat : %d x %d ",length(blist),length(s0)); |
#if 0 |
/* s0 : all the terms appeared in symbolic reduction */ |
if ( DP_Print ) |
for ( s = s0, nred = 0; s; s = NEXT(s) ) { |
fprintf(asir_out,"initial spmat : %d x %d ",length(blist),length(s0)); |
for ( r = gall; r; r = NEXT(r) ) |
#endif |
if ( _dl_redble(BDY(ps[(int)BDY(r)])->dl,BDY(s),nv) ) |
/* s0 : all the terms appeared in symbolic reduction */ |
break; |
nred = 0; |
if ( r ) { |
s0 = 0; |
dltod(BDY(s),nv,&tdp); |
while ( 1 ) { |
dp_subd(tdp,ps[(int)BDY(r)],&sd); |
head = remove_head_bucket(bucket,nv); |
dt = mul_dllist(BDY(sd)->dl,ps[(int)BDY(r)]); |
if ( !head ) break; |
/* fprintf(stderr,"[%d]",length(dt)); */ |
else { |
/* list of [t,f] */ |
NEXTNODE(s0,s); |
bt1 = mknode(2,BDY(sd)->dl,BDY(r)); |
BDY(s) = (pointer)head; |
MKNODE(bt,bt1,blist); blist = bt; |
} |
symb_merge(s,dt,nv); |
for ( r = gall; r; r = NEXT(r) ) |
/* fprintf(stderr,"%d-",length(s)); */ |
if ( _dl_redble(BDY(ps[(int)BDY(r)])->dl,head,nv) ) |
nred++; |
break; |
} |
if ( r ) { |
} |
dltod(head,nv,&tdp); |
/* fprintf(stderr,"\n"); */ |
dp_subd(tdp,ps[(int)BDY(r)],&sd); |
if ( DP_Print ) |
dt = mul_dllist(BDY(sd)->dl,ps[(int)BDY(r)]); |
fprintf(asir_out,"number of reducers : %d\n",nred); |
add_bucket(bucket,NEXT(dt),nv); |
|
/* fprintf(stderr,"[%d]",length(dt)); */ |
|
/* list of [t,f] */ |
|
bt1 = mknode(2,BDY(sd)->dl,BDY(r)); |
|
MKNODE(bt,bt1,blist); blist = bt; |
|
/* fprintf(stderr,"%d-",length(s0)); */ |
|
nred++; |
|
} |
|
} |
|
if ( s0 ) NEXT(s) = 0; |
|
/* fprintf(stderr,"\n"); */ |
|
get_eg(&tmp1); add_eg(&eg_symb,&tmp0,&tmp1); |
|
init_eg(&eg_split_symb); add_eg(&eg_split_symb,&tmp0,&tmp1); |
|
|
/* the first nred polys in blist are reducers */ |
if ( DP_Print ) |
/* row = the number of all the polys */ |
fprintf(asir_out,"number of reducers : %d\n",nred); |
for ( r = blist, row = 0; r; r = NEXT(r), row++ ); |
|
|
|
/* col = number of all terms */ |
get_eg(&tmp0); |
for ( s = s0, col = 0; s; s = NEXT(s), col++ ); |
/* the first nred polys in blist are reducers */ |
|
/* row = the number of all the polys */ |
|
for ( r = blist, row = 0; r; r = NEXT(r), row++ ); |
|
|
/* head terms of all terms */ |
/* col = number of all terms */ |
at = (DL *)MALLOC(col*sizeof(DL)); |
for ( s = s0, col = 0; s; s = NEXT(s), col++ ); |
for ( s = s0, i = 0; i < col; s = NEXT(s), i++ ) |
|
at[i] = (DL)BDY(s); |
|
|
|
/* store coefficients separately in spmat and redmat */ |
/* head terms of all terms */ |
nsp = row-nred; |
at = (DL *)MALLOC(col*sizeof(DL)); |
|
for ( s = s0, i = 0; i < col; s = NEXT(s), i++ ) |
|
at[i] = (DL)BDY(s); |
|
|
/* reducer matrix */ |
/* store coefficients separately in spmat and redmat */ |
/* indred : register the position of the head term */ |
nsp = row-nred; |
redmat = (CDP *)MALLOC(nred*sizeof(CDP)); |
|
for ( i = 0, r = blist; i < nred; r = NEXT(r), i++ ) |
|
_tf_to_vect_compress(BDY(r),at,&redmat[i]); |
|
|
|
/* register the position of the head term */ |
/* reducer matrix */ |
indred = (int *)MALLOC_ATOMIC(nred*sizeof(int)); |
/* indred : register the position of the head term */ |
bzero(indred,nred*sizeof(int)); |
redmat = (CDP *)MALLOC(nred*sizeof(CDP)); |
isred = (int *)MALLOC_ATOMIC(col*sizeof(int)); |
for ( i = 0, r = blist; i < nred; r = NEXT(r), i++ ) |
bzero(isred,col*sizeof(int)); |
_tf_to_vect_compress(BDY(r),at,&redmat[i]); |
for ( i = 0; i < nred; i++ ) { |
|
ri = redmat[i]; |
|
indred[i] = ri->body[0]; |
|
isred[indred[i]] = 1; |
|
} |
|
|
|
spcol = col-nred; |
/* register the position of the head term */ |
/* head terms not in ht */ |
indred = (int *)MALLOC_ATOMIC(nred*sizeof(int)); |
st = (DL *)MALLOC(spcol*sizeof(DL)); |
bzero(indred,nred*sizeof(int)); |
for ( j = 0, k = 0; j < col; j++ ) |
isred = (int *)MALLOC_ATOMIC(col*sizeof(int)); |
if ( !isred[j] ) |
bzero(isred,col*sizeof(int)); |
st[k++] = at[j]; |
for ( i = 0; i < nred; i++ ) { |
get_eg(&tmp1); add_eg(&eg_symb,&tmp0,&tmp1); |
ri = redmat[i]; |
init_eg(&eg_split_symb); add_eg(&eg_split_symb,&tmp0,&tmp1); |
indred[i] = ri->body[0]; |
|
isred[indred[i]] = 1; |
|
} |
|
|
get_eg(&tmp1); |
spcol = col-nred; |
/* spoly matrix; stored in reduced form; terms in ht[] are omitted */ |
/* head terms not in ht */ |
spmat = (int **)MALLOC(nsp*sizeof(int *)); |
st = (DL *)MALLOC(spcol*sizeof(DL)); |
w = (int *)MALLOC_ATOMIC(col*sizeof(int)); |
for ( j = 0, k = 0; j < col; j++ ) |
|
if ( !isred[j] ) |
|
st[k++] = at[j]; |
|
get_eg(&tmp1); add_eg(&eg_conv,&tmp0,&tmp1); |
|
init_eg(&eg_split_conv); add_eg(&eg_split_conv,&tmp0,&tmp1); |
|
|
/* skip reducers in blist */ |
get_eg(&tmp1); |
for ( i = 0, r = blist; i < nred; r = NEXT(r), i++ ); |
/* spoly matrix; stored in reduced form; terms in ht[] are omitted */ |
for ( i = 0; r; r = NEXT(r) ) { |
spmat = (int **)MALLOC(nsp*sizeof(int *)); |
bzero(w,col*sizeof(int)); |
w = (int *)MALLOC_ATOMIC(col*sizeof(int)); |
_dpmod_to_vect(BDY(r),at,w); |
|
reduce_sp_by_red_mod_compress(w,redmat,indred,nred,col,m); |
|
for ( j = 0; j < col; j++ ) |
|
if ( w[j] ) |
|
break; |
|
if ( j < col ) { |
|
w1 = (int *)MALLOC_ATOMIC(spcol*sizeof(int)); |
|
for ( j = 0, k = 0; j < col; j++ ) |
|
if ( !isred[j] ) |
|
w1[k++] = w[j]; |
|
spmat[i] = w1; |
|
i++; |
|
} |
|
} |
|
/* update nsp */ |
|
nsp0 = nsp; |
|
nsp = i; |
|
|
|
/* XXX free redmat explicitly */ |
/* skip reducers in blist */ |
for ( k = 0; k < nred; k++ ) { |
for ( i = 0, r = blist; i < nred; r = NEXT(r), i++ ); |
GC_free(BDY(redmat[k])); |
for ( i = 0; r; r = NEXT(r) ) { |
GC_free(redmat[k]); |
bzero(w,col*sizeof(int)); |
} |
_dpmod_to_vect(BDY(r),at,w); |
|
reduce_sp_by_red_mod_compress(w,redmat,indred,nred,col,m); |
|
for ( j = 0; j < col; j++ ) |
|
if ( w[j] ) |
|
break; |
|
if ( j < col ) { |
|
w1 = (int *)MALLOC_ATOMIC(spcol*sizeof(int)); |
|
for ( j = 0, k = 0; j < col; j++ ) |
|
if ( !isred[j] ) |
|
w1[k++] = w[j]; |
|
spmat[i] = w1; |
|
i++; |
|
} |
|
} |
|
/* update nsp */ |
|
nsp0 = nsp; |
|
nsp = i; |
|
|
get_eg(&tmp0); add_eg(&eg_elim1,&tmp1,&tmp0); |
/* XXX free redmat explicitly */ |
init_eg(&eg_split_elim1); add_eg(&eg_split_elim1,&tmp1,&tmp0); |
for ( k = 0; k < nred; k++ ) { |
|
GCFREE(BDY(redmat[k])); |
|
GCFREE(redmat[k]); |
|
} |
|
|
colstat = (int *)MALLOC_ATOMIC(spcol*sizeof(int)); |
get_eg(&tmp0); add_eg(&eg_elim1,&tmp1,&tmp0); |
bzero(colstat,spcol*sizeof(int)); |
init_eg(&eg_split_elim1); add_eg(&eg_split_elim1,&tmp1,&tmp0); |
for ( i = 0, nonzero=0; i < nsp; i++ ) |
|
for ( j = 0; j < spcol; j++ ) |
|
if ( spmat[i][j] ) |
|
nonzero++; |
|
if ( DP_Print && nsp ) |
|
fprintf(asir_out,"spmat : %d x %d (nonzero=%f%%)...", |
|
nsp,spcol,((double)nonzero*100)/(nsp*spcol)); |
|
if ( nsp ) |
|
rank = generic_gauss_elim_mod(spmat,nsp,spcol,m,colstat); |
|
else |
|
rank = 0; |
|
get_eg(&tmp1); add_eg(&eg_elim2,&tmp0,&tmp1); |
|
init_eg(&eg_split_elim2); add_eg(&eg_split_elim2,&tmp0,&tmp1); |
|
|
|
if ( DP_Print ) { |
colstat = (int *)MALLOC_ATOMIC(spcol*sizeof(int)); |
fprintf(asir_out,"done rank = %d\n",rank,row,col); |
bzero(colstat,spcol*sizeof(int)); |
print_eg("Symb",&eg_split_symb); |
for ( i = 0, nonzero=0; i < nsp; i++ ) |
print_eg("Elim1",&eg_split_elim1); |
for ( j = 0; j < spcol; j++ ) |
print_eg("Elim2",&eg_split_elim2); |
if ( spmat[i][j] ) |
fprintf(asir_out,"\n"); |
nonzero++; |
} |
if ( DP_Print && nsp ) |
|
fprintf(asir_out,"spmat : %d x %d (nonzero=%f%%)...", |
|
nsp,spcol,((double)nonzero*100)/(nsp*spcol)); |
|
if ( nsp ) |
|
rank = generic_gauss_elim_mod(spmat,nsp,spcol,m,colstat); |
|
else |
|
rank = 0; |
|
get_eg(&tmp1); add_eg(&eg_elim2,&tmp0,&tmp1); |
|
init_eg(&eg_split_elim2); add_eg(&eg_split_elim2,&tmp0,&tmp1); |
|
|
NZR += rank; |
if ( DP_Print ) { |
ZR += nsp0-rank; |
fprintf(asir_out,"done rank = %d\n",rank,row,col); |
|
print_eg("Symb",&eg_split_symb); |
|
print_eg("Conv",&eg_split_conv); |
|
print_eg("Elim1",&eg_split_elim1); |
|
print_eg("Elim2",&eg_split_elim2); |
|
fprintf(asir_out,"\n"); |
|
} |
|
|
if ( !rank ) |
NZR += rank; |
continue; |
ZR += nsp0-rank; |
|
|
for ( j = 0, i = 0; j < spcol; j++ ) |
if ( !rank ) |
if ( colstat[j] ) { |
continue; |
mp0 = 0; |
|
NEXTMP(mp0,mp); mp->dl = st[j]; mp->c = STOI(1); |
|
for ( k = j+1; k < spcol; k++ ) |
|
if ( !colstat[k] && spmat[i][k] ) { |
|
NEXTMP(mp0,mp); mp->dl = st[k]; |
|
mp->c = STOI(spmat[i][k]); |
|
} |
|
NEXT(mp) = 0; |
|
MKDP(nv,mp0,nf); nf->sugar = dm->sugar; |
|
nh = newps_mod(nf,m); |
|
if ( nh == pscalen ) { |
|
psca = (unsigned int **) |
|
REALLOC(psca,2*pscalen*sizeof(unsigned int *)); |
|
pscalen *= 2; |
|
} |
|
dptoca(ps[nh],&psca[nh]); |
|
d = updpairs(d,g,nh); |
|
g = updbase(g,nh); |
|
gall = append_one(gall,nh); |
|
i++; |
|
} |
|
|
|
/* XXX free spmat[] explicitly */ |
for ( j = 0, i = 0; j < spcol; j++ ) |
for ( j = 0; j < nsp; j++ ) { |
if ( colstat[j] ) { |
GC_free(spmat[j]); |
mp0 = 0; |
} |
NEXTMP(mp0,mp); mp->dl = st[j]; mp->c = (Obj)STOI(1); |
} |
for ( k = j+1; k < spcol; k++ ) |
if ( DP_Print ) { |
if ( !colstat[k] && spmat[i][k] ) { |
print_eg("Symb",&eg_symb); |
NEXTMP(mp0,mp); mp->dl = st[k]; |
print_eg("Elim1",&eg_elim1); |
mp->c = (Obj)STOI(spmat[i][k]); |
print_eg("Elim2",&eg_elim2); |
} |
fflush(asir_out); |
NEXT(mp) = 0; |
} |
MKDP(nv,mp0,nf); nf->sugar = dm->sugar; |
return g; |
nh = newps_mod(nf,m); |
|
if ( nh == pscalen ) { |
|
psca = (unsigned int **) |
|
REALLOC(psca,2*pscalen*sizeof(unsigned int *)); |
|
pscalen *= 2; |
|
} |
|
dptoca(ps[nh],&psca[nh]); |
|
d = updpairs(d,g,nh); |
|
g = updbase(g,nh); |
|
gall = append_one(gall,nh); |
|
i++; |
|
} |
|
|
|
/* XXX free spmat[] explicitly */ |
|
for ( j = 0; j < nsp; j++ ) { |
|
GCFREE(spmat[j]); |
|
} |
|
} |
|
if ( DP_Print ) { |
|
print_eg("Symb",&eg_symb); |
|
print_eg("Conv",&eg_conv); |
|
print_eg("Elim1",&eg_elim1); |
|
print_eg("Elim2",&eg_elim2); |
|
fflush(asir_out); |
|
} |
|
return g; |
} |
} |
|
|
NODE gb_f4_mod_old(NODE f,int m) |
NODE gb_f4_mod_old(NODE f,int m) |
{ |
{ |
int i,j,k,nh,row,col,nv; |
int i,j,k,nh,row,col,nv; |
NODE r,g,gall; |
NODE r,g,gall; |
NODE s,s0; |
NODE s,s0; |
DP_pairs d,dm,dr,t; |
DP_pairs d,dm,dr,t; |
DP nf,f2,sp,sd,sdm,tdp; |
DP nf,f2,sp,sd,sdm,tdp; |
MP mp,mp0; |
MP mp,mp0; |
NODE blist,bt; |
NODE blist,bt; |
DL *ht,*at,*st; |
DL *ht,*at,*st; |
int **spmat,**redmat; |
int **spmat,**redmat; |
int *colstat,*w; |
int *colstat,*w; |
int rank,nred,nsp,nonzero,spcol; |
int rank,nred,nsp,nonzero,spcol; |
int *indred,*isred,*ri; |
int *indred,*isred,*ri; |
struct oEGT tmp0,tmp1,eg_split_symb,eg_split_elim1,eg_split_elim2; |
struct oEGT tmp0,tmp1,eg_split_symb,eg_split_elim1,eg_split_elim2; |
extern struct oEGT eg_symb,eg_elim1,eg_elim2; |
extern struct oEGT eg_symb,eg_elim1,eg_elim2; |
|
|
init_eg(&eg_symb); init_eg(&eg_elim1); init_eg(&eg_elim2); |
init_eg(&eg_symb); init_eg(&eg_elim1); init_eg(&eg_elim2); |
for ( gall = g = 0, d = 0, r = f; r; r = NEXT(r) ) { |
for ( gall = g = 0, d = 0, r = f; r; r = NEXT(r) ) { |
i = (int)BDY(r); |
i = (int)BDY(r); |
d = updpairs(d,g,i); |
d = updpairs(d,g,i); |
g = updbase(g,i); |
g = updbase(g,i); |
gall = append_one(gall,i); |
gall = append_one(gall,i); |
} |
} |
if ( gall ) |
if ( gall ) |
nv = ((DP)ps[(int)BDY(gall)])->nv; |
nv = ((DP)ps[(int)BDY(gall)])->nv; |
while ( d ) { |
while ( d ) { |
get_eg(&tmp0); |
get_eg(&tmp0); |
minsugar(d,&dm,&dr); d = dr; |
minsugar(d,&dm,&dr); d = dr; |
if ( DP_Print ) |
if ( DP_Print ) |
fprintf(asir_out,"sugar=%d\n",dm->sugar); |
fprintf(asir_out,"sugar=%d\n",dm->sugar); |
blist = 0; s0 = 0; |
blist = 0; s0 = 0; |
/* asph : sum of all head terms of spoly */ |
/* asph : sum of all head terms of spoly */ |
for ( t = dm; t; t = NEXT(t) ) { |
for ( t = dm; t; t = NEXT(t) ) { |
_dp_sp_mod(ps[t->dp1],ps[t->dp2],m,&sp); |
_dp_sp_mod(ps[t->dp1],ps[t->dp2],m,&sp); |
if ( sp ) { |
if ( sp ) { |
MKNODE(bt,sp,blist); blist = bt; |
MKNODE(bt,sp,blist); blist = bt; |
s0 = symb_merge(s0,dp_dllist(sp),nv); |
s0 = symb_merge(s0,dp_dllist(sp),nv); |
} |
} |
} |
} |
/* s0 : all the terms appeared in symbolic redunction */ |
/* s0 : all the terms appeared in symbolic redunction */ |
for ( s = s0, nred = 0; s; s = NEXT(s) ) { |
for ( s = s0, nred = 0; s; s = NEXT(s) ) { |
for ( r = gall; r; r = NEXT(r) ) |
for ( r = gall; r; r = NEXT(r) ) |
if ( _dl_redble(BDY(ps[(int)BDY(r)])->dl,BDY(s),nv) ) |
if ( _dl_redble(BDY(ps[(int)BDY(r)])->dl,BDY(s),nv) ) |
break; |
break; |
if ( r ) { |
if ( r ) { |
dltod(BDY(s),nv,&tdp); |
dltod(BDY(s),nv,&tdp); |
dp_subd(tdp,ps[(int)BDY(r)],&sd); |
dp_subd(tdp,ps[(int)BDY(r)],&sd); |
_dp_mod(sd,m,0,&sdm); |
_dp_mod(sd,m,0,&sdm); |
mulmd_dup(m,sdm,ps[(int)BDY(r)],&f2); |
mulmd_dup(m,sdm,ps[(int)BDY(r)],&f2); |
MKNODE(bt,f2,blist); blist = bt; |
MKNODE(bt,f2,blist); blist = bt; |
s = symb_merge(s,dp_dllist(f2),nv); |
s = symb_merge(s,dp_dllist(f2),nv); |
nred++; |
nred++; |
} |
} |
} |
} |
|
|
get_eg(&tmp1); add_eg(&eg_symb,&tmp0,&tmp1); |
get_eg(&tmp1); add_eg(&eg_symb,&tmp0,&tmp1); |
init_eg(&eg_split_symb); add_eg(&eg_split_symb,&tmp0,&tmp1); |
init_eg(&eg_split_symb); add_eg(&eg_split_symb,&tmp0,&tmp1); |
|
|
/* the first nred polys in blist are reducers */ |
/* the first nred polys in blist are reducers */ |
/* row = the number of all the polys */ |
/* row = the number of all the polys */ |
for ( r = blist, row = 0; r; r = NEXT(r), row++ ); |
for ( r = blist, row = 0; r; r = NEXT(r), row++ ); |
|
|
/* head terms of reducers */ |
/* head terms of reducers */ |
ht = (DL *)MALLOC(nred*sizeof(DL)); |
ht = (DL *)MALLOC(nred*sizeof(DL)); |
for ( r = blist, i = 0; i < nred; r = NEXT(r), i++ ) |
for ( r = blist, i = 0; i < nred; r = NEXT(r), i++ ) |
ht[i] = BDY((DP)BDY(r))->dl; |
ht[i] = BDY((DP)BDY(r))->dl; |
|
|
/* col = number of all terms */ |
/* col = number of all terms */ |
for ( s = s0, col = 0; s; s = NEXT(s), col++ ); |
for ( s = s0, col = 0; s; s = NEXT(s), col++ ); |
|
|
/* head terms of all terms */ |
/* head terms of all terms */ |
at = (DL *)MALLOC(col*sizeof(DL)); |
at = (DL *)MALLOC(col*sizeof(DL)); |
for ( s = s0, i = 0; i < col; s = NEXT(s), i++ ) |
for ( s = s0, i = 0; i < col; s = NEXT(s), i++ ) |
at[i] = (DL)BDY(s); |
at[i] = (DL)BDY(s); |
|
|
/* store coefficients separately in spmat and redmat */ |
/* store coefficients separately in spmat and redmat */ |
nsp = row-nred; |
nsp = row-nred; |
|
|
/* reducer matrix */ |
/* reducer matrix */ |
redmat = (int **)almat(nred,col); |
redmat = (int **)almat(nred,col); |
for ( i = 0, r = blist; i < nred; r = NEXT(r), i++ ) |
for ( i = 0, r = blist; i < nred; r = NEXT(r), i++ ) |
_dpmod_to_vect(BDY(r),at,redmat[i]); |
_dpmod_to_vect(BDY(r),at,redmat[i]); |
/* XXX */ |
/* XXX */ |
/* reduce_reducers_mod(redmat,nred,col,m); */ |
/* reduce_reducers_mod(redmat,nred,col,m); */ |
/* register the position of the head term */ |
/* register the position of the head term */ |
indred = (int *)MALLOC(nred*sizeof(int)); |
indred = (int *)MALLOC(nred*sizeof(int)); |
bzero(indred,nred*sizeof(int)); |
bzero(indred,nred*sizeof(int)); |
isred = (int *)MALLOC(col*sizeof(int)); |
isred = (int *)MALLOC(col*sizeof(int)); |
bzero(isred,col*sizeof(int)); |
bzero(isred,col*sizeof(int)); |
for ( i = 0; i < nred; i++ ) { |
for ( i = 0; i < nred; i++ ) { |
ri = redmat[i]; |
ri = redmat[i]; |
for ( j = 0; j < col && !ri[j]; j++ ); |
for ( j = 0; j < col && !ri[j]; j++ ); |
indred[i] = j; |
indred[i] = j; |
isred[j] = 1; |
isred[j] = 1; |
} |
} |
|
|
spcol = col-nred; |
spcol = col-nred; |
/* head terms not in ht */ |
/* head terms not in ht */ |
st = (DL *)MALLOC(spcol*sizeof(DL)); |
st = (DL *)MALLOC(spcol*sizeof(DL)); |
for ( j = 0, k = 0; j < col; j++ ) |
for ( j = 0, k = 0; j < col; j++ ) |
if ( !isred[j] ) |
if ( !isred[j] ) |
st[k++] = at[j]; |
st[k++] = at[j]; |
|
|
/* spoly matrix; stored in reduced form; terms in ht[] are omitted */ |
/* spoly matrix; stored in reduced form; terms in ht[] are omitted */ |
spmat = almat(nsp,spcol); |
spmat = almat(nsp,spcol); |
w = (int *)MALLOC(col*sizeof(int)); |
w = (int *)MALLOC(col*sizeof(int)); |
for ( ; i < row; r = NEXT(r), i++ ) { |
for ( ; i < row; r = NEXT(r), i++ ) { |
bzero(w,col*sizeof(int)); |
bzero(w,col*sizeof(int)); |
_dpmod_to_vect(BDY(r),at,w); |
_dpmod_to_vect(BDY(r),at,w); |
reduce_sp_by_red_mod(w,redmat,indred,nred,col,m); |
reduce_sp_by_red_mod(w,redmat,indred,nred,col,m); |
for ( j = 0, k = 0; j < col; j++ ) |
for ( j = 0, k = 0; j < col; j++ ) |
if ( !isred[j] ) |
if ( !isred[j] ) |
spmat[i-nred][k++] = w[j]; |
spmat[i-nred][k++] = w[j]; |
} |
} |
|
|
get_eg(&tmp0); add_eg(&eg_elim1,&tmp1,&tmp0); |
get_eg(&tmp0); add_eg(&eg_elim1,&tmp1,&tmp0); |
init_eg(&eg_split_elim1); add_eg(&eg_split_elim1,&tmp1,&tmp0); |
init_eg(&eg_split_elim1); add_eg(&eg_split_elim1,&tmp1,&tmp0); |
|
|
colstat = (int *)MALLOC_ATOMIC(spcol*sizeof(int)); |
colstat = (int *)MALLOC_ATOMIC(spcol*sizeof(int)); |
for ( i = 0, nonzero=0; i < nsp; i++ ) |
for ( i = 0, nonzero=0; i < nsp; i++ ) |
for ( j = 0; j < spcol; j++ ) |
for ( j = 0; j < spcol; j++ ) |
if ( spmat[i][j] ) |
if ( spmat[i][j] ) |
nonzero++; |
nonzero++; |
if ( DP_Print && nsp ) |
if ( DP_Print && nsp ) |
fprintf(asir_out,"spmat : %d x %d (nonzero=%f%%)...", |
fprintf(asir_out,"spmat : %d x %d (nonzero=%f%%)...", |
nsp,spcol,((double)nonzero*100)/(nsp*spcol)); |
nsp,spcol,((double)nonzero*100)/(nsp*spcol)); |
if ( nsp ) |
if ( nsp ) |
rank = generic_gauss_elim_mod(spmat,nsp,spcol,m,colstat); |
rank = generic_gauss_elim_mod(spmat,nsp,spcol,m,colstat); |
else |
else |
rank = 0; |
rank = 0; |
get_eg(&tmp1); add_eg(&eg_elim2,&tmp0,&tmp1); |
get_eg(&tmp1); add_eg(&eg_elim2,&tmp0,&tmp1); |
init_eg(&eg_split_elim2); add_eg(&eg_split_elim2,&tmp0,&tmp1); |
init_eg(&eg_split_elim2); add_eg(&eg_split_elim2,&tmp0,&tmp1); |
|
|
if ( DP_Print ) { |
if ( DP_Print ) { |
fprintf(asir_out,"done rank = %d\n",rank,row,col); |
fprintf(asir_out,"done rank = %d\n",rank,row,col); |
print_eg("Symb",&eg_split_symb); |
print_eg("Symb",&eg_split_symb); |
print_eg("Elim1",&eg_split_elim1); |
print_eg("Elim1",&eg_split_elim1); |
print_eg("Elim2",&eg_split_elim2); |
print_eg("Elim2",&eg_split_elim2); |
fprintf(asir_out,"\n"); |
fprintf(asir_out,"\n"); |
} |
} |
for ( j = 0, i = 0; j < spcol; j++ ) |
for ( j = 0, i = 0; j < spcol; j++ ) |
if ( colstat[j] ) { |
if ( colstat[j] ) { |
mp0 = 0; |
mp0 = 0; |
NEXTMP(mp0,mp); mp->dl = st[j]; mp->c = STOI(1); |
NEXTMP(mp0,mp); mp->dl = st[j]; mp->c = (Obj)STOI(1); |
for ( k = j+1; k < spcol; k++ ) |
for ( k = j+1; k < spcol; k++ ) |
if ( !colstat[k] && spmat[i][k] ) { |
if ( !colstat[k] && spmat[i][k] ) { |
NEXTMP(mp0,mp); mp->dl = st[k]; |
NEXTMP(mp0,mp); mp->dl = st[k]; |
mp->c = STOI(spmat[i][k]); |
mp->c = (Obj)STOI(spmat[i][k]); |
} |
} |
NEXT(mp) = 0; |
NEXT(mp) = 0; |
MKDP(nv,mp0,nf); nf->sugar = dm->sugar; |
MKDP(nv,mp0,nf); nf->sugar = dm->sugar; |
nh = newps_mod(nf,m); |
nh = newps_mod(nf,m); |
d = updpairs(d,g,nh); |
d = updpairs(d,g,nh); |
g = updbase(g,nh); |
g = updbase(g,nh); |
gall = append_one(gall,nh); |
gall = append_one(gall,nh); |
i++; |
i++; |
} |
} |
} |
} |
if ( DP_Print ) { |
if ( DP_Print ) { |
print_eg("Symb",&eg_symb); |
print_eg("Symb",&eg_symb); |
print_eg("Elim1",&eg_elim1); |
print_eg("Elim1",&eg_elim1); |
print_eg("Elim2",&eg_elim2); |
print_eg("Elim2",&eg_elim2); |
fflush(asir_out); |
fflush(asir_out); |
} |
} |
return g; |
return g; |
} |
} |
|
|
int DPPlength(DP_pairs n) |
int DPPlength(DP_pairs n) |
{ |
{ |
int i; |
int i; |
|
|
for ( i = 0; n; n = NEXT(n), i++ ); |
for ( i = 0; n; n = NEXT(n), i++ ); |
return i; |
return i; |
} |
} |
|
|
void printdl(DL dl) |
void printdl(DL dl) |
{ |
{ |
int i; |
int i; |
|
|
fprintf(asir_out,"<<"); |
fprintf(asir_out,"<<"); |
for ( i = 0; i < CNVars-1; i++ ) |
for ( i = 0; i < CNVars-1; i++ ) |
fprintf(asir_out,"%d,",dl->d[i]); |
fprintf(asir_out,"%d,",dl->d[i]); |
fprintf(asir_out,"%d>>",dl->d[i]); |
fprintf(asir_out,"%d>>",dl->d[i]); |
} |
} |
|
|
void pltovl(LIST l,VL *vl) |
void pltovl(LIST l,VL *vl) |
{ |
{ |
NODE n; |
NODE n; |
VL r,r0; |
VL r,r0; |
|
|
n = BDY(l); |
n = BDY(l); |
for ( r0 = 0; n; n = NEXT(n) ) { |
for ( r0 = 0; n; n = NEXT(n) ) { |
NEXTVL(r0,r); r->v = VR((P)BDY(n)); |
NEXTVL(r0,r); r->v = VR((P)BDY(n)); |
} |
} |
if ( r0 ) NEXT(r) = 0; |
if ( r0 ) NEXT(r) = 0; |
*vl = r0; |
*vl = r0; |
} |
} |
|
|
|
void vltopl(VL vl,LIST *l) |
|
{ |
|
VL n; |
|
NODE r,r0; |
|
P p; |
|
|
|
n = vl; |
|
for ( r0 = 0; n; n = NEXT(n) ) { |
|
NEXTNODE(r0,r); MKV(n->v,p); BDY(r) = (pointer)p; |
|
} |
|
if ( r0 ) NEXT(r) = 0; |
|
MKLIST(*l,r0); |
|
} |
|
|
void makesubst(VL v,NODE *s) |
void makesubst(VL v,NODE *s) |
{ |
{ |
NODE r,r0; |
NODE r,r0; |
Q q; |
Q q; |
unsigned int n; |
unsigned int n; |
|
|
for ( r0 = 0; v; v = NEXT(v) ) { |
for ( r0 = 0; v; v = NEXT(v) ) { |
NEXTNODE(r0,r); BDY(r) = (pointer)v->v; |
NEXTNODE(r0,r); BDY(r) = (pointer)v->v; |
#if defined(_PA_RISC1_1) |
#if defined(_PA_RISC1_1) |
n = mrand48()&BMASK; UTOQ(n,q); |
n = mrand48()&BMASK; UTOQ(n,q); |
#else |
#else |
n = random(); UTOQ(n,q); |
n = random(); UTOQ(n,q); |
#endif |
#endif |
NEXTNODE(r0,r); BDY(r) = (pointer)q; |
NEXTNODE(r0,r); BDY(r) = (pointer)q; |
} |
} |
if ( r0 ) NEXT(r) = 0; |
if ( r0 ) NEXT(r) = 0; |
*s = r0; |
*s = r0; |
} |
} |
|
|
void printsubst(NODE s) |
void printsubst(NODE s) |
{ |
{ |
fputc('[',asir_out); |
fputc('[',asir_out); |
while ( s ) { |
while ( s ) { |
printv(CO,(V)BDY(s)); s = NEXT(s); |
printv(CO,(V)BDY(s)); s = NEXT(s); |
fprintf(asir_out,"->%d",QTOS((Q)BDY(s))); |
fprintf(asir_out,"->%d",QTOS((Q)BDY(s))); |
if ( NEXT(s) ) { |
if ( NEXT(s) ) { |
fputc(',',asir_out); s = NEXT(s); |
fputc(',',asir_out); s = NEXT(s); |
} else |
} else |
break; |
break; |
} |
} |
fprintf(asir_out,"]\n"); return; |
fprintf(asir_out,"]\n"); return; |
} |
} |
|
|
void vlminus(VL v,VL w,VL *d) |
void vlminus(VL v,VL w,VL *d) |
{ |
{ |
int i,j,n,m; |
int i,j,n,m; |
V *va,*wa; |
V *va,*wa; |
V a; |
V a; |
VL r,r0; |
VL r,r0; |
VL t; |
VL t; |
|
|
for ( n = 0, t = v; t; t = NEXT(t), n++ ); |
for ( n = 0, t = v; t; t = NEXT(t), n++ ); |
va = (V *)ALLOCA(n*sizeof(V)); |
va = (V *)ALLOCA(n*sizeof(V)); |
for ( i = 0, t = v; t; t = NEXT(t), i++ ) |
for ( i = 0, t = v; t; t = NEXT(t), i++ ) |
va[i] = t->v; |
va[i] = t->v; |
for ( m = 0, t = w; t; t = NEXT(t), m++ ); |
for ( m = 0, t = w; t; t = NEXT(t), m++ ); |
wa = (V *)ALLOCA(m*sizeof(V)); |
wa = (V *)ALLOCA(m*sizeof(V)); |
for ( i = 0, t = w; t; t = NEXT(t), i++ ) |
for ( i = 0, t = w; t; t = NEXT(t), i++ ) |
wa[i] = t->v; |
wa[i] = t->v; |
for ( i = 0; i < n; i++ ) { |
for ( i = 0; i < n; i++ ) { |
a = va[i]; |
a = va[i]; |
for ( j = 0; j < m; j++ ) |
for ( j = 0; j < m; j++ ) |
if ( a == wa[j] ) |
if ( a == wa[j] ) |
break; |
break; |
if ( j < m ) |
if ( j < m ) |
va[i] = 0; |
va[i] = 0; |
} |
} |
for ( r0 = 0, i = 0; i < n; i++ ) |
for ( r0 = 0, i = 0; i < n; i++ ) |
if ( va[i] ) { NEXTVL(r0,r); r->v = va[i]; } |
if ( va[i] ) { NEXTVL(r0,r); r->v = va[i]; } |
if ( r0 ) NEXT(r) = 0; |
if ( r0 ) NEXT(r) = 0; |
*d = r0; |
*d = r0; |
} |
} |
|
|
int validhc(P a,int m,NODE s) |
int validhc(P a,int m,NODE s) |
{ |
{ |
P c,c1; |
P c,c1; |
V v; |
V v; |
|
|
if ( !a ) |
if ( !a ) |
return 0; |
return 0; |
for ( c = a; s; s = NEXT(s) ) { |
for ( c = a; s; s = NEXT(s) ) { |
v = (V)BDY(s); s = NEXT(s); |
v = (V)BDY(s); s = NEXT(s); |
substp(CO,c,v,(P)BDY(s),&c1); c = c1; |
substp(CO,c,v,(P)BDY(s),&c1); c = c1; |
} |
} |
ptomp(m,c,&c1); |
ptomp(m,c,&c1); |
return c1 ? 1 : 0; |
return c1 ? 1 : 0; |
} |
} |
|
|
void setup_arrays(NODE f,int m,NODE *r) |
void setup_arrays(NODE f,int m,NODE *r) |
{ |
{ |
int i; |
int i; |
NODE s,s0,f0; |
NODE s,s0,f0; |
|
|
#if 1 |
#if 1 |
f0 = f = NODE_sortb(f,1); |
f0 = f = NODE_sortb(f,1); |
#else |
#else |
f0 = f; |
f0 = f; |
#endif |
#endif |
psn = length(f); pslen = 2*psn; |
psn = length(f); pslen = 2*psn; |
ps = (DP *)MALLOC(pslen*sizeof(DP)); |
ps = (DP *)MALLOC(pslen*sizeof(DP)); |
psh = (DL *)MALLOC(pslen*sizeof(DL)); |
psh = (DL *)MALLOC(pslen*sizeof(DL)); |
pss = (int *)MALLOC(pslen*sizeof(int)); |
pss = (int *)MALLOC(pslen*sizeof(int)); |
psc = (P *)MALLOC(pslen*sizeof(P)); |
psc = (P *)MALLOC(pslen*sizeof(P)); |
for ( i = 0; i < psn; i++, f = NEXT(f) ) { |
for ( i = 0; i < psn; i++, f = NEXT(f) ) { |
prim_part((DP)BDY(f),m,&ps[i]); |
prim_part((DP)BDY(f),m,&ps[i]); |
if ( Demand ) |
if ( Demand ) |
dp_save(i,(Obj)ps[i],0); |
dp_save(i,(Obj)ps[i],0); |
psh[i] = BDY(ps[i])->dl; |
psh[i] = BDY(ps[i])->dl; |
pss[i] = ps[i]->sugar; |
pss[i] = ps[i]->sugar; |
psc[i] = BDY(ps[i])->c; |
psc[i] = (P)BDY(ps[i])->c; |
} |
} |
if ( GenTrace ) { |
if ( GenTrace ) { |
Q q; |
Q q; |
STRING fname; |
STRING fname; |
LIST input; |
LIST input; |
NODE arg,t,t1; |
NODE arg,t,t1; |
Obj obj; |
Obj obj; |
|
|
t = 0; |
t = 0; |
for ( i = psn-1; i >= 0; i-- ) { |
for ( i = psn-1; i >= 0; i-- ) { |
MKNODE(t1,ps[i],t); |
MKNODE(t1,ps[i],t); |
t = t1; |
t = t1; |
} |
} |
MKLIST(input,t); |
MKLIST(input,t); |
|
|
if ( OXCheck >= 0 ) { |
if ( OXCheck >= 0 ) { |
STOQ(OXCheck,q); |
STOQ(OXCheck,q); |
MKSTR(fname,"register_input"); |
MKSTR(fname,"register_input"); |
arg = mknode(3,q,fname,input); |
arg = mknode(3,q,fname,input); |
Pox_cmo_rpc(arg,&obj); |
Pox_cmo_rpc(arg,&obj); |
} else if ( OXCheck < 0 ) { |
} else if ( OXCheck < 0 ) { |
MKNODE(AllTraceList,input,0); |
MKNODE(AllTraceList,input,0); |
} |
} |
} |
} |
for ( s0 = 0, i = 0; i < psn; i++ ) { |
for ( s0 = 0, i = 0; i < psn; i++ ) { |
NEXTNODE(s0,s); BDY(s) = (pointer)i; |
NEXTNODE(s0,s); BDY(s) = (pointer)i; |
} |
} |
if ( s0 ) NEXT(s) = 0; |
if ( s0 ) NEXT(s) = 0; |
*r = s0; |
*r = s0; |
} |
} |
|
|
void prim_part(DP f,int m,DP *r) |
void prim_part(DP f,int m,DP *r) |
{ |
{ |
P d,t; |
P d,t; |
|
|
if ( m > 0 ) { |
if ( m > 0 ) { |
if ( PCoeffs ) |
if ( PCoeffs ) |
dp_prim_mod(f,m,r); |
dp_prim_mod(f,m,r); |
else |
else |
*r = f; |
_dp_monic(f,m,r); |
} else { |
} else { |
if ( dp_fcoeffs ) |
if ( dp_fcoeffs || PCoeffs ) |
*r = f; |
dp_prim(f,r); |
else if ( PCoeffs ) |
else |
dp_prim(f,r); |
dp_ptozp(f,r); |
else |
if ( GenTrace && TraceList ) { |
dp_ptozp(f,r); |
/* adust the denominator according to the final |
if ( GenTrace && TraceList ) { |
content reduction */ |
/* adust the denominator according to the final |
divsp(CO,(P)BDY(f)->c,(P)BDY(*r)->c,&d); |
content reduction */ |
mulp(CO,(P)ARG3(BDY((LIST)BDY(TraceList))),d,&t); |
divsp(CO,BDY(f)->c,BDY(*r)->c,&d); |
ARG3(BDY((LIST)BDY(TraceList))) = t; |
mulp(CO,(P)ARG3(BDY((LIST)BDY(TraceList))),d,&t); |
} |
ARG3(BDY((LIST)BDY(TraceList))) = t; |
} |
} |
|
} |
|
} |
} |
|
|
NODE /* of DP */ NODE_sortb_insert( DP newdp, NODE /* of DP */ nd, int dec ) |
NODE /* of DP */ NODE_sortb_insert( DP newdp, NODE /* of DP */ nd, int dec ) |
{ |
{ |
register NODE last, p; |
register NODE last, p; |
register DL newdl = BDY(newdp)->dl; |
register DL newdl = BDY(newdp)->dl; |
register int (*cmpfun)() = cmpdl, nv = CNVars; |
register int (*cmpfun)() = cmpdl, nv = CNVars; |
NODE newnd; |
NODE newnd; |
int sgn = dec ? 1 : -1; |
int sgn = dec ? 1 : -1; |
MKNODE( newnd, newdp, 0 ); |
MKNODE( newnd, newdp, 0 ); |
if ( !(last = nd) || sgn*(*cmpfun)( nv, newdl, BDY((DP) BDY(last))->dl ) > 0 ) { |
if ( !(last = nd) || sgn*(*cmpfun)( nv, newdl, BDY((DP) BDY(last))->dl ) > 0 ) { |
NEXT(newnd) = last; |
NEXT(newnd) = last; |
return newnd; |
return newnd; |
} |
} |
for ( ; p = NEXT(last); last = p ) |
for ( ; p = NEXT(last); last = p ) |
if ( sgn*(*cmpfun)( nv, newdl, BDY((DP) BDY(p))->dl ) > 0 ) break; |
if ( sgn*(*cmpfun)( nv, newdl, BDY((DP) BDY(p))->dl ) > 0 ) break; |
if ( p ) NEXT(NEXT(last) = newnd) = p; |
if ( p ) NEXT(NEXT(last) = newnd) = p; |
else NEXT(last) = newnd; |
else NEXT(last) = newnd; |
return nd; |
return nd; |
} |
} |
|
|
NODE NODE_sortb( NODE node, int dec ) |
NODE NODE_sortb( NODE node, int dec ) |
{ |
{ |
register NODE nd, ans; |
register NODE nd, ans; |
|
|
for ( ans = 0, nd = node; nd; nd = NEXT(nd) ) |
for ( ans = 0, nd = node; nd; nd = NEXT(nd) ) |
ans = NODE_sortb_insert( (DP) BDY(nd), ans, dec ); |
ans = NODE_sortb_insert( (DP) BDY(nd), ans, dec ); |
return ans; |
return ans; |
} |
} |
|
|
NODE /* of index */ NODE_sortbi_insert( int newdpi, NODE /* of index */ nd, int dec ) |
NODE /* of index */ NODE_sortbi_insert( int newdpi, NODE /* of index */ nd, int dec ) |
{ |
{ |
register NODE last, p; |
register NODE last, p; |
register DL newdl = psh[newdpi]; |
register DL newdl = psh[newdpi]; |
register int (*cmpfun)() = cmpdl, nv = CNVars; |
register int (*cmpfun)() = cmpdl, nv = CNVars; |
NODE newnd; |
NODE newnd; |
int sgn = dec ? 1 : -1; |
int sgn = dec ? 1 : -1; |
MKNODE( newnd, newdpi, 0 ); |
MKNODE( newnd, newdpi, 0 ); |
if ( !(last = nd) || sgn*(*cmpfun)( nv, newdl, psh[(int)BDY(last)] ) > 0 ) { |
if ( !(last = nd) || sgn*(*cmpfun)( nv, newdl, psh[(int)BDY(last)] ) > 0 ) { |
NEXT(newnd) = last; |
NEXT(newnd) = last; |
return newnd; |
return newnd; |
} |
} |
for ( ; p = NEXT(last); last = p ) |
for ( ; p = NEXT(last); last = p ) |
if ( sgn*(*cmpfun)( nv, newdl, psh[(int)BDY(p)] ) > 0 ) break; |
if ( sgn*(*cmpfun)( nv, newdl, psh[(int)BDY(p)] ) > 0 ) break; |
if ( p ) NEXT(NEXT(last) = newnd) = p; |
if ( p ) NEXT(NEXT(last) = newnd) = p; |
else NEXT(last) = newnd; |
else NEXT(last) = newnd; |
return nd; |
return nd; |
} |
} |
|
|
NODE NODE_sortbi( NODE node, int dec ) |
NODE NODE_sortbi( NODE node, int dec ) |
{ |
{ |
register NODE nd, ans; |
register NODE nd, ans; |
|
|
for ( ans = 0, nd = node; nd; nd = NEXT(nd) ) |
for ( ans = 0, nd = node; nd; nd = NEXT(nd) ) |
ans = NODE_sortbi_insert( (int) BDY(nd), ans, dec ); |
ans = NODE_sortbi_insert( (int) BDY(nd), ans, dec ); |
return ans; |
return ans; |
} |
} |
|
|
void reduceall(NODE in,NODE *h) |
void reduceall(NODE in,NODE *h) |
{ |
{ |
NODE r,t,top; |
NODE r,t,top; |
int n,i,j; |
int n,i,j; |
int *w; |
int *w; |
DP g,g1; |
DP g,g1; |
struct oEGT tmp0,tmp1; |
struct oEGT tmp0,tmp1; |
|
|
if ( NoRA ) { |
if ( NoRA ) { |
*h = in; return; |
*h = in; return; |
} |
} |
if ( DP_Print || DP_PrintShort ) { |
if ( DP_Print || DP_PrintShort ) { |
fprintf(asir_out,"reduceall\n"); fflush(asir_out); |
fprintf(asir_out,"reduceall\n"); fflush(asir_out); |
} |
} |
r = NODE_sortbi(in,0); |
r = NODE_sortbi(in,0); |
n = length(r); |
n = length(r); |
w = (int *)ALLOCA(n*sizeof(int)); |
w = (int *)ALLOCA(n*sizeof(int)); |
for ( i = 0, t = r; i < n; i++, t = NEXT(t) ) |
for ( i = 0, t = r; i < n; i++, t = NEXT(t) ) |
w[i] = (int)BDY(t); |
w[i] = (int)BDY(t); |
for ( i = 0; i < n; i++ ) { |
/* w[i] < 0 : reduced to 0 */ |
for ( top = 0, j = n-1; j >= 0; j-- ) |
for ( i = 0; i < n; i++ ) { |
if ( j != i ) { |
for ( top = 0, j = n-1; j >= 0; j-- ) |
MKNODE(t,(pointer)w[j],top); top = t; |
if ( w[j] >= 0 && j != i ) { |
} |
MKNODE(t,(pointer)w[j],top); top = t; |
get_eg(&tmp0); |
} |
dp_load(w[i],&ps[w[i]]); |
get_eg(&tmp0); |
|
dp_load(w[i],&ps[w[i]]); |
|
|
if ( GenTrace ) { |
if ( GenTrace ) { |
Q q; |
Q q; |
NODE node; |
NODE node; |
LIST hist; |
LIST hist; |
|
|
STOQ(w[i],q); |
STOQ(w[i],q); |
node = mknode(4,ONE,q,ONE,ONE); |
node = mknode(4,ONE,q,ONE,ONE); |
MKLIST(hist,node); |
MKLIST(hist,node); |
MKNODE(TraceList,hist,0); |
MKNODE(TraceList,hist,0); |
} |
} |
_dp_nf(top,ps[w[i]],ps,1,&g); |
_dp_nf(top,ps[w[i]],ps,1,&g); |
prim_part(g,0,&g1); |
prim_part(g,0,&g1); |
get_eg(&tmp1); add_eg(&eg_ra,&tmp0,&tmp1); |
get_eg(&tmp1); add_eg(&eg_ra,&tmp0,&tmp1); |
if ( DP_Print || DP_PrintShort ) { |
if ( DP_Print || DP_PrintShort ) { |
fprintf(asir_out,"."); fflush(asir_out); |
fprintf(asir_out,"."); fflush(asir_out); |
} |
} |
w[i] = newps(g1,0,(NODE)0); |
if ( g1 ) { |
} |
w[i] = newps(g1,0,(NODE)0); |
for ( top = 0, j = n-1; j >= 0; j-- ) { |
} else { |
MKNODE(t,(pointer)w[j],top); top = t; |
w[i] = -1; |
} |
} |
*h = top; |
} |
if ( DP_Print || DP_PrintShort ) |
for ( top = 0, j = n-1; j >= 0; j-- ) { |
fprintf(asir_out,"\n"); |
if ( w[j] >= 0 ) { |
|
MKNODE(t,(pointer)w[j],top); top = t; |
|
} |
|
} |
|
*h = top; |
|
if ( DP_Print || DP_PrintShort ) |
|
fprintf(asir_out,"\n"); |
} |
} |
|
|
void reduceall_mod(NODE in,int m,NODE *h) |
void reduceall_mod(NODE in,int m,NODE *h) |
{ |
{ |
NODE r,t,top; |
NODE r,t,top; |
int n,i,j; |
int n,i,j; |
int *w; |
int *w; |
DP g,p; |
DP g,p; |
struct oEGT tmp0,tmp1; |
struct oEGT tmp0,tmp1; |
|
|
if ( NoRA ) { |
if ( NoRA ) { |
*h = in; return; |
*h = in; return; |
} |
} |
if ( DP_Print || DP_PrintShort ) { |
if ( DP_Print || DP_PrintShort ) { |
fprintf(asir_out,"reduceall\n"); fflush(asir_out); |
fprintf(asir_out,"reduceall\n"); fflush(asir_out); |
} |
} |
r = NODE_sortbi(in,0); |
r = NODE_sortbi(in,0); |
n = length(r); |
n = length(r); |
w = (int *)ALLOCA(n*sizeof(int)); |
w = (int *)ALLOCA(n*sizeof(int)); |
for ( i = 0, t = r; i < n; i++, t = NEXT(t) ) |
for ( i = 0, t = r; i < n; i++, t = NEXT(t) ) |
w[i] = (int)BDY(t); |
w[i] = (int)BDY(t); |
for ( i = 0; i < n; i++ ) { |
/* w[i] < 0 : reduced to 0 */ |
for ( top = 0, j = n-1; j >= 0; j-- ) |
for ( i = 0; i < n; i++ ) { |
if ( j != i ) { |
for ( top = 0, j = n-1; j >= 0; j-- ) |
MKNODE(t,(pointer)w[j],top); top = t; |
if ( w[j] >= 0 && j != i ) { |
} |
MKNODE(t,(pointer)w[j],top); top = t; |
get_eg(&tmp0); |
} |
if ( PCoeffs ) |
get_eg(&tmp0); |
dp_nf_mod(top,ps[w[i]],ps,m,1,&g); |
if ( PCoeffs ) |
else { |
dp_nf_mod(top,ps[w[i]],ps,m,1,&g); |
dpto_dp(ps[w[i]],&p); |
else { |
_dp_nf_mod_destructive(top,p,ps,m,1,&g); |
dpto_dp(ps[w[i]],&p); |
} |
_dp_nf_mod_destructive(top,p,ps,m,1,&g); |
get_eg(&tmp1); add_eg(&eg_ra,&tmp0,&tmp1); |
} |
if ( DP_Print || DP_PrintShort ) { |
get_eg(&tmp1); add_eg(&eg_ra,&tmp0,&tmp1); |
fprintf(asir_out,"."); fflush(asir_out); |
if ( DP_Print || DP_PrintShort ) { |
} |
fprintf(asir_out,"."); fflush(asir_out); |
w[i] = newps_mod(g,m); |
} |
} |
if ( g ) { |
for ( top = 0, j = n-1; j >= 0; j-- ) { |
w[i] = newps_mod(g,m); |
MKNODE(t,(pointer)w[j],top); top = t; |
} else { |
} |
w[i] = -1; |
*h = top; |
} |
if ( DP_Print || DP_PrintShort ) |
} |
fprintf(asir_out,"\n"); |
for ( top = 0, j = n-1; j >= 0; j-- ) { |
|
if ( w[j] >= 0 ) { |
|
MKNODE(t,(pointer)w[j],top); top = t; |
|
} |
|
} |
|
*h = top; |
|
if ( DP_Print || DP_PrintShort ) |
|
fprintf(asir_out,"\n"); |
} |
} |
|
|
int newps(DP a,int m,NODE subst) |
int newps(DP a,int m,NODE subst) |
{ |
{ |
if ( m && !validhc(!a?0:BDY(a)->c,m,subst) ) |
if ( m && !validhc(!a?0:(P)BDY(a)->c,m,subst) ) |
return -1; |
return -1; |
if ( psn == pslen ) { |
if ( psn == pslen ) { |
pslen *= 2; |
pslen *= 2; |
ps = (DP *)REALLOC((char *)ps,pslen*sizeof(DP)); |
ps = (DP *)REALLOC((char *)ps,pslen*sizeof(DP)); |
psh = (DL *)REALLOC((char *)psh,pslen*sizeof(DL)); |
psh = (DL *)REALLOC((char *)psh,pslen*sizeof(DL)); |
pss = (int *)REALLOC((char *)pss,pslen*sizeof(int)); |
pss = (int *)REALLOC((char *)pss,pslen*sizeof(int)); |
psc = (P *)REALLOC((char *)psc,pslen*sizeof(P)); |
psc = (P *)REALLOC((char *)psc,pslen*sizeof(P)); |
if ( m ) |
if ( m ) |
psm = (DP *)REALLOC((char *)psm,pslen*sizeof(DP)); |
psm = (DP *)REALLOC((char *)psm,pslen*sizeof(DP)); |
} |
} |
if ( Demand ) { |
if ( Demand ) { |
if ( doing_f4 ) |
if ( doing_f4 ) |
ps[psn] = a; |
ps[psn] = a; |
else |
else |
ps[psn] = 0; |
ps[psn] = 0; |
dp_save(psn,(Obj)a,0); |
dp_save(psn,(Obj)a,0); |
} else |
} else |
ps[psn] = a; |
ps[psn] = a; |
psh[psn] = BDY(a)->dl; |
psh[psn] = BDY(a)->dl; |
pss[psn] = a->sugar; |
pss[psn] = a->sugar; |
psc[psn] = BDY(a)->c; |
psc[psn] = (P)BDY(a)->c; |
if ( m ) |
if ( m ) |
_dp_mod(a,m,subst,&psm[psn]); |
_dp_mod(a,m,subst,&psm[psn]); |
if ( GenTrace ) { |
if ( GenTrace ) { |
NODE tn,tr,tr1; |
NODE tn,tr,tr1; |
LIST trace,trace1; |
LIST trace,trace1; |
NODE arg; |
NODE arg; |
Q q1,q2; |
Q q1,q2; |
STRING fname; |
STRING fname; |
Obj obj; |
Obj obj; |
|
|
/* reverse the TraceList */ |
/* reverse the TraceList */ |
tn = TraceList; |
tn = TraceList; |
for ( tr = 0; tn; tn = NEXT(tn) ) { |
for ( tr = 0; tn; tn = NEXT(tn) ) { |
MKNODE(tr1,BDY(tn),tr); tr = tr1; |
MKNODE(tr1,BDY(tn),tr); tr = tr1; |
} |
} |
MKLIST(trace,tr); |
MKLIST(trace,tr); |
if ( OXCheck >= 0 ) { |
if ( OXCheck >= 0 ) { |
STOQ(OXCheck,q1); |
STOQ(OXCheck,q1); |
MKSTR(fname,"check_trace"); |
MKSTR(fname,"check_trace"); |
STOQ(psn,q2); |
STOQ(psn,q2); |
arg = mknode(5,q1,fname,a,q2,trace); |
arg = mknode(5,q1,fname,a,q2,trace); |
Pox_cmo_rpc(arg,&obj); |
Pox_cmo_rpc(arg,&obj); |
} else if ( OXCheck < 0 ) { |
} else if ( OXCheck < 0 ) { |
STOQ(psn,q1); |
STOQ(psn,q1); |
tn = mknode(2,q1,trace); |
tn = mknode(2,q1,trace); |
MKLIST(trace1,tn); |
MKLIST(trace1,tn); |
MKNODE(tr,trace1,AllTraceList); |
MKNODE(tr,trace1,AllTraceList); |
AllTraceList = tr; |
AllTraceList = tr; |
} else |
} else |
dp_save(psn,(Obj)trace,"t"); |
dp_save(psn,(Obj)trace,"t"); |
TraceList = 0; |
TraceList = 0; |
} |
} |
return psn++; |
return psn++; |
} |
} |
|
|
int newps_nosave(DP a,int m,NODE subst) |
int newps_nosave(DP a,int m,NODE subst) |
{ |
{ |
if ( m && !validhc(!a?0:BDY(a)->c,m,subst) ) |
if ( m && !validhc(!a?0:(P)BDY(a)->c,m,subst) ) |
return -1; |
return -1; |
if ( psn == pslen ) { |
if ( psn == pslen ) { |
pslen *= 2; |
pslen *= 2; |
ps = (DP *)REALLOC((char *)ps,pslen*sizeof(DP)); |
ps = (DP *)REALLOC((char *)ps,pslen*sizeof(DP)); |
psh = (DL *)REALLOC((char *)psh,pslen*sizeof(DL)); |
psh = (DL *)REALLOC((char *)psh,pslen*sizeof(DL)); |
pss = (int *)REALLOC((char *)pss,pslen*sizeof(int)); |
pss = (int *)REALLOC((char *)pss,pslen*sizeof(int)); |
psc = (P *)REALLOC((char *)psc,pslen*sizeof(P)); |
psc = (P *)REALLOC((char *)psc,pslen*sizeof(P)); |
if ( m ) |
if ( m ) |
psm = (DP *)REALLOC((char *)psm,pslen*sizeof(DP)); |
psm = (DP *)REALLOC((char *)psm,pslen*sizeof(DP)); |
} |
} |
ps[psn] = 0; |
ps[psn] = 0; |
psh[psn] = BDY(a)->dl; |
psh[psn] = BDY(a)->dl; |
pss[psn] = a->sugar; |
pss[psn] = a->sugar; |
psc[psn] = BDY(a)->c; |
psc[psn] = (P)BDY(a)->c; |
if ( m ) |
if ( m ) |
_dp_mod(a,m,subst,&psm[psn]); |
_dp_mod(a,m,subst,&psm[psn]); |
return psn++; |
return psn++; |
} |
} |
|
|
int newps_mod(DP a,int m) |
int newps_mod(DP a,int m) |
{ |
{ |
if ( psn == pslen ) { |
if ( psn == pslen ) { |
pslen *= 2; |
pslen *= 2; |
ps = (DP *)REALLOC((char *)ps,pslen*sizeof(DP)); |
ps = (DP *)REALLOC((char *)ps,pslen*sizeof(DP)); |
psh = (DL *)REALLOC((char *)psh,pslen*sizeof(DL)); |
psh = (DL *)REALLOC((char *)psh,pslen*sizeof(DL)); |
pss = (int *)REALLOC((char *)pss,pslen*sizeof(int)); |
pss = (int *)REALLOC((char *)pss,pslen*sizeof(int)); |
psc = (P *)REALLOC((char *)psc,pslen*sizeof(P)); /* XXX */ |
psc = (P *)REALLOC((char *)psc,pslen*sizeof(P)); /* XXX */ |
} |
} |
ps[psn] = a; |
ps[psn] = a; |
psh[psn] = BDY(ps[psn])->dl; |
psh[psn] = BDY(ps[psn])->dl; |
pss[psn] = ps[psn]->sugar; |
pss[psn] = ps[psn]->sugar; |
return psn++; |
return psn++; |
} |
} |
|
|
void reducebase_dehomo(NODE f,NODE *g) |
void reducebase_dehomo(NODE f,NODE *g) |
{ |
{ |
int n,i,j,k; |
int n,i,j,k; |
int *r; |
int *r; |
DL *w,d; |
DL *w,d; |
DP u; |
DP u; |
NODE t,top; |
NODE t,top; |
|
|
n = length(f); |
n = length(f); |
w = (DL *)ALLOCA(n*sizeof(DL)); |
w = (DL *)ALLOCA(n*sizeof(DL)); |
r = (int *)ALLOCA(n*sizeof(int)); |
r = (int *)ALLOCA(n*sizeof(int)); |
for ( i = 0, t = f; i < n; i++, t = NEXT(t) ) { |
for ( i = 0, t = f; i < n; i++, t = NEXT(t) ) { |
r[i] = (int)BDY(t); w[i] = psh[r[i]]; |
r[i] = (int)BDY(t); w[i] = psh[r[i]]; |
} |
} |
for ( i = 0; i < n; i++ ) { |
for ( i = 0; i < n; i++ ) { |
for ( j = 0, d = w[i]; j < n; j++ ) { |
for ( j = 0, d = w[i]; j < n; j++ ) { |
if ( j != i ) { |
if ( j != i ) { |
for ( k = 0; k < NVars; k++ ) |
for ( k = 0; k < NVars; k++ ) |
if ( d->d[k] < w[j]->d[k] ) |
if ( d->d[k] < w[j]->d[k] ) |
break; |
break; |
if ( k == NVars ) |
if ( k == NVars ) |
break; |
break; |
} |
} |
} |
} |
if ( j != n ) |
if ( j != n ) |
r[i] = -1; |
r[i] = -1; |
} |
} |
for ( top = 0, i = n-1; i >= 0; i-- ) |
for ( top = 0, i = n-1; i >= 0; i-- ) |
if ( r[i] >= 0 ) { |
if ( r[i] >= 0 ) { |
dp_load(r[i],&ps[r[i]]); dp_dehomo(ps[r[i]],&u); |
dp_load(r[i],&ps[r[i]]); dp_dehomo(ps[r[i]],&u); |
if ( GenTrace ) { |
if ( GenTrace ) { |
Q q; |
Q q; |
LIST hist; |
LIST hist; |
NODE node; |
NODE node; |
|
|
STOQ(r[i],q); |
STOQ(r[i],q); |
node = mknode(4,0,q,0,0); |
node = mknode(4,NULLP,q,NULLP,NULLP); |
MKLIST(hist,node); |
MKLIST(hist,node); |
MKNODE(TraceList,hist,0); |
MKNODE(TraceList,hist,0); |
} |
} |
j = newps(u,0,0); |
j = newps(u,0,0); |
MKNODE(t,j,top); top = t; |
MKNODE(t,j,top); top = t; |
} |
} |
*g = top; |
*g = top; |
} |
} |
|
|
NODE append_one(NODE f,int n) |
NODE append_one(NODE f,int n) |
{ |
{ |
NODE t; |
NODE t; |
|
|
if ( Reverse || !f ) { |
if ( Reverse || !f ) { |
MKNODE(t,(pointer)n,f); return t; |
MKNODE(t,(pointer)n,f); return t; |
} else { |
} else { |
for ( t = f; NEXT(t); t = NEXT(t) ); |
for ( t = f; NEXT(t); t = NEXT(t) ); |
MKNODE(NEXT(t),(pointer)n,0); |
MKNODE(NEXT(t),(pointer)n,0); |
return f; |
return f; |
} |
} |
} |
} |
|
|
DP_pairs minp( DP_pairs d, DP_pairs *prest ) |
DP_pairs minp( DP_pairs d, DP_pairs *prest ) |
{ |
{ |
register DP_pairs m, ml, p, l; |
register DP_pairs m, ml, p, l; |
register DL lcm; |
register DL lcm; |
register int s, nv = CNVars; |
register int s, nv = CNVars; |
register int (*cmpfun)() = cmpdl; |
register int (*cmpfun)() = cmpdl; |
|
|
if ( !(p = NEXT(m = d)) ) { |
if ( !(p = NEXT(m = d)) ) { |
*prest = p; |
*prest = p; |
NEXT(m) = 0; |
NEXT(m) = 0; |
return m; |
return m; |
} |
} |
for ( lcm = m->lcm, s = m->sugar, ml = 0, l = m; p; p = NEXT(l = p) ) |
for ( lcm = m->lcm, s = m->sugar, ml = 0, l = m; p; p = NEXT(l = p) ) |
if ( NoSugar ? (*cmpfun)( nv, lcm, p->lcm ) >= 0 : |
if ( NoSugar ? (*cmpfun)( nv, lcm, p->lcm ) >= 0 : |
(s > p->sugar || s == p->sugar && (*cmpfun)( nv, lcm, p->lcm ) >= 0) ) |
(s > p->sugar || s == p->sugar && (*cmpfun)( nv, lcm, p->lcm ) >= 0) ) |
ml = l, lcm = (m = p)->lcm, s = p->sugar; |
ml = l, lcm = (m = p)->lcm, s = p->sugar; |
if ( !ml ) *prest = NEXT(m); |
if ( !ml ) *prest = NEXT(m); |
else { |
else { |
NEXT(ml) = NEXT(m); |
NEXT(ml) = NEXT(m); |
*prest = d; |
*prest = d; |
} |
} |
NEXT(m) = 0; |
NEXT(m) = 0; |
return m; |
return m; |
} |
} |
|
|
void minsugar(DP_pairs d,DP_pairs *dm,DP_pairs *dr) |
void minsugar(DP_pairs d,DP_pairs *dm,DP_pairs *dr) |
{ |
{ |
int msugar; |
int msugar; |
DP_pairs t,dm0,dr0,dmt,drt; |
DP_pairs t,dm0,dr0,dmt,drt; |
|
|
for ( msugar = d->sugar, t = NEXT(d); t; t = NEXT(t) ) |
for ( msugar = d->sugar, t = NEXT(d); t; t = NEXT(t) ) |
if ( t->sugar < msugar ) |
if ( t->sugar < msugar ) |
msugar = t->sugar; |
msugar = t->sugar; |
dm0 = 0; dr0 = 0; |
dm0 = 0; dr0 = 0; |
for ( t = d; t; t = NEXT(t) ) { |
for ( t = d; t; t = NEXT(t) ) { |
if ( t->sugar == msugar ) { |
if ( t->sugar == msugar ) { |
NEXTDPP(dm0,dmt); |
NEXTDPP(dm0,dmt); |
dmt->dp1 = t->dp1; dmt->dp2 = t->dp2; |
dmt->dp1 = t->dp1; dmt->dp2 = t->dp2; |
dmt->lcm = t->lcm; dmt->sugar = t->sugar; |
dmt->lcm = t->lcm; dmt->sugar = t->sugar; |
} else { |
} else { |
NEXTDPP(dr0,drt); |
NEXTDPP(dr0,drt); |
drt->dp1 = t->dp1; drt->dp2 = t->dp2; |
drt->dp1 = t->dp1; drt->dp2 = t->dp2; |
drt->lcm = t->lcm; drt->sugar = t->sugar; |
drt->lcm = t->lcm; drt->sugar = t->sugar; |
} |
} |
} |
} |
if ( dm0 ) NEXT(dmt) = 0; |
if ( dm0 ) NEXT(dmt) = 0; |
if ( dr0 ) NEXT(drt) = 0; |
if ( dr0 ) NEXT(drt) = 0; |
*dm = dm0; *dr = dr0; |
*dm = dm0; *dr = dr0; |
} |
} |
|
|
NODE gb(NODE f,int m,NODE subst) |
NODE gb(NODE f,int m,NODE subst) |
{ |
{ |
int i,nh,prev,mag; |
int i,nh,prev,mag,mag0,magt; |
NODE r,g,gall; |
NODE r,g,gall; |
DP_pairs d; |
DP_pairs d; |
DP_pairs l; |
DP_pairs l; |
DP h,nf,nfm,dp1,dp2; |
DP h,nf,nfm,dp1,dp2; |
MP mp; |
MP mp; |
struct oEGT tnf0,tnf1,tnfm0,tnfm1,tpz0,tpz1,tnp0,tnp1; |
struct oEGT tnf0,tnf1,tnfm0,tnfm1,tpz0,tpz1,tnp0,tnp1; |
int skip_nf_flag; |
int skip_nf_flag; |
double t_0; |
double t_0; |
Q q; |
Q q; |
int new_sugar; |
int new_sugar; |
static prev_sugar = -1; |
static prev_sugar = -1; |
|
|
Max_mag = 0; |
Max_mag = 0; |
prev = 1; |
Max_coef = 0; |
doing_f4 = 0; |
prev = 1; |
if ( m ) { |
doing_f4 = 0; |
psm = (DP *)MALLOC(pslen*sizeof(DP)); |
init_denomlist(); |
for ( i = 0; i < psn; i++ ) |
if ( m ) { |
if ( psh[i] && !validhc(psc[i],m,subst) ) |
psm = (DP *)MALLOC(pslen*sizeof(DP)); |
return 0; |
for ( i = 0; i < psn; i++ ) |
else |
if ( psh[i] && !validhc(psc[i],m,subst) ) |
_dp_mod(ps[i],m,subst,&psm[i]); |
return 0; |
} |
else |
for ( gall = g = 0, d = 0, r = f; r; r = NEXT(r) ) { |
_dp_mod(ps[i],m,subst,&psm[i]); |
i = (int)BDY(r); |
} |
d = updpairs(d,g,i); |
for ( gall = g = 0, d = 0, r = f; r; r = NEXT(r) ) { |
g = updbase(g,i); |
i = (int)BDY(r); |
gall = append_one(gall,i); |
d = updpairs(d,g,i); |
} |
g = updbase(g,i); |
while ( d ) { |
gall = append_one(gall,i); |
l = minp(d,&d); |
} |
if ( m ) { |
while ( d ) { |
_dp_sp_mod_dup(psm[l->dp1],psm[l->dp2],m,&h); |
l = minp(d,&d); |
if ( h ) |
if ( m ) { |
new_sugar = h->sugar; |
_dp_sp_mod_dup(psm[l->dp1],psm[l->dp2],m,&h); |
get_eg(&tnfm0); |
if ( h ) |
_dp_nf_mod_destructive(gall,h,psm,m,0,&nfm); |
new_sugar = h->sugar; |
get_eg(&tnfm1); add_eg(&eg_nfm,&tnfm0,&tnfm1); |
get_eg(&tnfm0); |
} else |
_dp_nf_mod_destructive(gall,h,psm,m,0,&nfm); |
nfm = (DP)1; |
get_eg(&tnfm1); add_eg(&eg_nfm,&tnfm0,&tnfm1); |
if ( nfm ) { |
} else |
if ( Demand ) { |
nfm = (DP)1; |
if ( dp_load_t(psn,&nf) ) { |
if ( nfm ) { |
skip_nf_flag = 1; |
if ( Demand ) { |
goto skip_nf; |
if ( dp_load_t(psn,&nf) ) { |
} else { |
skip_nf_flag = 1; |
skip_nf_flag = 0; |
goto skip_nf; |
dp_load(l->dp1,&dp1); dp_load(l->dp2,&dp2); |
} else { |
dp_sp(dp1,dp2,&h); |
skip_nf_flag = 0; |
} |
dp_load(l->dp1,&dp1); dp_load(l->dp2,&dp2); |
} else |
dp_sp(dp1,dp2,&h); |
dp_sp(ps[l->dp1],ps[l->dp2],&h); |
} |
if ( GenTrace ) { |
} else |
STOQ(l->dp1,q); ARG1(BDY((LIST)BDY(NEXT(TraceList)))) = q; |
dp_sp(ps[l->dp1],ps[l->dp2],&h); |
STOQ(l->dp2,q); ARG1(BDY((LIST)BDY(TraceList))) = q; |
if ( GenTrace ) { |
} |
STOQ(l->dp1,q); ARG1(BDY((LIST)BDY(NEXT(TraceList)))) = q; |
if ( h ) |
STOQ(l->dp2,q); ARG1(BDY((LIST)BDY(TraceList))) = q; |
new_sugar = h->sugar; |
} |
get_eg(&tnf0); |
if ( h ) |
t_0 = get_rtime(); |
new_sugar = h->sugar; |
if ( PCoeffs || dp_fcoeffs ) |
get_eg(&tnf0); |
_dp_nf(gall,h,ps,!Top,&nf); |
t_0 = get_rtime(); |
else |
if ( PCoeffs || dp_fcoeffs ) |
_dp_nf_z(gall,h,ps,!Top,DP_Multiple,&nf); |
_dp_nf(gall,h,ps,!Top,&nf); |
if ( DP_Print ) |
else |
fprintf(asir_out,"(%.3g)",get_rtime()-t_0); |
_dp_nf_z(gall,h,ps,!Top,DP_Multiple,&nf); |
get_eg(&tnf1); add_eg(&eg_nf,&tnf0,&tnf1); |
if ( DP_Print && nf ) |
} else |
fprintf(asir_out,"(%.3g)",get_rtime()-t_0); |
nf = 0; |
get_eg(&tnf1); add_eg(&eg_nf,&tnf0,&tnf1); |
|
} else |
|
nf = 0; |
skip_nf: |
skip_nf: |
if ( nf ) { |
if ( nf ) { |
NZR++; |
NZR++; |
get_eg(&tpz0); |
get_eg(&tpz0); |
prim_part(nf,0,&h); |
prim_part(nf,0,&h); |
get_eg(&tpz1); add_eg(&eg_pz,&tpz0,&tpz1); |
get_eg(&tpz1); add_eg(&eg_pz,&tpz0,&tpz1); |
get_eg(&tnp0); |
add_denomlist((P)BDY(h)->c); |
if ( Demand && skip_nf_flag ) |
get_eg(&tnp0); |
nh = newps_nosave(h,m,subst); |
if ( Demand && skip_nf_flag ) |
else |
nh = newps_nosave(h,m,subst); |
nh = newps(h,m,subst); |
else |
get_eg(&tnp1); add_eg(&eg_np,&tnp0,&tnp1); |
nh = newps(h,m,subst); |
if ( nh < 0 ) |
get_eg(&tnp1); add_eg(&eg_np,&tnp0,&tnp1); |
return 0; |
if ( nh < 0 ) |
d = updpairs(d,g,nh); |
return 0; |
g = updbase(g,nh); |
d = updpairs(d,g,nh); |
gall = append_one(gall,nh); |
g = updbase(g,nh); |
if ( !dp_fcoeffs && ShowMag ) { |
gall = append_one(gall,nh); |
for ( mag = 0, mp = BDY(h); mp; mp = NEXT(mp) ) |
if ( !dp_fcoeffs && ShowMag ) { |
mag += p_mag((P)mp->c); |
for ( mag = 0, mag0 = 0, mp = BDY(h); mp; mp = NEXT(mp) ) { |
Max_mag = MAX(Max_mag,mag); |
magt = p_mag((P)mp->c); |
} |
mag0 = MAX(mag0,magt); |
if ( DP_Print ) { |
mag += magt; |
if ( !prev ) |
} |
fprintf(asir_out,"\n"); |
Max_coef = MAX(Max_coef,mag0); |
print_split_e(&tnf0,&tnf1); print_split_e(&tpz0,&tpz1); |
Max_mag = MAX(Max_mag,mag); |
printdl(psh[nh]); |
} |
fprintf(asir_out,"(%d,%d),nb=%d,nab=%d,rp=%d,sugar=%d", |
if ( DP_Print ) { |
l->dp1,l->dp2,length(g),length(gall),DPPlength(d), |
if ( !prev ) |
pss[nh]); |
fprintf(asir_out,"\n"); |
if ( ShowMag ) |
print_split_e(&tnf0,&tnf1); print_split_e(&tpz0,&tpz1); |
fprintf(asir_out,",mag=%d",mag); |
printdl(psh[nh]); |
fprintf(asir_out,"\n"); fflush(asir_out); |
fprintf(asir_out,"(%d,%d),nb=%d,nab=%d,rp=%d,sugar=%d", |
} else if ( DP_PrintShort ) { |
l->dp1,l->dp2,length(g),length(gall),DPPlength(d), |
fprintf(asir_out,"+"); fflush(asir_out); |
pss[nh]); |
} |
if ( ShowMag ) |
prev = 1; |
fprintf(asir_out,",mag=(%d,%d)",mag,mag0); |
} else { |
fprintf(asir_out,"\n"); fflush(asir_out); |
if ( m ) |
} else if ( DP_PrintShort ) { |
add_eg(&eg_znfm,&tnfm0,&tnfm1); |
fprintf(asir_out,"+"); fflush(asir_out); |
ZR++; |
} |
if ( DP_Print || DP_PrintShort ) { |
prev = 1; |
if ( new_sugar != prev_sugar ) { |
} else { |
fprintf(asir_out,"[%d]",new_sugar); |
if ( m ) |
prev_sugar = new_sugar; |
add_eg(&eg_znfm,&tnfm0,&tnfm1); |
} |
ZR++; |
fprintf(asir_out,"."); fflush(asir_out); prev = 0; |
if ( DP_Print || DP_PrintShort ) { |
} |
if ( new_sugar != prev_sugar ) { |
} |
fprintf(asir_out,"[%d]",new_sugar); |
} |
prev_sugar = new_sugar; |
if ( DP_Print || DP_PrintShort ) |
} |
fprintf(asir_out,"gb done\n"); |
fprintf(asir_out,"."); fflush(asir_out); prev = 0; |
return g; |
} |
|
} |
|
} |
|
if ( DP_Print || DP_PrintShort ) |
|
fprintf(asir_out,"gb done\n"); |
|
return g; |
} |
} |
|
|
NODE gb_mod(NODE f,int m) |
NODE gb_mod(NODE f,int m) |
{ |
{ |
int i,nh,prev; |
int i,nh,prev; |
NODE r,g,gall; |
NODE r,g,gall; |
DP_pairs d; |
DP_pairs d; |
DP_pairs l; |
DP_pairs l; |
DP h,nf; |
DP h,nf; |
struct oEGT tnfm0,tnfm1,tpz0,tpz1; |
struct oEGT tnfm0,tnfm1,tpz0,tpz1; |
|
|
prev = 1; |
prev = 1; |
for ( gall = g = 0, d = 0, r = f; r; r = NEXT(r) ) { |
for ( gall = g = 0, d = 0, r = f; r; r = NEXT(r) ) { |
i = (int)BDY(r); |
i = (int)BDY(r); |
d = updpairs(d,g,i); |
d = updpairs(d,g,i); |
g = updbase(g,i); |
g = updbase(g,i); |
gall = append_one(gall,i); |
gall = append_one(gall,i); |
} |
} |
while ( d ) { |
while ( d ) { |
l = minp(d,&d); |
l = minp(d,&d); |
if ( PCoeffs ) { |
if ( PCoeffs ) { |
dp_sp_mod(ps[l->dp1],ps[l->dp2],m,&h); |
dp_sp_mod(ps[l->dp1],ps[l->dp2],m,&h); |
get_eg(&tnfm0); |
get_eg(&tnfm0); |
dp_nf_mod(gall,h,ps,m,!Top,&nf); |
dp_nf_mod(gall,h,ps,m,!Top,&nf); |
} else { |
} else { |
_dp_sp_mod_dup(ps[l->dp1],ps[l->dp2],m,&h); |
_dp_sp_mod_dup(ps[l->dp1],ps[l->dp2],m,&h); |
get_eg(&tnfm0); |
get_eg(&tnfm0); |
_dp_nf_mod_destructive(gall,h,ps,m,!Top,&nf); |
_dp_nf_mod_destructive(gall,h,ps,m,!Top,&nf); |
} |
} |
get_eg(&tnfm1); add_eg(&eg_nfm,&tnfm0,&tnfm1); |
get_eg(&tnfm1); add_eg(&eg_nfm,&tnfm0,&tnfm1); |
if ( nf ) { |
if ( nf ) { |
NZR++; |
NZR++; |
get_eg(&tpz0); |
get_eg(&tpz0); |
prim_part(nf,m,&h); |
prim_part(nf,m,&h); |
get_eg(&tpz1); add_eg(&eg_pz,&tpz0,&tpz1); |
get_eg(&tpz1); add_eg(&eg_pz,&tpz0,&tpz1); |
nh = newps_mod(h,m); |
nh = newps_mod(h,m); |
if ( nh < 0 ) |
if ( nh < 0 ) |
return 0; |
return 0; |
d = updpairs(d,g,nh); |
d = updpairs(d,g,nh); |
g = updbase(g,nh); |
g = updbase(g,nh); |
gall = append_one(gall,nh); |
gall = append_one(gall,nh); |
if ( DP_Print ) { |
if ( DP_Print ) { |
if ( !prev ) |
if ( !prev ) |
fprintf(asir_out,"\n"); |
fprintf(asir_out,"\n"); |
print_split_eg(&tnfm0,&tnfm1); fflush(asir_out); |
print_split_eg(&tnfm0,&tnfm1); fflush(asir_out); |
fprintf(asir_out,"(%d,%d),nb=%d,nab=%d,rp=%d,sugar=%d",l->dp1,l->dp2,length(g),length(gall),DPPlength(d),pss[nh]); |
fprintf(asir_out,"(%d,%d),nb=%d,nab=%d,rp=%d,sugar=%d",l->dp1,l->dp2,length(g),length(gall),DPPlength(d),pss[nh]); |
printdl(psh[nh]); fprintf(asir_out,"\n"); fflush(asir_out); |
printdl(psh[nh]); fprintf(asir_out,"\n"); fflush(asir_out); |
} else if ( DP_PrintShort ) { |
} else if ( DP_PrintShort ) { |
fprintf(asir_out,"+"); fflush(asir_out); |
fprintf(asir_out,"+"); fflush(asir_out); |
} |
} |
prev = 1; |
prev = 1; |
} else { |
} else { |
add_eg(&eg_znfm,&tnfm0,&tnfm1); |
add_eg(&eg_znfm,&tnfm0,&tnfm1); |
ZR++; |
ZR++; |
if ( DP_Print || DP_PrintShort ) { |
if ( DP_Print || DP_PrintShort ) { |
fprintf(asir_out,"."); fflush(asir_out); prev = 0; |
fprintf(asir_out,"."); fflush(asir_out); prev = 0; |
} |
} |
} |
} |
} |
} |
if ( DP_Print || DP_PrintShort ) |
if ( DP_Print || DP_PrintShort ) |
fprintf(asir_out,"gb_mod done\n"); |
fprintf(asir_out,"gb_mod done\n"); |
return g; |
return g; |
} |
} |
|
|
DP_pairs updpairs( DP_pairs d, NODE /* of index */ g, int t) |
DP_pairs updpairs( DP_pairs d, NODE /* of index */ g, int t) |
{ |
{ |
register DP_pairs d1, dd, nd; |
register DP_pairs d1, dd, nd; |
int dl,dl1; |
int dl,dl1; |
|
|
if ( !g ) return d; |
if ( !g ) return d; |
if ( !NoCriB && d ) { |
if ( !NoCriB && d ) { |
dl = DPPlength(d); |
dl = DPPlength(d); |
d = criterion_B( d, t ); |
d = criterion_B( d, t ); |
dl -= DPPlength(d); NBP += dl; |
dl -= DPPlength(d); N_BP += dl; |
} |
} |
d1 = newpairs( g, t ); |
d1 = newpairs( g, t ); |
if ( NEXT(d1) ) { |
if ( NEXT(d1) ) { |
dl = DPPlength(d1); TP += dl; |
dl = DPPlength(d1); TP += dl; |
d1 = criterion_M( d1 ); |
d1 = criterion_M( d1 ); |
dl1 = DPPlength(d1); NMP += (dl-dl1); dl = dl1; |
dl1 = DPPlength(d1); NMP += (dl-dl1); dl = dl1; |
d1 = criterion_F( d1 ); |
d1 = criterion_F( d1 ); |
dl1 = DPPlength(d1); NFP += (dl-dl1); dl = dl1; |
dl1 = DPPlength(d1); NFP += (dl-dl1); dl = dl1; |
} else |
} else |
dl = 1; |
dl = 1; |
if ( !do_weyl ) |
if ( !do_weyl ) |
for ( dd = 0; d1; d1 = nd ) { |
for ( dd = 0; d1; d1 = nd ) { |
nd = NEXT(d1); |
nd = NEXT(d1); |
if ( !criterion_2( d1->dp1, d1->dp2 ) ) { |
if ( !criterion_2( d1->dp1, d1->dp2 ) ) { |
NEXT(d1) = dd; |
NEXT(d1) = dd; |
dd = d1; |
dd = d1; |
} |
} |
} |
} |
else |
else |
dd = d1; |
dd = d1; |
dl1 = DPPlength(dd); NDP += (dl-dl1); |
dl1 = DPPlength(dd); NDP += (dl-dl1); |
if ( !(nd = d) ) return dd; |
if ( !(nd = d) ) return dd; |
while ( nd = NEXT(d1 = nd) ) ; |
while ( nd = NEXT(d1 = nd) ) ; |
NEXT(d1) = dd; |
NEXT(d1) = dd; |
return d; |
return d; |
} |
} |
|
|
DP_pairs newpairs( NODE /* of index */ g, int t ) |
DP_pairs newpairs( NODE /* of index */ g, int t ) |
{ |
{ |
register NODE r; |
register NODE r; |
register DL tdl = psh[t]; |
register DL tdl = psh[t]; |
register int ts; |
register int ts; |
register DP_pairs p, last; |
register DP_pairs p, last; |
int dp; |
int dp; |
register DL dl; |
register DL dl; |
register int s; |
register int s; |
|
|
ts = pss[t] - tdl->td; |
ts = pss[t] - tdl->td; |
for ( last = 0, r = g; r; r = NEXT(r) ) { |
for ( last = 0, r = g; r; r = NEXT(r) ) { |
NEXT(p = NEWDP_pairs) = last; |
NEXT(p = NEWDP_pairs) = last; |
last = p; |
last = p; |
dp = p->dp1 = (int)BDY(r); p->dp2 = t; |
dp = p->dp1 = (int)BDY(r); p->dp2 = t; |
p->lcm = lcm_of_DL(CNVars, dl = psh[dp], tdl, (DL)0 ); |
p->lcm = lcm_of_DL(CNVars, dl = psh[dp], tdl, (DL)0 ); |
#if 0 |
#if 0 |
if ( do_weyl ) |
if ( do_weyl ) |
p->sugar = dl_weight(p->lcm); |
p->sugar = dl_weyl_weight(p->lcm); |
else |
else |
#endif |
#endif |
p->sugar = (ts > (s = pss[dp] - dl->td) ? ts : s) + p->lcm->td; |
p->sugar = (ts > (s = pss[dp] - dl->td) ? ts : s) + p->lcm->td; |
} |
} |
return last; |
return last; |
} |
} |
|
|
DP_pairs criterion_B( DP_pairs d, int s ) |
DP_pairs criterion_B( DP_pairs d, int s ) |
{ |
{ |
register DP_pairs dd, p; |
register DP_pairs dd, p; |
register DL tij, t = psh[s], dltmp; |
register DL tij, t = psh[s], dltmp; |
|
|
if ( !d ) return 0; |
if ( !d ) return 0; |
NEWDL( dltmp, CNVars ); |
NEWDL( dltmp, CNVars ); |
for ( dd = 0; d; d = p ) { |
for ( dd = 0; d; d = p ) { |
p = NEXT(d), |
p = NEXT(d), |
tij = d->lcm; |
tij = d->lcm; |
if ( tij->td != lcm_of_DL(CNVars, tij, t, dltmp )->td |
if ( tij->td != lcm_of_DL(CNVars, tij, t, dltmp )->td |
|| !dl_equal(CNVars, tij, dltmp ) |
|| !dl_equal(CNVars, tij, dltmp ) |
|| (tij->td == lcm_of_DL(CNVars, psh[d->dp1], t, dltmp )->td |
|| (tij->td == lcm_of_DL(CNVars, psh[d->dp1], t, dltmp )->td |
&& dl_equal(CNVars, dltmp, tij )) |
&& dl_equal(CNVars, dltmp, tij )) |
|| (tij->td == lcm_of_DL(CNVars, psh[d->dp2], t, dltmp )->td |
|| (tij->td == lcm_of_DL(CNVars, psh[d->dp2], t, dltmp )->td |
&& dl_equal(CNVars, dltmp, tij )) ) { |
&& dl_equal(CNVars, dltmp, tij )) ) { |
NEXT(d) = dd; |
NEXT(d) = dd; |
dd = d; |
dd = d; |
} |
} |
} |
} |
return dd; |
return dd; |
} |
} |
|
|
DP_pairs criterion_M( DP_pairs d1 ) |
DP_pairs criterion_M( DP_pairs d1 ) |
{ |
{ |
register DP_pairs dd, e, d3, d2, p; |
register DP_pairs dd, e, d3, d2, p; |
register DL itdl, jtdl; |
register DL itdl, jtdl; |
register int itdltd, jtdltd; |
register int itdltd, jtdltd; |
|
|
for ( dd = 0, e = d1; e; e = d3 ) { |
for ( dd = 0, e = d1; e; e = d3 ) { |
if ( !(d2 = NEXT(e)) ) { |
if ( !(d2 = NEXT(e)) ) { |
NEXT(e) = dd; |
NEXT(e) = dd; |
return e; |
return e; |
} |
} |
itdltd = (itdl = e->lcm)->td; |
itdltd = (itdl = e->lcm)->td; |
for ( d3 = 0; d2; d2 = p ) { |
for ( d3 = 0; d2; d2 = p ) { |
p = NEXT(d2), |
p = NEXT(d2), |
jtdltd = (jtdl = d2->lcm)->td; |
jtdltd = (jtdl = d2->lcm)->td; |
if ( jtdltd == itdltd ) |
if ( jtdltd == itdltd ) |
if ( dl_equal(CNVars, itdl, jtdl ) ) ; |
if ( dl_equal(CNVars, itdl, jtdl ) ) ; |
else if ( dl_redble( jtdl, itdl ) ) continue; |
else if ( dl_redble( jtdl, itdl ) ) continue; |
else if ( dl_redble( itdl, jtdl ) ) goto delit; |
else if ( dl_redble( itdl, jtdl ) ) goto delit; |
else ; |
else ; |
else if ( jtdltd > itdltd ) |
else if ( jtdltd > itdltd ) |
if ( dl_redble( jtdl, itdl ) ) continue; |
if ( dl_redble( jtdl, itdl ) ) continue; |
else ; |
else ; |
else if ( dl_redble( itdl, jtdl ) ) goto delit; |
else if ( dl_redble( itdl, jtdl ) ) goto delit; |
NEXT(d2) = d3; |
NEXT(d2) = d3; |
d3 = d2; |
d3 = d2; |
} |
} |
NEXT(e) = dd; |
NEXT(e) = dd; |
dd = e; |
dd = e; |
continue; |
continue; |
/**/ |
/**/ |
delit: NEXT(d2) = d3; |
delit: NEXT(d2) = d3; |
d3 = d2; |
d3 = d2; |
for ( ; p; p = d2 ) { |
for ( ; p; p = d2 ) { |
d2 = NEXT(p); |
d2 = NEXT(p); |
NEXT(p) = d3; |
NEXT(p) = d3; |
d3 = p; |
d3 = p; |
} |
} |
} |
} |
return dd; |
return dd; |
} |
} |
|
|
static DP_pairs collect_pairs_of_hdlcm( DP_pairs d1, DP_pairs *prest ) |
static DP_pairs collect_pairs_of_hdlcm( DP_pairs d1, DP_pairs *prest ) |
{ |
{ |
register DP_pairs w, p, r, s; |
register DP_pairs w, p, r, s; |
register DL ti; |
register DL ti; |
register int td; |
register int td; |
|
|
td = (ti = (w = d1)->lcm)->td; |
td = (ti = (w = d1)->lcm)->td; |
s = NEXT(w); |
s = NEXT(w); |
NEXT(w) = 0; |
NEXT(w) = 0; |
for ( r = 0; s; s = p ) { |
for ( r = 0; s; s = p ) { |
p = NEXT(s); |
p = NEXT(s); |
if ( td == s->lcm->td && dl_equal(CNVars, ti, s->lcm ) ) |
if ( td == s->lcm->td && dl_equal(CNVars, ti, s->lcm ) ) |
{ |
{ |
NEXT(s) = w; |
NEXT(s) = w; |
w = s; |
w = s; |
} else { |
} else { |
NEXT(s) = r; |
NEXT(s) = r; |
r = s; |
r = s; |
} |
} |
} |
} |
*prest = r; |
*prest = r; |
return w; |
return w; |
} |
} |
|
|
int criterion_2( int dp1, int dp2 ) |
int criterion_2( int dp1, int dp2 ) |
{ |
{ |
register int i, *d1, *d2; |
register int i, *d1, *d2; |
|
|
d1 = psh[dp1]->d, d2 = psh[dp2]->d; |
d1 = psh[dp1]->d, d2 = psh[dp2]->d; |
for ( i = CNVars; --i >= 0; d1++, d2++ ) |
for ( i = CNVars; --i >= 0; d1++, d2++ ) |
if ( (*d1 <= *d2 ? *d1 : *d2) > 0 ) return 0; |
if ( (*d1 <= *d2 ? *d1 : *d2) > 0 ) return 0; |
return 1; |
return 1; |
} |
} |
|
|
DP_pairs criterion_F( DP_pairs d1 ) |
DP_pairs criterion_F( DP_pairs d1 ) |
{ |
{ |
DP_pairs rest, head; |
DP_pairs rest, head; |
register DP_pairs last, p, r, w; |
register DP_pairs last, p, r, w; |
register int s; |
register int s; |
|
|
for ( head = last = 0, p = d1; NEXT(p); ) { |
for ( head = last = 0, p = d1; NEXT(p); ) { |
s = (r = w = collect_pairs_of_hdlcm( p, &rest ))->sugar; |
s = (r = w = collect_pairs_of_hdlcm( p, &rest ))->sugar; |
while ( w = NEXT(w) ) |
while ( w = NEXT(w) ) |
if ( criterion_2( w->dp1, w->dp2 ) ) { |
if ( !do_weyl && criterion_2( w->dp1, w->dp2 ) ) { |
r = w; |
r = w; |
break; |
break; |
} else if ( w->sugar < s ) s = (r = w)->sugar; |
} else if ( w->sugar < s ) s = (r = w)->sugar; |
if ( last ) NEXT(last) = r; |
if ( last ) NEXT(last) = r; |
else head = r; |
else head = r; |
NEXT(last = r) = 0; |
NEXT(last = r) = 0; |
if ( !(p = rest) ) return head; |
if ( !(p = rest) ) return head; |
} |
} |
if ( !last ) return p; |
if ( !last ) return p; |
NEXT(last) = p; |
NEXT(last) = p; |
return head; |
return head; |
} |
} |
|
|
NODE updbase(NODE g,int t) |
NODE updbase(NODE g,int t) |
{ |
{ |
g = remove_reducibles(g,t); |
g = remove_reducibles(g,t); |
g = append_one(g,t); |
g = append_one(g,t); |
return g; |
return g; |
} |
} |
|
|
NODE /* of index */ remove_reducibles(NODE /* of index */ nd, int newdp ) |
NODE /* of index */ remove_reducibles(NODE /* of index */ nd, int newdp ) |
{ |
{ |
register DL dl, dln; |
register DL dl, dln; |
register NODE last, p, head; |
register NODE last, p, head; |
register int td; |
register int td; |
|
|
dl = psh[newdp]; |
dl = psh[newdp]; |
td = dl->td; |
td = dl->td; |
for ( head = last = 0, p = nd; p; ) { |
for ( head = last = 0, p = nd; p; ) { |
dln = psh[(int)BDY(p)]; |
dln = psh[(int)BDY(p)]; |
if ( dln->td >= td && dl_redble( dln, dl ) ) { |
if ( dln->td >= td && dl_redble( dln, dl ) ) { |
p = NEXT(p); |
p = NEXT(p); |
if ( last ) NEXT(last) = p; |
if ( last ) NEXT(last) = p; |
} else { |
} else { |
if ( !last ) head = p; |
if ( !last ) head = p; |
p = NEXT(last = p); |
p = NEXT(last = p); |
} |
} |
} |
} |
return head; |
return head; |
} |
} |
|
|
int dl_redble(DL dl1,DL dl2) |
int dl_redble(DL dl1,DL dl2) |
{ |
{ |
register int n, *d1, *d2; |
register int n, *d1, *d2; |
|
|
for ( d1 = dl1->d, d2 = dl2->d, n = CNVars; --n >= 0; d1++, d2++ ) |
for ( d1 = dl1->d, d2 = dl2->d, n = CNVars; --n >= 0; d1++, d2++ ) |
if ( *d1 < *d2 ) return 0; |
if ( *d1 < *d2 ) return 0; |
return 1; |
return 1; |
} |
} |
|
|
int dl_weight(DL dl) |
#if 0 |
|
int dl_weyl_weight(DL dl) |
{ |
{ |
int n,w,i; |
int n,w,i; |
|
|
n = CNVars/2; |
n = CNVars/2; |
for ( i = 0, w = 0; i < n; i++ ) |
for ( i = 0, w = 0; i < n; i++ ) |
w += (-dl->d[i]+dl->d[n+i]); |
w += (-dl->d[i]+dl->d[n+i]); |
return w; |
return w; |
} |
} |
|
#endif |
|
|
int gbcheck(NODE f) |
int gbcheck(NODE f) |
{ |
{ |
int i; |
int i; |
NODE r,g,gall; |
NODE r,g,gall; |
DP_pairs d,l; |
DP_pairs d,l; |
DP h,nf,dp1,dp2; |
DP h,nf,dp1,dp2; |
struct oEGT tmp0,tmp1; |
struct oEGT tmp0,tmp1; |
|
|
if ( NoGC ) |
if ( NoGC ) |
return 1; |
return 1; |
for ( gall = g = 0, d = 0, r = f; r; r = NEXT(r) ) { |
for ( gall = g = 0, d = 0, r = f; r; r = NEXT(r) ) { |
i = (int)BDY(r); |
i = (int)BDY(r); |
d = updpairs(d,g,i); |
d = updpairs(d,g,i); |
g = updbase(g,i); |
g = updbase(g,i); |
gall = append_one(gall,i); |
gall = append_one(gall,i); |
} |
} |
if ( DP_Print || DP_PrintShort ) { |
if ( DP_Print || DP_PrintShort ) { |
fprintf(asir_out,"gbcheck total %d pairs\n",DPPlength(d)); fflush(asir_out); |
fprintf(asir_out,"gbcheck total %d pairs\n",DPPlength(d)); fflush(asir_out); |
} |
} |
while ( d ) { |
while ( d ) { |
l = d; d = NEXT(d); |
l = d; d = NEXT(d); |
get_eg(&tmp0); |
get_eg(&tmp0); |
dp_load(l->dp1,&dp1); dp_load(l->dp2,&dp2); |
dp_load(l->dp1,&dp1); dp_load(l->dp2,&dp2); |
dp_sp(dp1,dp2,&h); |
dp_sp(dp1,dp2,&h); |
/* fprintf(stderr,"{%d,%d}",l->dp1,l->dp2); */ |
/* fprintf(stderr,"{%d,%d}",l->dp1,l->dp2); */ |
_dp_nf(gall,h,ps,1,&nf); |
_dp_nf(gall,h,ps,1,&nf); |
get_eg(&tmp1); add_eg(&eg_gc,&tmp0,&tmp1); |
get_eg(&tmp1); add_eg(&eg_gc,&tmp0,&tmp1); |
if ( DP_Print || DP_PrintShort ) { |
if ( DP_Print || DP_PrintShort ) { |
fprintf(asir_out,"."); fflush(asir_out); |
fprintf(asir_out,"."); fflush(asir_out); |
} |
} |
if ( nf ) |
if ( nf ) |
return 0; |
return 0; |
} |
} |
if ( DP_Print || DP_PrintShort ) |
if ( DP_Print || DP_PrintShort ) |
fprintf(asir_out,"\n"); |
fprintf(asir_out,"\n"); |
return 1; |
return 1; |
} |
} |
|
|
void gbcheck_list(NODE f,LIST *gp,LIST *pp) |
void gbcheck_list(NODE f,int n,VECT *gp,LIST *pp) |
{ |
{ |
int i; |
int i; |
NODE r,g,gall,u,u0,t; |
NODE r,g,gall,u,u0,t; |
LIST pair; |
VECT vect; |
DP_pairs d,l; |
LIST pair; |
Q q1,q2; |
DP_pairs d,l; |
|
Q q1,q2; |
|
|
for ( gall = g = 0, d = 0, r = f; r; r = NEXT(r) ) { |
/* we need the following settings */ |
i = (int)BDY(r); |
NVars = CNVars = n; |
d = updpairs(d,g,i); |
setup_arrays(f,0,&r); |
g = updbase(g,i); |
for ( gall = g = 0, d = 0; r; r = NEXT(r) ) { |
gall = append_one(gall,i); |
i = (int)BDY(r); |
} |
d = updpairs(d,g,i); |
for ( u0 = 0, t = gall; t; t = NEXT(t) ) { |
g = updbase(g,i); |
NEXTNODE(u0,u); |
gall = append_one(gall,i); |
BDY(u) = ps[(int)BDY(t)]; |
} |
} |
NEWVECT(vect); vect->len = psn; vect->body = (pointer)ps; |
if ( u0 ) |
*gp = vect; |
NEXT(u) = 0; |
|
MKLIST(*gp,u); |
for ( u0 = 0, l = d; l; l = NEXT(l) ) { |
for ( u0 = 0, l = d; l; l = NEXT(l) ) { |
NEXTNODE(u0,u); |
NEXTNODE(u0,u); |
STOQ(l->dp1,q1); |
STOQ(l->dp1,q1); |
STOQ(l->dp2,q2); |
STOQ(l->dp2,q2); |
t = mknode(2,q1,q2); |
t = mknode(2,q1,q2); |
MKLIST(pair,t); |
MKLIST(pair,t); |
BDY(u) = (pointer)pair; |
BDY(u) = (pointer)pair; |
} |
} |
if ( u0 ) |
if ( u0 ) |
NEXT(u) = 0; |
NEXT(u) = 0; |
MKLIST(*pp,u0); |
MKLIST(*pp,u); |
|
} |
} |
|
|
int membercheck(NODE f,NODE x) |
int membercheck(NODE f,NODE x) |
{ |
{ |
DP g; |
DP g; |
struct oEGT tmp0,tmp1; |
struct oEGT tmp0,tmp1; |
|
|
if ( NoMC ) |
if ( NoMC ) |
return 1; |
return 1; |
if ( DP_Print || DP_PrintShort ) { |
if ( DP_Print || DP_PrintShort ) { |
fprintf(asir_out,"membercheck\n"); fflush(asir_out); |
fprintf(asir_out,"membercheck\n"); fflush(asir_out); |
} |
} |
for ( ; f; f = NEXT(f) ) { |
for ( ; f; f = NEXT(f) ) { |
get_eg(&tmp0); |
get_eg(&tmp0); |
_dp_nf(x,(DP)BDY(f),ps,1,&g); |
_dp_nf(x,(DP)BDY(f),ps,1,&g); |
get_eg(&tmp1); add_eg(&eg_mc,&tmp0,&tmp1); |
get_eg(&tmp1); add_eg(&eg_mc,&tmp0,&tmp1); |
if ( DP_Print ) { |
if ( DP_Print ) { |
print_split_eg(&tmp0,&tmp1); fflush(asir_out); |
print_split_eg(&tmp0,&tmp1); fflush(asir_out); |
} else if ( DP_PrintShort ) { |
} else if ( DP_PrintShort ) { |
fprintf(asir_out,"."); fflush(asir_out); |
fprintf(asir_out,"."); fflush(asir_out); |
} |
} |
if ( g ) |
if ( g ) |
return 0; |
return 0; |
} |
} |
if ( DP_Print || DP_PrintShort ) |
if ( DP_Print || DP_PrintShort ) |
fprintf(asir_out,"\n"); |
fprintf(asir_out,"\n"); |
return 1; |
return 1; |
} |
} |
|
|
void dp_set_flag(Obj name,Obj value) |
void dp_set_flag(Obj name,Obj value) |
{ |
{ |
char *n; |
char *n; |
int v; |
int v; |
|
Q ratio; |
|
|
if ( OID(name) != O_STR ) |
if ( OID(name) != O_STR ) |
return; |
return; |
n = BDY((STRING)name); |
n = BDY((STRING)name); |
if ( !strcmp(n,"Demand") ) { |
if ( !strcmp(n,"Demand") ) { |
Demand = value ? BDY((STRING)value) : 0; return; |
Demand = value ? BDY((STRING)value) : 0; return; |
} |
} |
if ( !strcmp(n,"Dist") ) { |
if ( !strcmp(n,"Dist") ) { |
Dist = (LIST)value; return; |
Dist = (LIST)value; return; |
} |
} |
if ( value && OID(value) != O_N ) |
if ( !strcmp(n,"Content") ) { |
return; |
ratio = (Q)value; |
v = QTOS((Q)value); |
if ( ratio ) { |
if ( !strcmp(n,"NoSugar") ) |
DP_Multiple = BD(NM(ratio))[0]; |
NoSugar = v; |
Denominator = INT(ratio) ? 1 : BD(DN(ratio))[0]; |
else if ( !strcmp(n,"NoCriB") ) |
} else { |
NoCriB = v; |
DP_Multiple = 0; |
else if ( !strcmp(n,"NoGC") ) |
Denominator = 1; |
NoGC = v; |
} |
else if ( !strcmp(n,"NoMC") ) |
} |
NoMC = v; |
if ( value && OID(value) != O_N ) |
else if ( !strcmp(n,"NoRA") ) |
return; |
NoRA = v; |
v = QTOS((Q)value); |
else if ( !strcmp(n,"NoGCD") ) |
if ( !strcmp(n,"NoSugar") ) |
NoGCD = v; |
NoSugar = v; |
else if ( !strcmp(n,"Top") ) |
else if ( !strcmp(n,"NoCriB") ) |
Top = v; |
NoCriB = v; |
else if ( !strcmp(n,"ShowMag") ) |
else if ( !strcmp(n,"NoGC") ) |
ShowMag = v; |
NoGC = v; |
else if ( !strcmp(n,"PrintShort") ) |
else if ( !strcmp(n,"NoMC") ) |
DP_PrintShort = v; |
NoMC = v; |
else if ( !strcmp(n,"Print") ) |
else if ( !strcmp(n,"NoRA") ) |
DP_Print = v; |
NoRA = v; |
else if ( !strcmp(n,"NFStat") ) |
else if ( !strcmp(n,"NoGCD") ) |
DP_NFStat = v; |
NoGCD = v; |
else if ( !strcmp(n,"Stat") ) |
else if ( !strcmp(n,"Top") ) |
Stat = v; |
Top = v; |
else if ( !strcmp(n,"Reverse") ) |
else if ( !strcmp(n,"ShowMag") ) |
Reverse = v; |
ShowMag = v; |
else if ( !strcmp(n,"Multiple") ) |
else if ( !strcmp(n,"PrintShort") ) |
DP_Multiple = v; |
DP_PrintShort = v; |
else if ( !strcmp(n,"Denominator") ) |
else if ( !strcmp(n,"Print") ) |
Denominator = v; |
DP_Print = v; |
else if ( !strcmp(n,"PtozpRA") ) |
else if ( !strcmp(n,"NFStat") ) |
PtozpRA = v; |
DP_NFStat = v; |
else if ( !strcmp(n,"GenTrace") ) |
else if ( !strcmp(n,"Stat") ) |
GenTrace = v; |
Stat = v; |
else if ( !strcmp(n,"OXCheck") ) |
else if ( !strcmp(n,"Reverse") ) |
OXCheck = v; |
Reverse = v; |
|
else if ( !strcmp(n,"Multiple") ) |
|
DP_Multiple = v; |
|
else if ( !strcmp(n,"Denominator") ) |
|
Denominator = v; |
|
else if ( !strcmp(n,"PtozpRA") ) |
|
PtozpRA = v; |
|
else if ( !strcmp(n,"GenTrace") ) |
|
GenTrace = v; |
|
else if ( !strcmp(n,"OXCheck") ) |
|
OXCheck = v; |
|
else if ( !strcmp(n,"GenSyz") ) |
|
GenSyz = v; |
|
else if ( !strcmp(n,"OneZeroHomo") ) |
|
OneZeroHomo = v; |
|
else if ( !strcmp(n,"MaxDeg") ) |
|
MaxDeg = v; |
} |
} |
|
|
void dp_make_flaglist(LIST *list) |
void dp_make_flaglist(LIST *list) |
{ |
{ |
Q v; |
Q v,nm,dn; |
STRING name,path; |
STRING name,path; |
NODE n,n1; |
NODE n,n1; |
|
|
STOQ(DP_Multiple,v); MKNODE(n,v,0); MKSTR(name,"DP_Multiple"); MKNODE(n1,name,n); n = n1; |
#if 0 |
STOQ(Denominator,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"Denominator"); MKNODE(n1,name,n); n = n1; |
STOQ(DP_Multiple,v); MKNODE(n,v,0); MKSTR(name,"DP_Multiple"); MKNODE(n1,name,n); n = n1; |
MKNODE(n1,Dist,n); n = n1; MKSTR(name,"Dist"); MKNODE(n1,name,n); n = n1; |
STOQ(Denominator,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"Denominator"); MKNODE(n1,name,n); n = n1; |
STOQ(Reverse,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"Reverse"); MKNODE(n1,name,n); n = n1; |
#else |
STOQ(Stat,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"Stat"); MKNODE(n1,name,n); n = n1; |
if ( DP_Multiple ) { |
STOQ(DP_Print,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"Print"); MKNODE(n1,name,n); n = n1; |
STOQ(DP_Multiple,nm); STOQ(Denominator,dn); divq(nm,dn,&v); |
STOQ(DP_PrintShort,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"PrintShort"); MKNODE(n1,name,n); n = n1; |
} else |
STOQ(DP_NFStat,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"NFStat"); MKNODE(n1,name,n); n = n1; |
v = 0; |
STOQ(OXCheck,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"OXCheck"); MKNODE(n1,name,n); n = n1; |
MKNODE(n,v,0); MKSTR(name,"Content"); MKNODE(n1,name,n); n = n1; |
STOQ(GenTrace,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"GenTrace"); MKNODE(n1,name,n); n = n1; |
#endif |
STOQ(PtozpRA,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"PtozpRA"); MKNODE(n1,name,n); n = n1; |
MKNODE(n1,Dist,n); n = n1; MKSTR(name,"Dist"); MKNODE(n1,name,n); n = n1; |
STOQ(ShowMag,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"ShowMag"); MKNODE(n1,name,n); n = n1; |
STOQ(Reverse,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"Reverse"); MKNODE(n1,name,n); n = n1; |
STOQ(Top,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"Top"); MKNODE(n1,name,n); n = n1; |
STOQ(Stat,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"Stat"); MKNODE(n1,name,n); n = n1; |
STOQ(NoGCD,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"NoGCD"); MKNODE(n1,name,n); n = n1; |
STOQ(DP_Print,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"Print"); MKNODE(n1,name,n); n = n1; |
STOQ(NoRA,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"NoRA"); MKNODE(n1,name,n); n = n1; |
STOQ(DP_PrintShort,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"PrintShort"); MKNODE(n1,name,n); n = n1; |
STOQ(NoMC,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"NoMC"); MKNODE(n1,name,n); n = n1; |
STOQ(DP_NFStat,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"NFStat"); MKNODE(n1,name,n); n = n1; |
STOQ(NoGC,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"NoGC"); MKNODE(n1,name,n); n = n1; |
STOQ(OXCheck,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"OXCheck"); MKNODE(n1,name,n); n = n1; |
STOQ(NoCriB,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"NoCriB"); MKNODE(n1,name,n); n = n1; |
STOQ(GenTrace,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"GenTrace"); MKNODE(n1,name,n); n = n1; |
STOQ(NoSugar,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"NoSugar"); MKNODE(n1,name,n); n = n1; |
STOQ(GenSyz,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"GenSyz"); MKNODE(n1,name,n); n = n1; |
if ( Demand ) |
STOQ(MaxDeg,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"MaxDeg"); MKNODE(n1,name,n); n = n1; |
MKSTR(path,Demand); |
STOQ(OneZeroHomo,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"OneZeroHomo"); MKNODE(n1,name,n); n = n1; |
else |
STOQ(PtozpRA,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"PtozpRA"); MKNODE(n1,name,n); n = n1; |
path = 0; |
STOQ(ShowMag,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"ShowMag"); MKNODE(n1,name,n); n = n1; |
MKNODE(n1,path,n); n = n1; MKSTR(name,"Demand"); MKNODE(n1,name,n); n = n1; |
STOQ(Top,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"Top"); MKNODE(n1,name,n); n = n1; |
MKLIST(*list,n); |
STOQ(NoGCD,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"NoGCD"); MKNODE(n1,name,n); n = n1; |
|
STOQ(NoRA,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"NoRA"); MKNODE(n1,name,n); n = n1; |
|
STOQ(NoMC,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"NoMC"); MKNODE(n1,name,n); n = n1; |
|
STOQ(NoGC,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"NoGC"); MKNODE(n1,name,n); n = n1; |
|
STOQ(NoCriB,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"NoCriB"); MKNODE(n1,name,n); n = n1; |
|
STOQ(NoSugar,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"NoSugar"); MKNODE(n1,name,n); n = n1; |
|
if ( Demand ) |
|
MKSTR(path,Demand); |
|
else |
|
path = 0; |
|
MKNODE(n1,path,n); n = n1; MKSTR(name,"Demand"); MKNODE(n1,name,n); n = n1; |
|
MKLIST(*list,n); |
} |
} |
|
|
#define DELIM '/' |
#define DELIM '/' |
|
|
void dp_save(int index,Obj p,char *prefix) |
void dp_save(int index,Obj p,char *prefix) |
{ |
{ |
FILE *fp; |
FILE *fp; |
char path[BUFSIZ]; |
char path[BUFSIZ]; |
|
|
if ( prefix ) |
if ( prefix ) |
sprintf(path,"%s%c%s%d",Demand,DELIM,prefix,index); |
sprintf(path,"%s%c%s%d",Demand,DELIM,prefix,index); |
else |
else |
sprintf(path,"%s%c%d",Demand,DELIM,index); |
sprintf(path,"%s%c%d",Demand,DELIM,index); |
if ( !(fp = fopen(path,"wb") ) ) |
if ( !(fp = fopen(path,"wb") ) ) |
error("dp_save : cannot open a file"); |
error("dp_save : cannot open a file"); |
savevl(fp,VC); saveobj(fp,p); fclose(fp); |
savevl(fp,VC); saveobj(fp,p); fclose(fp); |
} |
} |
|
|
void dp_load(int index,DP *p) |
void dp_load(int index,DP *p) |
{ |
{ |
FILE *fp; |
FILE *fp; |
char path[BUFSIZ]; |
char path[BUFSIZ]; |
|
|
if ( !Demand || ps[index] ) |
if ( !Demand || ps[index] ) |
*p = ps[index]; |
*p = ps[index]; |
else { |
else { |
sprintf(path,"%s%c%d",Demand,DELIM,index); |
sprintf(path,"%s%c%d",Demand,DELIM,index); |
if ( !(fp = fopen(path,"rb") ) ) |
if ( !(fp = fopen(path,"rb") ) ) |
error("dp_load : cannot open a file"); |
error("dp_load : cannot open a file"); |
skipvl(fp); loadobj(fp,(Obj *)p); fclose(fp); |
if ( PCoeffs ) |
} |
loadvl(fp); |
|
else |
|
skipvl(fp); |
|
loadobj(fp,(Obj *)p); fclose(fp); |
|
} |
} |
} |
|
|
int dp_load_t(int index,DP *p) |
int dp_load_t(int index,DP *p) |
{ |
{ |
FILE *fp; |
FILE *fp; |
char path[BUFSIZ]; |
char path[BUFSIZ]; |
|
|
sprintf(path,"%s%c%d",Demand,DELIM,index); |
sprintf(path,"%s%c%d",Demand,DELIM,index); |
if ( !(fp = fopen(path,"rb") ) ) |
if ( !(fp = fopen(path,"rb") ) ) |
return 0; |
return 0; |
else { |
else { |
skipvl(fp); loadobj(fp,(Obj *)p); fclose(fp); return 1; |
if ( PCoeffs ) |
} |
loadvl(fp); |
|
else |
|
skipvl(fp); |
|
loadobj(fp,(Obj *)p); fclose(fp); return 1; |
|
} |
} |
} |
|
|
void init_stat() { |
void init_stat() { |
init_eg(&eg_nf); init_eg(&eg_nfm); init_eg(&eg_znfm); |
init_eg(&eg_nf); init_eg(&eg_nfm); init_eg(&eg_znfm); |
init_eg(&eg_pz); init_eg(&eg_np); |
init_eg(&eg_pz); init_eg(&eg_np); |
init_eg(&eg_ra); init_eg(&eg_mc); init_eg(&eg_gc); |
init_eg(&eg_ra); init_eg(&eg_mc); init_eg(&eg_gc); |
ZR = NZR = TP = NMP = NBP = NFP = NDP = 0; |
ZR = NZR = TP = NMP = N_BP = NFP = NDP = 0; |
} |
} |
|
|
void print_stat() { |
void print_stat() { |
if ( !DP_Print && !Stat ) |
if ( !DP_Print && !Stat ) |
return; |
return; |
print_eg("NF",&eg_nf); print_eg("NFM",&eg_nfm); print_eg("ZNFM",&eg_znfm); |
print_eg("NF",&eg_nf); print_eg("NFM",&eg_nfm); print_eg("ZNFM",&eg_znfm); |
print_eg("PZ",&eg_pz); print_eg("NP",&eg_np); |
print_eg("PZ",&eg_pz); print_eg("NP",&eg_np); |
print_eg("RA",&eg_ra); print_eg("MC",&eg_mc); print_eg("GC",&eg_gc); |
print_eg("RA",&eg_ra); print_eg("MC",&eg_mc); print_eg("GC",&eg_gc); |
fprintf(asir_out,"T=%d,B=%d M=%d F=%d D=%d ZR=%d NZR=%d\n",TP,NBP,NMP,NFP,NDP,ZR,NZR); |
fprintf(asir_out,"T=%d,B=%d M=%d F=%d D=%d ZR=%d NZR=%d\n",TP,N_BP,NMP,NFP,NDP,ZR,NZR); |
} |
} |
|
|
/* |
/* |
Line 2216 extern int mpi_mag; |
|
Line 2456 extern int mpi_mag; |
|
|
|
void dp_mulc_d(DP p,P c,DP *r) |
void dp_mulc_d(DP p,P c,DP *r) |
{ |
{ |
if ( Dist && BDY(Dist) |
if ( Dist && BDY(Dist) |
&& HMAG(p) > mpi_mag |
&& HMAG(p) > mpi_mag |
&& p_mag((P)c) > mpi_mag ) { |
&& p_mag((P)c) > mpi_mag ) { |
if ( DP_NFStat ) fprintf(asir_out,"~"); |
if ( DP_NFStat ) fprintf(asir_out,"~"); |
dp_imul_d(p,(Q)c,r); |
dp_imul_d(p,(Q)c,r); |
} else { |
} else { |
if ( DP_NFStat ) fprintf(asir_out,"_"); |
if ( DP_NFStat ) fprintf(asir_out,"_"); |
muldc(CO,p,c,r); |
muldc(CO,p,(Obj)c,r); |
} |
} |
} |
} |
|
|
void _dp_nf(NODE b,DP g,DP *ps,int full,DP *rp) |
void _dp_nf(NODE b,DP g,DP *ps,int full,DP *rp) |
{ |
{ |
DP u,p,d,s,t,mult; |
DP u,p,d,s,t,mult; |
P coef; |
P coef; |
NODE l; |
NODE l; |
MP m,mr; |
MP m,mr; |
int sugar,psugar; |
int sugar,psugar; |
|
|
if ( !g ) { |
if ( !g ) { |
*rp = 0; return; |
*rp = 0; return; |
} |
} |
sugar = g->sugar; |
sugar = g->sugar; |
for ( d = 0; g; ) { |
for ( d = 0; g; ) { |
for ( u = 0, l = b; l; l = NEXT(l) ) { |
for ( u = 0, l = b; l; l = NEXT(l) ) { |
if ( dl_redble(BDY(g)->dl,psh[(int)BDY(l)]) ) { |
if ( dl_redble(BDY(g)->dl,psh[(int)BDY(l)]) ) { |
dp_load((int)BDY(l),&p); |
dp_load((int)BDY(l),&p); |
/* t+u = coef*(d+g) - mult*p (t = coef*d) */ |
/* t+u = coef*(d+g) - mult*p (t = coef*d) */ |
dp_red(d,g,p,&t,&u,&coef,&mult); |
dp_red(d,g,p,&t,&u,&coef,&mult); |
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); |
if ( GenTrace ) { |
if ( GenTrace ) { |
LIST hist; |
LIST hist; |
Q cq; |
Q cq; |
NODE node,node0; |
NODE node,node0; |
|
|
STOQ((int)BDY(l),cq); |
STOQ((int)BDY(l),cq); |
node0 = mknode(4,coef,cq,mult,ONE); |
node0 = mknode(4,coef,cq,mult,ONE); |
MKLIST(hist,node0); |
MKLIST(hist,node0); |
MKNODE(node,hist,TraceList); TraceList = node; |
MKNODE(node,hist,TraceList); TraceList = node; |
} |
} |
if ( !u ) { |
if ( !u ) { |
if ( d ) |
if ( d ) |
d->sugar = sugar; |
d->sugar = sugar; |
*rp = d; return; |
*rp = d; return; |
} |
} |
d = t; |
d = t; |
break; |
break; |
} |
} |
} |
} |
if ( u ) |
if ( u ) |
g = u; |
g = u; |
else if ( !full ) { |
else if ( !full ) { |
if ( g ) { |
if ( g ) { |
MKDP(g->nv,BDY(g),t); t->sugar = sugar; g = t; |
MKDP(g->nv,BDY(g),t); t->sugar = sugar; g = t; |
} |
} |
*rp = g; return; |
*rp = g; return; |
} else { |
} else { |
m = BDY(g); NEWMP(mr); mr->dl = m->dl; mr->c = m->c; |
m = BDY(g); NEWMP(mr); mr->dl = m->dl; mr->c = m->c; |
NEXT(mr) = 0; MKDP(g->nv,mr,t); t->sugar = mr->dl->td; |
NEXT(mr) = 0; MKDP(g->nv,mr,t); t->sugar = mr->dl->td; |
addd(CO,d,t,&s); d = s; |
addd(CO,d,t,&s); d = s; |
dp_rest(g,&t); g = t; |
dp_rest(g,&t); g = t; |
} |
} |
} |
} |
if ( d ) |
if ( d ) |
d->sugar = sugar; |
d->sugar = sugar; |
*rp = d; |
*rp = d; |
} |
} |
|
|
void _dp_nf_z(NODE b,DP g,DP *ps,int full,int multiple,DP *r) |
void _dp_nf_z(NODE b,DP g,DP *ps,int full,int multiple,DP *r) |
{ |
{ |
DP u,dp,rp,t,t1,red,shift; |
DP u,dp,rp,t,t1,red,shift; |
Q dc,rc,dcq,rcq,cont,hr,hred,cr,cred,mcred,c,gcd,cq; |
Q dc,rc,dcq,rcq,cont,hr,hred,cr,cred,mcred,c,gcd,cq; |
NODE l; |
NODE l; |
int hmag,denom; |
int hmag,denom; |
int sugar,psugar; |
int sugar,psugar; |
STRING imul; |
STRING imul; |
double t_0,tt,t_p,t_m,t_g,t_a; |
double t_0,tt,t_p,t_m,t_g,t_a; |
LIST hist; |
LIST hist; |
NODE node; |
NODE node; |
Q rcred,mrcred; |
Q rcred,mrcred; |
|
|
if ( !g ) { |
if ( !g ) { |
*r = 0; return; |
*r = 0; return; |
} |
} |
pz_t_e = pz_t_d = pz_t_d1 = pz_t_c = 0; |
pz_t_e = pz_t_d = pz_t_d1 = pz_t_c = 0; |
t_p = t_m = t_g = t_a = 0; |
t_p = t_m = t_g = t_a = 0; |
|
|
denom = Denominator?Denominator:1; |
denom = Denominator?Denominator:1; |
hmag = multiple*HMAG(g)/denom; |
hmag = multiple*HMAG(g)/denom; |
sugar = g->sugar; |
sugar = g->sugar; |
|
|
dc = 0; dp = 0; rc = ONE; rp = g; |
dc = 0; dp = 0; rc = ONE; rp = g; |
MKSTR(imul,"dp_imul_index"); |
MKSTR(imul,"dp_imul_index"); |
|
|
/* g = dc*dp+rc*rp */ |
/* g = dc*dp+rc*rp */ |
for ( ; rp; ) { |
for ( ; rp; ) { |
for ( u = 0, l = b; l; l = NEXT(l) ) { |
for ( u = 0, l = b; l; l = NEXT(l) ) { |
if ( dl_redble(BDY(rp)->dl,psh[(int)BDY(l)]) ) { |
if ( dl_redble(BDY(rp)->dl,psh[(int)BDY(l)]) ) { |
t_0 = get_rtime(); |
t_0 = get_rtime(); |
dp_load((int)BDY(l),&red); |
dp_load((int)BDY(l),&red); |
hr = (Q)BDY(rp)->c; hred = (Q)BDY(red)->c; |
hr = (Q)BDY(rp)->c; hred = (Q)BDY(red)->c; |
igcd_cofactor((Q)BDY(rp)->c,(Q)BDY(red)->c,&gcd,&cred,&cr); |
igcd_cofactor((Q)BDY(rp)->c,(Q)BDY(red)->c,&gcd,&cred,&cr); |
tt = get_rtime(); t_p += tt-t_0; |
tt = get_rtime(); t_p += tt-t_0; |
|
|
dp_subd(rp,red,&shift); |
dp_subd(rp,red,&shift); |
dp_mulc_d(rp,(P)cr,&t); |
dp_mulc_d(rp,(P)cr,&t); |
chsgnp((P)cred,(P *)&mcred); |
chsgnp((P)cred,(P *)&mcred); |
dp_mulc_d(red,(P)mcred,&t1); |
dp_mulc_d(red,(P)mcred,&t1); |
muld(CO,shift,t1,&t1); |
muld(CO,shift,t1,&t1); |
addd(CO,t,t1,&u); |
addd(CO,t,t1,&u); |
t_m += get_rtime()-tt; |
t_m += get_rtime()-tt; |
|
|
psugar = (BDY(rp)->dl->td - BDY(red)->dl->td) + red->sugar; |
psugar = (BDY(rp)->dl->td - BDY(red)->dl->td) + red->sugar; |
sugar = MAX(sugar,psugar); |
sugar = MAX(sugar,psugar); |
|
|
if ( GenTrace ) { |
if ( GenTrace ) { |
/* u = cr*rp + (-cred)*shift*red */ |
/* u = cr*rp + (-cred)*shift*red */ |
STOQ((int)BDY(l),cq); |
STOQ((int)BDY(l),cq); |
node = mknode(4,cr,cq,0,0); |
node = mknode(4,cr,cq,NULLP,NULLP); |
mulq(cred,rc,&rcred); |
mulq(cred,rc,&rcred); |
chsgnnum((Num)rcred,(Num *)&mrcred); |
chsgnnum((Num)rcred,(Num *)&mrcred); |
muldc(CO,shift,(P)mrcred,(DP *)&ARG2(node)); |
muldc(CO,shift,(Obj)mrcred,(DP *)&ARG2(node)); |
MKLIST(hist,node); |
MKLIST(hist,node); |
} |
} |
|
|
if ( !u ) { |
if ( !u ) { |
if ( dp ) |
if ( dp ) |
dp->sugar = sugar; |
dp->sugar = sugar; |
*r = dp; |
*r = dp; |
if ( GenTrace ) { |
if ( GenTrace ) { |
ARG3(BDY(hist)) = ONE; |
ARG3(BDY(hist)) = ONE; |
MKNODE(node,hist,TraceList); TraceList = node; |
MKNODE(node,hist,TraceList); TraceList = node; |
} |
} |
goto final; |
goto final; |
} |
} |
break; |
break; |
} |
} |
} |
} |
if ( u ) { |
if ( u ) { |
if ( multiple && HMAG(u) > hmag ) { |
if ( multiple && HMAG(u) > hmag ) { |
t_0 = get_rtime(); |
t_0 = get_rtime(); |
dp_ptozp_d(u,&rp); |
dp_ptozp_d(u,&rp); |
tt = get_rtime(); t_g += tt-t_0; |
tt = get_rtime(); t_g += tt-t_0; |
|
|
divsq((Q)BDY(u)->c,(Q)BDY(rp)->c,&cont); |
divsq((Q)BDY(u)->c,(Q)BDY(rp)->c,&cont); |
if ( !dp_fcoeffs && DP_NFStat ) { |
if ( !dp_fcoeffs && DP_NFStat ) { |
fprintf(asir_out, |
fprintf(asir_out, |
"(%d)",p_mag((P)cont)*100/p_mag((P)BDY(u)->c)); |
"(%d)",p_mag((P)cont)*100/p_mag((P)BDY(u)->c)); |
fflush(asir_out); |
fflush(asir_out); |
} |
} |
mulq(cr,dc,&dcq); mulq(cont,rc,&rcq); |
mulq(cr,dc,&dcq); mulq(cont,rc,&rcq); |
igcd_cofactor(dcq,rcq,&gcd,&dc,&rc); |
igcd_cofactor(dcq,rcq,&gcd,&dc,&rc); |
t_a = get_rtime()-tt; |
t_a = get_rtime()-tt; |
|
|
hmag = multiple*HMAG(rp)/denom; |
hmag = multiple*HMAG(rp)/denom; |
if ( GenTrace ) { |
if ( GenTrace ) { |
ARG3(BDY(hist)) = (pointer)gcd; |
ARG3(BDY(hist)) = (pointer)gcd; |
MKNODE(node,hist,TraceList); TraceList = node; |
MKNODE(node,hist,TraceList); TraceList = node; |
} |
} |
} else { |
} else { |
rp = u; |
rp = u; |
t_0 = get_rtime(); |
t_0 = get_rtime(); |
mulq(cr,dc,&dc); |
mulq(cr,dc,&dc); |
t_a += get_rtime()-t_0; |
t_a += get_rtime()-t_0; |
if ( GenTrace ) { |
if ( GenTrace ) { |
ARG3(BDY(hist)) = (pointer)ONE; |
ARG3(BDY(hist)) = (pointer)ONE; |
MKNODE(node,hist,TraceList); TraceList = node; |
MKNODE(node,hist,TraceList); TraceList = node; |
} |
} |
} |
} |
} else if ( !full ) { |
} else if ( !full ) { |
if ( rp ) { |
if ( rp ) { |
MKDP(rp->nv,BDY(rp),t); t->sugar = sugar; rp = t; |
MKDP(rp->nv,BDY(rp),t); t->sugar = sugar; rp = t; |
} |
} |
*r = rp; |
*r = rp; |
goto final; |
goto final; |
} else { |
} else { |
t_0 = get_rtime(); |
t_0 = get_rtime(); |
mulq((Q)BDY(rp)->c,rc,&c); |
mulq((Q)BDY(rp)->c,rc,&c); |
igcd_cofactor(dc,c,&dc,&dcq,&cq); |
igcd_cofactor(dc,c,&dc,&dcq,&cq); |
muldc(CO,dp,(P)dcq,&t); |
muldc(CO,dp,(Obj)dcq,&t); |
dp_hm(rp,&t1); BDY(t1)->c = (P)cq; addd(CO,t,t1,&dp); |
dp_hm(rp,&t1); BDY(t1)->c = (Obj)cq; addd(CO,t,t1,&dp); |
dp_rest(rp,&rp); |
dp_rest(rp,&rp); |
t_a += get_rtime()-t_0; |
t_a += get_rtime()-t_0; |
} |
} |
} |
} |
if ( GenTrace ) { |
if ( GenTrace ) { |
mulq(ARG3(BDY((LIST)BDY(TraceList))),dc,&cq); |
mulq(ARG3(BDY((LIST)BDY(TraceList))),dc,&cq); |
ARG3(BDY((LIST)BDY(TraceList))) = (pointer)cq; |
ARG3(BDY((LIST)BDY(TraceList))) = (pointer)cq; |
} |
} |
if ( dp ) |
if ( dp ) |
dp->sugar = sugar; |
dp->sugar = sugar; |
*r = dp; |
*r = dp; |
final: |
final: |
if ( DP_NFStat ) |
if ( DP_NFStat ) |
fprintf(asir_out, |
fprintf(asir_out, |
"(%.3g %.3g %.3g %.3g %.3g %.3g %.3g %.3g)", |
"(%.3g %.3g %.3g %.3g %.3g %.3g %.3g %.3g)", |
t_p,t_m,t_g,t_a, |
t_p,t_m,t_g,t_a, |
pz_t_e, pz_t_d, pz_t_d1, pz_t_c); |
pz_t_e, pz_t_d, pz_t_d1, pz_t_c); |
} |
} |
|
|
void imulv(); |
void imulv(); |
|
|
void dp_imul_d(DP p,Q q,DP *rp) |
void dp_imul_d(DP p,Q q,DP *rp) |
{ |
{ |
int nsep,ndist,i,j,k,l,n; |
int nsep,ndist,i,j,k,l,n; |
double t0,t1,t2; |
double t0,t1,t2; |
Q *s; |
Q *s; |
pointer *b; |
pointer *b; |
VECT c,cs,ri; |
VECT c,cs,ri; |
VECT *r; |
VECT *r; |
MP m; |
MP m; |
NODE tn,dist,n0; |
NODE tn,dist,n0; |
Obj obj; |
Obj obj; |
STRING imul; |
STRING imul; |
extern LIST Dist; |
extern LIST Dist; |
|
|
if ( !p || !q ) { |
if ( !p || !q ) { |
*rp = 0; return; |
*rp = 0; return; |
} |
} |
dist = BDY(Dist); |
dist = BDY(Dist); |
for ( tn = dist, ndist = 0; tn; tn = NEXT(tn), ndist++ ); |
for ( tn = dist, ndist = 0; tn; tn = NEXT(tn), ndist++ ); |
nsep = ndist + 1; |
nsep = ndist + 1; |
for ( m = BDY(p), n = 0; m; m = NEXT(m), n++ ); |
for ( m = BDY(p), n = 0; m; m = NEXT(m), n++ ); |
if ( n <= nsep ) { |
if ( n <= nsep ) { |
muldc(CO,p,(P)q,rp); return; |
muldc(CO,p,(Obj)q,rp); return; |
} |
} |
MKSTR(imul,"imulv"); |
MKSTR(imul,"imulv"); |
t0 = get_rtime(); |
t0 = get_rtime(); |
dp_dtov(p,&c); |
dp_dtov(p,&c); |
sepvect(c,nsep,&cs); |
sepvect(c,nsep,&cs); |
r = (VECT *)CALLOC(nsep,sizeof(VECT *)); |
r = (VECT *)CALLOC(nsep,sizeof(VECT *)); |
for ( i = 0, tn = dist, b = BDY(cs); i < ndist; i++, tn = NEXT(tn) ) { |
for ( i = 0, tn = dist, b = BDY(cs); i < ndist; i++, tn = NEXT(tn) ) { |
n0 = mknode(4,BDY(tn),imul,b[i],q); |
n0 = mknode(4,BDY(tn),imul,b[i],q); |
Pox_rpc(n0,&obj); |
Pox_rpc(n0,&obj); |
} |
} |
t1 = get_rtime(); |
t1 = get_rtime(); |
im_t_s += t1 - t0; |
im_t_s += t1 - t0; |
imulv(b[i],q,&r[i]); |
imulv(b[i],q,&r[i]); |
t1 = get_rtime(); |
t1 = get_rtime(); |
for ( i = 0, tn = dist; i < ndist; i++, tn = NEXT(tn) ) { |
for ( i = 0, tn = dist; i < ndist; i++, tn = NEXT(tn) ) { |
MKNODE(n0,BDY(tn),0); |
MKNODE(n0,BDY(tn),0); |
Pox_pop_local(n0,&obj); r[i] = (VECT)obj; |
Pox_pop_local(n0,&obj); r[i] = (VECT)obj; |
if ( OID(r[i]) == O_ERR ) { |
if ( OID(r[i]) == O_ERR ) { |
printexpr(CO,(Obj)r[i]); |
printexpr(CO,(Obj)r[i]); |
error("dp_imul_d : aborted"); |
error("dp_imul_d : aborted"); |
} |
} |
} |
} |
t2 = get_rtime(); |
t2 = get_rtime(); |
im_t_r += t2 - t1; |
im_t_r += t2 - t1; |
s = (Q *)CALLOC(n,sizeof(Q)); |
s = (Q *)CALLOC(n,sizeof(Q)); |
for ( i = j = 0; i < nsep; i++ ) { |
for ( i = j = 0; i < nsep; i++ ) { |
for ( k = 0, ri = r[i], l = ri->len; k < l; k++, j++ ) { |
for ( k = 0, ri = r[i], l = ri->len; k < l; k++, j++ ) { |
s[j] = (Q)BDY(ri)[k]; |
s[j] = (Q)BDY(ri)[k]; |
} |
} |
} |
} |
dp_vtod(s,p,rp); |
dp_vtod(s,p,rp); |
} |
} |
|
|
void imulv(VECT w,Q c,VECT *rp) |
void imulv(VECT w,Q c,VECT *rp) |
{ |
{ |
int n,i; |
int n,i; |
VECT r; |
VECT r; |
|
|
n = w->len; |
n = w->len; |
MKVECT(r,n); *rp = r; |
MKVECT(r,n); *rp = r; |
for ( i = 0; i < n; i++ ) |
for ( i = 0; i < n; i++ ) |
mulq((Q)BDY(w)[i],(Q)c,(Q *)&BDY(r)[i]); |
mulq((Q)BDY(w)[i],(Q)c,(Q *)&BDY(r)[i]); |
} |
} |
|
|
void dptoca(DP p,unsigned int **rp) |
void dptoca(DP p,unsigned int **rp) |
{ |
{ |
int i; |
int i; |
MP m; |
MP m; |
unsigned int *r; |
unsigned int *r; |
|
|
if ( !p ) |
if ( !p ) |
*rp = 0; |
*rp = 0; |
else { |
else { |
for ( m = BDY(p), i = 0; m; m = NEXT(m), i++ ); |
for ( m = BDY(p), i = 0; m; m = NEXT(m), i++ ); |
*rp = r = (unsigned int *)MALLOC_ATOMIC(i*sizeof(unsigned int)); |
*rp = r = (unsigned int *)MALLOC_ATOMIC(i*sizeof(unsigned int)); |
for ( m = BDY(p), i = 0; m; m = NEXT(m), i++ ) |
for ( m = BDY(p), i = 0; m; m = NEXT(m), i++ ) |
r[i] = ITOS(C(m)); |
r[i] = ITOS(C(m)); |
} |
} |
} |
} |
|
|