version 1.64, 2013/11/05 02:55:02 |
version 1.68, 2015/08/14 13:51:54 |
|
|
* 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.63 2013/09/09 07:29:25 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/builtin/array.c,v 1.67 2015/08/08 14:19:41 fujimoto Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "base.h" |
#include "base.h" |
Line 895 void Pvtol(NODE arg,LIST *rp) |
|
Line 895 void Pvtol(NODE arg,LIST *rp) |
|
pointer *a; |
pointer *a; |
int len,i; |
int len,i; |
|
|
|
if ( OID(ARG0(arg)) == O_LIST ) { |
|
*rp = ARG0(arg); |
|
return; |
|
} |
asir_assert(ARG0(arg),O_VECT,"vtol"); |
asir_assert(ARG0(arg),O_VECT,"vtol"); |
v = (VECT)ARG0(arg); len = v->len; a = BDY(v); |
v = (VECT)ARG0(arg); len = v->len; a = BDY(v); |
for ( i = len - 1, n = 0; i >= 0; i-- ) { |
for ( i = len - 1, n = 0; i >= 0; i-- ) { |
Line 906 void Pvtol(NODE arg,LIST *rp) |
|
Line 910 void Pvtol(NODE arg,LIST *rp) |
|
void Pltov(NODE arg,VECT *rp) |
void Pltov(NODE arg,VECT *rp) |
{ |
{ |
NODE n; |
NODE n; |
VECT v; |
VECT v,v0; |
int len,i; |
int len,i; |
|
|
|
if ( OID(ARG0(arg)) == O_VECT ) { |
|
v0 = (VECT)ARG0(arg); len = v0->len; |
|
MKVECT(v,len); |
|
for ( i = 0; i < len; i++ ) { |
|
BDY(v)[i] = BDY(v0)[i]; |
|
} |
|
*rp = v; |
|
return; |
|
} |
asir_assert(ARG0(arg),O_LIST,"ltov"); |
asir_assert(ARG0(arg),O_LIST,"ltov"); |
n = (NODE)BDY((LIST)ARG0(arg)); |
n = (NODE)BDY((LIST)ARG0(arg)); |
len = length(n); |
len = length(n); |
Line 2353 int generic_gauss_elim_mod(int **mat0,int row,int col, |
|
Line 2366 int generic_gauss_elim_mod(int **mat0,int row,int col, |
|
colstat[j] = 1; |
colstat[j] = 1; |
if ( i != rank ) { |
if ( i != rank ) { |
t = mat[i]; mat[i] = mat[rank]; mat[rank] = t; |
t = mat[i]; mat[i] = mat[rank]; mat[rank] = t; |
|
} |
|
pivot = mat[rank]; |
|
inv = invm(pivot[j],md); |
|
for ( k = j, pk = pivot+k; k < col; k++, pk++ ) |
|
if ( *pk ) { |
|
if ( *pk >= (unsigned int)md ) |
|
*pk %= md; |
|
DMAR(*pk,inv,0,md,*pk) |
|
} |
|
for ( i = rank+1; i < row; i++ ) { |
|
t = mat[i]; |
|
if ( a = t[j] ) |
|
red_by_vect(md,t+j,pivot+j,md-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]; |
|
t[j] %= md; |
|
if ( a = t[j] ) |
|
red_by_vect(md,t+j,pivot+j,md-a,col-j); |
|
} |
|
l--; |
|
} |
|
for ( j = 0, l = 0; l < rank; j++ ) |
|
if ( colstat[j] ) { |
|
t = mat[l]; |
|
for ( k = j; k < col; k++ ) |
|
if ( t[k] >= (unsigned int)md ) |
|
t[k] %= md; |
|
l++; |
|
} |
|
return rank; |
|
} |
|
|
|
int generic_gauss_elim_mod2(int **mat0,int row,int col,int md,int *colstat,int *rowstat) |
|
{ |
|
int i,j,k,l,inv,a,rank; |
|
unsigned int *t,*pivot,*pk; |
|
unsigned int **mat; |
|
|
|
for ( i = 0; i < row; i++ ) rowstat[i] = i; |
|
mat = (unsigned int **)mat0; |
|
for ( rank = 0, j = 0; j < col; j++ ) { |
|
for ( i = rank; i < row; i++ ) |
|
mat[i][j] %= md; |
|
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; |
|
k = rowstat[i]; rowstat[i] = rowstat[rank]; rowstat[rank] = k; |
} |
} |
pivot = mat[rank]; |
pivot = mat[rank]; |
inv = invm(pivot[j],md); |
inv = invm(pivot[j],md); |