Changeset acccd2 in git


Ignore:
Timestamp:
Nov 27, 2014, 5:03:55 PM (9 years ago)
Author:
Stephan Oberfranz <oberfran@…>
Branches:
(u'spielwiese', 'e7cc1ebecb61be8b9ca6c18016352af89940b21a')
Children:
0011f4ba4d5c10c441c70b05f3dd4b8c1e0a263e
Parents:
f2ba60d666fcc3a4164b840100f6e982e9749517
Message:
randomization, printout
Location:
Singular
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • Singular/LIB/grwalk.lib

    rf2ba60d racccd2  
    255255}
    256256
    257 proc gwalk(ideal Go, list #)
    258 "SYNTAX: gwalk(ideal i);
    259          gwalk(ideal i, intvec v, intvec w);
     257proc gwalk(ideal Go, int reduction,int printout, list #)
     258"SYNTAX: gwalk(ideal i, int reduction, int printout);
     259         gwalk(ideal i, int reduction, int printout, intvec v, intvec w);
    260260TYPE:    ideal
    261261PURPOSE: compute the standard basis of the ideal, calculated via
     
    284284   //print("//** help ring = " + string(basering));
    285285   ideal G = fetch(xR, Go);
    286    G = system("Mwalk", G, curr_weight, target_weight,basering);
     286   G = system("Mwalk", G, curr_weight, target_weight,basering,reduction,printout);
    287287
    288288   setring xR;
     
    300300  ring r = 32003,(z,y,x), lp;
    301301  ideal I = y3+xyz+y2z+xz3, 3+xy+x2y+y2z;
    302   gwalk(I);
     302  gwalk(I,0,1);
    303303}
    304304
     
    346346}
    347347
    348 proc fwalk(ideal Go, list #)
    349 "SYNTAX: fwalk(ideal i);
    350          fwalk(ideal i, intvec v, intvec w);
     348proc fwalk(ideal Go, int reduction, list #)
     349"SYNTAX: fwalk(ideal i,int reductioin);
     350         fwalk(ideal i, int reduction intvec v, intvec w);
    351351TYPE:    ideal
    352352PURPOSE: compute the standard basis of the ideal w.r.t. the
     
    372372
    373373   ideal G = fetch(xR, Go);
    374    G = system("Mfwalk", G, curr_weight, target_weight);
     374   G = system("Mfwalk", G, curr_weight, target_weight, reduction);
    375375
    376376   setring xR;
     
    387387    ring r = 32003,(z,y,x), lp;
    388388    ideal I = y3+xyz+y2z+xz3, 3+xy+x2y+y2z;
    389     fwalk(I);
     389    int reduction = 1;
     390    fwalk(I,reduction);
    390391}
    391392
     
    437438}
    438439
    439 proc pwalk(ideal Go, int n1, int n2, list #)
    440 "SYNTAX: pwalk(int d, ideal i, int n1, int n2);
    441          pwalk(int d, ideal i, int n1, int n2, intvec v, intvec w);
     440proc pwalk(ideal Go, int n1, int n2, int reduction, int printout, list #)
     441"SYNTAX: pwalk(int d, ideal i, int n1, int n2, int reduction, int printout);
     442         pwalk(int d, ideal i, int n1, int n2, int reduction, int printout, intvec v, intvec w);
    442443TYPE:    ideal
    443444PURPOSE: compute the standard basis of the ideal, calculated via
     
    477478  ideal G = fetch(xR, Go);
    478479
    479   G = system("Mpwalk", G, n1, n2, curr_weight, target_weight,nP);
     480  G = system("Mpwalk",G,n1,n2,curr_weight,target_weight,nP,reduction,printout);
    480481 
    481482  setring xR;
     
    492493    ring r = 32003,(z,y,x), lp;
    493494    ideal I = y3+xyz+y2z+xz3, 3+xy+x2y+y2z;
    494     //I = std(I);
    495     //ring rr = 32003,(z,y,x),lp;
    496     //ideal I = fetch(r,I);
    497     pwalk(I,2,2);
     495    int reduction = 1;
     496    int printout = 2;
     497    pwalk(I,2,2,reduction,printout);
    498498}
    499499
  • Singular/LIB/modwalk.lib

    rf2ba60d racccd2  
    3030////////////////////////////////////////////////////////////////////////////////
    3131
    32 proc modpWalk(def II, int p, int variant, list #)
     32proc modpWalk(def II, int p, int variant, int reduction, list #)
    3333"USAGE:  modpWalk(I,p,#); I ideal, p integer, variant integer
    3434ASSUME:  If size(#) > 0, then
     
    8686    if(size(#)>0)
    8787    {
    88       i = rwalk(i,radius,pert_deg,#);
    89     }
    90     else
    91     {
    92       i = rwalk(i,radius,pert_deg);
     88      i = rwalk(i,radius,pert_deg,reduction,#);
     89    }
     90    else
     91    {
     92      i = rwalk(i,radius,pert_deg,reduction);
    9393    }
    9494  }
     
    9797    if(size(#) == 2)
    9898    {
    99       i = gwalk(i,#);
    100     }
    101     else
    102     {
    103       i = gwalk(i);
     99      i = gwalk(i,reduction,#);
     100    }
     101    else
     102    {
     103      i = gwalk(i,reduction);
    104104    }
    105105  }
     
    108108    if(size(#) == 2)
    109109    {
    110       i = frandwalk(i,radius,#);
    111     }
    112     else
    113     {
    114       i = frandwalk(i,radius);
     110      i = frandwalk(i,radius,reduction,#);
     111    }
     112    else
     113    {
     114      i = frandwalk(i,radius,reduction);
    115115    }
    116116  }
     
    130130    if(size(#) == 2)
    131131    {
    132      i=prwalk(i,radius,pert_deg,pert_deg,#);
    133     }
    134     else
    135     {
    136       i=prwalk(i,radius,pert_deg,pert_deg);
     132     i=prwalk(i,radius,pert_deg,pert_deg,reduction,#);
     133    }
     134    else
     135    {
     136      i=prwalk(i,radius,pert_deg,pert_deg,reduction);
    137137    }
    138138  }
     
    141141    if(size(#) == 2)
    142142    {
    143       i=pwalk(i,pert_deg,pert_deg,#);
    144     }
    145     else
    146     {
    147       i=pwalk(i,pert_deg,pert_deg);
     143      i=pwalk(i,pert_deg,pert_deg,reduction,#);
     144    }
     145    else
     146    {
     147      i=pwalk(i,pert_deg,pert_deg,reduction);
    148148    }
    149149  }
     
    162162  ring ra = 0,x(1..4),(a(a),lp);
    163163  ideal I = std(cyclic(4));
     164  int reduction = 1;
    164165  ring rb = 0,x(1..4),(a(b),lp);
    165166  ideal I = imap(ra,I);
    166   modpWalk(I,p,1,a,b);
     167  modpWalk(I,p,1,reduction,a,b);
    167168  std(I);
    168169}
     
    170171////////////////////////////////////////////////////////////////////////////////
    171172
    172 proc modWalk(def II, int variant, list #)
     173proc modWalk(def II, int variant, int reduction, list #)
    173174"USAGE:  modWalk(II); II ideal or list(ideal,int)
    174175ASSUME:  If variant =
     
    462463    for(i=1; i<=size(L); i++)
    463464    {
    464       Arguments[i] = list(II,L[i],variant,list(curr_weight,target_weight));
     465      Arguments[i] = list(II,L[i],variant,reduction,list(curr_weight,target_weight));
    465466    }
    466467  }
     
    469470    for(i=1; i<=size(L); i++)
    470471    {
    471       Arguments[i] = list(II,L[i],variant);
     472      Arguments[i] = list(II,L[i],variant,reduction);
    472473    }
    473474  }
     
    567568      for(i=j; i<=size(L); i++)
    568569      {
    569         Arguments[size(Arguments)+1] = list(II,L[i],variant,list(curr_weight,target_weight));
     570        Arguments[size(Arguments)+1] = list(II,L[i],variant,reduction,list(curr_weight,target_weight));
    570571      }
    571572    }
     
    574575      for(i=j; i<=size(L); i++)
    575576      {
    576         Arguments[size(Arguments)+1] = list(II,L[i],variant);
     577        Arguments[size(Arguments)+1] = list(II,L[i],variant,reduction);
    577578      }
    578579    }
     
    601602  ring R=0,(x,y,z),lp;
    602603  ideal I= y3+xyz+y2z+xz3, 3+xy+x2y+y2z;
    603   ideal J = modWalk(I,2);
     604  int reduction = 0;
     605  ideal J = modWalk(I,1,1);
    604606  J;
    605607}
  • Singular/LIB/rwalk.lib

    rf2ba60d racccd2  
    141141 * Random Walk  *
    142142 ****************/
    143 proc rwalk(ideal Go, int radius, int pert_deg, list #)
     143proc rwalk(ideal Go, int radius, int pert_deg, int reduction, int printout, list #)
    144144"SYNTAX: rwalk(ideal i, int radius);
    145145         if size(#)>0 then rwalk(ideal i, int radius, intvec v, intvec w);
     146         intermediate Groebner bases are not reduced if reduction = 0
    146147TYPE:    ideal
    147148PURPOSE: compute the standard basis of the ideal, calculated via
     
    178179
    179180ideal G = fetch(xR, Go);
    180 G = system("Mrwalk", G, curr_weight, target_weight, radius, pert_deg, basering);
     181G = system("Mrwalk", G, curr_weight, target_weight, radius, pert_deg, reduction, printout);
    181182
    182183setring xR;
     
    196197  int radius = 1;
    197198  int perturb_deg = 2;
    198   rwalk(I,radius,perturb_deg);
     199  int reduction = 0;
     200  int printout = 1;
     201  rwalk(I,radius,perturb_deg,reduction,printout);
    199202}
    200203
     
    202205 * Perturbation Walk with random element *
    203206 *****************************************/
    204 proc prwalk(ideal Go, int radius, int o_pert_deg, int t_pert_deg, list #)
     207proc prwalk(ideal Go, int radius, int o_pert_deg, int t_pert_deg, int reduction, int printout, list #)
    205208"SYNTAX: rwalk(ideal i, int radius);
    206209         if size(#)>0 then rwalk(ideal i, int radius, intvec v, intvec w);
     
    227230  OSCTW= OrderStringalp_NP("al", #);
    228231  }
     232int nP = OSCTW[1];
    229233string ord_str = OSCTW[2];
    230234intvec curr_weight = OSCTW[3]; // original weight vector
     
    238242
    239243ideal G = fetch(xR, Go);
    240 G = system("Mprwalk", G, curr_weight, target_weight, radius, o_pert_deg, t_pert_deg, basering);
     244G = system("Mprwalk", G, curr_weight, target_weight, radius, o_pert_deg, t_pert_deg,
     245           nP, reduction, printout);
    241246
    242247setring xR;
     
    257262  int o_perturb_deg = 2;
    258263  int t_perturb_deg = 2;
    259   prwalk(I,radius,o_perturb_deg,t_perturb_deg);
     264  int reduction = 0;
     265  int printout = 2;
     266  prwalk(I,radius,o_perturb_deg,t_perturb_deg,reduction,printout);
    260267}
    261268
     
    314321    ring r = 0,(z,y,x), lp;
    315322    ideal I = y3+xyz+y2z+xz3, 3+xy+x2y+y2z;
    316     frandwalk(I,2);
    317 }
     323    int reduction = 0;
     324    frandwalk(I,2,0);
     325}
  • Singular/extra.cc

    rf2ba60d racccd2  
    17771777    if (strcmp(sys_cmd, "Mwalk") == 0)
    17781778    {
    1779       const short t[]={4,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD,RING_CMD};
     1779      const short t[]={6,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD,RING_CMD,INT_CMD,INT_CMD};
    17801780      if (!iiCheckTypes(h,t,1)) return TRUE;
    17811781      if (((intvec*) h->next->Data())->length() != currRing->N &&
     
    17881788      ideal arg1 = (ideal) h->Data();
    17891789      intvec* arg2 = (intvec*) h->next->Data();
    1790       intvec* arg3   =  (intvec*) h->next->next->Data();
    1791       ring arg4   =  (ring) h->next->next->next->Data();
    1792       ideal result = (ideal) Mwalk(arg1, arg2, arg3,arg4);
     1790      intvec* arg3 = (intvec*) h->next->next->Data();
     1791      ring arg4 = (ring) h->next->next->next->Data();
     1792      int arg5 = (int) (long) h->next->next->next->next->Data();
     1793      int arg6 = (int) (long) h->next->next->next->next->next->Data();
     1794      ideal result = (ideal) Mwalk(arg1, arg2, arg3, arg4, arg5, arg6);
    17931795      res->rtyp = IDEAL_CMD;
    17941796      res->data =  result;
     
    18261828    if (strcmp(sys_cmd, "Mpwalk") == 0)
    18271829    {
    1828       const short t[]={6,IDEAL_CMD,INT_CMD,INT_CMD,INTVEC_CMD,INTVEC_CMD,INT_CMD};
     1830      const short t[]={8,IDEAL_CMD,INT_CMD,INT_CMD,INTVEC_CMD,INTVEC_CMD,INT_CMD,INT_CMD,INT_CMD};
    18291831      if (!iiCheckTypes(h,t,1)) return TRUE;
    18301832      if(((intvec*) h->next->next->next->Data())->length() != currRing->N &&
     
    18401842      intvec* arg5 = (intvec*) h->next->next->next->next->Data();
    18411843      int arg6 = (int) (long) h->next->next->next->next->next->Data();
    1842       ideal result = (ideal) Mpwalk(arg1, arg2, arg3, arg4, arg5,arg6);
     1844      int arg7 = (int) (long) h->next->next->next->next->next->next->Data();
     1845      int arg8 = (int) (long) h->next->next->next->next->next->next->next->Data();
     1846      ideal result = (ideal) Mpwalk(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
    18431847      res->rtyp = IDEAL_CMD;
    18441848      res->data =  result;
     
    18521856    if (strcmp(sys_cmd, "Mrwalk") == 0)
    18531857    {
    1854       const short t[]={6,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD,INT_CMD,INT_CMD,RING_CMD};
     1858      const short t[]={7,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD,INT_CMD,INT_CMD,INT_CMD,INT_CMD};
    18551859      if (!iiCheckTypes(h,t,1)) return TRUE;
    1856       if((((intvec*) h->next->Data())->length() != currRing->N &&
    1857          ((intvec*) h->next->next->Data())->length() != currRing->N ) &&
    1858          (((intvec*) h->next->Data())->length() != (currRing->N)*(currRing->N) &&
    1859          ((intvec*) h->next->next->Data())->length() != (currRing->N)*(currRing->N) ))
     1860      if(((intvec*) h->next->Data())->length() != currRing->N &&
     1861         ((intvec*) h->next->Data())->length() != (currRing->N)*(currRing->N) &&
     1862         ((intvec*) h->next->next->Data())->length() != currRing->N &&
     1863         ((intvec*) h->next->next->Data())->length() != (currRing->N)*(currRing->N) )
    18601864      {
    18611865        Werror("system(\"Mrwalk\" ...) intvecs not of length %d or %d\n",
     
    18681872      int arg4 = (int)(long) h->next->next->next->Data();
    18691873      int arg5 = (int)(long) h->next->next->next->next->Data();
    1870       ring arg6 = (ring) h->next->next->next->next->next->Data();
    1871       ideal result = (ideal) Mrwalk(arg1, arg2, arg3, arg4, arg5, arg6);
     1874      int arg6 = (int)(long) h->next->next->next->next->next->Data();
     1875      int arg7 = (int)(long) h->next->next->next->next->next->next->Data();
     1876      ideal result = (ideal) Mrwalk(arg1, arg2, arg3, arg4, arg5, arg6, arg7);
    18721877      res->rtyp = IDEAL_CMD;
    18731878      res->data =  result;
     
    19311936    if (strcmp(sys_cmd, "Mfwalk") == 0)
    19321937    {
    1933       const short t[]={3,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD};
     1938      const short t[]={4,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD,INT_CMD};
    19341939      if (!iiCheckTypes(h,t,1)) return TRUE;
    19351940      if (((intvec*) h->next->Data())->length() != currRing->N &&
     
    19381943        Werror("system(\"Mfwalk\" ...) intvecs not of length %d\n",
    19391944                 currRing->N);
    1940         return TRUE;
    1941       }
    1942       ideal arg1 = (ideal) h->Data();
    1943       intvec* arg2 = (intvec*) h->next->Data();
    1944       intvec* arg3   =  (intvec*) h->next->next->Data();
    1945       ideal result = (ideal) Mfwalk(arg1, arg2, arg3);
    1946       res->rtyp = IDEAL_CMD;
    1947       res->data =  result;
    1948       return FALSE;
    1949     }
    1950     else
    1951   #endif
    1952   /*==================== Mfrwalk =================*/
    1953   #ifdef HAVE_WALK
    1954     if (strcmp(sys_cmd, "Mfrwalk") == 0)
    1955     {
    1956       const short t[]={4,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD,INT_CMD};
    1957       if (!iiCheckTypes(h,t,1)) return TRUE;
    1958       if (((intvec*) h->next->Data())->length() != currRing->N &&
    1959           ((intvec*) h->next->next->Data())->length() != currRing->N)
    1960       {
    1961         Werror("system(\"Mfrwalk\" ...) intvecs not of length %d\n",currRing->N);
    19621945        return TRUE;
    19631946      }
     
    19661949      intvec* arg3 = (intvec*) h->next->next->Data();
    19671950      int arg4 = (int)(long) h->next->next->next->Data();
    1968       ideal result = (ideal) Mfrwalk(arg1, arg2, arg3, arg4);
     1951      ideal result = (ideal) Mfwalk(arg1, arg2, arg3, arg4);
    19691952      res->rtyp = IDEAL_CMD;
    19701953      res->data =  result;
     
    19721955    }
    19731956    else
     1957  #endif
     1958  /*==================== Mfrwalk =================*/
     1959  #ifdef HAVE_WALK
     1960    if (strcmp(sys_cmd, "Mfrwalk") == 0)
     1961    {
     1962      const short t[]={5,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD,INT_CMD,INT_CMD};
     1963      if (!iiCheckTypes(h,t,1)) return TRUE;
     1964      if (((intvec*) h->next->Data())->length() != currRing->N &&
     1965          ((intvec*) h->next->next->Data())->length() != currRing->N)
     1966      {
     1967        Werror("system(\"Mfrwalk\" ...) intvecs not of length %d\n",currRing->N);
     1968        return TRUE;
     1969      }
     1970      ideal arg1 = (ideal) h->Data();
     1971      intvec* arg2 = (intvec*) h->next->Data();
     1972      intvec* arg3 = (intvec*) h->next->next->Data();
     1973      int arg4 = (int)(long) h->next->next->next->Data();
     1974      int arg5 = (int)(long) h->next->next->next->next->Data();
     1975      ideal result = (ideal) Mfrwalk(arg1, arg2, arg3, arg4, arg5);
     1976      res->rtyp = IDEAL_CMD;
     1977      res->data =  result;
     1978      return FALSE;
     1979    }
     1980    else
    19741981  /*==================== Mprwalk =================*/
    19751982    if (strcmp(sys_cmd, "Mprwalk") == 0)
    19761983    {
    1977       const short t[]={7,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD,INT_CMD,INT_CMD,INT_CMD,RING_CMD};
     1984      const short t[]={9,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD,INT_CMD,INT_CMD,INT_CMD,INT_CMD,INT_CMD,INT_CMD};
    19781985      if (!iiCheckTypes(h,t,1)) return TRUE;
    1979       if (((intvec*) h->next->Data())->length() != currRing->N &&
    1980           ((intvec*) h->next->next->Data())->length() != currRing->N )
    1981       {
    1982         Werror("system(\"Mrwalk\" ...) intvecs not of length %d\n",
    1983                currRing->N);
     1986      if((((intvec*) h->next->Data())->length() != currRing->N &&
     1987         ((intvec*) h->next->next->Data())->length() != currRing->N ) &&
     1988         (((intvec*) h->next->Data())->length() != (currRing->N)*(currRing->N) &&
     1989         ((intvec*) h->next->next->Data())->length() != (currRing->N)*(currRing->N) ))
     1990      {
     1991        Werror("system(\"Mrwalk\" ...) intvecs not of length %d or %d\n",
     1992               currRing->N,(currRing->N)*(currRing->N));
    19841993        return TRUE;
    19851994      }
     
    19901999      int arg5 = (int)(long) h->next->next->next->next->Data();
    19912000      int arg6 = (int)(long) h->next->next->next->next->next->Data();
    1992       ring arg7 = (ring) h->next->next->next->next->next->next->Data();
    1993       ideal result = (ideal) Mprwalk(arg1, arg2, arg3, arg4, arg5, arg6, arg7);
     2001      int arg7 = (int)(long) h->next->next->next->next->next->next->Data();
     2002      int arg8 = (int)(long) h->next->next->next->next->next->next->next->Data();
     2003      int arg9 = (int)(long) h->next->next->next->next->next->next->next->next->Data();
     2004      ideal result = (ideal) Mprwalk(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
    19942005      res->rtyp = IDEAL_CMD;
    19952006      res->data =  result;
  • Singular/walk.cc

    rf2ba60d racccd2  
    431431#endif
    432432
    433 #ifdef CHECK_IDEAL_MWALK
     433//#ifdef CHECK_IDEAL_MWALK
    434434static void idString(ideal L, const char* st)
    435435{
     
    443443  Print(" %s;", pString(L->m[nL-1]));
    444444}
    445 #endif
     445//#endif
    446446
    447447#if defined(CHECK_IDEAL_MWALK) || defined(ENDWALKS)
     
    31553155    else
    31563156    {
    3157       rChangeCurrRing(VMrDefault(curr_weight)); //Aenderung
     3157      rChangeCurrRing(VMrDefault(curr_weight));
    31583158    }
    31593159    newRing = currRing;
     
    39113911    else
    39123912    {
    3913       rChangeCurrRing(VMrDefault(curr_weight)); //Aenderung
     3913      rChangeCurrRing(VMrDefault(curr_weight));
    39143914    }
    39153915    newRing = currRing;
     
    41724172    else
    41734173    {
    4174       rChangeCurrRing(VMrDefault(curr_weight)); // Aenderung
     4174      rChangeCurrRing(VMrDefault(curr_weight));
    41754175    }
    41764176    newRing = currRing;
     
    50005000      M=kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight);
    50015001      delete hilb_func;
    5002 #endif // BUCHBERGER_ALG
     5002#endif
    50035003      tstd = tstd + clock() - to;
    50045004
     
    50095009
    50105010      to = clock();
    5011       // compute a representation of the generators of submod (M) with respect to those of mod (Gomega). Gomega is a reduced Groebner basis w.r.t. the current ring.
     5011      // compute a representation of the generators of submod (M) with respect
     5012      // to those of mod (Gomega).
     5013      // Gomega is a reduced Groebner basis w.r.t. the current ring.
    50125014      F = MLifttwoIdeal(Gomega2, M1, G);
    50135015      tlift = tlift + clock() - to;
     
    51065108 * THE GROEBNER WALK ALGORITHM *
    51075109 *******************************/
    5108 ideal Mwalk(ideal Go, intvec* orig_M, intvec* target_M, ring baseRing)
     5110ideal Mwalk(ideal Go, intvec* orig_M, intvec* target_M,
     5111            ring baseRing, int reduction, int printout)
    51095112{
    51105113  BITSET save1 = si_opt_1; // save current options
    5111   //si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis
    5112   //si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions
    5113   //si_opt_1|=(Sy_bit(OPT_REDTAIL)|Sy_bit(OPT_REDSB));
     5114  if(reduction == 0)
     5115  {
     5116    si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis
     5117    //si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions
     5118  }
    51145119  Set_Error(FALSE);
    51155120  Overflow_Error = FALSE;
     
    51525157#endif
    51535158  rComplete(currRing);
    5154 #ifdef CHECK_IDEAL_MWALK
    5155     idString(Go,"Go");
    5156 #endif
     5159//#ifdef CHECK_IDEAL_MWALK
     5160  if(printout > 2)
     5161  {
     5162    idString(Go,"//** Mwalk: Go");
     5163  }
     5164//#endif
    51575165#ifdef TIME_TEST
    51585166  to = clock();
     
    51815189    to = clock();
    51825190#endif
    5183 #ifdef CHECK_IDEAL_MWALK
    5184     idString(G,"G");
    5185 #endif
     5191//#ifdef CHECK_IDEAL_MWALK
     5192    if(printout > 2)
     5193    {
     5194      idString(G,"//** Mwalk: G");
     5195    }
     5196//#endif
    51865197    Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector"
    51875198#ifdef TIME_TEST
    51885199    tif = tif + clock()-to; //time for computing initial form ideal
    51895200#endif
    5190 #ifdef CHECK_IDEAL_MWALK
    5191     idString(Gomega,"Gomega");
    5192 #endif
     5201//#ifdef CHECK_IDEAL_MWALK
     5202    if(printout > 1)
     5203    {
     5204      idString(Gomega,"//** Mwalk: Gomega");
     5205    }
     5206//#endif
    51935207#ifndef  BUCHBERGER_ALG
    51945208    if(isNolVector(curr_weight) == 0)
     
    52405254#endif
    52415255    idSkipZeroes(M);
    5242 #ifdef CHECK_IDEAL_MWALK
    5243     PrintS("\n//** Mwalk: computed M.\n");
    5244     idString(M, "M");
    5245 #endif
     5256//#ifdef CHECK_IDEAL_MWALK
     5257    if(printout > 2)
     5258    {
     5259      idString(M, "//** Mwalk: M");
     5260    }
     5261//#endif
    52465262    //change the ring to baseRing
    52475263    rChangeCurrRing(baseRing);
     
    52585274    tlift = tlift + clock() - to;
    52595275#endif
    5260 #ifdef CHECK_IDEAL_MWALK
    5261     idString(F, "F");
    5262 #endif
     5276//#ifdef CHECK_IDEAL_MWALK
     5277    if(printout > 2)
     5278    {
     5279      idString(F, "//** Mwalk: F");
     5280    }
     5281//#endif
    52635282    idDelete(&Gomega2);
    52645283    idDelete(&M1);
     
    52755294#endif
    52765295    idSkipZeroes(G);
    5277 #ifdef CHECK_IDEAL_MWALK
    5278     idString(G, "G");
    5279 #endif
     5296//#ifdef CHECK_IDEAL_MWALK
     5297    if(printout > 2)
     5298    {
     5299      idString(G, "//** Mwalk: G");
     5300    }
     5301//#endif
    52805302#ifdef TIME_TEST
    52815303    to = clock();
     
    52855307    tnw = tnw + clock() - to;
    52865308#endif
    5287 #ifdef PRINT_VECTORS
    5288     MivString(curr_weight, target_weight, next_weight);
    5289 #endif
    5290     if(MivComp(next_weight, ivNull) == 1 || MivComp(target_weight,curr_weight) == 1)// || test_w_in_ConeCC(G, target_weight) == 1 || MivComp(next_weight,curr_weight) == 1)
     5309//#ifdef PRINT_VECTORS
     5310    if(printout > 0)
     5311    {
     5312      MivString(curr_weight, target_weight, next_weight);
     5313    }
     5314//#endif
     5315    if(MivComp(next_weight, ivNull) == 1 || MivComp(target_weight,curr_weight) == 1)// || test_w_in_ConeCC(G, target_weight) == 1
    52915316    {
    52925317#ifdef CHECK_IDEAL_MWALK
     
    53055330      Gomega1 = idrMoveR(Gomega, baseRing,currRing);
    53065331      idDelete(&Gomega);
    5307 #ifdef CHECK_IDEAL_MWALK
    5308       idString(Gomega1, "Gomega");
    5309 #endif
     5332//#ifdef CHECK_IDEAL_MWALK
     5333      if(printout > 1)
     5334      {
     5335        idString(Gomega1, "//** Mwalk: Gomega");
     5336      }
     5337//#endif
    53105338      M = kStd(Gomega1,NULL,testHomog,NULL,NULL,0,0,NULL);
    5311 #ifdef CHECK_IDEAL_MWALK
    5312       idString(M,"M");
    5313 #endif
     5339//#ifdef CHECK_IDEAL_MWALK
     5340      if(printout > 1)
     5341      {
     5342        idString(M,"//** Mwalk: M");
     5343      }
     5344//#endif
    53145345      rChangeCurrRing(baseRing);
    53155346      M1 =  idrMoveR(M, newRing,currRing);
     
    53185349      idDelete(&Gomega1);
    53195350      F = MLifttwoIdeal(Gomega2, M1, G);
    5320 #ifdef CHECK_IDEAL_MWALK
    5321       idString(F,"F");
    5322 #endif
     5351//#ifdef CHECK_IDEAL_MWALK
     5352    if(printout > 2)
     5353    {
     5354      idString(F,"//** Mwalk: F");
     5355    }
     5356//#endif
    53235357      idDelete(&Gomega2);
    53245358      idDelete(&M1);
     
    53325366      to = clock();
    53335367#endif
    5334  //     if(si_opt_1 == (Sy_bit(OPT_REDSB)))
    5335   //    {
    5336         G = kInterRedCC(G,NULL); //reduce the Groebner basis <G> w.r.t. currRing, if option(redSB) is set
    5337   //    }
     5368//   if(si_opt_1 == (Sy_bit(OPT_REDSB))){
     5369      G = kInterRedCC(G,NULL); //interreduce the Groebner basis <G> w.r.t. currRing
     5370//  }
    53385371#ifdef TIME_TEST
    53395372      tred = tred + clock() - to;
     
    53425375      delete next_weight;
    53435376      break;
    5344 #ifdef CHECK_IDEAL_MWALK
    5345       PrintS("\n//** Mwalk: last cone.\n");
    5346 #endif
    5347     }
    5348 #ifdef CHECK_IDEAL_MWALK
    5349     PrintS("\n//** Mwalk: update weight vectors.\n");
    5350 #endif
     5377    }
    53515378    for(i=nV-1; i>=0; i--)
    53525379    {
     
    53695396#endif
    53705397#ifdef TIME_TEST
    5371   Print("\n//** Mwalk: Groebner Walk took %d steps.\n", nstep);
    53725398  TimeString(tinput, tostd, tif, tstd, tlift, tred, tnw, nstep);
    5373   Print("\n//** Mwalk: Ergebnis.\n");
    53745399  //Print("\n// pSetm_Error = (%d)", ErrorCheck());
    53755400  //Print("\n// Overflow_Error? (%d)\n", Overflow_Error);
    53765401#endif
     5402  Print("\n//** Mwalk: Groebner Walk took %d steps.\n", nstep);
    53775403  return(result);
    53785404}
    53795405
    53805406// 07.11.2012
    5381 // THE RANDOM WALK ALGORITHM  ideal Go, intvec* orig_M, intvec* target_M, ring baseRing
    5382 ideal Mrwalk(ideal Go, intvec* orig_M, intvec* target_M, int weight_rad, int pert_deg, ring baseRing)
     5407// THE RANDOM WALK ALGORITHM
     5408ideal Mrwalk(ideal Go, intvec* orig_M, intvec* target_M, int weight_rad, int pert_deg,
     5409             int reduction, int printout)
    53835410{
    53845411  BITSET save1 = si_opt_1; // save current options
    5385   //si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis
    5386   //si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions
    5387   //si_opt_1|=(Sy_bit(OPT_REDTAIL)|Sy_bit(OPT_REDSB));
     5412  if(reduction == 0)
     5413  {
     5414    si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis
     5415    //si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions
     5416    //si_opt_1|=(Sy_bit(OPT_REDTAIL)|Sy_bit(OPT_REDSB));
     5417  }
    53885418  Set_Error(FALSE);
    53895419  Overflow_Error = FALSE;
     
    53955425#endif
    53965426  nstep=0;
    5397   int i,nwalk,endwalks = 0;
    5398   int nV = baseRing->N;
     5427  int i,polylength,nwalk,endwalks = 0;
     5428  int nV = currRing->N;
    53995429
    54005430  ideal Gomega, M, F, Gomega1, Gomega2, M1; //, F1;
    54015431  ring newRing;
    5402   ring XXRing = baseRing;
     5432  ring baseRing = currRing;
     5433  ring XXRing = currRing;
    54035434  intvec* ivNull = new intvec(nV);
    54045435  intvec* curr_weight = new intvec(nV);
     
    54065437  intvec* exivlp = Mivlp(nV);
    54075438  intvec* tmp_weight = new intvec(nV);
     5439  intvec* next_weight= new intvec(nV);
    54085440  for(i=0; i<nV; i++)
    54095441  {
     
    54265458#endif
    54275459  rComplete(currRing);
    5428 #ifdef CHECK_IDEAL_MWALK
    5429     idString(Go,"Go");
    5430 #endif
    54315460#ifdef TIME_TEST
    54325461  to = clock();
    54335462#endif
    5434      if(orig_M->length() == nV)
    5435       {
    5436         newRing = VMrDefault(curr_weight); // define a new ring with ordering "(a(curr_weight),lp)
    5437       }
    5438       else
    5439       {
    5440         newRing = VMatrDefault(orig_M);
    5441       }
     5463  if(orig_M->length() == nV)
     5464  {
     5465    newRing = VMrDefault(curr_weight); // define a new ring with ordering "(a(curr_weight),lp)
     5466  }
     5467  else
     5468  {
     5469    newRing = VMatrDefault(orig_M);
     5470  }
    54425471  rChangeCurrRing(newRing);
    54435472  ideal G = MstdCC(idrMoveR(Go,baseRing,currRing));
     
    54555484    to = clock();
    54565485#endif
    5457 #ifdef CHECK_IDEAL_MWALK
    5458     idString(G,"G");
    5459 #endif
     5486//#ifdef CHECK_IDEAL_MWALK
     5487    if(printout > 2)
     5488    {
     5489      idString(G,"//** Mrwalk: G");
     5490    }
     5491//#endif
    54605492    Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector"
     5493    //polylength = 1 if there is a polynomial in Gomega with at least 3 monomials and 0 otherwise
     5494    polylength = lengthpoly(Gomega);
    54615495#ifdef TIME_TEST
    54625496    tif = tif + clock()-to; //time for computing initial form ideal
    54635497#endif
    5464 #ifdef CHECK_IDEAL_MWALK
    5465     idString(Gomega,"Gomega");
    5466 #endif
     5498//#ifdef CHECK_IDEAL_MWALK
     5499    if(printout > 1)
     5500    {
     5501      idString(Gomega,"//** Mrwalk: Gomega");
     5502    }
     5503//#endif
    54675504#ifndef  BUCHBERGER_ALG
    54685505    if(isNolVector(curr_weight) == 0)
     
    55145551#endif
    55155552    idSkipZeroes(M);
    5516 #ifdef CHECK_IDEAL_MWALK
    5517     PrintS("\n//** Mwalk: computed M.\n");
    5518     idString(M, "M");
    5519 #endif
     5553//#ifdef CHECK_IDEAL_MWALK
     5554    if(printout > 2)
     5555    {
     5556      idString(M, "//** Mrwalk: M");
     5557    }
     5558//#endif
    55205559    //change the ring to baseRing
    55215560    rChangeCurrRing(baseRing);
     
    55275566    to = clock();
    55285567#endif
    5529     // compute a representation of the generators of submod (M) with respect to those of mod (Gomega), where Gomega is a reduced Groebner basis w.r.t. the current ring
     5568    // compute a representation of the generators of submod (M) with respect to those of mod (Gomega),
     5569    // where Gomega is a reduced Groebner basis w.r.t. the current ring
    55305570    F = MLifttwoIdeal(Gomega2, M1, G);
    55315571#ifdef TIME_TEST
    55325572    tlift = tlift + clock() - to;
    55335573#endif
    5534 #ifdef CHECK_IDEAL_MWALK
    5535     idString(F, "F");
    5536 #endif
     5574//#ifdef CHECK_IDEAL_MWALK
     5575    if(printout > 2)
     5576    {
     5577      idString(F, "//** Mrwalk: F");
     5578    }
     5579//#endif
    55375580    idDelete(&Gomega2);
    55385581    idDelete(&M1);
     
    55435586#ifdef TIME_TEST
    55445587    to = clock();
    5545 #endif
    5546     //G = kStd(F1,NULL,testHomog,NULL,NULL,0,0,NULL);
    5547 #ifdef TIME_TEST
    55485588    tstd = tstd + clock() - to;
    55495589#endif
    55505590    idSkipZeroes(G);
    5551 #ifdef CHECK_IDEAL_MWALK
    5552     idString(G, "G");
    5553 #endif
     5591//#ifdef CHECK_IDEAL_MWALK
     5592    if(printout > 2)
     5593    {
     5594      idString(G, "//** Mrwalk: G");
     5595    }
     5596//#endif
    55545597#ifdef TIME_TEST
    55555598    to = clock();
    55565599#endif
    5557     intvec* next_weight = MWalkRandomNextWeight(G, curr_weight, target_weight, weight_rad, pert_deg);//next_weight = MwalkNextWeightCC(curr_weight,target_weight,G);
     5600    next_weight = MwalkNextWeightCC(curr_weight,target_weight,G);
     5601    if(polylength > 0)
     5602    {
     5603      //there is a polynomial in Gomega with at least 3 monomials,
     5604      //low-dimensional facet of the cone
     5605      delete next_weight;
     5606      next_weight = MWalkRandomNextWeight(G, curr_weight, target_weight, weight_rad, pert_deg);
     5607    }
    55585608#ifdef TIME_TEST
    55595609    tnw = tnw + clock() - to;
    55605610#endif
    5561 #ifdef PRINT_VECTORS
    5562     MivString(curr_weight, target_weight, next_weight);
    5563 #endif
     5611//#ifdef PRINT_VECTORS
     5612    if(printout > 0)
     5613    {
     5614      MivString(curr_weight, target_weight, next_weight);
     5615    }
     5616//#endif
    55645617    if(MivComp(next_weight, ivNull) == 1 || MivComp(target_weight,curr_weight) == 1)// || test_w_in_ConeCC(G, target_weight) == 1 || MivComp(next_weight,curr_weight) == 1)
    55655618    {
     
    55685621#endif
    55695622      Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector"
     5623//#ifdef CHECK_IDEAL_MWALK
     5624      if(printout > 1)
     5625      {
     5626        idString(Gomega, "//** Mrwalk: Gomega");
     5627      }
     5628//#endif
    55705629      if(target_M->length() == nV)
    55715630      {
     
    55795638      Gomega1 = idrMoveR(Gomega, baseRing,currRing);
    55805639      idDelete(&Gomega);
    5581 #ifdef CHECK_IDEAL_MWALK
    5582       idString(Gomega1, "Gomega");
    5583 #endif
    55845640      M = kStd(Gomega1,NULL,testHomog,NULL,NULL,0,0,NULL);
    5585 #ifdef CHECK_IDEAL_MWALK
    5586       idString(M,"M");
    5587 #endif
     5641//#ifdef CHECK_IDEAL_MWALK
     5642      if(printout > 2)
     5643      {
     5644        idString(M,"//** Mrwalk: M");
     5645      }
     5646//#endif
    55885647      rChangeCurrRing(baseRing);
    55895648      M1 =  idrMoveR(M, newRing,currRing);
     
    55925651      idDelete(&Gomega1);
    55935652      F = MLifttwoIdeal(Gomega2, M1, G);
    5594 #ifdef CHECK_IDEAL_MWALK
    5595       idString(F,"F");
    5596 #endif
    55975653      idDelete(&Gomega2);
    55985654      idDelete(&M1);
     
    56015657      idDelete(&F);
    56025658      baseRing = currRing;
    5603       si_opt_1 = save1; //set original options, e. g. option(RedSB)
    56045659      idSkipZeroes(G);
    56055660#ifdef TIME_TEST
    56065661      to = clock();
    56075662#endif
    5608  //     if(si_opt_1 == (Sy_bit(OPT_REDSB)))
    5609   //    {
    5610         //G = kInterRedCC(G,NULL); //reduce the Groebner basis <G> w.r.t. currRing, if option(redSB) is set
    5611   //    }
     5663//#ifdef CHECK_IDEAL_MWALK
     5664      if(printout > 2)
     5665      {
     5666        idString(G,"//** Mrwalk: G");
     5667      }
     5668/*#endif
     5669      if(si_opt_1 == (Sy_bit(OPT_REDSB)))
     5670      {*/
     5671        G = kInterRedCC(G,NULL); //interreduce the Groebner basis <G> w.r.t. currRing
     5672//      }
    56125673#ifdef TIME_TEST
    56135674      tred = tred + clock() - to;
     
    56165677      delete next_weight;
    56175678      break;
    5618 #ifdef CHECK_IDEAL_MWALK
    5619       PrintS("\n//** Mwalk: last cone.\n");
    5620 #endif
    5621     }
    5622 #ifdef CHECK_IDEAL_MWALK
    5623     PrintS("\n//** Mwalk: update weight vectors.\n");
    5624 #endif
     5679    }
    56255680    for(i=nV-1; i>=0; i--)
    56265681    {
     
    56305685    delete next_weight;
    56315686  }
     5687  baseRing = currRing;
    56325688  rChangeCurrRing(XXRing);
    56335689  ideal result = idrMoveR(G,baseRing,currRing);
    56345690  idDelete(&G);
    5635 /*#ifdef CHECK_IDEAL_MWALK
    5636   pDelete(&p);
    5637 #endif*/
     5691  si_opt_1 = save1; //set original options, e. g. option(RedSB)
    56385692  delete tmp_weight;
    56395693  delete ivNull;
     
    56425696  delete last_omega;
    56435697#endif
     5698  Print("\n//** Mrwalk: Groebner Walk took %d steps.\n", nstep);
    56445699#ifdef TIME_TEST
    5645   Print("\n//** Mwalk: Groebner Walk took %d steps.\n", nstep);
    56465700  TimeString(tinput, tostd, tif, tstd, tlift, tred, tnw, nstep);
    5647   Print("\n//** Mwalk: Ergebnis.\n");
    56485701  //Print("\n// pSetm_Error = (%d)", ErrorCheck());
    56495702  //Print("\n// Overflow_Error? (%d)\n", Overflow_Error);
     
    57925845// use kStd, if nP = 0, else call LastGB
    57935846ideal Mpwalk(ideal Go, int op_deg, int tp_deg,intvec* curr_weight,
    5794              intvec* target_weight, int nP)
    5795 {
     5847             intvec* target_weight, int nP, int reduction, int printout)
     5848{
     5849  BITSET save1 = si_opt_1; // save current options
     5850  if(reduction == 0)
     5851  {
     5852    si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis
     5853    //si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions
     5854    //si_opt_1|=(Sy_bit(OPT_REDTAIL)|Sy_bit(OPT_REDSB));
     5855  }
    57965856  Set_Error(FALSE  );
    57975857  Overflow_Error = FALSE;
     
    58315891  ring XXRing = currRing;
    58325892
    5833 
    58345893  to = clock();
    58355894  // perturbs the original vector
     
    58935952    G = idrMoveR(ssG, TargetRing,currRing);
    58945953  }
    5895   /*
    5896     Print("\n// Perturbationwalkalg. vom Gradpaar (%d,%d):",op_deg,tp_deg);
    5897     ivString(curr_weight, "new sigma");
    5898     ivString(target_weight, "new tau");
    5899   */
     5954    if(printout > 0)
     5955    {
     5956      Print("\n//** Mpwalk: Perturbation Walk of degree (%d,%d):",op_deg,tp_deg);
     5957      ivString(curr_weight, "//** Mpwalk: new current weight");
     5958      ivString(target_weight, "//** Mpwalk: new target weight");
     5959    }
    59005960  while(1)
    59015961  {
     
    59055965       "curr_weight" */
    59065966    Gomega = MwalkInitialForm(G, curr_weight);
    5907 
     5967//#ifdef CHECK_IDEAL_MWALK
     5968      if(printout > 1)
     5969      {
     5970        idString(Gomega,"//** Mpwalk: Gomega");
     5971      }
     5972//#endif
    59085973
    59095974#ifdef ENDWALKS
    5910     if(endwalks == 1){
     5975    if(endwalks == 1)
     5976    {
    59115977      Print("\n// ring r%d = %s;\n", nstep, rString(currRing));
    59125978      idElements(G, "G");
    5913       // idElements(Gomega, "Gw");
    59145979      headidString(G, "G");
    5915       //headidString(Gomega, "Gw");
    59165980    }
    59175981#endif
     
    59596023    M=kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight);
    59606024    delete hilb_func;
    5961 #endif // BUCHBERGER_ALG
     6025#endif
     6026//#ifdef CHECK_IDEAL_MWALK
     6027      if(printout > 2)
     6028      {
     6029        idString(M,"//** Mpwalk: M");
     6030      }
     6031//#endif
    59626032
    59636033    if(endwalks == 1){
     
    59756045    M1 =  idrMoveR(M, newRing,currRing);
    59766046    Gomega2 =  idrMoveR(Gomega1, newRing,currRing);
    5977 
    5978     //if(endwalks==1)  PrintS("\n// Lifting is working:..");
    59796047
    59806048    to=clock();
     
    59886056      xtlift=clock()-to;
    59896057
     6058//#ifdef CHECK_IDEAL_MWALK
     6059    if(printout > 2)
     6060    {
     6061      idString(F,"//** Mpwalk: F");
     6062    }
     6063//#endif
     6064
    59906065    idDelete(&M1);
    59916066    idDelete(&Gomega2);
     
    59956070    rChangeCurrRing(newRing);
    59966071    F1 = idrMoveR(F, oldRing,currRing);
    5997 
    5998     //if(endwalks==1)PrintS("\n// InterRed is working now:");
    59996072
    60006073    to=clock();
     
    60126085
    60136086    to=clock();
    6014     /* compute a next weight vector */
     6087    // compute a next weight vector
    60156088    next_weight = MkInterRedNextWeight(curr_weight,target_weight, G);
    60166089    tnw=tnw+clock()-to;
    6017 #ifdef PRINT_VECTORS
    6018     MivString(curr_weight, target_weight, next_weight);
    6019 #endif
     6090//#ifdef PRINT_VECTORS
     6091    if(printout > 2)
     6092    {
     6093      MivString(curr_weight, target_weight, next_weight);
     6094    }
     6095//#endif
    60206096
    60216097    if(Overflow_Error == TRUE)
     
    61096185    Eresult = idrMoveR(G, newRing,currRing);
    61106186  }
     6187  si_opt_1 = save1; //set original options, e. g. option(RedSB)
    61116188  delete ivNull;
    61126189  if(tp_deg != 1)
     
    61236200             tnw+xtnw);
    61246201
    6125   Print("\n// pSetm_Error = (%d)", ErrorCheck());
    6126   Print("\n// It took %d steps and Overflow_Error? (%d)\n", nstep,  Overflow_Error);
    6127 #endif
     6202  //Print("\n// pSetm_Error = (%d)", ErrorCheck());
     6203  //Print("\n// It took %d steps and Overflow_Error? (%d)\n", nstep,  Overflow_Error);
     6204#endif
     6205  Print("\n//** Mpwalk: Perturbation Walk took %d steps.\n", nstep);
     6206  return(Eresult);
     6207}
     6208
     6209/*******************************************************
     6210 * THE PERTURBATION WALK ALGORITHM WITH RANDOM ELEMENT *
     6211 *******************************************************/
     6212ideal Mprwalk(ideal Go, intvec* orig_M, intvec* target_M, int weight_rad,
     6213              int op_deg, int tp_deg, int nP, int reduction, int printout)
     6214{
     6215  BITSET save1 = si_opt_1; // save current options
     6216  if(reduction == 0)
     6217  {
     6218    si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis
     6219    //si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions
     6220    //si_opt_1|=(Sy_bit(OPT_REDTAIL)|Sy_bit(OPT_REDSB));
     6221  }
     6222  Set_Error(FALSE);
     6223  Overflow_Error = FALSE;
     6224  //Print("// pSetm_Error = (%d)", ErrorCheck());
     6225
     6226  clock_t  tinput, tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0;
     6227  xtextra=0;
     6228  xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0;
     6229  tinput = clock();
     6230
     6231  clock_t tim;
     6232
     6233  nstep = 0;
     6234  int i, ntwC=1, ntestw=1, polylength, nV = currRing->N;
     6235  int endwalks=0;
     6236
     6237  ideal Gomega, M, F, G, Gomega1, Gomega2, M1,F1,Eresult,ssG;
     6238  ring newRing, oldRing, TargetRing;
     6239  intvec* iv_M_dp;
     6240  intvec* iv_M_lp;
     6241  intvec* exivlp = Mivlp(nV);
     6242  intvec* curr_weight = new intvec(nV);
     6243  intvec* target_weight = new intvec(nV);
     6244  for(i=0; i<nV; i++)
     6245  {
     6246    (*curr_weight)[i] = (*orig_M)[i];
     6247    (*target_weight)[i] = (*target_M)[i];
     6248  }
     6249  intvec* orig_target = target_weight;
     6250  intvec* pert_target_vector = target_weight;
     6251  intvec* ivNull = new intvec(nV);
     6252  intvec* iv_dp = MivUnit(nV);// define (1,1,...,1)
     6253#ifndef BUCHBERGER_ALG
     6254  intvec* hilb_func;
     6255#endif
     6256  intvec* next_weight;
     6257
     6258  // to avoid (1,0,...,0) as the target vector
     6259  intvec* last_omega = new intvec(nV);
     6260  for(i=nV-1; i>0; i--)
     6261    (*last_omega)[i] = 1;
     6262  (*last_omega)[0] = 10000;
     6263
     6264  ring XXRing = currRing;
     6265
     6266  to = clock();
     6267  // perturbs the original vector
     6268  if(orig_M->length() == nV)
     6269  {
     6270    if(MivComp(curr_weight, iv_dp) == 1) //rOrdStr(currRing) := "dp"
     6271    {
     6272      G = MstdCC(Go);
     6273      tostd = clock()-to;
     6274      if(op_deg != 1)
     6275      {
     6276        iv_M_dp = MivMatrixOrderdp(nV);
     6277        //ivString(iv_M_dp, "iv_M_dp");
     6278        curr_weight = MPertVectors(G, iv_M_dp, op_deg);
     6279      }
     6280    }
     6281    else
     6282    {
     6283      //define ring order := (a(curr_weight),lp);
     6284      if (rParameter(currRing) != NULL)
     6285        DefRingPar(curr_weight);
     6286      else
     6287        rChangeCurrRing(VMrDefault(curr_weight));
     6288
     6289      G = idrMoveR(Go, XXRing,currRing);
     6290      G = MstdCC(G);
     6291      tostd = clock()-to;
     6292      if(op_deg != 1)
     6293      {
     6294        iv_M_dp = MivMatrixOrder(curr_weight);
     6295        curr_weight = MPertVectors(G, iv_M_dp, op_deg);
     6296      }
     6297    }
     6298  }
     6299  else
     6300  {
     6301    rChangeCurrRing(VMatrDefault(orig_M));
     6302    G = idrMoveR(Go, XXRing,currRing);
     6303    G = MstdCC(G);
     6304    tostd = clock()-to;
     6305    if(op_deg != 1)
     6306    {
     6307      curr_weight = MPertVectors(G, orig_M, op_deg);
     6308    }
     6309  }
     6310
     6311  delete iv_dp;
     6312  if(op_deg != 1) delete iv_M_dp;
     6313
     6314  ring HelpRing = currRing;
     6315
     6316  // perturbs the target weight vector
     6317  if(target_M->length() == nV)
     6318  {
     6319    if(tp_deg > 1 && tp_deg <= nV)
     6320    {
     6321      if (rParameter(currRing) != NULL)
     6322        DefRingPar(target_weight);
     6323      else
     6324        rChangeCurrRing(VMrDefault(target_weight));
     6325
     6326      TargetRing = currRing;
     6327      ssG = idrMoveR(G,HelpRing,currRing);
     6328      if(MivSame(target_weight, exivlp) == 1)
     6329      {
     6330        iv_M_lp = MivMatrixOrderlp(nV);
     6331        //ivString(iv_M_lp, "iv_M_lp");
     6332        //target_weight = MPertVectorslp(ssG, iv_M_lp, tp_deg);
     6333        target_weight = MPertVectors(ssG, iv_M_lp, tp_deg);
     6334      }
     6335      else
     6336      {
     6337        iv_M_lp = MivMatrixOrder(target_weight);
     6338        //target_weight = MPertVectorslp(ssG, iv_M_lp, tp_deg);
     6339        target_weight = MPertVectors(ssG, iv_M_lp, tp_deg);
     6340      }
     6341      delete iv_M_lp;
     6342      pert_target_vector = target_weight;
     6343      rChangeCurrRing(HelpRing);
     6344      G = idrMoveR(ssG, TargetRing,currRing);
     6345    }
     6346  }
     6347  else
     6348  {
     6349    if(tp_deg > 1 && tp_deg <= nV)
     6350    {
     6351      rChangeCurrRing(VMatrDefault(target_M));
     6352      TargetRing = currRing;
     6353      ssG = idrMoveR(G,HelpRing,currRing);
     6354      target_weight = MPertVectors(ssG, target_M, tp_deg);
     6355    }
     6356  }
     6357  if(printout > 0)
     6358  {
     6359    Print("\n//** Mprwalk: Random Perturbation Walk of degree (%d,%d):",op_deg,tp_deg);
     6360    ivString(curr_weight, "//** Mprwalk: new current weight");
     6361    ivString(target_weight, "//** Mprwalk: new target weight");
     6362  }
     6363  while(1)
     6364  {
     6365    nstep ++;
     6366    to = clock();
     6367    /* compute an initial form ideal of <G> w.r.t. the weight vector
     6368       "curr_weight" */
     6369    Gomega = MwalkInitialForm(G, curr_weight);
     6370//#ifdef CHECK_IDEAL_MWALK
     6371    if(printout > 1)
     6372    {
     6373      idString(Gomega,"//** Mprwalk: Gomega");
     6374    }
     6375//#endif
     6376    polylength = lengthpoly(Gomega);
     6377#ifdef ENDWALKS
     6378    if(endwalks == 1)
     6379    {
     6380      Print("\n// ring r%d = %s;\n", nstep, rString(currRing));
     6381      idElements(G, "G");
     6382      headidString(G, "G");
     6383    }
     6384#endif
     6385
     6386    tif = tif + clock()-to;
     6387
     6388#ifndef  BUCHBERGER_ALG
     6389    if(isNolVector(curr_weight) == 0)
     6390      hilb_func = hFirstSeries(Gomega,NULL,NULL,curr_weight,currRing);
     6391    else
     6392      hilb_func = hFirstSeries(Gomega,NULL,NULL,last_omega,currRing);
     6393#endif // BUCHBERGER_ALG
     6394
     6395    oldRing = currRing;
     6396
     6397    if(target_M->length() == nV)
     6398    {
     6399      // define a new ring with ordering "(a(curr_weight),lp)
     6400      if (rParameter(currRing) != NULL)
     6401        DefRingPar(curr_weight);
     6402      else
     6403        rChangeCurrRing(VMrDefault(curr_weight));
     6404    }
     6405    else
     6406    {
     6407      rChangeCurrRing(VMatrRefine(target_M,curr_weight));
     6408    }
     6409    newRing = currRing;
     6410    Gomega1 = idrMoveR(Gomega, oldRing,currRing);
     6411
     6412#ifdef ENDWALKS
     6413    if(endwalks==1)
     6414    {
     6415      Print("\n// ring r%d = %s;\n", nstep, rString(currRing));
     6416      idElements(Gomega1, "Gw");
     6417      headidString(Gomega1, "headGw");
     6418      PrintS("\n// compute a rGB of Gw:\n");
     6419
     6420#ifndef  BUCHBERGER_ALG
     6421      ivString(hilb_func, "w");
     6422#endif
     6423    }
     6424#endif
     6425
     6426    tim = clock();
     6427    to = clock();
     6428    /* compute a reduced Groebner basis of <Gomega> w.r.t. "newRing" */
     6429#ifdef  BUCHBERGER_ALG
     6430    M = MstdhomCC(Gomega1);
     6431#else
     6432    M=kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight);
     6433    delete hilb_func;
     6434#endif
     6435//#ifdef CHECK_IDEAL_MWALK
     6436    if(printout > 2)
     6437    {
     6438      idString(M,"//** Mprwalk: M");
     6439    }
     6440//#endif
     6441
     6442    if(endwalks == 1)
     6443    {
     6444      xtstd = xtstd+clock()-to;
     6445#ifdef ENDWALKS
     6446      Print("\n// time for the last std(Gw)  = %.2f sec\n",
     6447            ((double) clock())/1000000 -((double)tim) /1000000);
     6448#endif
     6449    }
     6450    else
     6451      tstd=tstd+clock()-to;
     6452
     6453    /* change the ring to oldRing */
     6454    rChangeCurrRing(oldRing);
     6455    M1 =  idrMoveR(M, newRing,currRing);
     6456    Gomega2 =  idrMoveR(Gomega1, newRing,currRing);
     6457
     6458    to=clock();
     6459    /* compute a representation of the generators of submod (M)
     6460       with respect to those of mod (Gomega).
     6461       Gomega is a reduced Groebner basis w.r.t. the current ring */
     6462    F = MLifttwoIdeal(Gomega2, M1, G);
     6463    if(endwalks != 1)
     6464      tlift = tlift+clock()-to;
     6465    else
     6466      xtlift=clock()-to;
     6467
     6468//#ifdef CHECK_IDEAL_MWALK
     6469    if(printout > 2)
     6470    {
     6471      idString(F,"//** Mprwalk: F");
     6472    }
     6473//#endif
     6474
     6475    idDelete(&M1);
     6476    idDelete(&Gomega2);
     6477    idDelete(&G);
     6478
     6479    /* change the ring to newRing */
     6480    rChangeCurrRing(newRing);
     6481    F1 = idrMoveR(F, oldRing,currRing);
     6482
     6483    to=clock();
     6484    /* reduce the Groebner basis <G> w.r.t. new ring */
     6485    G = kInterRedCC(F1, NULL);
     6486    if(endwalks != 1)
     6487      tred = tred+clock()-to;
     6488    else
     6489      xtred=clock()-to;
     6490
     6491    idDelete(&F1);
     6492
     6493    if(endwalks == 1)
     6494      break;
     6495
     6496    to=clock();
     6497    // compute a next weight vector
     6498    next_weight = MkInterRedNextWeight(curr_weight,target_weight, G);
     6499    if(polylength > 0)
     6500    {
     6501      //there is a polynomial in Gomega with at least 3 monomials,
     6502      //low-dimensional facet of the cone
     6503      delete next_weight;
     6504      next_weight = MWalkRandomNextWeight(G, curr_weight, target_weight, weight_rad, op_deg);
     6505    }
     6506    tnw=tnw+clock()-to;
     6507//#ifdef PRINT_VECTORS
     6508    if(printout > 2)
     6509    {
     6510      MivString(curr_weight, target_weight, next_weight);
     6511    }
     6512//#endif
     6513
     6514    if(Overflow_Error == TRUE)
     6515    {
     6516      ntwC = 0;
     6517      //ntestomega = 1;
     6518      //Print("\n// ring r%d = %s;\n", nstep, rString(currRing));
     6519      //idElements(G, "G");
     6520      delete next_weight;
     6521      goto FINISH_160302;
     6522    }
     6523    if(MivComp(next_weight, ivNull) == 1){
     6524      newRing = currRing;
     6525      delete next_weight;
     6526      //Print("\n// ring r%d = %s;\n", nstep, rString(currRing));
     6527      break;
     6528    }
     6529    if(MivComp(next_weight, target_weight) == 1)
     6530      endwalks = 1;
     6531
     6532    for(i=nV-1; i>=0; i--)
     6533      (*curr_weight)[i] = (*next_weight)[i];
     6534
     6535    delete next_weight;
     6536  }//while
     6537
     6538  if(tp_deg != 1)
     6539  {
     6540    FINISH_160302:
     6541    if(target_M->length() == nV)
     6542    {
     6543      if(MivSame(orig_target, exivlp) == 1)
     6544        if (rParameter(currRing) != NULL)
     6545          DefRingParlp();
     6546        else
     6547          VMrDefaultlp();
     6548      else
     6549        if (rParameter(currRing) != NULL)
     6550          DefRingPar(orig_target);
     6551        else
     6552          rChangeCurrRing(VMrDefault(orig_target));
     6553    }
     6554    else
     6555    {
     6556      rChangeCurrRing(VMatrDefault(target_M));
     6557    }
     6558    TargetRing=currRing;
     6559    F1 = idrMoveR(G, newRing,currRing);
     6560#ifdef CHECK_IDEAL
     6561      headidString(G, "G");
     6562#endif
     6563
     6564    // check whether the pertubed target vector stays in the correct cone
     6565    if(ntwC != 0){
     6566      ntestw = test_w_in_ConeCC(F1, pert_target_vector);
     6567    }
     6568
     6569    if( ntestw != 1 || ntwC == 0)
     6570    {
     6571      /*
     6572      if(ntestw != 1){
     6573        ivString(pert_target_vector, "tau");
     6574        PrintS("\n// ** perturbed target vector doesn't stay in cone!!");
     6575        Print("\n// ring r%d = %s;\n", nstep, rString(currRing));
     6576        idElements(F1, "G");
     6577      }
     6578      */
     6579      // LastGB is "better" than the kStd subroutine
     6580      to=clock();
     6581      ideal eF1;
     6582      if(nP == 0 || tp_deg == 1 || MivSame(orig_target, exivlp) != 1 || target_M->length() != nV){
     6583        // PrintS("\n// ** calls \"std\" to compute a GB");
     6584        eF1 = MstdCC(F1);
     6585        idDelete(&F1);
     6586      }
     6587      else {
     6588        // PrintS("\n// ** calls \"LastGB\" to compute a GB");
     6589        rChangeCurrRing(newRing);
     6590        ideal F2 = idrMoveR(F1, TargetRing,currRing);
     6591        eF1 = LastGB(F2, curr_weight, tp_deg-1);
     6592        F2=NULL;
     6593      }
     6594      xtextra=clock()-to;
     6595      ring exTargetRing = currRing;
     6596
     6597      rChangeCurrRing(XXRing);
     6598      Eresult = idrMoveR(eF1, exTargetRing,currRing);
     6599    }
     6600    else{
     6601      rChangeCurrRing(XXRing);
     6602      Eresult = idrMoveR(F1, TargetRing,currRing);
     6603    }
     6604  }
     6605  else {
     6606    rChangeCurrRing(XXRing);
     6607    Eresult = idrMoveR(G, newRing,currRing);
     6608  }
     6609  si_opt_1 = save1; //set original options, e. g. option(RedSB)
     6610  delete ivNull;
     6611  if(tp_deg != 1)
     6612    delete target_weight;
     6613
     6614  if(op_deg != 1 )
     6615    delete curr_weight;
     6616
     6617  delete exivlp;
     6618  delete last_omega;
     6619
     6620#ifdef TIME_TEST
     6621  TimeStringFractal(tinput, tostd, tif+xtif, tstd+xtstd,0, tlift+xtlift, tred+xtred,
     6622             tnw+xtnw);
     6623
     6624  //Print("\n// pSetm_Error = (%d)", ErrorCheck());
     6625  //Print("\n// It took %d steps and Overflow_Error? (%d)\n", nstep,  Overflow_Error);
     6626#endif
     6627  Print("\n//** Mprwalk: Perturbation Walk took %d steps.\n", nstep);
    61286628  return(Eresult);
    61296629}
     
    68567356 * of a matrix. This matrix defines the given monomial order, e.g. "lp"        *
    68577357 *******************************************************************************/
    6858 ideal Mfwalk(ideal G, intvec* ivstart, intvec* ivtarget)
    6859 {
     7358ideal Mfwalk(ideal G, intvec* ivstart, intvec* ivtarget, int reduction)
     7359{
     7360  BITSET save1 = si_opt_1; // save current options
     7361  if(reduction == 0)
     7362  {
     7363    si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis
     7364    //si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions
     7365    //si_opt_1|=(Sy_bit(OPT_REDTAIL)|Sy_bit(OPT_REDSB));
     7366  }
    68607367  Set_Error(FALSE);
    68617368  Overflow_Error = FALSE;
     
    69647471  idSkipZeroes(resF);
    69657472
     7473  si_opt_1 = save1; //set original options, e. g. option(RedSB)
    69667474  delete Xivlp;
    69677475  delete Xsigma;
     
    69827490}
    69837491
    6984 ideal Mfrwalk(ideal G, intvec* ivstart, intvec* ivtarget,int weight_rad)
    6985 {
     7492/*******************************************************************************
     7493 * The implementation of the fractal walk algorithm with random element        *
     7494 *                                                                             *
     7495 * The main procedur Mfwalk calls the recursive Subroutine                     *
     7496 * rec_r_fractal_call to compute the wanted Groebner basis.                    *
     7497 * At the main procedur we compute the reduced Groebner basis w.r.t. a "fast"  *
     7498 * order, e.g. "dp" and a sequence of weight vectors which are row vectors     *
     7499 * of a matrix. This matrix defines the given monomial order, e.g. "lp"        *
     7500 *******************************************************************************/
     7501ideal Mfrwalk(ideal G, intvec* ivstart, intvec* ivtarget,
     7502              int weight_rad, int reduction)
     7503{
     7504  BITSET save1 = si_opt_1; // save current options
     7505  if(reduction == 0)
     7506  {
     7507    si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis
     7508    //si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions
     7509  }
    69867510  Set_Error(FALSE);
    69877511  Overflow_Error = FALSE;
     
    70837607  ideal resF;
    70847608  ring helpRing = currRing;
    7085 //ideal G, int nlev, intvec* omtmp, int weight_rad)
     7609
    70867610  J = rec_r_fractal_call(J, 1, ivtarget,weight_rad);
    70877611
     
    70907614  idSkipZeroes(resF);
    70917615
     7616  si_opt_1 = save1; //set original options, e. g. option(RedSB)
    70927617  delete Xivlp;
    70937618  delete Xsigma;
     
    82818806
    82828807  //Print("\n// \"Mpwalk\" (1,%d) took %d steps and %.2f sec. Overflow_Error (%d)", tp_deg, nwalk, ((double) clock()-tinput)/1000000, nOverflow_Error);
    8283 
     8808  Print("\n// Mprwalk took %d steps. Ring= %s;\n", nwalk, rString(currRing));
    82848809  return(result);
    8285 }
    8286 
    8287 /*******************************************************
    8288  * THE PERTURBATION WALK ALGORITHM WITH RANDOM ELEMENT *
    8289  *******************************************************/
    8290 ideal Mprwalk(ideal Go, intvec* curr_weight, intvec* target_weight, int weight_rad, int op_deg, int tp_deg, ring baseRing)
    8291 {
    8292   BITSET save1 = si_opt_1; // save current options
    8293   si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis
    8294   Set_Error(FALSE);
    8295   Overflow_Error = FALSE;
    8296 #ifdef TIME_TEST
    8297   clock_t tinput=0, tostd=0, tif=0, tstd=0, tlift=0, tred=0, tnw=0;
    8298   xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0;
    8299   tinput = clock();
    8300   clock_t tim;
    8301 #endif
    8302   int i,nwalk,nV = baseRing->N;
    8303 
    8304   ideal G, Gomega, M, F, Gomega1, Gomega2, M1;
    8305   ring newRing;
    8306   ring XXRing = baseRing;
    8307   intvec* exivlp = Mivlp(nV);
    8308   intvec* orig_target = target_weight;
    8309   intvec* pert_target_vector = target_weight;
    8310   intvec* ivNull = new intvec(nV);
    8311   intvec* tmp_weight = new intvec(nV);
    8312 #ifdef CHECK_IDEAL_MWALK
    8313   poly p;
    8314 #endif
    8315   for(i=0; i<nV; i++)
    8316   {
    8317     (*tmp_weight)[i] = (*curr_weight)[i];
    8318   }
    8319 #ifndef BUCHBERGER_ALG
    8320   intvec* hilb_func;
    8321    // to avoid (1,0,...,0) as the target vector
    8322   intvec* last_omega = new intvec(nV);
    8323   for(i=0 i<nV; i++)
    8324   {
    8325     (*last_omega)[i] = 1;
    8326   }
    8327   (*last_omega)[0] = 10000;
    8328 #endif
    8329   baseRing = currRing;
    8330   newRing = VMrDefault(curr_weight);
    8331   rChangeCurrRing(newRing);
    8332   G = idrMoveR(Go,baseRing,currRing);
    8333 #ifdef TIME_TEST
    8334   to = clock();
    8335 #endif
    8336   G = kStd(G,NULL,testHomog,NULL,NULL,0,0,NULL);
    8337   idSkipZeroes(G);
    8338 #ifdef TIME_TEST
    8339   tostd = tostd + to - clock();
    8340 #endif
    8341 #ifdef CHECK_IDEAL_MWALK
    8342   idString(G,"G");
    8343 #endif
    8344   if(op_deg >1)
    8345   {
    8346     if(MivComp(curr_weight,MivUnit(nV)) == 1) //ring order is "dp"
    8347     {
    8348       curr_weight = MPertVectors(G, MivMatrixOrderdp(nV), op_deg);
    8349     }
    8350     else //ring order is not "dp"
    8351     {
    8352       curr_weight = MPertVectors(G, MivMatrixOrder(curr_weight), op_deg);
    8353     }
    8354   }
    8355   baseRing = currRing;
    8356   if(tp_deg > 1 && tp_deg <= nV)
    8357   {
    8358     pert_target_vector = target_weight;
    8359   }
    8360 #ifdef CHECK_IDEAL_MWALK
    8361   ivString(curr_weight, "new curr_weight");
    8362   ivString(target_weight, "new target_weight");
    8363 #endif
    8364   nwalk = 0;
    8365   while(1)
    8366   {
    8367     nwalk ++;
    8368 #ifdef TIME_TEST
    8369     to = clock();
    8370 #endif
    8371     Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector"
    8372 #ifdef TIME_TEST
    8373     tif = tif + clock()-to; //time for computing initial form ideal
    8374 #endif
    8375 #ifdef CHECK_IDEAL_MWALK
    8376     idString(Gomega,"Gomega");
    8377 #endif
    8378 #ifndef  BUCHBERGER_ALG
    8379     if(isNolVector(curr_weight) == 0)
    8380     {
    8381       hilb_func = hFirstSeries(Gomega,NULL,NULL,curr_weight,currRing);
    8382     }   
    8383     else
    8384     {
    8385       hilb_func = hFirstSeries(Gomega,NULL,NULL,last_omega,currRing);
    8386     }
    8387 #endif
    8388     if(nwalk == 1)
    8389     {
    8390       newRing = VMrDefault(curr_weight); // define a new ring with ordering "(a(curr_weight),lp)
    8391     }
    8392     else
    8393     {
    8394       newRing = VMrRefine(curr_weight,target_weight); //define a new ring with ordering "(a(curr_weight),Wp(target_weight))"
    8395     }
    8396     rChangeCurrRing(newRing);
    8397     Gomega1 = idrMoveR(Gomega, baseRing,currRing);
    8398     idDelete(&Gomega);
    8399     // compute a Groebner basis of <Gomega> w.r.t. "newRing"
    8400 #ifdef TIME_TEST
    8401     to = clock();
    8402 #endif
    8403 #ifndef  BUCHBERGER_ALG
    8404     M=kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight);
    8405     delete hilb_func;
    8406 #else
    8407     M = kStd(Gomega1,NULL,testHomog,NULL,NULL,0,0,NULL);
    8408 #endif
    8409     idSkipZeroes(M);
    8410 #ifdef TIME_TEST
    8411     tstd = tstd + clock() - to;
    8412 #endif
    8413 #ifdef CHECK_IDEAL_MWALK
    8414     idString(M, "M");
    8415 #endif
    8416     //change the ring to baseRing
    8417     rChangeCurrRing(baseRing);
    8418     M1 =  idrMoveR(M, newRing,currRing);
    8419     idDelete(&M);
    8420     Gomega2 = idrMoveR(Gomega1, newRing,currRing);
    8421     idDelete(&Gomega1);
    8422     to = clock();
    8423     // compute a representation of the generators of submod (M) with respect to those of mod (Gomega), where Gomega is a reduced Groebner basis w.r.t. the current ring
    8424     F = MLifttwoIdeal(Gomega2, M1, G);
    8425     idSkipZeroes(F);
    8426 #ifdef TIME_TEST
    8427     tlift = tlift + clock() - to;
    8428 #endif
    8429 #ifdef CHECK_IDEAL_MWALK
    8430     idString(F,"F");
    8431 #endif
    8432     rChangeCurrRing(newRing); // change the ring to newRing
    8433     G = idrMoveR(F,baseRing,currRing);
    8434     idDelete(&F);
    8435     baseRing = currRing; // set baseRing equal to newRing
    8436 #ifdef CHECK_IDEAL_MWALK
    8437     idString(G,"G");
    8438 #endif
    8439 #ifdef TIME_TEST
    8440     to = clock();
    8441 #endif
    8442     intvec* next_weight = MWalkRandomNextWeight(G, curr_weight, target_weight, weight_rad, op_deg);
    8443 #ifdef TIME_TEST
    8444     tnw = tnw + clock() - to;
    8445 #endif
    8446 #ifdef PRINT_VECTORS
    8447     MivString(curr_weight, target_weight, next_weight);
    8448 #endif
    8449     if(Overflow_Error == TRUE)
    8450     {
    8451       PrintS("\n//**Mprwalk: OVERFLOW: The computed vector does not stay in cone, the result may be wrong.\n");
    8452       delete next_weight;
    8453       break;
    8454     }
    8455 
    8456     if(test_w_in_ConeCC(G,target_weight) == 1 || MivComp(next_weight, ivNull) == 1)
    8457     {
    8458       delete next_weight;
    8459       break;
    8460     }
    8461     //update tmp_weight and curr_weight
    8462     for(i=nV-1; i>=0; i--)
    8463     {
    8464       (*tmp_weight)[i] = (*curr_weight)[i];
    8465       (*curr_weight)[i] = (*next_weight)[i];
    8466     }
    8467     delete next_weight;
    8468   } //end of while-loop
    8469   Print("\n// Mprwalk took %d steps. Ring= %s;\n", nwalk, rString(currRing));
    8470   idSkipZeroes(G);
    8471   si_opt_1 = save1; //set original options, e. g. option(RedSB)
    8472   baseRing = currRing;
    8473   rChangeCurrRing(XXRing);
    8474   ideal Res = idrMoveR(G,baseRing,currRing);
    8475   delete tmp_weight;
    8476   delete ivNull;
    8477   delete exivlp;
    8478 #ifndef BUCHBERGER_ALG
    8479   delete last_omega;
    8480 #endif
    8481 #ifdef TIME_TEST
    8482   TimeString(tinput, tostd, tif, tstd, tlift, tred, tnw, nstep);
    8483 #endif
    8484   return(Res);
    84858810}
    84868811
  • Singular/walk.h

    rf2ba60d racccd2  
    5454// compute a Groebner basis of an ideal G w.r.t. lexicographic order
    5555//ideal Mwalk(ideal Go, intvec* orig_M, intvec* target_M);
    56 ideal Mwalk(ideal Go, intvec* orig_M, intvec* target_M, ring baseRing);
     56ideal Mwalk(ideal Go, intvec* orig_M, intvec* target_M, ring baseRing, int reduction, int printout);
    5757
    5858// random walk algorithm to compute a Groebner basis
    59 ideal Mrwalk(ideal Go, intvec* curr_weight, intvec* target_weight, int weight_rad, int pert_deg, ring baseRing);
     59
     60ideal Mrwalk(ideal Go, intvec* orig_M, intvec* target_M, int weight_rad, int pert_deg, int reduction, int printout);
    6061
    6162/* the perturbation walk algorithm */
    6263
    63 ideal Mpwalk(ideal Go, int op_deg, int tp_deg,intvec* curr_weight,intvec* target_weight, int nP);
     64ideal Mpwalk(ideal Go, int op_deg, int tp_deg,intvec* curr_weight,intvec* target_weight, int nP, int reduction, int printout);
    6465
    6566/* the perturbation walk algorithm with random element */
    66 
    67 ideal Mprwalk(ideal Go, intvec* curr_weight, intvec* target_weight, int weight_rad, int op_deg, int tp_deg, ring baseRing);
     67ideal Mprwalk(ideal Go, intvec* orig_M, intvec* target_M, int weight_rad, int op_deg, int tp_deg, int nP, int reduction, int printout);
    6868
    6969/* The fractal walk algorithm */
    70 ideal Mfwalk(ideal G, intvec* ivstart, intvec* ivtarget);
     70ideal Mfwalk(ideal G, intvec* ivstart, intvec* ivtarget, int reduction);
    7171
    7272/* The fractal walk algorithm with random element */
    73 ideal Mfrwalk(ideal G, intvec* ivstart, intvec* ivtarget,int weight_rad);
     73ideal Mfrwalk(ideal G, intvec* ivstart, intvec* ivtarget, int weight_rad, int reduction);
    7474
    7575/* Implement Tran's idea */
Note: See TracChangeset for help on using the changeset viewer.