[BACK]Return to array.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / asir2000 / builtin

Diff for /OpenXM_contrib2/asir2000/builtin/array.c between version 1.6 and 1.13

version 1.6, 2000/08/21 08:31:18 version 1.13, 2001/06/07 05:14:48
Line 23 
Line 23 
  * shall be made on your publication or presentation in any form of the   * shall be made on your publication or presentation in any form of the
  * results obtained by use of the SOFTWARE.   * results obtained by use of the SOFTWARE.
  * (4) In the event that you modify the SOFTWARE, you shall notify FLL by   * (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   * for such modification or the source code of the modified part of the
  * SOFTWARE.   * SOFTWARE.
  *   *
Line 45 
Line 45 
  * 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.5 2000/06/05 02:26:47 noro Exp $   * $OpenXM: OpenXM_contrib2/asir2000/builtin/array.c,v 1.12 2001/06/07 04:54:38 noro Exp $
 */  */
 #include "ca.h"  #include "ca.h"
 #include "base.h"  #include "base.h"
Line 57 
Line 57 
 #define DMAR(a1,a2,a3,d,r) (r)=dmar(a1,a2,a3,d);  #define DMAR(a1,a2,a3,d,r) (r)=dmar(a1,a2,a3,d);
 #endif  #endif
   
 extern int Print; /* XXX */  extern int DP_Print; /* XXX */
   
 void inner_product_mat_int_mod(Q **,int **,int,int,int,Q *);  void inner_product_mat_int_mod(Q **,int **,int,int,int,Q *);
 void solve_by_lu_mod(int **,int,int,int **,int);  void solve_by_lu_mod(int **,int,int,int **,int);
Line 73  int gauss_elim_mod1(int **,int,int,int);
Line 73  int gauss_elim_mod1(int **,int,int,int);
 int gauss_elim_geninv_mod(unsigned 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 **);  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 Pnewvect(), Pnewmat(), Psepvect(), Psize(), Pdet(), Pleqm(), Pleqm1(), Pgeninvm();
   void Pnewbytearray();
   
 void Pgeneric_gauss_elim_mod();  void Pgeneric_gauss_elim_mod();
   
Line 97  struct ftab array_tab[] = {
Line 98  struct ftab array_tab[] = {
         {"generic_gauss_elim_mod",Pgeneric_gauss_elim_mod,2},          {"generic_gauss_elim_mod",Pgeneric_gauss_elim_mod,2},
         {"newvect",Pnewvect,-2},          {"newvect",Pnewvect,-2},
         {"newmat",Pnewmat,-3},          {"newmat",Pnewmat,-3},
           {"newbytearray",Pnewbytearray,-2},
         {"sepmat_destructive",Psepmat_destructive,2},          {"sepmat_destructive",Psepmat_destructive,2},
         {"sepvect",Psepvect,2},          {"sepvect",Psepvect,2},
         {"qsort",Pqsort,-2},          {"qsort",Pqsort,-2},
Line 374  VECT *rp;
Line 376  VECT *rp;
         *rp = vect;          *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)  void Pnewmat(arg,rp)
 NODE arg;  NODE arg;
 MAT *rp;  MAT *rp;
Line 712  int row,col,md;
Line 758  int row,col,md;
                         t = mat[i];                          t = mat[i];
                         if ( i != j && (a = t[j]) )                          if ( i != j && (a = t[j]) )
                                 for ( k = j, a = md - a; k <= n; k++ ) {                                  for ( k = j, a = md - a; k <= n; k++ ) {
                                           unsigned int tk;
 /*                                      t[k] = dmar(pivot[k],a,t[k],md); */  /*                                      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;
                                 }                                  }
                 }                  }
         }          }
Line 757  int **rindp,**cindp;
Line 805  int **rindp,**cindp;
         colstat = (int *)MALLOC_ATOMIC(col*sizeof(int));          colstat = (int *)MALLOC_ATOMIC(col*sizeof(int));
         wcolstat = (int *)MALLOC_ATOMIC(col*sizeof(int));          wcolstat = (int *)MALLOC_ATOMIC(col*sizeof(int));
         for ( ind = 0; ; ind++ ) {          for ( ind = 0; ; ind++ ) {
                 if ( Print ) {                  if ( DP_Print ) {
                         fprintf(asir_out,"."); fflush(asir_out);                          fprintf(asir_out,"."); fflush(asir_out);
                 }                  }
                 md = lprime[ind];                  md = get_lprime(ind);
                 get_eg(&tmp0);                  get_eg(&tmp0);
                 for ( i = 0; i < row; i++ )                  for ( i = 0; i < row; i++ )
                         for ( j = 0, bmi = bmat[i], wmi = wmat[i]; j < col; j++ )                          for ( j = 0, bmi = bmat[i], wmi = wmat[i]; j < col; j++ )
Line 794  RESET:
Line 842  RESET:
                                         }                                          }
                 } else {                  } else {
                         if ( rank < rank0 ) {                          if ( rank < rank0 ) {
                                 if ( Print ) {                                  if ( DP_Print ) {
                                         fprintf(asir_out,"lower rank matrix; continuing...\n");                                          fprintf(asir_out,"lower rank matrix; continuing...\n");
                                         fflush(asir_out);                                          fflush(asir_out);
                                 }                                  }
                                 continue;                                  continue;
                         } else if ( rank > rank0 ) {                          } else if ( rank > rank0 ) {
                                 if ( Print ) {                                  if ( DP_Print ) {
                                         fprintf(asir_out,"higher rank matrix; resetting...\n");                                          fprintf(asir_out,"higher rank matrix; resetting...\n");
                                         fflush(asir_out);                                          fflush(asir_out);
                                 }                                  }
Line 808  RESET:
Line 856  RESET:
                         } else {                          } else {
                                 for ( j = 0; (j<col) && (colstat[j]==wcolstat[j]); j++ );                                  for ( j = 0; (j<col) && (colstat[j]==wcolstat[j]); j++ );
                                 if ( j < col ) {                                  if ( j < col ) {
                                         if ( Print ) {                                          if ( DP_Print ) {
                                                 fprintf(asir_out,"inconsitent colstat; resetting...\n");                                                  fprintf(asir_out,"inconsitent colstat; resetting...\n");
                                                 fflush(asir_out);                                                  fflush(asir_out);
                                         }                                          }
Line 847  RESET:
Line 895  RESET:
                         add_eg(&eg_chrem_split,&tmp0,&tmp1);                          add_eg(&eg_chrem_split,&tmp0,&tmp1);
   
                         get_eg(&tmp0);                          get_eg(&tmp0);
                         ret = intmtoratm(crmat,m1,*nm,dn);                          if ( ind % 16 )
                                   ret = 0;
                           else
                                   ret = intmtoratm(crmat,m1,*nm,dn);
                         get_eg(&tmp1);                          get_eg(&tmp1);
                         add_eg(&eg_intrat,&tmp0,&tmp1);                          add_eg(&eg_intrat,&tmp0,&tmp1);
                         add_eg(&eg_intrat_split,&tmp0,&tmp1);                          add_eg(&eg_intrat_split,&tmp0,&tmp1);
Line 864  RESET:
Line 915  RESET:
                                         get_eg(&tmp1);                                          get_eg(&tmp1);
                                         add_eg(&eg_gschk,&tmp0,&tmp1);                                          add_eg(&eg_gschk,&tmp0,&tmp1);
                                         add_eg(&eg_gschk_split,&tmp0,&tmp1);                                          add_eg(&eg_gschk_split,&tmp0,&tmp1);
                                         if ( Print ) {                                          if ( DP_Print ) {
                                                 print_eg("Mod",&eg_mod_split);                                                  print_eg("Mod",&eg_mod_split);
                                                 print_eg("Elim",&eg_elim_split);                                                  print_eg("Elim",&eg_elim_split);
                                                 print_eg("ChRem",&eg_chrem_split);                                                  print_eg("ChRem",&eg_chrem_split);
Line 905  int **rindp,**cindp;
Line 956  int **rindp,**cindp;
         row = mat->row; col = mat->col;          row = mat->row; col = mat->col;
         w = (int **)almat(row,col);          w = (int **)almat(row,col);
         for ( ind = 0; ; ind++ ) {          for ( ind = 0; ; ind++ ) {
                 md = lprime[ind];                  md = get_lprime(ind);
                 STOQ(md,mdq);                  STOQ(md,mdq);
                 for ( i = 0; i < row; i++ )                  for ( i = 0; i < row; i++ )
                         for ( j = 0, ai = a0[i], wi = w[i]; j < col; j++ )                          for ( j = 0, ai = a0[i], wi = w[i]; j < col; j++ )
Line 987  int **rindp,**cindp;
Line 1038  int **rindp,**cindp;
                                 add_eg(&eg_mul,&tmp0,&tmp1);                                  add_eg(&eg_mul,&tmp0,&tmp1);
                                 /* q = q*md */                                  /* q = q*md */
                                 mulq(q,mdq,&u); q = u;                                  mulq(q,mdq,&u); q = u;
                                 if ( !(count % 2) && intmtoratm_q(xmat,NM(q),*nmmat,dn) ) {                                  if ( !(count % 16) && intmtoratm_q(xmat,NM(q),*nmmat,dn) ) {
                                         for ( j = k = l = 0; j < col; j++ )                                          for ( j = k = l = 0; j < col; j++ )
                                                 if ( cinfo[j] )                                                  if ( cinfo[j] )
                                                         rind[k++] = j;                                                          rind[k++] = j;
Line 1462  int *perm;
Line 1513  int *perm;
                                 DMAR(inv,m,0,md,t[k])                                  DMAR(inv,m,0,md,t[k])
                                 for ( j = k+1, m = md - t[k]; j < col; j++ )                                  for ( j = k+1, m = md - t[k]; j < col; j++ )
                                         if ( pivot[j] ) {                                          if ( pivot[j] ) {
                                                 DMAR(m,pivot[j],t[j],md,t[j])                                                  unsigned int tj;
   
                                                   DMAR(m,pivot[j],t[j],md,tj)
                                                   t[j] = tj;
                                         }                                          }
                         }                          }
                 }                  }
Line 1517  int **rinfo,**cinfo;
Line 1571  int **rinfo,**cinfo;
                                 DMAR(inv,m,0,md,t[k])                                  DMAR(inv,m,0,md,t[k])
                                 for ( j = k+1, m = md - t[k]; j < col; j++ )                                  for ( j = k+1, m = md - t[k]; j < col; j++ )
                                         if ( pivot[j] ) {                                          if ( pivot[j] ) {
                                                 DMAR(m,pivot[j],t[j],md,t[j])                                                  unsigned int tj;
                                                   DMAR(m,pivot[j],t[j],md,tj)
                                                   t[j] = tj;
                                         }                                          }
                         }                          }
                 }                  }
Line 2466  int row,col;
Line 2522  int row,col;
   
         for ( i = 0; i < row; i++ ) {          for ( i = 0; i < row; i++ ) {
                 for ( j = 0; j < col; j++ ) {                  for ( j = 0; j < col; j++ ) {
                         printnum(mat[i][j]); printf(" ");                          printnum((Num)mat[i][j]); printf(" ");
                 }                  }
                 printf("\n");                  printf("\n");
         }          }

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.13

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>