[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.49 and 1.53

version 1.49, 2021/02/28 02:33:16 version 1.53, 2021/03/12 01:18:33
Line 1 
Line 1 
 /* $OpenXM: OpenXM_contrib2/asir2018/engine/nd.c,v 1.48 2021/02/18 05:35:01 noro Exp $ */  /* $OpenXM: OpenXM_contrib2/asir2018/engine/nd.c,v 1.52 2021/03/09 08:48:50 noro Exp $ */
   
 #include "nd.h"  #include "nd.h"
   
Line 2623  init_eg(&eg_update);
Line 2623  init_eg(&eg_update);
   }    }
   sugar = 0;    sugar = 0;
   if ( nd_hpdata ) {    if ( nd_hpdata ) {
       if ( DP_Print ) fprintf(asir_out,"Hilbert driven algorithm.\n");
     setup_hpdata(&final_hpdata,&current_hpdata);      setup_hpdata(&final_hpdata,&current_hpdata);
   }    }
   while ( d ) {    while ( d ) {
Line 2647  again:
Line 2648  again:
         else {          else {
           final_hpvalue = hpvalue(&final_hpdata,sugar);            final_hpvalue = hpvalue(&final_hpdata,sugar);
           if ( final_hpvalue == hpvalue(&current_hpdata,sugar) ) {            if ( final_hpvalue == hpvalue(&current_hpdata,sugar) ) {
             if ( DP_Print ) fprintf(asir_out,"sugar=%d done.\n",sugar);  //            if ( DP_Print ) fprintf(asir_out,"done.\n",sugar);
             d = nd_remove_same_sugar(d,sugar);              d = nd_remove_same_sugar(d,sugar);
             continue;              continue;
           }            }
Line 2713  get_eg(&eg2); add_eg(&eg_update,&eg1,&eg2);
Line 2714  get_eg(&eg2); add_eg(&eg_update,&eg1,&eg2);
       if ( nd_hpdata ) {        if ( nd_hpdata ) {
         update_hpdata(&current_hpdata,nh,1);          update_hpdata(&current_hpdata,nh,1);
         if ( final_hpvalue == hpvalue(&current_hpdata,sugar) ) {          if ( final_hpvalue == hpvalue(&current_hpdata,sugar) ) {
           if ( DP_Print ) fprintf(asir_out,"sugar=%d done.\n",sugar);  //          if ( DP_Print ) fprintf(asir_out,"sugar=%d done.\n",sugar);
           d = nd_remove_same_sugar(d,sugar);            d = nd_remove_same_sugar(d,sugar);
         }          }
       }        }
Line 2753  int nd_nf_s(int mod,ND d,ND g,NDV *ps,int full,ND *nf)
Line 2754  int nd_nf_s(int mod,ND d,ND g,NDV *ps,int full,ND *nf)
 void _copydl(int n,DL d1,DL d2);  void _copydl(int n,DL d1,DL d2);
 void _subfromdl(int n,DL d1,DL d2);  void _subfromdl(int n,DL d1,DL d2);
 extern int (*cmpdl)(int n,DL d1,DL d2);  extern int (*cmpdl)(int n,DL d1,DL d2);
   int _dl_redble_ext(DL,DL,DL,int);
   
   int primitive_irred(ND p,SIG sig)
   {
     static int wpd=0,dlen=0;
     static DL dquo,squo;
     static UINT *quo;
     int i;
   
     if ( dlen < nd_nvar ) {
       NEWDL(dquo,nd_nvar);
       NEWDL(squo,nd_nvar);
       dlen = nd_nvar;
     }
     if ( wpd != nd_wpd ) {
       wpd = nd_wpd;
       quo = (UINT *)MALLOC(wpd*sizeof(UINT));
     }
     for ( i = 0; i < nd_psn; i++ ) {
       if ( sig->pos == nd_psh[i]->sig->pos &&
         _dl_redble_ext(DL(nd_psh[i]->sig),DL(sig),squo,nd_nvar) )
         if ( ndl_reducible(HDL(p),DL(nd_psh[i])) ) {
           if ( DP_Print ) fprintf(asir_out,"D");
           ndl_sub(HDL(p),DL(nd_psh[i]),quo);
           _ndltodl(quo,dquo);
           if ( _eqdl(nd_nvar,squo,dquo) )
             return 0;
         }
     }
     return 1;
   }
   
 NODE insert_sig(NODE l,SIG s)  NODE insert_sig(NODE l,SIG s)
 {  {
   int pos;    int pos;
Line 2806  ND_pairs remove_spair_s(ND_pairs d,SIG sig)
Line 2838  ND_pairs remove_spair_s(ND_pairs d,SIG sig)
   return (ND_pairs)root.next;    return (ND_pairs)root.next;
 }  }
   
 int _dl_redble_ext(DL,DL,DL,int);  
   
 int small_lcm(ND_pairs l)  int small_lcm(ND_pairs l)
 {  {
   SIG sig;    SIG sig;
Line 3005  NODE nd_sba_buch(int m,int ishomo,int **indp,NODE *syz
Line 3035  NODE nd_sba_buch(int m,int ishomo,int **indp,NODE *syz
   int Nnominimal,Nredundant;    int Nnominimal,Nredundant;
   DL lcm,quo,mul;    DL lcm,quo,mul;
   struct oHPDATA final_hpdata,current_hpdata;    struct oHPDATA final_hpdata,current_hpdata;
   struct oEGT eg1,eg2,eg_update,eg_remove,eg_large,eg_nf,eg_nfzero,eg_minsig,eg_smallest;    struct oEGT eg1,eg2,eg3,eg4,eg_update,eg_remove,eg_large,eg_nf,eg_nfzero;
     struct oEGT eg_minsig,eg_smallest,eg_removecont,eg_hpdata,eg_updatepairs,eg_sbabuch,eg_sp;
   int Nnfs=0,Nnfz=0,Nnfnz=0,dlen,nsyz;    int Nnfs=0,Nnfz=0,Nnfnz=0,dlen,nsyz;
   
 init_eg(&eg_remove);  init_eg(&eg_remove);
Line 3034  init_eg(&eg_remove);
Line 3065  init_eg(&eg_remove);
     setup_hpdata(&final_hpdata,&current_hpdata);      setup_hpdata(&final_hpdata,&current_hpdata);
   }    }
   NEWDL(lcm,nd_nvar); NEWDL(quo,nd_nvar); NEWDL(mul,nd_nvar);    NEWDL(lcm,nd_nvar); NEWDL(quo,nd_nvar); NEWDL(mul,nd_nvar);
   init_eg(&eg_sp);
 init_eg(&eg_create);  init_eg(&eg_create);
 init_eg(&eg_merge);  init_eg(&eg_merge);
 init_eg(&eg_minsig);  init_eg(&eg_minsig);
Line 3041  init_eg(&eg_smallest);
Line 3073  init_eg(&eg_smallest);
 init_eg(&eg_large);  init_eg(&eg_large);
 init_eg(&eg_nf);  init_eg(&eg_nf);
 init_eg(&eg_nfzero);  init_eg(&eg_nfzero);
   init_eg(&eg_removecont);
   init_eg(&eg_updatepairs);
   init_eg(&eg_hpdata);
   init_eg(&eg_sbabuch);
   get_eg(&eg3);
   while ( 1 ) {    while ( 1 ) {
     if ( DP_Print && dlen%100 == 0 ) fprintf(asir_out,"(%d)",dlen);      if ( DP_Print && !nd_hpdata && dlen%1000 == 0 ) fprintf(asir_out,"(%d)",dlen);
 again :  again :
 get_eg(&eg1);  get_eg(&eg1);
     ind = nd_minsig(d);      ind = nd_minsig(d);
Line 3055  get_eg(&eg1);
Line 3092  get_eg(&eg1);
 get_eg(&eg2); add_eg(&eg_smallest,&eg1,&eg2);  get_eg(&eg2); add_eg(&eg_smallest,&eg1,&eg2);
     if ( l1 == 0 ) {      if ( l1 == 0 ) {
       d[ind] = d[ind]->next; dlen--;        d[ind] = d[ind]->next; dlen--;
       if ( DP_Print ) fprintf(asir_out,"M");  //      if ( DP_Print && !nd_hpdata ) fprintf(asir_out,"M");
       Nnominimal++;        Nnominimal++;
       continue;        continue;
     }      }
Line 3070  get_eg(&eg2); add_eg(&eg_smallest,&eg1,&eg2);
Line 3107  get_eg(&eg2); add_eg(&eg_smallest,&eg1,&eg2);
         pos = sig->pos;          pos = sig->pos;
       }        }
     }      }
   get_eg(&eg1);
     stat = nd_sp(m,0,l1,&h);      stat = nd_sp(m,0,l1,&h);
   get_eg(&eg2); add_eg(&eg_sp,&eg1,&eg2);
     if ( !stat ) {      if ( !stat ) {
       nd_reconstruct_s(0,d);        nd_reconstruct_s(0,d);
       goto again;        goto again;
Line 3105  get_eg(&eg2); 
Line 3144  get_eg(&eg2); 
       }        }
       add_eg(&eg_nf,&eg1,&eg2);        add_eg(&eg_nf,&eg1,&eg2);
       hc = HCU(nf);        hc = HCU(nf);
         get_eg(&eg1);
       nd_removecont(m,nf);        nd_removecont(m,nf);
         get_eg(&eg2); add_eg(&eg_removecont,&eg1,&eg2);
       nfv = ndtondv(m,nf); nd_free(nf);        nfv = ndtondv(m,nf); nd_free(nf);
       nh = ndv_newps(m,nfv,0);        nh = ndv_newps(m,nfv,0);
   
         get_eg(&eg1);
       dlen += update_pairs_array_s(d,nh,syzlist);        dlen += update_pairs_array_s(d,nh,syzlist);
         get_eg(&eg2); add_eg(&eg_updatepairs,&eg1,&eg2);
       nd_sba_pos[sig->pos] = append_one(nd_sba_pos[sig->pos],nh);        nd_sba_pos[sig->pos] = append_one(nd_sba_pos[sig->pos],nh);
       if ( nd_hpdata ) {        if ( nd_hpdata ) {
           get_eg(&eg1);
         update_hpdata(&current_hpdata,nh,0);          update_hpdata(&current_hpdata,nh,0);
           get_eg(&eg2); add_eg(&eg_hpdata,&eg1,&eg2);
         if ( !compp(CO,final_hpdata.hn,current_hpdata.hn) ) {          if ( !compp(CO,final_hpdata.hn,current_hpdata.hn) ) {
           if ( DP_Print ) { printf("\nWe found a gb.\n"); }            if ( DP_Print ) { printf("\nWe found a gb.\n"); }
           break;              break;
         }          }
       }        }
    } else {     } else {
Line 3132  get_eg(&eg2); add_eg(&eg_remove,&eg1,&eg2);
Line 3177  get_eg(&eg2); add_eg(&eg_remove,&eg1,&eg2);
      if ( DP_Print ) { printf("."); fflush(stdout); }       if ( DP_Print ) { printf("."); fflush(stdout); }
    }     }
  }   }
    get_eg(&eg4); add_eg(&eg_sbabuch,&eg3,&eg4);
  g = conv_ilist_s(nd_demand,0,indp);   g = conv_ilist_s(nd_demand,0,indp);
  if ( DP_Print ) {   if ( DP_Print ) {
    printf("\ndlen=%d,nd_sba done. nd_add=%d,Nsyz=%d,Nsamesig=%d,Nnominimal=%d\n",dlen,Nnd_add,Nsyz,Nsamesig,Nnominimal);     printf("\ndlen=%d,nd_sba done. nd_add=%d,Nsyz=%d,Nsamesig=%d,Nnominimal=%d\n",dlen,Nnd_add,Nsyz,Nsamesig,Nnominimal);
    printf("Nnfnz=%d,Nnfz=%d,Nnfsingular=%d\n",Nnfnz,Nnfz,Nnfs);     printf("Nnfnz=%d,Nnfz=%d,Nnfsingular=%d\n",Nnfnz,Nnfz,Nnfs);
    fflush(stdout);     fflush(stdout);
    if ( nd_sba_redundant_check )     if ( nd_sba_redundant_check )
    printf("Nredundant=%d\n",Nredundant);     printf("Nredundant=%d\n",Nredundant);
    fflush(stdout);     fflush(stdout);
      print_eg("sp",&eg_sp);
    print_eg("create",&eg_create);     print_eg("create",&eg_create);
    print_eg("merge",&eg_merge);     print_eg("merge",&eg_merge);
    print_eg("minsig",&eg_minsig);     print_eg("minsig",&eg_minsig);
    print_eg("smallest",&eg_smallest);     print_eg("smallest",&eg_smallest);
    print_eg("remove",&eg_remove);     print_eg("remove",&eg_remove);
      printf("\n");
    print_eg("nf",&eg_nf);     print_eg("nf",&eg_nf);
    print_eg("nfzero",&eg_nfzero);     print_eg("nfzero",&eg_nfzero);
      print_eg("removecont",&eg_removecont);
      print_eg("updatepairs",&eg_updatepairs);
      print_eg("hpdata",&eg_hpdata);
      print_eg("total",&eg_sbabuch);
    printf("\n");     printf("\n");
  }   }
  if ( nd_sba_syz ) {   if ( nd_sba_syz ) {
Line 3349  NODE nd_gb_trace(int m,int ishomo,int **indp)
Line 3401  NODE nd_gb_trace(int m,int ishomo,int **indp)
   }    }
   sugar = 0;    sugar = 0;
   if ( nd_hpdata ) {    if ( nd_hpdata ) {
       if ( DP_Print ) fprintf(asir_out,"Hilbert driven algorithm.\n");
     setup_hpdata(&final_hpdata,&current_hpdata);      setup_hpdata(&final_hpdata,&current_hpdata);
   }    }
   
Line 3378  again:
Line 3431  again:
         else {          else {
           final_hpvalue = hpvalue(&final_hpdata,sugar);            final_hpvalue = hpvalue(&final_hpdata,sugar);
           if ( final_hpvalue == hpvalue(&current_hpdata,sugar) ) {            if ( final_hpvalue == hpvalue(&current_hpdata,sugar) ) {
             if ( DP_Print ) fprintf(asir_out,"sugar=%d done.\n",sugar);  //            if ( DP_Print ) fprintf(asir_out,"sugar=%d done.\n",sugar);
             d = nd_remove_same_sugar(d,sugar);              d = nd_remove_same_sugar(d,sugar);
             continue;              continue;
           }            }
Line 3460  again:
Line 3513  again:
         if ( nd_hpdata ) {          if ( nd_hpdata ) {
           update_hpdata(&current_hpdata,nh,1);            update_hpdata(&current_hpdata,nh,1);
           if ( final_hpvalue == hpvalue(&current_hpdata,sugar) ) {            if ( final_hpvalue == hpvalue(&current_hpdata,sugar) ) {
             if ( DP_Print ) fprintf(asir_out,"sugar=%d done.\n",sugar);  //            if ( DP_Print ) fprintf(asir_out,"sugar=%d done.\n",sugar);
             d = nd_remove_same_sugar(d,sugar);              d = nd_remove_same_sugar(d,sugar);
           }            }
         }          }
Line 5032  void nd_sba(LIST f,LIST v,int m,int homo,int retdp,int
Line 5085  void nd_sba(LIST f,LIST v,int m,int homo,int retdp,int
   int *perm;    int *perm;
   EPOS oepos;    EPOS oepos;
   int obpe,oadv,ompos,cbpe;    int obpe,oadv,ompos,cbpe;
   struct oEGT eg0,eg1,egconv;    struct oEGT eg0,eg1,egconv,egintred;
   
   nd_module = 0;    nd_module = 0;
   nd_demand = 0;    nd_demand = 0;
Line 5118  void nd_sba(LIST f,LIST v,int m,int homo,int retdp,int
Line 5171  void nd_sba(LIST f,LIST v,int m,int homo,int retdp,int
     nd_setup_parameters(nvar,0);      nd_setup_parameters(nvar,0);
   }    }
   nd_demand = 0;    nd_demand = 0;
     get_eg(&eg0);
   x = ndv_reducebase(x,perm);    x = ndv_reducebase(x,perm);
   x = ndv_reduceall(m,x);    x = ndv_reduceall(m,x);
     get_eg(&eg1); init_eg(&egintred); add_eg(&egintred,&eg0,&eg1);
   nd_setup_parameters(nd_nvar,0);    nd_setup_parameters(nd_nvar,0);
   get_eg(&eg0);    get_eg(&eg0);
   for ( r0 = 0, t = x; t; t = NEXT(t) ) {    for ( r0 = 0, t = x; t; t = NEXT(t) ) {
Line 5139  void nd_sba(LIST f,LIST v,int m,int homo,int retdp,int
Line 5194  void nd_sba(LIST f,LIST v,int m,int homo,int retdp,int
   } else    } else
     MKLIST(*rp,r0);      MKLIST(*rp,r0);
   get_eg(&eg1); init_eg(&egconv); add_eg(&egconv,&eg0,&eg1);    get_eg(&eg1); init_eg(&egconv); add_eg(&egconv,&eg0,&eg1);
     print_eg("intred",&egintred); fprintf(asir_out,"\n");
   print_eg("conv",&egconv); fprintf(asir_out,"\n");    print_eg("conv",&egconv); fprintf(asir_out,"\n");
 }  }
   
Line 10631  void parse_nd_option(VL vl,NODE opt)
Line 10687  void parse_nd_option(VL vl,NODE opt)
     } else if ( !strcmp(key,"check_splist") ) {      } else if ( !strcmp(key,"check_splist") ) {
       nd_check_splist = BDY((LIST)value);        nd_check_splist = BDY((LIST)value);
     } else if ( !strcmp(key,"hpdata") ) {      } else if ( !strcmp(key,"hpdata") ) {
       nd_hpdata = BDY((LIST)value);        if ( value )
           nd_hpdata = BDY((LIST)value);
     } else if ( !strcmp(key,"sugarweight") ) {      } else if ( !strcmp(key,"sugarweight") ) {
       u = BDY((LIST)value);        u = BDY((LIST)value);
       n = length(u);        n = length(u);

Legend:
Removed from v.1.49  
changed lines
  Added in v.1.53

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