=================================================================== RCS file: /home/cvs/OpenXM_contrib2/asir2000/builtin/array.c,v retrieving revision 1.6 retrieving revision 1.11 diff -u -p -r1.6 -r1.11 --- OpenXM_contrib2/asir2000/builtin/array.c 2000/08/21 08:31:18 1.6 +++ OpenXM_contrib2/asir2000/builtin/array.c 2000/12/05 06:59:15 1.11 @@ -23,7 +23,7 @@ * shall be made on your publication or presentation in any form of the * results obtained by use of the SOFTWARE. * (4) In the event that you modify the SOFTWARE, you shall notify FLL by - * e-mail at risa-admin@flab.fujitsu.co.jp of the detailed specification + * e-mail at risa-admin@sec.flab.fujitsu.co.jp of the detailed specification * for such modification or the source code of the modified part of the * SOFTWARE. * @@ -45,7 +45,7 @@ * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. * - * $OpenXM: OpenXM_contrib2/asir2000/builtin/array.c,v 1.5 2000/06/05 02:26:47 noro Exp $ + * $OpenXM: OpenXM_contrib2/asir2000/builtin/array.c,v 1.10 2000/11/13 01:48:12 noro Exp $ */ #include "ca.h" #include "base.h" @@ -57,7 +57,7 @@ #define DMAR(a1,a2,a3,d,r) (r)=dmar(a1,a2,a3,d); #endif -extern int Print; /* XXX */ +extern int DP_Print; /* XXX */ void inner_product_mat_int_mod(Q **,int **,int,int,int,Q *); void solve_by_lu_mod(int **,int,int,int **,int); @@ -73,6 +73,7 @@ int gauss_elim_mod1(int **,int,int,int); int gauss_elim_geninv_mod(unsigned int **,int,int,int); int gauss_elim_geninv_mod_swap(unsigned int **,int,int,unsigned int,unsigned int ***,int **); void Pnewvect(), Pnewmat(), Psepvect(), Psize(), Pdet(), Pleqm(), Pleqm1(), Pgeninvm(); +void Pnewbytearray(); void Pgeneric_gauss_elim_mod(); @@ -97,6 +98,7 @@ struct ftab array_tab[] = { {"generic_gauss_elim_mod",Pgeneric_gauss_elim_mod,2}, {"newvect",Pnewvect,-2}, {"newmat",Pnewmat,-3}, + {"newbytearray",Pnewbytearray,-2}, {"sepmat_destructive",Psepmat_destructive,2}, {"sepvect",Psepvect,2}, {"qsort",Pqsort,-2}, @@ -374,6 +376,50 @@ VECT *rp; *rp = vect; } +void Pnewbytearray(arg,rp) +NODE arg; +BYTEARRAY *rp; +{ + int len,i,r; + BYTEARRAY array; + unsigned char *vb; + char *str; + LIST list; + NODE tn; + + asir_assert(ARG0(arg),O_N,"newbytearray"); + len = QTOS((Q)ARG0(arg)); + if ( len < 0 ) + error("newbytearray : invalid size"); + MKBYTEARRAY(array,len); + if ( argc(arg) == 2 ) { + if ( !ARG1(arg) ) + error("newbytearray : invalid initialization"); + switch ( OID((Obj)ARG1(arg)) ) { + case O_LIST: + list = (LIST)ARG1(arg); + asir_assert(list,O_LIST,"newbytearray"); + for ( r = 0, tn = BDY(list); tn; r++, tn = NEXT(tn) ); + if ( r <= len ) { + for ( i = 0, tn = BDY(list), vb = BDY(array); tn; + i++, tn = NEXT(tn) ) + vb[i] = (unsigned char)QTOS((Q)BDY(tn)); + } + break; + case O_STR: + str = BDY((STRING)ARG1(arg)); + r = strlen(str); + if ( r <= len ) + bcopy(str,BDY(array),r); + break; + default: + if ( !ARG1(arg) ) + error("newbytearray : invalid initialization"); + } + } + *rp = array; +} + void Pnewmat(arg,rp) NODE arg; MAT *rp; @@ -712,8 +758,10 @@ int row,col,md; t = mat[i]; if ( i != j && (a = t[j]) ) for ( k = j, a = md - a; k <= n; k++ ) { + unsigned int tk; /* t[k] = dmar(pivot[k],a,t[k],md); */ - DMAR(pivot[k],a,t[k],md,t[k]) + DMAR(pivot[k],a,t[k],md,tk) + t[k] = tk; } } } @@ -757,7 +805,7 @@ int **rindp,**cindp; colstat = (int *)MALLOC_ATOMIC(col*sizeof(int)); wcolstat = (int *)MALLOC_ATOMIC(col*sizeof(int)); for ( ind = 0; ; ind++ ) { - if ( Print ) { + if ( DP_Print ) { fprintf(asir_out,"."); fflush(asir_out); } md = lprime[ind]; @@ -794,13 +842,13 @@ RESET: } } else { if ( rank < rank0 ) { - if ( Print ) { + if ( DP_Print ) { fprintf(asir_out,"lower rank matrix; continuing...\n"); fflush(asir_out); } continue; } else if ( rank > rank0 ) { - if ( Print ) { + if ( DP_Print ) { fprintf(asir_out,"higher rank matrix; resetting...\n"); fflush(asir_out); } @@ -808,7 +856,7 @@ RESET: } else { for ( j = 0; (j