version 1.29, 2003/06/09 16:18:09 |
version 1.32, 2003/09/17 08:14:26 |
|
|
* 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/array.c,v 1.28 2003/05/29 16:44:59 saito Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/builtin/array.c,v 1.31 2003/07/01 08:12:37 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "base.h" |
#include "base.h" |
Line 495 void Pmat(NODE arg, MAT *rp) |
|
Line 495 void Pmat(NODE arg, MAT *rp) |
|
} |
} |
|
|
for (row = 0, tn = arg; tn; tn = NEXT(tn), row++); |
for (row = 0, tn = arg; tn; tn = NEXT(tn), row++); |
|
if ( row == 1 ) { |
|
if ( OID(ARG0(arg)) == O_MAT ) { |
|
*rp=ARG0(arg); |
|
return; |
|
} else if ( !(OID(ARG0(arg)) == O_LIST || OID(ARG0(arg)) == O_VECT)) { |
|
error("mat : invalid argument"); |
|
} |
|
} |
if ( OID(ARG0(arg)) == O_VECT ) { |
if ( OID(ARG0(arg)) == O_VECT ) { |
v = ARG0(arg); |
v = ARG0(arg); |
col = v->len; |
col = v->len; |
} else if ( OID(ARG0(arg)) == O_LIST ) { |
} else if ( OID(ARG0(arg)) == O_LIST ) { |
for (col = 0, tn = BDY((LIST)ARG0(arg)); tn ; tn = NEXT(tn), col++); |
for (col = 0, tn = BDY((LIST)ARG0(arg)); tn ; tn = NEXT(tn), col++); |
|
} else { |
|
error("mat : invalid argument"); |
} |
} |
|
|
MKMAT(m,row,col); |
MKMAT(m,row,col); |
Line 536 void Pmatc(NODE arg, MAT *rp) |
|
Line 546 void Pmatc(NODE arg, MAT *rp) |
|
} |
} |
|
|
for (col = 0, tn = arg; tn; tn = NEXT(tn), col++); |
for (col = 0, tn = arg; tn; tn = NEXT(tn), col++); |
|
if ( col == 1 ) { |
|
if ( OID(ARG0(arg)) == O_MAT ) { |
|
*rp=ARG0(arg); |
|
return; |
|
} else if ( !(OID(ARG0(arg)) == O_LIST || OID(ARG0(arg)) == O_VECT)) { |
|
error("matc : invalid argument"); |
|
} |
|
} |
if ( OID(ARG0(arg)) == O_VECT ) { |
if ( OID(ARG0(arg)) == O_VECT ) { |
v = ARG0(arg); |
v = ARG0(arg); |
row = v->len; |
row = v->len; |
} else if ( OID(ARG0(arg)) == O_LIST ) { |
} else if ( OID(ARG0(arg)) == O_LIST ) { |
for (row = 0, tn = BDY((LIST)ARG0(arg)); tn ; tn = NEXT(tn), row++); |
for (row = 0, tn = BDY((LIST)ARG0(arg)); tn ; tn = NEXT(tn), row++); |
|
} else { |
|
error("matc : invalid argument"); |
} |
} |
|
|
MKMAT(m,row,col); |
MKMAT(m,row,col); |
Line 933 int gauss_elim_mod(int **mat,int row,int col,int md) |
|
Line 953 int gauss_elim_mod(int **mat,int row,int col,int md) |
|
} |
} |
|
|
struct oEGT eg_mod,eg_elim,eg_elim1,eg_elim2,eg_chrem,eg_gschk,eg_intrat,eg_symb; |
struct oEGT eg_mod,eg_elim,eg_elim1,eg_elim2,eg_chrem,eg_gschk,eg_intrat,eg_symb; |
|
struct oEGT eg_conv; |
|
|
int generic_gauss_elim(MAT mat,MAT *nm,Q *dn,int **rindp,int **cindp) |
int generic_gauss_elim(MAT mat,MAT *nm,Q *dn,int **rindp,int **cindp) |
{ |
{ |
Line 1555 void red_by_vect(int m,unsigned int *p,unsigned int *r |
|
Line 1576 void red_by_vect(int m,unsigned int *p,unsigned int *r |
|
} |
} |
} |
} |
|
|
|
void red_by_vect_sf(int m,unsigned int *p,unsigned int *r,unsigned int hc,int len) |
|
{ |
|
*p++ = 0; r++; len--; |
|
for ( ; len; len--, r++, p++ ) |
|
if ( *r ) |
|
*p = _addsf(_mulsf(*r,hc),*p); |
|
} |
|
|
extern unsigned int **psca; |
extern unsigned int **psca; |
|
|
void reduce_sp_by_red_mod_compress (int *sp,CDP *redmat,int *ind, |
void reduce_sp_by_red_mod_compress (int *sp,CDP *redmat,int *ind, |
Line 1639 int generic_gauss_elim_mod(int **mat0,int row,int col, |
|
Line 1668 int generic_gauss_elim_mod(int **mat0,int row,int col, |
|
if ( t[k] >= (unsigned int)md ) |
if ( t[k] >= (unsigned int)md ) |
t[k] %= md; |
t[k] %= md; |
l++; |
l++; |
|
} |
|
return rank; |
|
} |
|
|
|
int generic_gauss_elim_sf(int **mat0,int row,int col,int md,int *colstat) |
|
{ |
|
int i,j,k,l,inv,a,rank; |
|
unsigned int *t,*pivot,*pk; |
|
unsigned int **mat; |
|
|
|
mat = (unsigned int **)mat0; |
|
for ( rank = 0, j = 0; j < col; j++ ) { |
|
for ( i = rank; i < row; i++ ) |
|
if ( mat[i][j] ) |
|
break; |
|
if ( i == row ) { |
|
colstat[j] = 0; |
|
continue; |
|
} else |
|
colstat[j] = 1; |
|
if ( i != rank ) { |
|
t = mat[i]; mat[i] = mat[rank]; mat[rank] = t; |
|
} |
|
pivot = mat[rank]; |
|
inv = _invsf(pivot[j]); |
|
for ( k = j, pk = pivot+k; k < col; k++, pk++ ) |
|
if ( *pk ) |
|
*pk = _mulsf(*pk,inv); |
|
for ( i = rank+1; i < row; i++ ) { |
|
t = mat[i]; |
|
if ( a = t[j] ) |
|
red_by_vect_sf(md,t+j,pivot+j,_chsgnsf(a),col-j); |
|
} |
|
rank++; |
|
} |
|
for ( j = col-1, l = rank-1; j >= 0; j-- ) |
|
if ( colstat[j] ) { |
|
pivot = mat[l]; |
|
for ( i = 0; i < l; i++ ) { |
|
t = mat[i]; |
|
if ( a = t[j] ) |
|
red_by_vect_sf(md,t+j,pivot+j,_chsgnsf(a),col-j); |
|
} |
|
l--; |
} |
} |
return rank; |
return rank; |
} |
} |