version 1.14, 2000/12/08 02:39:05 |
version 1.25, 2001/09/10 05:55:14 |
|
|
* 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.13 2000/12/05 08:29:43 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/builtin/gr.c,v 1.24 2001/09/07 08:54:57 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "parse.h" |
#include "parse.h" |
Line 105 DP_pairs criterion_M(DP_pairs); |
|
Line 105 DP_pairs criterion_M(DP_pairs); |
|
DP_pairs criterion_B(DP_pairs,int); |
DP_pairs criterion_B(DP_pairs,int); |
DP_pairs newpairs(NODE,int); |
DP_pairs newpairs(NODE,int); |
DP_pairs updpairs(DP_pairs,NODE,int); |
DP_pairs updpairs(DP_pairs,NODE,int); |
void _dp_nf(NODE,DP,DP *,int,int,DP *); |
void _dp_nf(NODE,DP,DP *,int,DP *); |
|
void _dp_nf_z(NODE,DP,DP *,int,int,DP *); |
NODE gb_mod(NODE,int); |
NODE gb_mod(NODE,int); |
NODE gbd(NODE,int,NODE,NODE); |
NODE gbd(NODE,int,NODE,NODE); |
NODE gb(NODE,int,NODE); |
NODE gb(NODE,int,NODE); |
Line 134 void pltovl(LIST,VL *); |
|
Line 135 void pltovl(LIST,VL *); |
|
void printdl(DL); |
void printdl(DL); |
int DPPlength(DP_pairs); |
int DPPlength(DP_pairs); |
void dp_gr_mod_main(LIST,LIST,Num,int,struct order_spec *,LIST *); |
void dp_gr_mod_main(LIST,LIST,Num,int,struct order_spec *,LIST *); |
void dp_gr_main(LIST,LIST,Num,int,struct order_spec *,LIST *); |
void dp_gr_main(LIST,LIST,Num,int,int,struct order_spec *,LIST *); |
void dp_f4_main(LIST,LIST,struct order_spec *,LIST *); |
void dp_f4_main(LIST,LIST,struct order_spec *,LIST *); |
void dp_f4_mod_main(LIST,LIST,int,struct order_spec *,LIST *); |
void dp_f4_mod_main(LIST,LIST,int,struct order_spec *,LIST *); |
double get_rtime(); |
double get_rtime(); |
|
|
|
|
static int *pss; |
static int *pss; |
static int psn,pslen; |
static int psn,pslen; |
static int NVars,CNVars,PCoeffs; |
static int NVars,CNVars; |
static VL VC; |
static VL VC; |
|
|
|
int PCoeffs; |
int DP_Print = 0; |
int DP_Print = 0; |
int DP_Multiple = 0; |
int DP_Multiple = 0; |
|
int DP_NFStat = 0; |
LIST Dist = 0; |
LIST Dist = 0; |
int NoGCD = 0; |
int NoGCD = 0; |
int GenTrace = 0; |
int GenTrace = 0; |
int OXCheck = -1; |
int OXCheck = -1; |
|
|
static DP_NFStat = 0; |
|
static int NoSugar = 0; |
static int NoSugar = 0; |
static int NoCriB = 0; |
static int NoCriB = 0; |
static int NoGC = 0; |
static int NoGC = 0; |
Line 178 static int PtozpRA = 0; |
|
Line 180 static int PtozpRA = 0; |
|
|
|
int doing_f4; |
int doing_f4; |
NODE TraceList; |
NODE TraceList; |
|
NODE AllTraceList; |
|
|
int eqdl(nv,dl1,dl2) |
int eqdl(nv,dl1,dl2) |
int nv; |
int nv; |
|
|
} |
} |
} |
} |
|
|
|
/* create compressed poly */ |
|
|
|
void _dpmod_to_vect_compress(f,at,b) |
|
DP f; |
|
DL *at; |
|
CDP *b; |
|
{ |
|
int i,j,nv,len; |
|
MP m; |
|
CDP r; |
|
|
|
nv = f->nv; |
|
for ( m = BDY(f), len = 0; m; m = NEXT(m), len++ ); |
|
r = (CDP)MALLOC(sizeof(struct oCDP)); |
|
r->len = len; |
|
r->body = (CMP)MALLOC(sizeof(struct oCMP)*len); |
|
|
|
for ( m = BDY(f), i = j = 0; m; m = NEXT(m), j++ ) { |
|
for ( ; !eqdl(nv,m->dl,at[i]); i++ ); |
|
r->body[j].index = i; |
|
r->body[j].c = ITOS(m->c); |
|
} |
|
*b = r; |
|
} |
|
|
|
/* dense vector -> CDP */ |
|
void compress_vect(a,n,rp) |
|
int *a; |
|
int n; |
|
CDP *rp; |
|
{ |
|
int i,j,nz; |
|
CDP r; |
|
|
|
for ( i = 0, nz = 0; i < n; i++ ) |
|
if ( a[i] ) nz++; |
|
*rp = r = (CDP)MALLOC(sizeof(struct oCDP)); |
|
r->len = nz; |
|
r->body = (CMP)MALLOC(sizeof(struct oCMP)*nz); |
|
for ( i = 0, j = 0; i < n; i++ ) { |
|
if ( a[i] ) { |
|
r->body[j].index = i; |
|
r->body[j].c = ITOS(a[i]); |
|
j++; |
|
} |
|
} |
|
} |
|
|
void dp_to_vect(f,at,b) |
void dp_to_vect(f,at,b) |
DP f; |
DP f; |
DL *at; |
DL *at; |
|
|
printf("\n"); |
printf("\n"); |
} |
} |
|
|
void dp_gr_main(f,v,homo,modular,ord,rp) |
void dp_gr_main(f,v,homo,modular,field,ord,rp) |
LIST f,v; |
LIST f,v; |
Num homo; |
Num homo; |
int modular; |
int modular,field; |
struct order_spec *ord; |
struct order_spec *ord; |
LIST *rp; |
LIST *rp; |
{ |
{ |
int i,mindex,m,nochk; |
int i,mindex,m,nochk; |
struct order_spec ord1; |
struct order_spec ord1; |
|
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; |
|
LIST trace,gbindex; |
|
|
mindex = 0; nochk = 0; dp_fcoeffs = 0; |
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; |
|
|
modular = -modular; nochk = 1; |
modular = -modular; nochk = 1; |
} |
} |
if ( modular ) |
if ( modular ) |
m = modular > 1 ? modular : lprime[mindex]; |
m = modular > 1 ? modular : get_lprime(mindex); |
else |
else |
m = 0; |
m = 0; |
makesubst(vc,&subst); |
makesubst(vc,&subst); |
|
|
if ( modular > 1 ) { |
if ( modular > 1 ) { |
*rp = 0; return; |
*rp = 0; return; |
} else |
} else |
m = lprime[++mindex]; |
m = get_lprime(++mindex); |
makesubst(vc,&subst); |
makesubst(vc,&subst); |
psn = length(s); |
psn = length(s); |
for ( i = psn; i < pslen; i++ ) { |
for ( i = psn; i < pslen; i++ ) { |
pss[i] = 0; psh[i] = 0; psc[i] = 0; ps[i] = 0; |
pss[i] = 0; psh[i] = 0; psc[i] = 0; ps[i] = 0; |
} |
} |
} |
} |
for ( r0 = 0; x; x = NEXT(x) ) { |
for ( r0 = 0, ind0 = 0; x; x = NEXT(x) ) { |
NEXTNODE(r0,r); dp_load((int)BDY(x),&ps[(int)BDY(x)]); |
NEXTNODE(r0,r); dp_load((int)BDY(x),&ps[(int)BDY(x)]); |
dtop(CO,vv,ps[(int)BDY(x)],(P *)&BDY(r)); |
dtop(CO,vv,ps[(int)BDY(x)],(P *)&BDY(r)); |
|
NEXTNODE(ind0,ind); |
|
STOQ((int)BDY(x),q); BDY(ind) = q; |
} |
} |
if ( r0 ) NEXT(r) = 0; |
if ( r0 ) NEXT(r) = 0; |
|
if ( ind0 ) NEXT(ind) = 0; |
MKLIST(*rp,r0); |
MKLIST(*rp,r0); |
|
MKLIST(gbindex,ind0); |
|
|
|
if ( GenTrace && OXCheck < 0 ) { |
|
|
|
x = AllTraceList; |
|
for ( r = 0; x; x = NEXT(x) ) { |
|
MKNODE(r0,BDY(x),r); r = r0; |
|
} |
|
MKLIST(trace,r); |
|
r0 = mknode(3,*rp,gbindex,trace); |
|
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\n",Max_mag); |
|
|
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; |
|
|
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; |
|
|
if ( homo ) { |
if ( homo ) { |
initd(&ord1); CNVars = NVars+1; |
initd(&ord1); CNVars = NVars+1; |
} |
} |
|
/* init_eg(&eg_red_mod); */ |
x = gb_mod(s,m); |
x = gb_mod(s,m); |
|
/* 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; |
|
|
MP mp,mp0; |
MP mp,mp0; |
NODE blist,bt,nt; |
NODE blist,bt,nt; |
DL *ht,*at,*st; |
DL *ht,*at,*st; |
int **spmat,**redmat; |
int **spmat; |
int *colstat,*w; |
CDP *redmat; |
|
int *colstat,*w,*w1; |
int rank,nred,nsp,nonzero,spcol; |
int rank,nred,nsp,nonzero,spcol; |
int *indred,*isred,*ri; |
int *indred,*isred; |
|
CDP ri; |
struct oEGT tmp0,tmp1,tmp2,eg_split_symb,eg_split_elim1,eg_split_elim2; |
struct oEGT tmp0,tmp1,tmp2,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; |
|
|
|
|
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 reduction */ |
|
#if 0 |
for ( s = s0, nred = 0; s; s = NEXT(s) ) { |
for ( s = s0, nred = 0; s; s = NEXT(s) ) { |
|
for ( j = psn-1; j >= 0; j-- ) |
|
if ( _dl_redble(BDY(ps[j])->dl,BDY(s),nv) ) |
|
break; |
|
if ( j >= 0 ) { |
|
dltod(BDY(s),nv,&tdp); |
|
dp_subd(tdp,ps[j],&sd); |
|
for ( k = 0, i = 0; k < nv; k++ ) |
|
if ( BDY(sd)->dl->d[k] ) |
|
i++; |
|
fprintf(stderr,"%c ",i<=1 ? 'o' : 'x'); |
|
_dp_mod(sd,m,0,&sdm); |
|
mulmd_dup(m,sdm,ps[j],&f2); |
|
MKNODE(bt,f2,blist); blist = bt; |
|
s = symb_merge(s,dp_dllist(f2),nv); |
|
nred++; |
|
} |
|
} |
|
#else |
|
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; |
|
|
nred++; |
nred++; |
} |
} |
} |
} |
|
#endif |
|
fprintf(stderr,"\n"); |
|
|
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); |
|
|
nsp = row-nred; |
nsp = row-nred; |
|
|
/* reducer matrix */ |
/* reducer matrix */ |
redmat = (int **)almat(nred,col); |
/* indred : register the position of the head term */ |
|
#if 0 |
|
reduce_reducers_mod_compress(blist,nred,at,col,m,&redmat,&indred); |
|
isred = (int *)MALLOC(col*sizeof(int)); |
|
bzero(isred,col*sizeof(int)); |
|
for ( i = 0; i < nred; i++ ) |
|
isred[indred[i]] = 1; |
|
#else |
|
redmat = (CDP *)MALLOC(nred*sizeof(CDP)); |
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_compress(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 */ |
|
|
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++ ); |
indred[i] = ri->body[0].index; |
indred[i] = j; |
isred[indred[i]] = 1; |
isred[j] = 1; |
|
} |
} |
|
#endif |
|
|
spcol = col-nred; |
spcol = col-nred; |
/* head terms not in ht */ |
/* head terms not in ht */ |
|
|
if ( !isred[j] ) |
if ( !isred[j] ) |
st[k++] = at[j]; |
st[k++] = at[j]; |
|
|
|
get_eg(&tmp1); |
/* 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 = (int **)MALLOC(nsp*sizeof(int *)); |
w = (int *)MALLOC(col*sizeof(int)); |
w = (int *)MALLOC(col*sizeof(int)); |
for ( ; i < row; r = NEXT(r), i++ ) { |
|
|
/* skip reducers in blist */ |
|
for ( i = 0, r = blist; i < nred; r = NEXT(r), i++ ); |
|
for ( i = 0; r; r = NEXT(r) ) { |
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_compress(w,redmat,indred,nred,col,m); |
for ( j = 0, k = 0; j < col; j++ ) |
for ( j = 0; j < col; j++ ) |
if ( !isred[j] ) |
if ( w[j] ) |
spmat[i-nred][k++] = 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 */ |
|
nsp = i; |
|
|
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)); |
|
bzero(colstat,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 ) |
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)); |
rank = generic_gauss_elim_mod(spmat,nsp,spcol,m,colstat); |
if ( nsp ) |
|
rank = generic_gauss_elim_mod(spmat,nsp,spcol,m,colstat); |
|
else |
|
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); |
|
|
|
|
print_eg("Elim2",&eg_split_elim2); |
print_eg("Elim2",&eg_split_elim2); |
fprintf(asir_out,"\n"); |
fprintf(asir_out,"\n"); |
} |
} |
|
|
|
if ( !rank ) |
|
continue; |
|
|
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; |
|
|
int i; |
int i; |
NODE s,s0,f0; |
NODE s,s0,f0; |
|
|
|
#if 1 |
f0 = f = NODE_sortb(f,1); |
f0 = f = NODE_sortb(f,1); |
|
#else |
|
f0 = f; |
|
#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[i] = ps[i]->sugar; |
pss[i] = ps[i]->sugar; |
psc[i] = BDY(ps[i])->c; |
psc[i] = BDY(ps[i])->c; |
} |
} |
if ( GenTrace && (OXCheck >= 0) ) { |
if ( GenTrace ) { |
Q q; |
Q q; |
STRING fname; |
STRING fname; |
LIST input; |
LIST input; |
NODE arg; |
NODE arg,t,t1; |
Obj dmy; |
Obj dmy; |
|
|
|
t = 0; |
|
for ( i = psn-1; i >= 0; i-- ) { |
|
MKNODE(t1,ps[i],t); |
|
t = t1; |
|
} |
|
MKLIST(input,t); |
|
|
STOQ(OXCheck,q); |
if ( OXCheck >= 0 ) { |
MKSTR(fname,"register_input"); |
STOQ(OXCheck,q); |
MKLIST(input,f0); |
MKSTR(fname,"register_input"); |
arg = mknode(3,q,fname,input); |
arg = mknode(3,q,fname,input); |
Pox_cmo_rpc(arg,&dmy); |
Pox_cmo_rpc(arg,&dmy); |
|
} else if ( OXCheck < 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; |
|
|
else |
else |
dp_ptozp(f,r); |
dp_ptozp(f,r); |
if ( GenTrace && TraceList ) { |
if ( GenTrace && TraceList ) { |
|
/* adust the denominator according to the final |
|
content reduction */ |
divsp(CO,BDY(f)->c,BDY(*r)->c,&d); |
divsp(CO,BDY(f)->c,BDY(*r)->c,&d); |
mulp(CO,(P)ARG3(BDY((LIST)BDY(TraceList))),d,&t); |
mulp(CO,(P)ARG3(BDY((LIST)BDY(TraceList))),d,&t); |
ARG3(BDY((LIST)BDY(TraceList))) = t; |
ARG3(BDY((LIST)BDY(TraceList))) = t; |
|
|
MKLIST(hist,node); |
MKLIST(hist,node); |
MKNODE(TraceList,hist,0); |
MKNODE(TraceList,hist,0); |
} |
} |
_dp_nf(top,ps[w[i]],ps,1,PtozpRA?DP_Multiple:0,&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 ) { |
|
|
_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; |
LIST trace,trace1; |
|
NODE arg; |
|
Q q1,q2; |
|
STRING fname; |
|
Obj dmy; |
|
|
/* reverse the TraceList */ |
/* reverse the TraceList */ |
tn = TraceList; |
tn = TraceList; |
|
|
} |
} |
MKLIST(trace,tr); |
MKLIST(trace,tr); |
if ( OXCheck >= 0 ) { |
if ( OXCheck >= 0 ) { |
NODE arg; |
|
Q q1,q2; |
|
STRING fname; |
|
Obj dmy; |
|
|
|
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,&dmy); |
Pox_cmo_rpc(arg,&dmy); |
|
} else if ( OXCheck < 0 ) { |
|
STOQ(psn,q1); |
|
tn = mknode(2,q1,trace); |
|
MKLIST(trace1,tn); |
|
MKNODE(tr,trace1,AllTraceList); |
|
AllTraceList = tr; |
} else |
} else |
dp_save(psn,(Obj)trace,"t"); |
dp_save(psn,(Obj)trace,"t"); |
TraceList = 0; |
TraceList = 0; |
|
|
new_sugar = h->sugar; |
new_sugar = h->sugar; |
get_eg(&tnf0); |
get_eg(&tnf0); |
t_0 = get_rtime(); |
t_0 = get_rtime(); |
_dp_nf(gall,h,ps,!Top,DP_Multiple,&nf); |
if ( PCoeffs || dp_fcoeffs ) |
|
_dp_nf(gall,h,ps,!Top,&nf); |
|
else |
|
_dp_nf_z(gall,h,ps,!Top,DP_Multiple,&nf); |
if ( DP_Print ) |
if ( DP_Print ) |
fprintf(asir_out,"(%.3g)",get_rtime()-t_0); |
fprintf(asir_out,"(%.3g)",get_rtime()-t_0); |
get_eg(&tnf1); add_eg(&eg_nf,&tnf0,&tnf1); |
get_eg(&tnf1); add_eg(&eg_nf,&tnf0,&tnf1); |
|
|
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_sp(dp1,dp2,&h); |
dp_load(l->dp1,&dp1); dp_load(l->dp2,&dp2); |
_dp_nf(gall,h,ps,1,0,&nf); |
dp_sp(dp1,dp2,&h); |
|
/* fprintf(stderr,"{%d,%d}",l->dp1,l->dp2); */ |
|
_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); |
|
|
} |
} |
for ( ; f; f = NEXT(f) ) { |
for ( ; f; f = NEXT(f) ) { |
get_eg(&tmp0); |
get_eg(&tmp0); |
_dp_nf(x,(DP)BDY(f),ps,1,0,&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); |
|
|
STOQ(Reverse,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"Reverse"); 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(Stat,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"Stat"); 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(DP_Print,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"Print"); 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(DP_PrintShort,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"PrintShort"); 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(DP_NFStat,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"NFStat"); 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(OXCheck,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"OXCheck"); 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(GenTrace,v); MKNODE(n1,v,n); n = n1; MKSTR(name,"GenTrace"); MKNODE(n1,name,n); n = n1; |
Line 2006 void print_stat() { |
|
Line 2158 void print_stat() { |
|
* |
* |
*/ |
*/ |
|
|
#define SAFENM(q) ((q)?NM(q):0) |
|
|
|
double pz_t_e, pz_t_d, pz_t_d1, pz_t_c, im_t_s, im_t_r; |
double pz_t_e, pz_t_d, pz_t_d1, pz_t_c, im_t_s, im_t_r; |
|
|
extern int GenTrace; |
extern int GenTrace; |
extern NODE TraceList; |
extern NODE TraceList; |
|
extern int mpi_mag; |
|
|
void _dp_nf(b,g,ps,full,multiple,r) |
void dp_mulc_d(p,c,r) |
|
DP p; |
|
P c; |
|
DP *r; |
|
{ |
|
if ( Dist && BDY(Dist) |
|
&& HMAG(p) > mpi_mag |
|
&& p_mag((P)c) > mpi_mag ) { |
|
if ( DP_NFStat ) fprintf(asir_out,"~"); |
|
dp_imul_d(p,(Q)c,r); |
|
} else { |
|
if ( DP_NFStat ) fprintf(asir_out,"_"); |
|
muldc(CO,p,c,r); |
|
} |
|
} |
|
|
|
void _dp_nf(b,g,ps,full,rp) |
NODE b; |
NODE b; |
DP g; |
DP g; |
DP *ps; |
DP *ps; |
|
int full; |
|
DP *rp; |
|
{ |
|
DP u,p,d,s,t,mult; |
|
P coef; |
|
NODE l; |
|
MP m,mr; |
|
int sugar,psugar; |
|
|
|
if ( !g ) { |
|
*rp = 0; return; |
|
} |
|
sugar = g->sugar; |
|
for ( d = 0; g; ) { |
|
for ( u = 0, l = b; l; l = NEXT(l) ) { |
|
if ( dl_redble(BDY(g)->dl,psh[(int)BDY(l)]) ) { |
|
dp_load((int)BDY(l),&p); |
|
/* t+u = coef*(d+g) - mult*p (t = coef*d) */ |
|
dp_red(d,g,p,&t,&u,&coef,&mult); |
|
psugar = (BDY(g)->dl->td - BDY(p)->dl->td) + p->sugar; |
|
sugar = MAX(sugar,psugar); |
|
if ( GenTrace ) { |
|
LIST hist; |
|
Q cq; |
|
NODE node,node0; |
|
|
|
STOQ((int)BDY(l),cq); |
|
node0 = mknode(4,coef,cq,mult,ONE); |
|
MKLIST(hist,node0); |
|
MKNODE(node,hist,TraceList); TraceList = node; |
|
} |
|
if ( !u ) { |
|
if ( d ) |
|
d->sugar = sugar; |
|
*rp = d; return; |
|
} |
|
d = t; |
|
break; |
|
} |
|
} |
|
if ( u ) |
|
g = u; |
|
else if ( !full ) { |
|
if ( g ) { |
|
MKDP(g->nv,BDY(g),t); t->sugar = sugar; g = t; |
|
} |
|
*rp = g; return; |
|
} else { |
|
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; |
|
addd(CO,d,t,&s); d = s; |
|
dp_rest(g,&t); g = t; |
|
} |
|
} |
|
if ( d ) |
|
d->sugar = sugar; |
|
*rp = d; |
|
} |
|
|
|
void _dp_nf_z(b,g,ps,full,multiple,r) |
|
NODE b; |
|
DP g; |
|
DP *ps; |
int full,multiple; |
int full,multiple; |
DP *r; |
DP *r; |
{ |
{ |
|
|
int sugar,psugar; |
int sugar,psugar; |
NODE dist; |
NODE dist; |
STRING imul; |
STRING imul; |
int ndist; |
|
int kara_bit; |
int kara_bit; |
extern int mpi_mag; |
|
double get_rtime(); |
double get_rtime(); |
double t_0,t_00,tt,ttt,t_p,t_m,t_m1,t_m2,t_s,t_g,t_a; |
double t_0,t_00,tt,ttt,t_p,t_m,t_g,t_a; |
LIST hist; |
LIST hist; |
NODE node; |
NODE node; |
Q rcred,mrcred; |
Q rcred,mrcred; |
|
|
*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_m1 = t_m2 = t_s = 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; |
if ( Dist ) { |
|
dist = BDY(Dist); |
|
ndist = length(dist); |
|
} |
|
sugar = g->sugar; |
sugar = g->sugar; |
|
|
dc = 0; dp = 0; rc = ONE; rp = g; |
dc = 0; dp = 0; rc = ONE; rp = g; |
|
|
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; |
/* |
|
* hr = HC(rp), hred = HC(red) |
|
* cred = hr/GCD(hr,hred), cr = hred/GCD(hr,hred) |
|
*/ |
|
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_0; t_p += tt; |
tt = get_rtime(); t_p += tt-t_0; |
|
|
t_0 = get_rtime(); |
|
dp_subd(rp,red,&shift); |
dp_subd(rp,red,&shift); |
|
dp_mulc_d(rp,cr,&t); |
t_00 = get_rtime(); |
|
if ( Dist && ndist |
|
&& HMAG(red) > mpi_mag |
|
&& p_mag((P)cr) > mpi_mag ) { |
|
if ( DP_NFStat ) fprintf(asir_out,"~"); |
|
dp_imul_d(rp,cr,&t); |
|
} else { |
|
if ( DP_NFStat ) fprintf(asir_out,"_"); |
|
muldc(CO,rp,(P)cr,&t); |
|
} |
|
ttt = get_rtime()-t_00; t_m1 += ttt/dp_nt(rp); |
|
|
|
t_00 = get_rtime(); |
|
chsgnp((P)cred,(P *)&mcred); |
chsgnp((P)cred,(P *)&mcred); |
if ( Dist && ndist |
dp_mulc_d(red,mcred,&t1); |
&& HMAG(red) > mpi_mag |
muld(CO,shift,t1,&t1); |
&& p_mag((P)mcred) > mpi_mag ) { |
addd(CO,t,t1,&u); |
if ( DP_NFStat ) fprintf(asir_out,"="); |
t_m += get_rtime()-tt; |
dp_imul_d(red,mcred,&t1); |
|
} else { |
|
if ( DP_NFStat ) fprintf(asir_out,"_"); |
|
muldc(CO,red,(P)mcred,&t1); |
|
} |
|
ttt = get_rtime()-t_00; t_m2 += ttt/dp_nt(red); |
|
|
|
t_00 = get_rtime(); |
|
muld(CO,shift,t1,&t2); |
|
addd(CO,t,t2,&u); |
|
tt = get_rtime(); t_m += tt-t_0; |
|
ttt = get_rtime(); t_s += ttt-t_00; |
|
|
|
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); |
|
|
muldc(CO,shift,(P)mrcred,(DP *)&ARG2(node)); |
muldc(CO,shift,(P)mrcred,(DP *)&ARG2(node)); |
MKLIST(hist,node); |
MKLIST(hist,node); |
} |
} |
|
|
if ( !u ) { |
if ( !u ) { |
if ( dp ) |
if ( dp ) |
dp->sugar = sugar; |
dp->sugar = sugar; |
|
|
if ( u ) { |
if ( u ) { |
if ( multiple && HMAG(u) > hmag ) { |
if ( multiple && HMAG(u) > hmag ) { |
t_0 = get_rtime(); |
t_0 = get_rtime(); |
if ( Dist && HMAG(u) > mpi_mag ) { |
dp_ptozp_d(u,&rp); |
if ( DP_NFStat ) |
tt = get_rtime(); t_g += tt-t_0; |
fprintf(asir_out,"D"); |
|
dp_ptozp_d(dist,ndist,u,&t); |
divsq((Q)BDY(u)->c,(Q)BDY(rp)->c,&cont); |
} else { |
|
if ( DP_NFStat ) |
|
fprintf(asir_out,"L"); |
|
dp_ptozp_d(0,0,u,&t); |
|
} |
|
tt = get_rtime()-t_0; t_g += tt; |
|
t_0 = get_rtime(); |
|
divsn(NM((Q)BDY(u)->c),NM((Q)BDY(t)->c),&cn); NTOQ(cn,1,cont); |
|
if ( !dp_fcoeffs && DP_NFStat ) { |
if ( !dp_fcoeffs && DP_NFStat ) { |
fprintf(asir_out,"(%d)",p_mag((P)cont)*100/p_mag((P)BDY(u)->c)); |
fprintf(asir_out, |
|
"(%d)",p_mag((P)cont)*100/p_mag((P)BDY(u)->c)); |
fflush(asir_out); |
fflush(asir_out); |
} |
} |
mulq(cr,dc,&dcq); |
mulq(cr,dc,&dcq); mulq(cont,rc,&rcq); |
mulq(cont,rc,&rcq); |
|
igcd_cofactor(dcq,rcq,&gcd,&dc,&rc); |
igcd_cofactor(dcq,rcq,&gcd,&dc,&rc); |
tt = get_rtime()-t_0; t_a += tt; |
t_a = get_rtime()-tt; |
rp = t; |
|
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 { |
t_0 = get_rtime(); |
|
mulq(cr,dc,&dcq); dc = dcq; |
|
tt = get_rtime()-t_0; t_a += tt; |
|
rp = u; |
rp = u; |
|
t_0 = get_rtime(); |
|
mulq(cr,dc,&dc); |
|
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 { |
} 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,&gcd,&dcq,&cq); |
igcd_cofactor(dc,c,&dc,&dcq,&cq); |
muldc(CO,dp,(P)dcq,&t1); |
muldc(CO,dp,(P)dcq,&t); |
m = BDY(rp); NEWMP(mr); mr->dl = m->dl; mr->c = (P)cq; |
dp_hm(rp,&t1); BDY(t1)->c = (P)cq; addd(CO,t,t1,&dp); |
NEXT(mr) = 0; MKDP(rp->nv,mr,t); t->sugar = mr->dl->td; |
dp_rest(rp,&rp); |
addd(CO,t,t1,&dp); |
t_a += get_rtime()-t_0; |
dc = gcd; |
|
|
|
dp_rest(rp,&t); rp = t; |
|
tt = get_rtime()-t_0; t_a += tt; |
|
} |
} |
} |
} |
if ( GenTrace ) { |
if ( GenTrace ) { |
|
|
*r = dp; |
*r = dp; |
final: |
final: |
if ( DP_NFStat ) |
if ( DP_NFStat ) |
fprintf(asir_out,"(%.3g %.3g %.3g %.3g %.3g %.3g %.3g %.3g %.3g %.3g %.3g)", |
fprintf(asir_out, |
t_p,t_m,t_m1,t_m2,t_s, |
"(%.3g %.3g %.3g %.3g %.3g %.3g %.3g %.3g)", |
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); |
} |
} |
|
|
|
|
NODE tn,dist,n0,n1,n2; |
NODE tn,dist,n0,n1,n2; |
Obj dmy; |
Obj dmy; |
STRING imul; |
STRING imul; |
|
|
extern LIST Dist; |
extern LIST Dist; |
|
|
if ( !p || !q ) { |
if ( !p || !q ) { |