version 1.28, 2001/09/13 03:04:27 |
version 1.29, 2001/09/13 03:19:56 |
|
|
* 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.27 2001/09/11 08:56:47 noro Exp $ |
* $OpenXM$ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "parse.h" |
#include "parse.h" |
Line 150 double get_rtime(); |
|
Line 150 double get_rtime(); |
|
void _dpmod_to_vect(DP,DL *,int *); |
void _dpmod_to_vect(DP,DL *,int *); |
void dp_to_vect(DP,DL *,Q *); |
void dp_to_vect(DP,DL *,Q *); |
NODE dp_dllist(DP f); |
NODE dp_dllist(DP f); |
DLBUCKET dp_dllist_bucket(DP f); |
|
NODE symb_merge(NODE,NODE,int),_symb_merge(NODE,NODE,int); |
NODE symb_merge(NODE,NODE,int),_symb_merge(NODE,NODE,int); |
DLBUCKET symb_merge_bucket(DLBUCKET,DLBUCKET,int); |
|
extern int dp_nelim; |
extern int dp_nelim; |
extern int dp_fcoeffs; |
extern int dp_fcoeffs; |
static DP *ps,*psm; |
static DP *ps,*psm; |
|
|
return mp0; |
return mp0; |
} |
} |
|
|
void print_dlbucket(d,nv) |
|
DLBUCKET d; |
|
int nv; |
|
{ |
|
int i; |
|
NODE n; |
|
|
|
for ( ; d; d = NEXT(d) ) { |
|
fprintf(stderr,"td = %d\n",d->td); |
|
for ( n = BDY(d); n; n = NEXT(n) ) { |
|
fprintf(stderr,"<"); |
|
for ( i = 0; i < nv; i++ ) { |
|
fprintf(stderr,"%d",((DL)BDY(n))->d[i]); |
|
if ( i != nv-1 ) |
|
fprintf(stderr," "); |
|
} |
|
fprintf(stderr,">"); |
|
} |
|
fprintf(stderr,"\n"); |
|
} |
|
} |
|
|
|
DLBUCKET dp_dllist_bucket(f) |
|
DP f; |
|
{ |
|
MP m; |
|
NODE n,n0; |
|
DLBUCKET d,d0; |
|
int td; |
|
|
|
if ( !f ) |
|
return 0; |
|
d0 = 0; |
|
m = BDY(f); |
|
do { |
|
NEXTDLBUCKET(d0,d); |
|
n0 = 0; |
|
d->td = td = m->dl->td; |
|
do { |
|
NEXTNODE(n0,n); |
|
BDY(n) = (pointer)m->dl; |
|
m = NEXT(m); |
|
} while ( m && m->dl->td == td ); |
|
NEXT(n) = 0; |
|
BDY(d) = n0; |
|
} while ( m ); |
|
NEXT(d) = 0; |
|
return d0; |
|
} |
|
|
|
void pdl(f) |
void pdl(f) |
NODE f; |
NODE f; |
{ |
{ |
|
|
{ |
{ |
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 sb; |
NODE s,s0; |
DLBUCKET s,s0,s1; |
|
DP_pairs d,dm,dr,t; |
DP_pairs d,dm,dr,t; |
DP h,nf,f1,f2,f21,f21r,sp,sp1,sd,sdm,tdp; |
DP h,nf,f1,f2,f21,f21r,sp,sp1,sd,sdm,tdp; |
MP mp,mp0; |
MP mp,mp0; |
|
|
_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_bucket(s0,dp_dllist_bucket(sp),nv); |
s0 = symb_merge(s0,dp_dllist(sp),nv); |
/* print_dlbucket(s0,nv); */ |
|
} |
} |
} |
} |
/* s0 : all the terms appeared in symbolic reduction */ |
/* s0 : all the terms appeared in symbolic reduction */ |
#if 0 |
#if 0 |
for ( s = s0, nred = 0; s; s = NEXT(s) ) { |
for ( s = s0, nred = 0; s; s = NEXT(s) ) { |
sb = BDY(s); |
for ( j = psn-1; j >= 0; j-- ) |
for ( ; sb; sb = NEXT(sb) ) { |
if ( _dl_redble(BDY(ps[j])->dl,BDY(s),nv) ) |
for ( j = psn-1; j >= 0; j-- ) |
break; |
if ( _dl_redble(BDY(ps[j])->dl,BDY(sb),nv) ) |
if ( j >= 0 ) { |
break; |
dltod(BDY(s),nv,&tdp); |
if ( j >= 0 ) { |
dp_subd(tdp,ps[j],&sd); |
dltod(BDY(sb),nv,&tdp); |
for ( k = 0, i = 0; k < nv; k++ ) |
dp_subd(tdp,ps[j],&sd); |
if ( BDY(sd)->dl->d[k] ) |
for ( k = 0, i = 0; k < nv; k++ ) |
i++; |
if ( BDY(sd)->dl->d[k] ) |
fprintf(stderr,"%c ",i<=1 ? 'o' : 'x'); |
i++; |
_dp_mod(sd,m,0,&sdm); |
fprintf(stderr,"%c ",i<=1 ? 'o' : 'x'); |
mulmd_dup(m,sdm,ps[j],&f2); |
_dp_mod(sd,m,0,&sdm); |
MKNODE(bt,f2,blist); blist = bt; |
mulmd_dup(m,sdm,ps[j],&f2); |
s = symb_merge(s,dp_dllist(f2),nv); |
MKNODE(bt,f2,blist); blist = bt; |
nred++; |
/* merge the highest degree part into sb */ |
|
s1 = dp_dllist_bucket(f2); |
|
symb_merge(sb,BDY(s1),nv); |
|
/* merge the rest into s */ |
|
symb_merge_bucket(s,NEXT(s1),nv); |
|
nred++; |
|
} |
|
} |
} |
} |
} |
#else |
#else |
for ( s = s0, nred = 0; s; s = NEXT(s) ) { |
for ( s = s0, nred = 0; s; s = NEXT(s) ) { |
sb = BDY(s); |
for ( r = gall; r; r = NEXT(r) ) |
for ( ; sb; sb = NEXT(sb) ) { |
if ( _dl_redble(BDY(ps[(int)BDY(r)])->dl,BDY(s),nv) ) |
for ( r = gall; r; r = NEXT(r) ) |
break; |
if ( _dl_redble(BDY(ps[(int)BDY(r)])->dl,BDY(sb),nv) ) |
if ( r ) { |
break; |
dltod(BDY(s),nv,&tdp); |
if ( r ) { |
dp_subd(tdp,ps[(int)BDY(r)],&sd); |
dltod(BDY(sb),nv,&tdp); |
_dp_mod(sd,m,0,&sdm); |
dp_subd(tdp,ps[(int)BDY(r)],&sd); |
mulmd_dup(m,sdm,ps[(int)BDY(r)],&f2); |
_dp_mod(sd,m,0,&sdm); |
MKNODE(bt,f2,blist); blist = bt; |
mulmd_dup(m,sdm,ps[(int)BDY(r)],&f2); |
s = symb_merge(s,dp_dllist(f2),nv); |
MKNODE(bt,f2,blist); blist = bt; |
nred++; |
/* merge the highest degree part into sb */ |
|
s1 = dp_dllist_bucket(f2); |
|
symb_merge(sb,BDY(s1),nv); |
|
/* merge the rest into s */ |
|
symb_merge_bucket(s,NEXT(s1),nv); |
|
nred++; |
|
} |
|
} |
} |
} |
} |
#endif |
#endif |
|
|
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) ) |
for ( s = s0, col = 0; s; s = NEXT(s), col++ ); |
for ( sb = BDY(s); sb; sb = NEXT(sb) ) |
|
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) ) |
for ( s = s0, i = 0; i < col; s = NEXT(s), i++ ) |
for ( sb = BDY(s); sb; sb = NEXT(sb), i++ ) |
at[i] = (DL)BDY(s); |
at[i] = (DL)BDY(sb); |
|
|
|
/* store coefficients separately in spmat and redmat */ |
/* store coefficients separately in spmat and redmat */ |
nsp = row-nred; |
nsp = row-nred; |