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

Diff for /OpenXM_contrib2/asir2000/engine/nd.c between version 1.163 and 1.164

version 1.163, 2009/01/05 06:29:46 version 1.164, 2009/01/07 05:33:18
Line 1 
Line 1 
 /* $OpenXM: OpenXM_contrib2/asir2000/engine/nd.c,v 1.162 2009/01/05 02:47:39 noro Exp $ */  /* $OpenXM: OpenXM_contrib2/asir2000/engine/nd.c,v 1.163 2009/01/05 06:29:46 noro Exp $ */
   
 #include "nd.h"  #include "nd.h"
   
Line 217  INLINE int ndl_reducible(UINT *d1,UINT *d2)
Line 217  INLINE int ndl_reducible(UINT *d1,UINT *d2)
  * order is either 0 or 2.   * order is either 0 or 2.
  */   */
   
 void ndl_homogenize(UINT *d,UINT *r,int obpe,EPOS oepos,int weight)  void ndl_homogenize(UINT *d,UINT *r,int obpe,EPOS oepos,int ompos,int weight)
 {  {
     int w,i,e,n,omask0;      int w,i,e,n,omask0;
   
Line 230  void ndl_homogenize(UINT *d,UINT *r,int obpe,EPOS oepo
Line 230  void ndl_homogenize(UINT *d,UINT *r,int obpe,EPOS oepo
     }      }
     w = TD(d);      w = TD(d);
     PUT_EXP(r,nd_nvar-1,weight-w);      PUT_EXP(r,nd_nvar-1,weight-w);
     if ( nd_module ) MPOS(r) = MPOS(d);      if ( nd_module ) MPOS(r) = d[ompos];
     TD(r) = weight;      TD(r) = weight;
     if ( nd_blockmask ) ndl_weight_mask(r);      if ( nd_blockmask ) ndl_weight_mask(r);
 }  }
Line 568  int ndl_ww_lex_compare(UINT *d1,UINT *d2)
Line 568  int ndl_ww_lex_compare(UINT *d1,UINT *d2)
   
 int ndl_module_grlex_compare(UINT *d1,UINT *d2)  int ndl_module_grlex_compare(UINT *d1,UINT *d2)
 {  {
     int i;      int i,c;
   
     if ( nd_ispot ) {      if ( nd_ispot ) {
         if ( MPOS(d1) < MPOS(d2) ) return 1;          if ( MPOS(d1) < MPOS(d2) ) return 1;
Line 576  int ndl_module_grlex_compare(UINT *d1,UINT *d2)
Line 576  int ndl_module_grlex_compare(UINT *d1,UINT *d2)
     }      }
     if ( TD(d1) > TD(d2) ) return 1;      if ( TD(d1) > TD(d2) ) return 1;
     else if ( TD(d1) < TD(d2) ) return -1;      else if ( TD(d1) < TD(d2) ) return -1;
     for ( i = nd_nvar-1; i >= 0; i-- )          if ( c = ndl_lex_compare(d1,d2) ) return c;
         if ( GET_EXP(d1,i) < GET_EXP(d2,i) ) return 1;  
         else if ( GET_EXP(d1,i) > GET_EXP(d2,i) ) return -1;  
     if ( !nd_ispot ) {      if ( !nd_ispot ) {
         if ( MPOS(d1) < MPOS(d2) ) return 1;          if ( MPOS(d1) < MPOS(d2) ) return 1;
         else if ( MPOS(d1) > MPOS(d2) ) return -1;          else if ( MPOS(d1) > MPOS(d2) ) return -1;
Line 588  int ndl_module_grlex_compare(UINT *d1,UINT *d2)
Line 586  int ndl_module_grlex_compare(UINT *d1,UINT *d2)
   
 int ndl_module_glex_compare(UINT *d1,UINT *d2)  int ndl_module_glex_compare(UINT *d1,UINT *d2)
 {  {
     int i;      int i,c;
   
     if ( nd_ispot ) {      if ( nd_ispot ) {
         if ( MPOS(d1) < MPOS(d2) ) return 1;          if ( MPOS(d1) < MPOS(d2) ) return 1;
Line 596  int ndl_module_glex_compare(UINT *d1,UINT *d2)
Line 594  int ndl_module_glex_compare(UINT *d1,UINT *d2)
     }      }
     if ( TD(d1) > TD(d2) ) return 1;      if ( TD(d1) > TD(d2) ) return 1;
     else if ( TD(d1) < TD(d2) ) return -1;      else if ( TD(d1) < TD(d2) ) return -1;
     for ( i = 0; i < nd_nvar; i++ )          if ( c = ndl_lex_compare(d1,d2) ) return c;
         if ( GET_EXP(d1,i) > GET_EXP(d2,i) ) return 1;  
         else if ( GET_EXP(d1,i) < GET_EXP(d2,i) ) return -1;  
     if ( !nd_ispot ) {      if ( !nd_ispot ) {
         if ( MPOS(d1) < MPOS(d2) ) return 1;          if ( MPOS(d1) < MPOS(d2) ) return 1;
         else if ( MPOS(d1) > MPOS(d2) ) return -1;          else if ( MPOS(d1) > MPOS(d2) ) return -1;
Line 608  int ndl_module_glex_compare(UINT *d1,UINT *d2)
Line 604  int ndl_module_glex_compare(UINT *d1,UINT *d2)
   
 int ndl_module_lex_compare(UINT *d1,UINT *d2)  int ndl_module_lex_compare(UINT *d1,UINT *d2)
 {  {
     int i;      int i,c;
   
     if ( nd_ispot ) {      if ( nd_ispot ) {
         if ( MPOS(d1) < MPOS(d2) ) return 1;          if ( MPOS(d1) < MPOS(d2) ) return 1;
         else if ( MPOS(d1) > MPOS(d2) ) return -1;          else if ( MPOS(d1) > MPOS(d2) ) return -1;
     }      }
     for ( i = 0; i < nd_nvar; i++ )          if ( c = ndl_lex_compare(d1,d2) ) return c;
         if ( GET_EXP(d1,i) > GET_EXP(d2,i) ) return 1;  
         else if ( GET_EXP(d1,i) < GET_EXP(d2,i) ) return -1;  
     if ( !nd_ispot ) {      if ( !nd_ispot ) {
         if ( MPOS(d1) < MPOS(d2) ) return 1;          if ( MPOS(d1) < MPOS(d2) ) return 1;
         else if ( MPOS(d1) > MPOS(d2) ) return -1;          else if ( MPOS(d1) > MPOS(d2) ) return -1;
Line 2823  void nd_gr_trace(LIST f,LIST v,int trace,int homo,int 
Line 2817  void nd_gr_trace(LIST f,LIST v,int trace,int homo,int 
     P p,zp;      P p,zp;
     Q dmy;      Q dmy;
     EPOS oepos;      EPOS oepos;
     int obpe,oadv,wmax,i,len,cbpe,ishomo,nalg,mrank,trank;      int obpe,oadv,wmax,i,len,cbpe,ishomo,nalg,mrank,trank,ompos;
     Alg alpha,dp;      Alg alpha,dp;
     P poly;      P poly;
     LIST f1,f2,zpl;      LIST f1,f2,zpl;
Line 2889  void nd_gr_trace(LIST f,LIST v,int trace,int homo,int 
Line 2883  void nd_gr_trace(LIST f,LIST v,int trace,int homo,int 
             }              }
         }          }
     nd_setup_parameters(nvar,max);      nd_setup_parameters(nvar,max);
     obpe = nd_bpe; oadv = nmv_adv; oepos = nd_epos;      obpe = nd_bpe; oadv = nmv_adv; oepos = nd_epos; ompos = nd_mpos;
     ishomo = 1;      ishomo = 1;
     for ( in0 = 0, fd0 = 0, t = BDY(f); t; t = NEXT(t) ) {      for ( in0 = 0, fd0 = 0, t = BDY(f); t; t = NEXT(t) ) {
         if ( nd_module ) {          if ( nd_module ) {
Line 2918  void nd_gr_trace(LIST f,LIST v,int trace,int homo,int 
Line 2912  void nd_gr_trace(LIST f,LIST v,int trace,int homo,int 
         nd_init_ord(ord1);          nd_init_ord(ord1);
         nd_setup_parameters(nvar+1,wmax);          nd_setup_parameters(nvar+1,wmax);
         for ( t = fd0; t; t = NEXT(t) )          for ( t = fd0; t; t = NEXT(t) )
             ndv_homogenize((NDV)BDY(t),obpe,oadv,oepos);              ndv_homogenize((NDV)BDY(t),obpe,oadv,oepos,ompos);
     }      }
     while ( 1 ) {      while ( 1 ) {
         if ( Demand )          if ( Demand )
Line 3180  void ndv_removecont(int mod,NDV p)
Line 3174  void ndv_removecont(int mod,NDV p)
   
 /* koko */  /* koko */
   
 void ndv_homogenize(NDV p,int obpe,int oadv,EPOS oepos)  void ndv_homogenize(NDV p,int obpe,int oadv,EPOS oepos,int ompos)
 {  {
     int len,i,max;      int len,i,max;
     NMV m,mr0,mr,t;      NMV m,mr0,mr,t;
Line 3193  void ndv_homogenize(NDV p,int obpe,int oadv,EPOS oepos
Line 3187  void ndv_homogenize(NDV p,int obpe,int oadv,EPOS oepos
     mr = (NMV)((char *)mr0+(len-1)*nmv_adv);      mr = (NMV)((char *)mr0+(len-1)*nmv_adv);
     t = (NMV)ALLOCA(nmv_adv);      t = (NMV)ALLOCA(nmv_adv);
     for ( i = 0; i < len; i++, NMV_OPREV(m), NMV_PREV(mr) ) {      for ( i = 0; i < len; i++, NMV_OPREV(m), NMV_PREV(mr) ) {
         ndl_homogenize(DL(m),DL(t),obpe,oepos,max);          ndl_homogenize(DL(m),DL(t),obpe,oepos,ompos,max);
         CQ(mr) = CQ(m);          CQ(mr) = CQ(m);
         ndl_copy(DL(t),DL(mr));          ndl_copy(DL(t),DL(mr));
     }      }
Line 3203  void ndv_homogenize(NDV p,int obpe,int oadv,EPOS oepos
Line 3197  void ndv_homogenize(NDV p,int obpe,int oadv,EPOS oepos
   
 void ndv_dehomogenize(NDV p,struct order_spec *ord)  void ndv_dehomogenize(NDV p,struct order_spec *ord)
 {  {
     int i,j,adj,len,newnvar,newwpd,newadv,newexporigin;      int i,j,adj,len,newnvar,newwpd,newadv,newexporigin,newmpos;
           int pos;
     Q *w;      Q *w;
     Q dvr,t;      Q dvr,t;
     NMV m,r;      NMV m,r;
Line 3211  void ndv_dehomogenize(NDV p,struct order_spec *ord)
Line 3206  void ndv_dehomogenize(NDV p,struct order_spec *ord)
     len = p->len;      len = p->len;
     newnvar = nd_nvar-1;      newnvar = nd_nvar-1;
     newexporigin = nd_get_exporigin(ord);      newexporigin = nd_get_exporigin(ord);
           if ( nd_module ) newmpos = newexporigin-1;
     newwpd = newnvar/nd_epw+(newnvar%nd_epw?1:0)+newexporigin;      newwpd = newnvar/nd_epw+(newnvar%nd_epw?1:0)+newexporigin;
     for ( m = BDY(p), i = 0; i < len; NMV_ADV(m), i++ )      for ( m = BDY(p), i = 0; i < len; NMV_ADV(m), i++ )
         ndl_dehomogenize(DL(m));          ndl_dehomogenize(DL(m));
Line 3218  void ndv_dehomogenize(NDV p,struct order_spec *ord)
Line 3214  void ndv_dehomogenize(NDV p,struct order_spec *ord)
         newadv = ROUND_FOR_ALIGN(sizeof(struct oNMV)+(newwpd-1)*sizeof(UINT));          newadv = ROUND_FOR_ALIGN(sizeof(struct oNMV)+(newwpd-1)*sizeof(UINT));
         for ( m = r = BDY(p), i = 0; i < len; NMV_ADV(m), NDV_NADV(r), i++ ) {          for ( m = r = BDY(p), i = 0; i < len; NMV_ADV(m), NDV_NADV(r), i++ ) {
             CQ(r) = CQ(m);              CQ(r) = CQ(m);
                           if ( nd_module ) pos = MPOS(DL(m));
             for ( j = 0; j < newexporigin; j++ ) DL(r)[j] = DL(m)[j];              for ( j = 0; j < newexporigin; j++ ) DL(r)[j] = DL(m)[j];
             adj = nd_exporigin-newexporigin;              adj = nd_exporigin-newexporigin;
             for ( ; j < newwpd; j++ ) DL(r)[j] = DL(m)[j+adj];              for ( ; j < newwpd; j++ ) DL(r)[j] = DL(m)[j+adj];
                           if ( nd_module ) {
                                   DL(r)[newmpos] = pos;
                           }
         }          }
     }      }
     NV(p)--;      NV(p)--;
Line 4472  void nd_init_ord(struct order_spec *ord)
Line 4472  void nd_init_ord(struct order_spec *ord)
         case 256:          case 256:
             nd_ispot = ord->ispot;              nd_ispot = ord->ispot;
             nd_dcomp = -1;              nd_dcomp = -1;
             nd_isrlex = 0;  
             switch ( ord->ord.simple ) {              switch ( ord->ord.simple ) {
                 case 0:                  case 0:
                           nd_isrlex = 1;
                     ndl_compare_function = ndl_module_grlex_compare;                      ndl_compare_function = ndl_module_grlex_compare;
                     break;                      break;
                 case 1:                  case 1:
                           nd_isrlex = 0;
                     ndl_compare_function = ndl_module_glex_compare;                      ndl_compare_function = ndl_module_glex_compare;
                     break;                      break;
                 case 2:                  case 2:
                           nd_isrlex = 0;
                     ndl_compare_function = ndl_module_lex_compare;                      ndl_compare_function = ndl_module_lex_compare;
                     break;                      break;
                 default:                  default:
Line 4514  BlockMask nd_create_blockmask(struct order_spec *ord)
Line 4516  BlockMask nd_create_blockmask(struct order_spec *ord)
     BlockMask bm;      BlockMask bm;
   
     /* we only create mask table for block order */      /* we only create mask table for block order */
     if ( ord->id != 1 )      if ( ord->id != 1 && ord->id != 257 )
         return 0;          return 0;
     n = ord->ord.block.length;      n = ord->ord.block.length;
     bm = (BlockMask)MALLOC(sizeof(struct oBlockMask));      bm = (BlockMask)MALLOC(sizeof(struct oBlockMask));
Line 4538  EPOS nd_create_epos(struct order_spec *ord)
Line 4540  EPOS nd_create_epos(struct order_spec *ord)
   
     epos = (EPOS)MALLOC_ATOMIC(nd_nvar*sizeof(struct oEPOS));      epos = (EPOS)MALLOC_ATOMIC(nd_nvar*sizeof(struct oEPOS));
     switch ( ord->id ) {      switch ( ord->id ) {
         case 0:          case 0: case 256:
             if ( nd_isrlex ) {              if ( nd_isrlex ) {
                 for ( i = 0; i < nd_nvar; i++ ) {                  for ( i = 0; i < nd_nvar; i++ ) {
                     epos[i].i = nd_exporigin + (nd_nvar-1-i)/nd_epw;                      epos[i].i = nd_exporigin + (nd_nvar-1-i)/nd_epw;
Line 4551  EPOS nd_create_epos(struct order_spec *ord)
Line 4553  EPOS nd_create_epos(struct order_spec *ord)
                 }                  }
             }              }
             break;              break;
         case 1:          case 1: case 257:
             /* block order */              /* block order */
             l = ord->ord.block.length;              l = ord->ord.block.length;
             op = ord->ord.block.order_pair;              op = ord->ord.block.order_pair;

Legend:
Removed from v.1.163  
changed lines
  Added in v.1.164

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