version 1.17, 2001/09/10 05:55:13 |
version 1.21, 2001/09/17 07:16:58 |
|
|
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* |
* |
* $OpenXM$ |
* $OpenXM: OpenXM_contrib2/asir2000/builtin/array.c,v 1.20 2001/09/17 03:33:57 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "base.h" |
#include "base.h" |
|
|
} |
} |
|
|
/* |
/* |
rlist : reducers list |
mat[i] : compressed reducers (i=0,...,nred-1) |
ht(BDY(rlist)) < ht(BDY(NEXT(rlist)) < ... w.r.t. the term order |
mat[0] < mat[1] < ... < mat[nred-1] w.r.t the term order |
*/ |
*/ |
|
|
void reduce_reducers_mod_compress(rlist,nred,at,col,md,redmatp,indredp) |
int red_by_compress(m,p,r,ri,hc,len) |
NODE rlist; |
int m; |
int nred; |
unsigned int *p; |
DL *at; |
register unsigned int *r; |
int col,md; |
register unsigned short *ri; |
CDP **redmatp; |
unsigned int hc; |
int **indredp; |
register int len; |
{ |
{ |
CDP *redmat; |
unsigned int up,lo; |
CDP t; |
unsigned int dmy; |
int *indred,*w; |
unsigned int *pj; |
int i,k; |
|
NODE r; |
|
|
|
*redmatp = redmat = (CDP *)CALLOC(nred,sizeof(CDP)); |
p[*ri] = 0; r++; ri++; |
*indredp = indred = (int *)CALLOC(nred,sizeof(int)); |
for ( len--; len; len--, r++, ri++ ) { |
w = (int *)CALLOC(col,sizeof(int)); |
pj = p+ *ri; |
|
DMA(*r,hc,*pj,up,lo); |
|
if ( up ) { |
|
DSAB(m,up,lo,dmy,*pj); |
|
} else |
|
*pj = lo; |
|
} |
|
} |
|
|
_dpmod_to_vect_compress(BDY(rlist),at,&redmat[0]); |
/* p -= hc*r */ |
indred[0] = redmat[0]->body[0].index; |
|
|
|
for ( i = 1, r = NEXT(rlist); i < nred; i++, r = NEXT(r) ) { |
int red_by_vect(m,p,r,hc,len) |
bzero(w,col*sizeof(int)); |
int m; |
_dpmod_to_vect(BDY(r),at,w); |
unsigned int *p,*r; |
reduce_sp_by_red_mod_compress(w,redmat,indred,i,col,md); |
unsigned int hc; |
compress_vect(w,col,&redmat[i]); |
int len; |
indred[i] = redmat[i]->body[0].index; |
{ |
} |
register unsigned int up,lo; |
|
unsigned int dmy; |
|
|
|
*p++ = 0; r++; len--; |
|
for ( ; len; len--, r++, p++ ) |
|
if ( *r ) { |
|
DMA(*r,hc,*p,up,lo); |
|
if ( up ) { |
|
DSAB(m,up,lo,dmy,*p); |
|
} else |
|
*p = lo; |
|
} |
} |
} |
|
|
/* |
extern unsigned int **psca; |
mat[i] : compressed reducers (i=0,...,nred-1) |
|
mat[0] < mat[1] < ... < mat[nred-1] w.r.t the term order |
|
*/ |
|
|
|
void reduce_sp_by_red_mod_compress (sp,redmat,ind,nred,col,md) |
void reduce_sp_by_red_mod_compress (sp,redmat,ind,nred,col,md) |
int *sp; |
int *sp; |
|
|
int nred,col; |
int nred,col; |
int md; |
int md; |
{ |
{ |
int i,j,k,hc,c,len; |
int i,j,k,len; |
int *tj; |
unsigned int *tj; |
CDP ri; |
CDP ri; |
|
unsigned int hc,up,lo,up1,lo1,c; |
|
unsigned int *usp; |
|
|
|
usp = (unsigned int *)sp; |
/* reduce the spolys by redmat */ |
/* reduce the spolys by redmat */ |
for ( i = nred-1; i >= 0; i-- ) { |
for ( i = nred-1; i >= 0; i-- ) { |
/* reduce sp by redmat[i] */ |
/* reduce sp by redmat[i] */ |
if ( hc = sp[ind[i]] ) { |
usp[ind[i]] %= md; |
|
if ( hc = usp[ind[i]] ) { |
/* sp = sp-hc*redmat[i] */ |
/* sp = sp-hc*redmat[i] */ |
hc = md-hc; |
hc = md-hc; |
ri = redmat[i]; |
ri = redmat[i]; |
len = ri->len; |
len = ri->len; |
for ( k = 0; k < len; k++ ) { |
red_by_compress(md,usp,psca[ri->psindex],ri->body,hc,len); |
j = ri->body[k].index; |
|
c = ri->body[k].c; |
|
tj = sp+j; |
|
#if 1 |
|
DMAR(c,hc,*tj,md,*tj); |
|
#else |
|
*tj = ((hc*c)+(*tj))%md; |
|
#endif |
|
} |
|
} |
} |
} |
} |
|
for ( i = 0; i < col; i++ ) |
|
if ( usp[i] >= md ) |
|
usp[i] %= md; |
} |
} |
|
|
#define ONE_STEP2 if ( zzz = *pk ) { DMAR(zzz,a,*tk,md,*tk) } pk++; tk++; |
#define ONE_STEP2 if ( zzz = *pk ) { DMAR(zzz,a,*tk,md,*tk) } pk++; tk++; |
|
|
int generic_gauss_elim_mod(mat,row,col,md,colstat) |
int generic_gauss_elim_mod(mat0,row,col,md,colstat) |
int **mat; |
int **mat0; |
int row,col,md; |
int row,col,md; |
int *colstat; |
int *colstat; |
{ |
{ |
int i,j,k,l,inv,a,rank,zzz; |
int i,j,k,l,inv,a,rank,zzz; |
int *t,*pivot,*pk,*tk; |
unsigned int *t,*pivot,*pk,*tk; |
|
unsigned int **mat; |
|
|
|
mat = (unsigned int **)mat0; |
for ( rank = 0, j = 0; j < col; j++ ) { |
for ( rank = 0, j = 0; j < col; j++ ) { |
for ( i = rank; i < row && !mat[i][j]; i++ ); |
for ( i = rank; i < row; i++ ) |
|
mat[i][j] %= md; |
|
for ( i = rank; i < row; i++ ) |
|
if ( mat[i][j] ) |
|
break; |
if ( i == row ) { |
if ( i == row ) { |
colstat[j] = 0; |
colstat[j] = 0; |
continue; |
continue; |
|
|
inv = invm(pivot[j],md); |
inv = invm(pivot[j],md); |
for ( k = j, pk = pivot+k; k < col; k++, pk++ ) |
for ( k = j, pk = pivot+k; k < col; k++, pk++ ) |
if ( *pk ) { |
if ( *pk ) { |
|
if ( *pk >= md ) |
|
*pk %= md; |
DMAR(*pk,inv,0,md,*pk) |
DMAR(*pk,inv,0,md,*pk) |
} |
} |
for ( i = rank+1; i < row; i++ ) { |
for ( i = rank+1; i < row; i++ ) { |
t = mat[i]; |
t = mat[i]; |
if ( a = t[j] ) { |
if ( a = t[j] ) |
a = md - a; pk = pivot+j; tk = t+j; |
red_by_vect(md,t+j,pivot+j,md-a,col-j); |
k = col-j; |
|
for ( ; k >= 64; k -= 64 ) { |
|
ONE_STEP2 ONE_STEP2 ONE_STEP2 ONE_STEP2 |
|
ONE_STEP2 ONE_STEP2 ONE_STEP2 ONE_STEP2 |
|
ONE_STEP2 ONE_STEP2 ONE_STEP2 ONE_STEP2 |
|
ONE_STEP2 ONE_STEP2 ONE_STEP2 ONE_STEP2 |
|
ONE_STEP2 ONE_STEP2 ONE_STEP2 ONE_STEP2 |
|
ONE_STEP2 ONE_STEP2 ONE_STEP2 ONE_STEP2 |
|
ONE_STEP2 ONE_STEP2 ONE_STEP2 ONE_STEP2 |
|
ONE_STEP2 ONE_STEP2 ONE_STEP2 ONE_STEP2 |
|
ONE_STEP2 ONE_STEP2 ONE_STEP2 ONE_STEP2 |
|
ONE_STEP2 ONE_STEP2 ONE_STEP2 ONE_STEP2 |
|
ONE_STEP2 ONE_STEP2 ONE_STEP2 ONE_STEP2 |
|
ONE_STEP2 ONE_STEP2 ONE_STEP2 ONE_STEP2 |
|
ONE_STEP2 ONE_STEP2 ONE_STEP2 ONE_STEP2 |
|
ONE_STEP2 ONE_STEP2 ONE_STEP2 ONE_STEP2 |
|
ONE_STEP2 ONE_STEP2 ONE_STEP2 ONE_STEP2 |
|
ONE_STEP2 ONE_STEP2 ONE_STEP2 ONE_STEP2 |
|
} |
|
for ( ; k > 0; k -- ) { |
|
if ( zzz = *pk ) { DMAR(zzz,a,*tk,md,*tk) } pk++; tk++; |
|
} |
|
} |
|
} |
} |
rank++; |
rank++; |
} |
} |
|
|
pivot = mat[l]; |
pivot = mat[l]; |
for ( i = 0; i < l; i++ ) { |
for ( i = 0; i < l; i++ ) { |
t = mat[i]; |
t = mat[i]; |
if ( a = t[j] ) { |
t[j] %= md; |
a = md-a; pk = pivot+j; tk = t+j; |
if ( a = t[j] ) |
k = col-j; |
red_by_vect(md,t+j,pivot+j,md-a,col-j); |
for ( ; k >= 64; k -= 64 ) { |
|
ONE_STEP2 ONE_STEP2 ONE_STEP2 ONE_STEP2 |
|
ONE_STEP2 ONE_STEP2 ONE_STEP2 ONE_STEP2 |
|
ONE_STEP2 ONE_STEP2 ONE_STEP2 ONE_STEP2 |
|
ONE_STEP2 ONE_STEP2 ONE_STEP2 ONE_STEP2 |
|
ONE_STEP2 ONE_STEP2 ONE_STEP2 ONE_STEP2 |
|
ONE_STEP2 ONE_STEP2 ONE_STEP2 ONE_STEP2 |
|
ONE_STEP2 ONE_STEP2 ONE_STEP2 ONE_STEP2 |
|
ONE_STEP2 ONE_STEP2 ONE_STEP2 ONE_STEP2 |
|
ONE_STEP2 ONE_STEP2 ONE_STEP2 ONE_STEP2 |
|
ONE_STEP2 ONE_STEP2 ONE_STEP2 ONE_STEP2 |
|
ONE_STEP2 ONE_STEP2 ONE_STEP2 ONE_STEP2 |
|
ONE_STEP2 ONE_STEP2 ONE_STEP2 ONE_STEP2 |
|
ONE_STEP2 ONE_STEP2 ONE_STEP2 ONE_STEP2 |
|
ONE_STEP2 ONE_STEP2 ONE_STEP2 ONE_STEP2 |
|
ONE_STEP2 ONE_STEP2 ONE_STEP2 ONE_STEP2 |
|
ONE_STEP2 ONE_STEP2 ONE_STEP2 ONE_STEP2 |
|
} |
|
for ( ; k > 0; k -- ) { |
|
if ( zzz = *pk ) { DMAR(zzz,a,*tk,md,*tk) } pk++; tk++; |
|
} |
|
} |
|
} |
} |
l--; |
l--; |
|
} |
|
for ( j = 0, l = 0; l < rank; j++ ) |
|
if ( colstat[j] ) { |
|
t = mat[l]; |
|
for ( k = j; k < col; k++ ) |
|
if ( t[k] >= md ) |
|
t[k] %= md; |
|
l++; |
} |
} |
return rank; |
return rank; |
} |
} |