version 1.134, 2006/06/06 07:14:16 |
version 1.137, 2006/06/11 06:57:54 |
|
|
/* $OpenXM: OpenXM_contrib2/asir2000/engine/nd.c,v 1.133 2006/06/05 08:11:10 noro Exp $ */ |
/* $OpenXM: OpenXM_contrib2/asir2000/engine/nd.c,v 1.136 2006/06/11 06:01:55 noro Exp $ */ |
|
|
#include "nd.h" |
#include "nd.h" |
|
|
Line 4168 IndArray nm_ind_pair_to_vect_compress(int mod,UINT *s0 |
|
Line 4168 IndArray nm_ind_pair_to_vect_compress(int mod,UINT *s0 |
|
return r; |
return r; |
} |
} |
|
|
|
int compress_array(Q *svect,Q *cvect,int n) |
|
{ |
|
int i,j; |
|
|
|
for ( i = j = 0; i < n; i++ ) |
|
if ( svect[i] ) cvect[j++] = svect[i]; |
|
return j; |
|
} |
|
|
|
void expand_array(Q *svect,Q *cvect,int n) |
|
{ |
|
int i,j; |
|
|
|
for ( i = j = 0; j < n; i++ ) |
|
if ( svect[i] ) svect[i] = cvect[j++]; |
|
} |
|
|
int ndv_reduce_vect_q(Q *svect,int trace,int col,IndArray *imat,NM_ind_pair *rp0,int nred) |
int ndv_reduce_vect_q(Q *svect,int trace,int col,IndArray *imat,NM_ind_pair *rp0,int nred) |
{ |
{ |
int i,j,k,len,pos,prev; |
int i,j,k,len,pos,prev,nz; |
Q cs,mcs,c1,c2,cr,gcd,t; |
Q cs,mcs,c1,c2,cr,gcd,t; |
IndArray ivect; |
IndArray ivect; |
unsigned char *ivc; |
unsigned char *ivc; |
Line 4181 int ndv_reduce_vect_q(Q *svect,int trace,int col,IndAr |
|
Line 4198 int ndv_reduce_vect_q(Q *svect,int trace,int col,IndAr |
|
NODE rp; |
NODE rp; |
int maxrs; |
int maxrs; |
double hmag; |
double hmag; |
struct oVECT v; |
Q *cvect; |
|
|
v.id = O_VECT; v.len = col; v.body = (pointer *)svect; |
|
maxrs = 0; |
maxrs = 0; |
for ( i = 0; i < col && !svect[i]; i++ ); |
for ( i = 0; i < col && !svect[i]; i++ ); |
if ( i == col ) return maxrs; |
if ( i == col ) return maxrs; |
hmag = p_mag((P)svect[i])*nd_scale; |
hmag = p_mag((P)svect[i])*nd_scale; |
|
cvect = (Q *)ALLOCA(col*sizeof(Q)); |
for ( i = 0; i < nred; i++ ) { |
for ( i = 0; i < nred; i++ ) { |
ivect = imat[i]; |
ivect = imat[i]; |
k = ivect->head; |
k = ivect->head; |
Line 4229 int ndv_reduce_vect_q(Q *svect,int trace,int col,IndAr |
|
Line 4246 int ndv_reduce_vect_q(Q *svect,int trace,int col,IndAr |
|
for ( j = k+1; j < col && !svect[j]; j++ ); |
for ( j = k+1; j < col && !svect[j]; j++ ); |
if ( j == col ) break; |
if ( j == col ) break; |
if ( hmag && ((double)p_mag((P)svect[j]) > hmag) ) { |
if ( hmag && ((double)p_mag((P)svect[j]) > hmag) ) { |
igcdv(&v,&t); |
nz = compress_array(svect,cvect,col); |
|
removecont_array(cvect,nz); |
|
expand_array(svect,cvect,nz); |
hmag = ((double)p_mag((P)svect[j]))*nd_scale; |
hmag = ((double)p_mag((P)svect[j]))*nd_scale; |
} |
} |
} |
} |
} |
} |
igcdv(&v,&t); |
nz = compress_array(svect,cvect,col); |
|
removecont_array(cvect,nz); |
|
expand_array(svect,cvect,nz); |
if ( DP_Print ) { |
if ( DP_Print ) { |
fprintf(asir_out,"-"); fflush(asir_out); |
fprintf(asir_out,"-"); fflush(asir_out); |
} |
} |
Line 4813 NODE nd_f4_red_q_main(ND_pairs sp0,int nsp,int trace,U |
|
Line 4834 NODE nd_f4_red_q_main(ND_pairs sp0,int nsp,int trace,U |
|
struct oEGT eg0,eg1,eg2,eg_f4,eg_f4_1,eg_f4_2; |
struct oEGT eg0,eg1,eg2,eg_f4,eg_f4_1,eg_f4_2; |
int maxrs; |
int maxrs; |
int *spsugar; |
int *spsugar; |
|
pointer *w; |
|
|
spcol = col-nred; |
spcol = col-nred; |
get_eg(&eg0); |
get_eg(&eg0); |
Line 4846 NODE nd_f4_red_q_main(ND_pairs sp0,int nsp,int trace,U |
|
Line 4868 NODE nd_f4_red_q_main(ND_pairs sp0,int nsp,int trace,U |
|
/* elimination (2nd step) */ |
/* elimination (2nd step) */ |
colstat = (int *)ALLOCA(spcol*sizeof(int)); |
colstat = (int *)ALLOCA(spcol*sizeof(int)); |
rank = nd_gauss_elim_q(spmat,spsugar,sprow,spcol,colstat); |
rank = nd_gauss_elim_q(spmat,spsugar,sprow,spcol,colstat); |
r0 = 0; |
w = (pointer *)ALLOCA(rank*sizeof(pointer)); |
for ( i = 0; i < rank; i++ ) { |
for ( i = 0; i < rank; i++ ) { |
NEXTNODE(r0,r); BDY(r) = |
w[rank-i-1] = (pointer)vect_to_ndv_q(spmat[i],spcol,col,rhead,s0vect); |
(pointer)vect_to_ndv_q(spmat[i],spcol,col,rhead,s0vect); |
SG((NDV)w[rank-i-1]) = spsugar[i]; |
SG((NDV)BDY(r)) = spsugar[i]; |
|
/* GC_free(spmat[i]); */ |
/* GC_free(spmat[i]); */ |
|
} |
|
#if 1 |
|
qsort(w,rank,sizeof(NDV), |
|
(int (*)(const void *,const void *))ndv_compare); |
|
#endif |
|
r0 = 0; |
|
for ( i = 0; i < rank; i++ ) { |
|
NEXTNODE(r0,r); BDY(r) = w[i]; |
} |
} |
if ( r0 ) NEXT(r) = 0; |
if ( r0 ) NEXT(r) = 0; |
|
|