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

Diff for /OpenXM_contrib2/asir2018/engine/nd.c between version 1.16 and 1.20

version 1.16, 2019/08/21 00:37:47 version 1.20, 2019/09/15 08:46:12
Line 1 
Line 1 
 /* $OpenXM: OpenXM_contrib2/asir2018/engine/nd.c,v 1.15 2019/04/20 06:04:18 noro Exp $ */  /* $OpenXM: OpenXM_contrib2/asir2018/engine/nd.c,v 1.19 2019/09/04 05:32:10 noro Exp $ */
   
 #include "nd.h"  #include "nd.h"
   
Line 8  struct oEGT eg_search,f4_symb,f4_conv,f4_elim1,f4_elim
Line 8  struct oEGT eg_search,f4_symb,f4_conv,f4_elim1,f4_elim
 int diag_period = 6;  int diag_period = 6;
 int weight_check = 1;  int weight_check = 1;
 int (*ndl_compare_function)(UINT *a1,UINT *a2);  int (*ndl_compare_function)(UINT *a1,UINT *a2);
   /* for schreyer order */
   int (*ndl_base_compare_function)(UINT *a1,UINT *a2);
 int nd_dcomp;  int nd_dcomp;
 int nd_rref2;  int nd_rref2;
 NM _nm_free_list;  NM _nm_free_list;
Line 476  int ndl_weight(UINT *d)
Line 478  int ndl_weight(UINT *d)
             for ( j = 0; j < nd_epw; j++, u>>=nd_bpe )              for ( j = 0; j < nd_epw; j++, u>>=nd_bpe )
                 t += (u&nd_mask0);                  t += (u&nd_mask0);
         }          }
     if ( nd_module && current_module_weight_vector && MPOS(d) )      if ( nd_module && nd_module_rank && MPOS(d) )
         t += current_module_weight_vector[MPOS(d)];          t += nd_module_weight[MPOS(d)-1];
       for ( i = nd_exporigin; i < nd_wpd; i++ )
         if ( d[i] && !t )
           printf("afo\n");
     return t;      return t;
 }  }
   
Line 492  int ndl_weight2(UINT *d)
Line 497  int ndl_weight2(UINT *d)
         u = GET_EXP(d,i);          u = GET_EXP(d,i);
         t += nd_sugarweight[i]*u;          t += nd_sugarweight[i]*u;
     }      }
     if ( nd_module && current_module_weight_vector && MPOS(d) )      if ( nd_module && nd_module_rank && MPOS(d) )
         t += current_module_weight_vector[MPOS(d)];          t += nd_module_weight[MPOS(d)-1];
     return t;      return t;
 }  }
   
Line 711  int ndl_module_grlex_compare(UINT *d1,UINT *d2)
Line 716  int ndl_module_grlex_compare(UINT *d1,UINT *d2)
 {  {
     int i,c;      int i,c;
   
     if ( nd_module_rank && (c = ndl_module_weight_compare(d1,d2)) ) return c;  //    if ( nd_module_rank && (c = ndl_module_weight_compare(d1,d2)) ) return c;
     if ( nd_ispot ) {      if ( nd_ispot ) {
     if ( nd_pot_nelim && MPOS(d1)>=nd_pot_nelim+1 && MPOS(d2) >= nd_pot_nelim+1 ) {        if ( nd_pot_nelim && MPOS(d1)>=nd_pot_nelim+1 && MPOS(d2) >= nd_pot_nelim+1 ) {
             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;
             if ( (c = ndl_lex_compare(d1,d2)) != 0 ) return c;           if ( (c = ndl_lex_compare(d1,d2)) != 0 ) return c;
             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;
             return 0;           return 0;
         }
         if ( MPOS(d1) < MPOS(d2) ) return 1;
         else if ( MPOS(d1) > MPOS(d2) ) return -1;
     }      }
         if ( MPOS(d1) < MPOS(d2) ) return 1;  
         else if ( MPOS(d1) > MPOS(d2) ) return -1;  
     }  
     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;
     if ( (c = ndl_lex_compare(d1,d2)) != 0 ) return c;      if ( (c = ndl_lex_compare(d1,d2)) != 0 ) return c;
Line 738  int ndl_module_glex_compare(UINT *d1,UINT *d2)
Line 743  int ndl_module_glex_compare(UINT *d1,UINT *d2)
 {  {
     int i,c;      int i,c;
   
     if ( nd_module_rank && (c = ndl_module_weight_compare(d1,d2)) ) return c;  //    if ( nd_module_rank && (c = ndl_module_weight_compare(d1,d2)) ) return 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;
Line 757  int ndl_module_lex_compare(UINT *d1,UINT *d2)
Line 762  int ndl_module_lex_compare(UINT *d1,UINT *d2)
 {  {
     int i,c;      int i,c;
   
     if ( nd_module_rank && (c = ndl_module_weight_compare(d1,d2)) ) return c;  //    if ( nd_module_rank && (c = ndl_module_weight_compare(d1,d2)) ) return 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;
Line 774  int ndl_module_block_compare(UINT *d1,UINT *d2)
Line 779  int ndl_module_block_compare(UINT *d1,UINT *d2)
 {  {
     int i,c;      int i,c;
   
     if ( nd_module_rank && (c = ndl_module_weight_compare(d1,d2)) ) return c;  //    if ( nd_module_rank && (c = ndl_module_weight_compare(d1,d2)) ) return 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;
Line 791  int ndl_module_matrix_compare(UINT *d1,UINT *d2)
Line 796  int ndl_module_matrix_compare(UINT *d1,UINT *d2)
 {  {
     int i,c;      int i,c;
   
     if ( nd_module_rank && (c = ndl_module_weight_compare(d1,d2)) ) return c;  //    if ( nd_module_rank && (c = ndl_module_weight_compare(d1,d2)) ) return 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;
Line 808  int ndl_module_composite_compare(UINT *d1,UINT *d2)
Line 813  int ndl_module_composite_compare(UINT *d1,UINT *d2)
 {  {
     int i,c;      int i,c;
   
     if ( nd_module_rank && (c = ndl_module_weight_compare(d1,d2)) ) return c;  //    if ( nd_module_rank && (c = ndl_module_weight_compare(d1,d2)) ) return 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;
Line 2611  ND_pairs nd_newpairs( NODE g, int t )
Line 2616  ND_pairs nd_newpairs( NODE g, int t )
   
   dl = DL(nd_psh[t]);    dl = DL(nd_psh[t]);
   ts = SG(nd_psh[t]) - TD(dl);    ts = SG(nd_psh[t]) - TD(dl);
   if ( nd_module && nd_intersect && (MPOS(dl) > 1) ) return 0;    if ( nd_module && nd_intersect && (MPOS(dl) > nd_intersect) ) return 0;
   for ( r0 = 0, h = g; h; h = NEXT(h) ) {    for ( r0 = 0, h = g; h; h = NEXT(h) ) {
     if ( nd_module && (MPOS(DL(nd_psh[(long)BDY(h)])) != MPOS(dl)) )      if ( nd_module && (MPOS(DL(nd_psh[(long)BDY(h)])) != MPOS(dl)) )
       continue;        continue;
Line 3370  void nd_gr(LIST f,LIST v,int m,int homo,int retdp,int 
Line 3375  void nd_gr(LIST f,LIST v,int m,int homo,int retdp,int 
     nd_demand = 0;      nd_demand = 0;
   if ( nd_module && nd_intersect ) {    if ( nd_module && nd_intersect ) {
     for ( j = nd_psn-1, x = 0; j >= 0; j-- )      for ( j = nd_psn-1, x = 0; j >= 0; j-- )
       if ( MPOS(DL(nd_psh[j])) > 1 ) {        if ( MPOS(DL(nd_psh[j])) > nd_intersect ) {
         MKNODE(xx,(pointer)((unsigned long)j),x); x = xx;          MKNODE(xx,(pointer)((unsigned long)j),x); x = xx;
       }        }
     conv_ilist(nd_demand,0,x,0);      conv_ilist(nd_demand,0,x,0);
Line 3778  void nd_gr_trace(LIST f,LIST v,int trace,int homo,int 
Line 3783  void nd_gr_trace(LIST f,LIST v,int trace,int homo,int 
             Z cont;              Z cont;
             DPM zdpm;              DPM zdpm;
   
             if ( !m && !nd_gentrace ) dpm_ptozp((DPM)BDY(t),&cont,&zdpm);              if ( !nd_gentrace ) dpm_ptozp((DPM)BDY(t),&cont,&zdpm);
             else zdpm = (DPM)BDY(t);              else zdpm = (DPM)BDY(t);
             c = (pointer)dpmtondv(m,zdpm);              c = (pointer)dpmtondv(m,zdpm);
           } else {            } else {
Line 3887  void nd_gr_trace(LIST f,LIST v,int trace,int homo,int 
Line 3892  void nd_gr_trace(LIST f,LIST v,int trace,int homo,int 
     nd_setup_parameters(nd_nvar,0);      nd_setup_parameters(nd_nvar,0);
     for ( r = cand; r; r = NEXT(r) ) {      for ( r = cand; r; r = NEXT(r) ) {
       if ( nd_module ) {        if ( nd_module ) {
         if ( retdp ) BDY(r) = ndvtodpm(0,BDY(t));          if ( retdp ) BDY(r) = ndvtodpm(0,BDY(r));
         else BDY(r) = ndvtopl(0,CO,vv,BDY(r),mrank);          else BDY(r) = ndvtopl(0,CO,vv,BDY(r),mrank);
       } else if ( retdp ) BDY(r) = ndvtodp(0,BDY(t));        } else if ( retdp ) BDY(r) = ndvtodp(0,BDY(r));
       else BDY(r) = (pointer)ndvtop(0,CO,vv,BDY(t));        else BDY(r) = (pointer)ndvtop(0,CO,vv,BDY(r));
     }      }
     if ( nd_nalg )      if ( nd_nalg )
         cand = postprocess_algcoef(av,alist,cand);          cand = postprocess_algcoef(av,alist,cand);
Line 5514  void dpm_sort(DPM p,DPM *rp)
Line 5519  void dpm_sort(DPM p,DPM *rp)
   *rp = d;    *rp = d;
 }  }
   
   int dpm_comp(DPM *a,DPM *b)
   {
     return compdpm(CO,*a,*b);
   }
   
   NODE dpm_sort_list(NODE l)
   {
     int i,len;
     NODE t,t1;
     DPM *a;
   
     len = length(l);
     a = (DPM *)MALLOC(len*sizeof(DPM));
     for ( t = l, i = 0; i < len; i++, t = NEXT(t) ) a[i] = (DPM)BDY(t);
     qsort(a,len,sizeof(DPM),(int (*)(const void *,const void *))dpm_comp);
     t = 0;
     for ( i = len-1; i >= 0; i-- ) {
       MKNODE(t1,(pointer)a[i],t); t = t1;
     }
     return t;
   }
   
   int nmv_comp(NMV a,NMV b)
   {
     return -DL_COMPARE(a->dl,b->dl);
   }
   
 NDV dpmtondv(int mod,DPM p)  NDV dpmtondv(int mod,DPM p)
 {  {
   NDV d;    NDV d;
Line 5538  NDV dpmtondv(int mod,DPM p)
Line 5570  NDV dpmtondv(int mod,DPM p)
   for ( i = 0; i < len; i++, NMV_ADV(m) ) {    for ( i = 0; i < len; i++, NMV_ADV(m) ) {
     dltondl(n,a[i]->dl,DL(m));      dltondl(n,a[i]->dl,DL(m));
     MPOS(DL(m)) = a[i]->pos;      MPOS(DL(m)) = a[i]->pos;
       TD(DL(m)) = ndl_weight(DL(m));
     CZ(m) = (Z)a[i]->c;      CZ(m) = (Z)a[i]->c;
   }    }
     qsort(m0,len,nmv_adv,(int (*)(const void *,const void *))nmv_comp);
   MKNDV(NV(p),m0,len,d);    MKNDV(NV(p),m0,len,d);
   SG(d) = SG(p);    SG(d) = SG(p);
   return d;    return d;
Line 7841  int ndv_ishomo(NDV p)
Line 7875  int ndv_ishomo(NDV p)
     h = TD(DL(m));      h = TD(DL(m));
     NMV_ADV(m);      NMV_ADV(m);
     for ( len--; len; len--, NMV_ADV(m) )      for ( len--; len; len--, NMV_ADV(m) )
         if ( TD(DL(m)) != h ) return 0;          if ( TD(DL(m)) != h ) {
             return 0;
           }
     return 1;      return 1;
 }  }
   
Line 8491  void parse_nd_option(NODE opt)
Line 8527  void parse_nd_option(NODE opt)
             nd_newelim = value?1:0;              nd_newelim = value?1:0;
     else if ( !strcmp(key,"intersect") )      else if ( !strcmp(key,"intersect") )
             nd_intersect = value?1:0;              nd_intersect = value?1:0;
       else if ( !strcmp(key,"syzgen") )
               nd_intersect = ZTOS((Q)value);
     else if ( !strcmp(key,"lf") )      else if ( !strcmp(key,"lf") )
             nd_lf = value?1:0;              nd_lf = value?1:0;
     else if ( !strcmp(key,"trace") ) {      else if ( !strcmp(key,"trace") ) {

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.20

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