version 1.24, 2001/09/07 08:54:57 |
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.23 2001/09/05 08:09:10 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" |
|
|
*b = r; |
*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; |
|
|
DL *ht,*at,*st; |
DL *ht,*at,*st; |
int **spmat; |
int **spmat; |
CDP *redmat; |
CDP *redmat; |
int *colstat,*w; |
int *colstat,*w,*w1; |
int rank,nred,nsp,nonzero,spcol; |
int rank,nred,nsp,nonzero,spcol; |
int *indred,*isred; |
int *indred,*isred; |
CDP ri; |
CDP ri; |
|
|
nsp = row-nred; |
nsp = row-nred; |
|
|
/* reducer matrix */ |
/* reducer matrix */ |
|
/* 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)); |
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_compress(BDY(r),at,&redmat[i]); |
_dpmod_to_vect_compress(BDY(r),at,&redmat[i]); |
|
|
indred[i] = ri->body[0].index; |
indred[i] = ri->body[0].index; |
isred[indred[i]] = 1; |
isred[indred[i]] = 1; |
} |
} |
|
#endif |
|
|
spcol = col-nred; |
spcol = col-nred; |
/* head terms not in ht */ |
/* head terms not in ht */ |
|
|
|
|
get_eg(&tmp1); |
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_compress(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] ) |
|
|
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; |