Changeset b075f5 in git


Ignore:
Timestamp:
Sep 8, 2015, 10:28:14 AM (8 years ago)
Author:
Stephan Oberfranz <oberfran@…>
Branches:
(u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
Children:
b430ca2b1337f52e1932f689e451e9abb002ec4a
Parents:
53535c6cbef445ffa8464eb62c4971b17a05b3da
Message:
update
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/walk.cc

    r53535c rb075f5  
    1616
    1717//#define TEST_OVERFLOW
    18 //#define CHECK_IDEAL
    19 //#define CHECK_IDEAL_MWALK
     18
     19#define CHECK_IDEAL_MWALK //to print intermediate results
    2020
    2121//#define NEXT_VECTORS_CC
    22 //#define PRINT_VECTORS //to print vectors (sigma, tau, omega)
     22#define PRINT_VECTORS //to print weight vectors
    2323
    2424#define INVEPS_SMALL_IN_FRACTAL  //to choose the small invers of epsilon
     
    2727
    2828#define FIRST_STEP_FRACTAL // to define the first step of the fractal
    29 #define MSTDCC_FRACTAL // apply Buchberger alg to compute a red GB, if
    30 //                          tau doesn't stay in the correct cone
     29#define MSTDCC_FRACTAL // apply Buchberger alg to compute a red GB, if tau doesn't stay in the correct cone
    3130
    3231//#define TIME_TEST // print the used time of each subroutine
     
    122121 ************************************/
    123122// unused
    124 #if 0
     123/*
    125124static void initSSpecialCC (ideal F, ideal Q, ideal P,kStrategy strat)
    126125{
     
    270269#endif
    271270}
    272 #endif
     271*/
    273272
    274273/*****************
     
    279278  int j;
    280279  kStrategy strat = new skStrategy;
    281 
    282 //  if (TEST_OPT_PROT)
    283 //  {
    284 //    writeTime("start InterRed:");
    285 //    mflush();
    286 //  }
    287   //strat->syzComp     = 0;
     280/*
     281  if (TEST_OPT_PROT)
     282  {
     283    writeTime("start InterRed:");
     284    mflush();
     285  }
     286  strat->syzComp     = 0;
     287*/
    288288  strat->kHEdgeFound = (currRing->ppNoether) != NULL;
    289289  strat->kNoether=pCopy((currRing->ppNoether));
     
    348348    strat->fromQ = NULL;
    349349  }
    350 //  if (TEST_OPT_PROT)
    351 //  {
    352 //    writeTime("end Interred:");
    353 //    mflush();
    354 //  }
     350/*
     351  if (TEST_OPT_PROT)
     352  {
     353    writeTime("end Interred:");
     354    mflush();
     355  }
     356*/
    355357  ideal shdl=strat->Shdl;
    356358  idSkipZeroes(shdl);
     
    360362}
    361363
    362 //unused
    363 #if 0
     364#ifdef TIME_TEST
    364365static void TimeString(clock_t tinput, clock_t tostd, clock_t tif,clock_t tstd,
    365366                       clock_t tlf,clock_t tred, clock_t tnw, int step)
     
    399400        ((((double) xtextra)/1000000)/totm)*100);
    400401}
    401 #endif
    402 
    403 //unused
    404 #if 0
     402
    405403static void TimeStringFractal(clock_t tinput, clock_t tostd, clock_t tif,clock_t tstd,
    406404                       clock_t textra, clock_t tlf,clock_t tred, clock_t tnw)
     
    431429#endif
    432430
    433 //#ifdef CHECK_IDEAL_MWALK
     431#ifdef CHECK_IDEAL_MWALK
    434432static void idString(ideal L, const char* st)
    435433{
     
    443441  Print(" %s;", pString(L->m[nL-1]));
    444442}
    445 //#endif
    446 
     443#endif
     444/*
    447445#if defined(CHECK_IDEAL_MWALK) || defined(ENDWALKS)
    448446static void headidString(ideal L, char* st)
     
    498496}
    499497#endif
    500 
     498*/
    501499
    502500static void ivString(intvec* iv, const char* ch)
     
    512510}
    513511
    514 //unused
    515 //#if 0
     512#ifdef PRINT_VECTORS
    516513static void MivString(intvec* iva, intvec* ivb, intvec* ivc)
    517514{
     
    536533  Print("%d)", (*ivc)[nV]);
    537534}
    538 //#endif
     535#endif
    539536
    540537/********************************************************************
     
    10401037 * print the max total degree and the max coefficient of G                   *
    10411038 *****************************************************************************/
    1042 #if 0
     1039/*
    10431040static void checkComplexity(ideal G, char* cG)
    10441041{
     
    10811078  PrintLn();
    10821079}
    1083 #endif
     1080*/
    10841081
    10851082/*****************************************************************************
     
    11031100  intvec* v_null =  new intvec(nV);
    11041101
    1105 
    11061102  // Check that the perturbed degree is valid
    11071103  if(pdeg > nV || pdeg <= 0)
     
    11171113  }
    11181114  mpz_t *pert_vector = (mpz_t*)omAlloc(nV*sizeof(mpz_t));
    1119   //mpz_t *pert_vector1 = (mpz_t*)omAlloc(nV*sizeof(mpz_t));
     1115  mpz_t *pert_vector1 = (mpz_t*)omAlloc(nV*sizeof(mpz_t));
    11201116
    11211117  for(i=0; i<nV; i++)
    11221118  {
    11231119    mpz_init_set_si(pert_vector[i], (*ivtarget)[i]);
    1124    // mpz_init_set_si(pert_vector1[i], (*ivtarget)[i]);
     1120    mpz_init_set_si(pert_vector1[i], (*ivtarget)[i]);
    11251121  }
    11261122  // Calculate max1 = Max(A2)+Max(A3)+...+Max(Apdeg),
     
    12021198    }
    12031199  }
     1200
     1201  // 2147483647 is max. integer representation in SINGULAR
     1202  mpz_t sing_int;
     1203  mpz_init_set_ui(sing_int,  2147483647);
     1204
     1205  mpz_t check_int;
     1206  mpz_init_set_ui(check_int,  100000);
     1207
    12041208  mpz_t ztemp;
    12051209  mpz_init(ztemp);
     
    12211225  }
    12221226
    1223   intvec *pert_vector1= new intvec(nV);
    1224   j = 0;
    12251227  for(i=0; i<nV; i++)
    12261228  {
    1227     (* pert_vector1)[i] = mpz_get_si(pert_vector[i]);
    1228     (* pert_vector1)[i] = 0.1*(* pert_vector1)[i];
    1229     (* pert_vector1)[i] = floor((* pert_vector1)[i] + 0.5);
    1230     if((* pert_vector1)[i] == 0)
    1231     {
    1232       j++;
    1233     }
    1234   }
    1235   if(j > nV - 1)
    1236   {
    1237     // Print("\n//  MPertVectors: geaenderter vector gleich Null! \n");
    1238     delete pert_vector1;
    1239     goto CHECK_OVERFLOW;
    1240   }
    1241 
    1242 // check that the perturbed weight vector lies in the Groebner cone
    1243   if(test_w_in_ConeCC(G,pert_vector1) != 0)
    1244   {
    1245     // Print("\n//  MPertVectors: geaenderter vector liegt in Groebnerkegel! \n");
     1229    if(mpz_cmp(pert_vector[i], check_int)>=0)
     1230    {
     1231      for(j=0; j<nV; j++)
     1232      {
     1233        mpz_fdiv_q_ui(pert_vector1[j], pert_vector[j], 100);
     1234      }
     1235    }
     1236  }
     1237
     1238  intvec* result = new intvec(nV);
     1239
     1240  int ntrue=0;
     1241
     1242  for(i=0; i<nV; i++)
     1243  {
     1244    (*result)[i] = mpz_get_si(pert_vector1[i]);
     1245    if(mpz_cmp(pert_vector1[i], sing_int)>=0)
     1246    {
     1247      ntrue++;
     1248    }
     1249  }
     1250  if(ntrue > 0 || test_w_in_ConeCC(G,result)==0)
     1251  {
     1252    ntrue=0;
    12461253    for(i=0; i<nV; i++)
    12471254    {
    1248       mpz_set_si(pert_vector[i], (*pert_vector1)[i]);
    1249     }
    1250   }
    1251   else
    1252   {
    1253     //Print("\n// MpertVectors: geaenderter vector liegt nicht in Groebnerkegel! \n");
    1254   }
    1255   delete pert_vector1;
    1256 
    1257   CHECK_OVERFLOW:
    1258   intvec* result = new intvec(nV);
    1259 
    1260   /* 2147483647 is max. integer representation in SINGULAR */
    1261   mpz_t sing_int;
    1262   mpz_init_set_ui(sing_int,  2147483647);
    1263 
    1264   int ntrue=0;
    1265   for(i=0; i<nV; i++)
    1266   {
    1267     (*result)[i] = mpz_get_si(pert_vector[i]);
    1268     if(mpz_cmp(pert_vector[i], sing_int)>=0)
    1269     {
    1270       ntrue++;
    1271       if(Overflow_Error == FALSE)
    1272       {
    1273         Overflow_Error = TRUE;
    1274         PrintS("\n// ** OVERFLOW in \"MPertvectors\": ");
    1275         mpz_out_str( stdout, 10, pert_vector[i]);
    1276         PrintS(" is greater than 2147483647 (max. integer representation)");
    1277         Print("\n//  So vector[%d] := %d is wrong!!", i+1, (*result)[i]);
    1278       }
    1279     }
    1280   }
    1281 
    1282   if(Overflow_Error == TRUE)
    1283   {
    1284     ivString(result, "pert_vector");
    1285     Print("\n// %d element(s) of it is overflow!!", ntrue);
     1255      (*result)[i] = mpz_get_si(pert_vector[i]);
     1256      if(mpz_cmp(pert_vector[i], sing_int)>=0)
     1257      {
     1258        ntrue++;
     1259        if(Overflow_Error == FALSE)
     1260        {
     1261          Overflow_Error = TRUE;
     1262          PrintS("\n// ** OVERFLOW in \"MPertvectors\": ");
     1263          mpz_out_str( stdout, 10, pert_vector[i]);
     1264          PrintS(" is greater than 2147483647 (max. integer representation)");
     1265          Print("\n//  So vector[%d] := %d is wrong!!", i+1, (*result)[i]);
     1266        }
     1267      }
     1268    }
     1269
     1270    if(Overflow_Error == TRUE)
     1271    {
     1272      ivString(result, "pert_vector");
     1273      Print("\n// %d element(s) of it is overflow!!", ntrue);
     1274    }
    12861275  }
    12871276
    12881277  mpz_clear(ztemp);
    12891278  mpz_clear(sing_int);
     1279  mpz_clear(check_int);
    12901280  omFree(pert_vector);
    1291   //omFree(pert_vector1);
     1281  omFree(pert_vector1);
    12921282  mpz_clear(tot_deg);
    12931283  mpz_clear(maxdeg);
     
    14911481
    14921482//unused
    1493 #if 0
     1483/*
    14941484static intvec* MatrixOrderdp(int nV)
    14951485{
     
    15071497  return(ivM);
    15081498}
    1509 #endif
     1499*/
    15101500
    15111501intvec* MivUnit(int nV)
     
    15841574    mpz_cdiv_q_ui(inveps, inveps, nV);
    15851575  }
    1586   //PrintS("\n// choose the \"small\" inverse epsilon!");
     1576  // choose the small inverse epsilon
    15871577#endif
    15881578
     
    16181608
    16191609    for(j=0; j<nV; j++)
    1620       {
     1610    {
    16211611      mpz_init_set(pert_vector[i*nV+j],ivtemp[j]);
    1622       }
    1623   }
    1624 
    1625   /* 2147483647 is max. integer representation in SINGULAR */
     1612    }
     1613  }
     1614
     1615  // 2147483647 is max. integer representation in SINGULAR
    16261616  mpz_t sing_int;
    16271617  mpz_init_set_ui(sing_int,  2147483647);
     
    16471637    (* result)[i] = mpz_get_si(pert_vector[i]);
    16481638  }
    1649 /*
    1650   j = 0;
    1651   for(i=0; i<niv; i++)
    1652   {
    1653     (* result1)[i] = mpz_get_si(pert_vector[i]);
    1654     (* result1)[i] = 0.1*(* result1)[i];
    1655     (* result1)[i] = floor((* result1)[i] + 0.5);
    1656     if((* result1)[i] == 0)
    1657     {
    1658       j++;
    1659     }
    1660   }
    1661   if(j > niv - 1)
    1662   {
    1663     // Print("\n//  MfPertwalk: geaenderter vector gleich Null! \n");
    1664     delete result1;
    1665     goto CHECK_OVERFLOW;
    1666   }
    1667 /*
    1668 // check that the perturbed weight vector lies in the Groebner cone
    1669   Print("\n========================================\n//** MfPertvector: test in Cone.\n");
    1670   if(test_w_in_ConeCC(G,result1) != 0)
    1671   {
    1672     // Print("\n//  MfPertwalk: geaenderter vector liegt in Groebnerkegel! \n");
    1673     delete result;
    1674     result = result1;
    1675     for(i=0; i<nV; i++)
    1676     {
    1677       mpz_set_si(pert_vector[i], (*result1)[i]);
    1678     }
    1679   }
    1680   else
    1681   {
    1682     delete result1;
    1683     // Print("\n// Mfpertwalk: geaenderter vector liegt nicht in Groebnerkegel! \n");
    1684   }
    1685   Print("\n ========================================\n");*/
     1639
    16861640  CHECK_OVERFLOW:
    16871641
     
    17211675    while(p!=NULL)
    17221676    {
    1723       p_Setm(p,currRing); pIter(p);
     1677      p_Setm(p,currRing);
     1678      pIter(p);
    17241679    }
    17251680  }
     
    18041759
    18051760//unused
    1806 #if 0
     1761/*
    18071762static void checkidealCC(ideal G, char* Ch)
    18081763{
     
    18301785  PrintLn();
    18311786}
    1832 #endif
     1787*/
    18331788
    18341789//unused
    1835 #if 0
     1790/*
    18361791static void HeadidString(ideal L, char* st)
    18371792{
     
    18451800  Print(" %s;\n", pString(pHead(L->m[nL])));
    18461801}
    1847 #endif
    1848 
     1802
     1803*/
    18491804static inline int MivComp(intvec* iva, intvec* ivb)
    18501805{
     
    19191874 * with respect to an ideal <G>.                                      *
    19201875**********************************************************************/
     1876/*
    19211877static intvec* MwalkNextWeightCC(intvec* curr_weight, intvec* target_weight,
    19221878                                 ideal G)
     
    20401996  if(mpz_cmp(t_nenner, t_null) == 0)
    20411997  {
    2042     #ifndef SING_NDEBUG
    2043     Print("\n//MwalkNextWeightCC: t_nenner ist Null!");
    2044     #endif
     1998#ifndef SING_NDEBUG
     1999    Print("\n//MwalkNextWeightCC: t_nenner=0\n");
     2000#endif
    20452001    delete diff_weight;
    20462002    diff_weight = ivCopy(curr_weight);//take memory
     
    21712127
    21722128  for(j=0; j<nRing; j++)
    2173     {
     2129  {
    21742130    if(mpz_cmp(vec[j], sing_int_half) >= 0)
    2175       {
     2131    {
    21762132      goto REDUCTION;
    2177       }
    2178     }
     2133    }
     2134  }
    21792135  checkRed = 1;
    21802136  for (j=0; j<nRing; j++)
     
    22712227return diff_weight;
    22722228}
     2229*/
     2230/**********************************************************************
     2231 * Compute a next weight vector between curr_weight and target_weight *
     2232 * with respect to an ideal <G>.                                      *
     2233**********************************************************************/
     2234static intvec* MwalkNextWeightCC(intvec* curr_weight, intvec* target_weight,
     2235                                 ideal G)
     2236{
     2237  BOOLEAN nError = Overflow_Error;
     2238  Overflow_Error = FALSE;
     2239
     2240  assume(currRing != NULL && curr_weight != NULL &&
     2241         target_weight != NULL && G != NULL);
     2242
     2243  int nRing = currRing->N;
     2244  int checkRed, j, nG = IDELEMS(G);
     2245  intvec* ivtemp;
     2246
     2247  mpz_t t_zaehler, t_nenner;
     2248  mpz_init(t_zaehler);
     2249  mpz_init(t_nenner);
     2250
     2251  mpz_t s_zaehler, s_nenner, temp, MwWd;
     2252  mpz_init(s_zaehler);
     2253  mpz_init(s_nenner);
     2254  mpz_init(temp);
     2255  mpz_init(MwWd);
     2256
     2257  mpz_t sing_int;
     2258  mpz_init(sing_int);
     2259  mpz_set_si(sing_int,  2147483647);
     2260
     2261  mpz_t sing_int_half;
     2262  mpz_init(sing_int_half);
     2263  mpz_set_si(sing_int_half,  3*(1073741824/2));
     2264
     2265  mpz_t deg_w0_p1, deg_d0_p1;
     2266  mpz_init(deg_w0_p1);
     2267  mpz_init(deg_d0_p1);
     2268
     2269  mpz_t sztn, sntz;
     2270  mpz_init(sztn);
     2271  mpz_init(sntz);
     2272
     2273  mpz_t t_null;
     2274  mpz_init(t_null);
     2275
     2276  mpz_t ggt;
     2277  mpz_init(ggt);
     2278
     2279  mpz_t dcw;
     2280  mpz_init(dcw);
     2281
     2282  int gcd_tmp;
     2283  //intvec* diff_weight = MivSub(target_weight, curr_weight);
     2284
     2285  intvec* diff_weight1 = new intvec(nRing); //MivSub(target_weight, curr_weight);
     2286  poly g;
     2287
     2288  // reduce the size of the entries of the current weight vector
     2289  if(TEST_OPT_REDSB)
     2290  {
     2291    for (j=0; j<nRing; j++)
     2292    {
     2293      (*diff_weight1)[j] = (*curr_weight)[j];
     2294    }
     2295    while(MivAbsMax(diff_weight1)>10000 && test_w_in_ConeCC(G,diff_weight1)==1)
     2296    {
     2297      for(j=0; j<nRing; j++)
     2298      {
     2299        (*curr_weight)[j] = (*diff_weight1)[j]; 
     2300      }
     2301      for(j=0; j<nRing; j++)
     2302      {
     2303        (*diff_weight1)[j] = floor(0.1*(*diff_weight1)[j] + 0.5);
     2304      }
     2305    }
     2306
     2307    if(MivAbsMax(curr_weight)>100000)
     2308    {
     2309      for(j=0; j<nRing; j++)
     2310      {
     2311        (*diff_weight1)[j] = (*curr_weight)[j];
     2312      }
     2313      j = 0;
     2314      while(test_w_in_ConeCC(G,diff_weight1)==1 && MivAbsMax(diff_weight1)>1000)
     2315      {
     2316        (*curr_weight)[j] = (*diff_weight1)[j];
     2317        j = MivAbsMaxArg(diff_weight1);
     2318        (*diff_weight1)[j] = floor(0.1*(*diff_weight1)[j] + 0.5);
     2319      }
     2320    }
     2321
     2322  }
     2323  intvec* diff_weight = MivSub(target_weight, curr_weight);
     2324
     2325  // compute a suitable next weight vector
     2326  for (j=0; j<nG; j++)
     2327  {
     2328    g = G->m[j];
     2329    if (g != NULL)
     2330    {
     2331      ivtemp = MExpPol(g);
     2332      mpz_set_si(deg_w0_p1, MivDotProduct(ivtemp, curr_weight));
     2333      mpz_set_si(deg_d0_p1, MivDotProduct(ivtemp, diff_weight));
     2334      delete ivtemp;
     2335
     2336      pIter(g);
     2337      while (g != NULL)
     2338      {
     2339        ivtemp = MExpPol(g);
     2340        mpz_set_si(MwWd, MivDotProduct(ivtemp, curr_weight));
     2341        mpz_sub(s_zaehler, deg_w0_p1, MwWd);
     2342        if(mpz_cmp(s_zaehler, t_null) != 0)
     2343        {
     2344          mpz_set_si(MwWd, MivDotProduct(ivtemp, diff_weight));
     2345          mpz_sub(s_nenner, MwWd, deg_d0_p1);
     2346          // check for 0 < s <= 1
     2347          if( (mpz_cmp(s_zaehler,t_null) > 0 &&
     2348               mpz_cmp(s_nenner, s_zaehler)>=0) ||
     2349              (mpz_cmp(s_zaehler, t_null) < 0 &&
     2350               mpz_cmp(s_nenner, s_zaehler)<=0))
     2351          {
     2352            // make both positive
     2353            if (mpz_cmp(s_zaehler, t_null) < 0)
     2354            {
     2355              mpz_neg(s_zaehler, s_zaehler);
     2356              mpz_neg(s_nenner, s_nenner);
     2357            }
     2358
     2359            //compute a simple fraction of s
     2360            cancel(s_zaehler, s_nenner);
     2361
     2362            if(mpz_cmp(t_nenner, t_null) != 0)
     2363            {
     2364              mpz_mul(sztn, s_zaehler, t_nenner);
     2365              mpz_mul(sntz, s_nenner, t_zaehler);
     2366
     2367              if(mpz_cmp(sztn,sntz) < 0)
     2368              {
     2369                mpz_add(t_nenner, t_null, s_nenner);
     2370                mpz_add(t_zaehler,t_null, s_zaehler);
     2371              }
     2372            }
     2373            else
     2374            {
     2375              mpz_add(t_nenner, t_null, s_nenner);
     2376              mpz_add(t_zaehler,t_null, s_zaehler);
     2377            }
     2378          }
     2379        }
     2380        pIter(g);
     2381        delete ivtemp;
     2382      }
     2383    }
     2384  }
     2385  //Print("\n// Alloc Size = %d \n", nRing*sizeof(mpz_t));
     2386  mpz_t *vec=(mpz_t*)omAlloc(nRing*sizeof(mpz_t));
     2387
     2388
     2389  // there is no 0<t<1 and define the next weight vector that is equal
     2390  // to the current weight vector
     2391  if(mpz_cmp(t_nenner, t_null) == 0)
     2392  {
     2393#ifndef SING_NDEBUG
     2394    Print("\n//MwalkNextWeightCC: t_nenner=0\n");
     2395#endif
     2396    delete diff_weight;
     2397    diff_weight = ivCopy(curr_weight);//take memory
     2398    goto FINISH;
     2399  }
     2400
     2401  // define the target vector as the next weight vector, if t = 1
     2402  if(mpz_cmp_si(t_nenner, 1)==0 && mpz_cmp_si(t_zaehler,1)==0)
     2403  {
     2404    delete diff_weight;
     2405    diff_weight = ivCopy(target_weight); //this takes memory
     2406    goto FINISH;
     2407  }
     2408
     2409   //checkRed = 0;
     2410
     2411  SIMPLIFY_GCD:
     2412
     2413  // simplify the vectors curr_weight and diff_weight (C-int)
     2414  gcd_tmp = (*curr_weight)[0];
     2415
     2416  for (j=1; j<nRing; j++)
     2417  {
     2418    gcd_tmp = gcd(gcd_tmp, (*curr_weight)[j]);
     2419    if(gcd_tmp == 1)
     2420    {
     2421      break;
     2422    }
     2423  }
     2424  if(gcd_tmp != 1)
     2425  {
     2426    for (j=0; j<nRing; j++)
     2427    {
     2428      gcd_tmp = gcd(gcd_tmp, (*diff_weight)[j]);
     2429      if(gcd_tmp == 1)
     2430      {
     2431        break;
     2432      }
     2433    }
     2434  }
     2435  if(gcd_tmp != 1)
     2436  {
     2437    for (j=0; j<nRing; j++)
     2438    {
     2439      (*curr_weight)[j] =  (*curr_weight)[j]/gcd_tmp;
     2440      (*diff_weight)[j] =  (*diff_weight)[j]/gcd_tmp;
     2441    }
     2442  }
     2443  if(checkRed > 0)
     2444  {
     2445    for (j=0; j<nRing; j++)
     2446    {
     2447      mpz_set_si(vec[j], (*diff_weight)[j]);
     2448    }
     2449    goto TEST_OVERFLOW;
     2450  }
     2451
     2452#ifdef  NEXT_VECTORS_CC
     2453  Print("\n// gcd of the weight vectors (current and target) = %d", gcd_tmp);
     2454  ivString(curr_weight, "new cw");
     2455  ivString(diff_weight, "new dw");
     2456
     2457  PrintS("\n// t_zaehler: ");  mpz_out_str( stdout, 10, t_zaehler);
     2458  PrintS(", t_nenner: ");  mpz_out_str( stdout, 10, t_nenner);
     2459#endif
     2460
     2461// construct a new weight vector and check whether vec[j] is overflow, i.e. vec[j] > 2^31.
     2462// If vec[j] doesn't overflow, define a weight vector. Otherwise, report that overflow
     2463// appears. In the second case, test whether the the correctness of the new vector plays
     2464// an important role
     2465
     2466  for (j=0; j<nRing; j++)
     2467  {
     2468    mpz_set_si(dcw, (*curr_weight)[j]);
     2469    mpz_mul(s_nenner, t_nenner, dcw);
     2470
     2471    if( (*diff_weight)[j]>0)
     2472    {
     2473      mpz_mul_ui(s_zaehler, t_zaehler, (*diff_weight)[j]);
     2474    }
     2475    else
     2476    {
     2477      mpz_mul_ui(s_zaehler, t_zaehler, -(*diff_weight)[j]);
     2478      mpz_neg(s_zaehler, s_zaehler);
     2479    }
     2480    mpz_add(sntz, s_nenner, s_zaehler);
     2481    mpz_init_set(vec[j], sntz);
     2482
     2483#ifdef NEXT_VECTORS_CC
     2484    Print("\n//   j = %d ==> ", j);
     2485    PrintS("(");
     2486    mpz_out_str( stdout, 10, t_nenner);
     2487    Print(" * %d)", (*curr_weight)[j]);
     2488    Print(" + ("); mpz_out_str( stdout, 10, t_zaehler);
     2489    Print(" * %d) =  ",  (*diff_weight)[j]);
     2490    mpz_out_str( stdout, 10, s_nenner);
     2491    PrintS(" + ");
     2492    mpz_out_str( stdout, 10, s_zaehler);
     2493    PrintS(" = "); mpz_out_str( stdout, 10, sntz);
     2494    Print(" ==> vector[%d]: ", j); mpz_out_str(stdout, 10, vec[j]);
     2495#endif
     2496
     2497    if(j==0)
     2498    {
     2499      mpz_set(ggt, sntz);
     2500    }
     2501    else
     2502    {
     2503      if(mpz_cmp_si(ggt,1) != 0)
     2504      {
     2505        mpz_gcd(ggt, ggt, sntz);
     2506      }
     2507    }
     2508  }
     2509  // reduce the vector with the gcd
     2510  if(mpz_cmp_si(ggt,1) != 0)
     2511  {
     2512    for (j=0; j<nRing; j++)
     2513    {
     2514      mpz_divexact(vec[j], vec[j], ggt);
     2515    }
     2516  }
     2517#ifdef  NEXT_VECTORS_CC
     2518  PrintS("\n// gcd of elements of the vector: ");
     2519  mpz_out_str( stdout, 10, ggt);
     2520#endif
     2521
     2522  for (j=0; j<nRing; j++)
     2523  {
     2524    (*diff_weight)[j] = mpz_get_si(vec[j]);
     2525  }
     2526
     2527 TEST_OVERFLOW:
     2528
     2529  for (j=0; j<nRing; j++)
     2530  {
     2531    if(mpz_cmp(vec[j], sing_int)>=0)
     2532    {
     2533      if(Overflow_Error == FALSE)
     2534      {
     2535        Overflow_Error = TRUE;
     2536        PrintS("\n// ** OVERFLOW in \"MwalkNextWeightCC\": ");
     2537        mpz_out_str( stdout, 10, vec[j]);
     2538        PrintS(" is greater than 2147483647 (max. integer representation)\n");
     2539        Print("//  So vector[%d] := %d is wrong!!\n",j+1, vec[j]);// vec[j] is mpz_t
     2540      }
     2541    }
     2542  }
     2543
     2544 FINISH:
     2545   delete diff_weight1;
     2546   mpz_clear(t_zaehler);
     2547   mpz_clear(t_nenner);
     2548   mpz_clear(s_zaehler);
     2549   mpz_clear(s_nenner);
     2550   mpz_clear(sntz);
     2551   mpz_clear(sztn);
     2552   mpz_clear(temp);
     2553   mpz_clear(MwWd);
     2554   mpz_clear(deg_w0_p1);
     2555   mpz_clear(deg_d0_p1);
     2556   mpz_clear(ggt);
     2557   omFree(vec);
     2558   mpz_clear(sing_int_half);
     2559   mpz_clear(sing_int);
     2560   mpz_clear(dcw);
     2561   mpz_clear(t_null);
     2562
     2563  if(Overflow_Error == FALSE)
     2564  {
     2565    Overflow_Error = nError;
     2566  }
     2567  rComplete(currRing);
     2568  for(j=0; j<IDELEMS(G); j++)
     2569  {
     2570    poly p=G->m[j];
     2571    while(p!=NULL)
     2572    {
     2573      p_Setm(p,currRing);
     2574      pIter(p);
     2575    }
     2576  }
     2577return diff_weight;
     2578}
     2579
    22732580
    22742581/**********************************************************************
     
    29563263  int i,j,N = IDELEMS(Gomega);
    29573264  poly p,lm,factor1,factor2;
    2958   //PrintS("\n//** idCopy\n");
     3265
    29593266  ideal Go = idCopy(G);
    29603267 
    2961   //PrintS("\n//** jetzt for-Loop!\n");
    2962 
    29633268  // check whether leading monomials of G and Gomega coincide
    29643269  // and return NULL if not
    29653270  for(i=0; i<N; i++)
    29663271  {
    2967     p = pCopy(Gomega->m[i]);
    2968     lm = pCopy(pHead(G->m[i]));
    2969     if(!pIsConstant(pSub(p,lm)))
    2970     {
    2971       //pDelete(&p);
    2972       //pDelete(&lm);
     3272    if(!pIsConstant(pSub(pCopy(Gomega->m[i]),pCopy(pHead(G->m[i])))))
     3273    {
    29733274      idDelete(&Go);
    29743275      return NULL;
    29753276    }
    2976     //pDelete(&p);
    2977     //pDelete(&lm);
    29783277  }
    29793278  for(i=0; i<N; i++)
     
    30073306    }
    30083307  }
    3009  
    3010   //PrintS("\n//** jetzt Delete!\n");
    3011   //pDelete(&p);
    3012   //pDelete(&factor);
    3013   //pDelete(&lm);
     3308
    30143309  if(middle == TRUE)
    30153310  {
    3016     //PrintS("\n//** middle TRUE!\n");
    30173311    return Go;
    30183312  }
    3019   //PrintS("\n//** middle FALSE!\n");
    30203313  idDelete(&Go);
    30213314  return NULL;
     
    31513444    {
    31523445      Print("\n// ring r%d_%d = %s;\n", tp_deg, nwalk, rString(currRing));
     3446/*
    31533447      idElements(Gomega, "Gw");
    31543448      headidString(Gomega, "Gw");
     3449*/
    31553450    }
    31563451#endif
     
    33093604  for(i=IDELEMS(G)-1; i>=0; i--)
    33103605  {
    3311 #if 0
    3312     if(pLength(G->m[i])>2)
    3313     {
    3314       return 1;
    3315     }
    3316 #else
    33173606    if((G->m[i]!=NULL) /* len >=0 */
    33183607       && (G->m[i]->next!=NULL) /* len >=1 */
    33193608       && (G->m[i]->next->next!=NULL) /* len >=2 */
    3320        && (G->m[i]->next->next->next!=NULL) /* len >=3 */
    3321       //&& (G->m[i]->next->next->next->next!=NULL) /* len >=4 */
    3322        )
    3323     {
    3324     return 1;
    3325     }
    3326 #endif
     3609       && (G->m[i]->next->next->next!=NULL) /* len >=3 */)
     3610    {
     3611      return 1;
     3612    }
    33273613  }
    33283614  return 0;
     
    34143700  for(i=nG-1; i>=0; i--)
    34153701  {
    3416 #if 0
     3702/*
    34173703    poly t;
    34183704    if((t=pSub(pCopy(H0->m[i]), pCopy(H1->m[i]))) != NULL)
     
    34223708    }
    34233709    pDelete(&t);
    3424 #else
     3710*/
    34253711    if(!pEqualPolys(H0->m[i],H1->m[i]))
    34263712    {
    34273713      return 0;
    34283714    }
    3429 #endif
    34303715  }
    34313716  return 1;
     
    34363721 * find the maximal total degree of polynomials in G *
    34373722 *****************************************************/
    3438 #if 0
     3723/*
    34393724static int Trandegreebound(ideal G)
    34403725{
     
    34573742  return result;
    34583743}
    3459 #endif
     3744*/
    34603745
    34613746//unused
     
    38044089 * basis or n times, where n is the numbers of variables.                    *
    38054090 *****************************************************************************/
    3806 
    3807 //unused
    3808 #if 0
    3809 static int testnegintvec(intvec* v)
    3810 {
    3811   int n = v->length();
    3812   int i;
    3813   for(i=0; i<n; i++)
    3814   {
    3815     if((*v)[i]<0)
    3816     {
    3817       return(1);
    3818     }
    3819   }
    3820   return(0);
    3821 }
    3822 #endif
    38234091
    38244092// npwinc = 0, if curr_weight doesn't stay in the correct Groebner cone
     
    40324300        //nOverflow_Error = Overflow_Error;
    40334301        tproc=tproc+clock()-tinput;
    4034         /*
    4035           Print("\n// takes %d steps and calls \"Rec_LastGB\" (%d):",
    4036           nwalk, tp_deg+1);
    4037         */
     4302       
     4303        Print("\n// takes %d steps and calls \"Rec_LastGB\" (%d):",
     4304        nwalk, tp_deg+1);
     4305       
    40384306        G = Rec_LastGB(G,curr_weight, orig_target_weight, tp_deg+1,nnwinC);
    40394307        newRing = currRing;
     
    40694337    {
    40704338      // nOverflow_Error = Overflow_Error;
    4071       //Print("\n//  takes %d steps and calls \"Rec_LastGB (%d):", tp_deg+1);
     4339      Print("\n//  takes %d steps and calls \"Rec_LastGB (%d):", tp_deg+1);
    40724340      tproc=tproc+clock()-tinput;
    40734341      F1 = Rec_LastGB(F1,curr_weight, orig_target_weight, tp_deg+1,nnwinC);
     
    41234391    Overflow_Error=nError;
    41244392    }
    4125 // Print("\n// \"Rec_LastGB\" (%d) took %d steps and %.2f sec.Overflow_Error (%d)", tp_deg, nwalk, ((double) tproc)/1000000, nOverflow_Error);
     4393#ifdef TIME_TEST
     4394   Print("\n// \"Rec_LastGB\" (%d) took %d steps and %.2f sec.Overflow_Error (%d)", tp_deg, nwalk, ((double) tproc)/1000000, nOverflow_Error);
     4395#endif
    41264396  return(result);
    41274397}
     
    41454415  //BOOLEAN nOverflow_Error = FALSE;
    41464416  //Print("// pSetm_Error = (%d)", ErrorCheck());
    4147 
     4417#ifdef TIME_TEST
    41484418  xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0; xtextra=0;
    41494419  xftinput = clock();
    41504420  clock_t tostd, tproc;
    4151 
     4421#endif
    41524422  nstep = 0;
    41534423  int i, nV = currRing->N;
     
    41604430  intvec* ivNull = new intvec(nV);
    41614431  intvec* next_weight;
    4162 #if 0
    4163   intvec* extra_curr_weight = new intvec(nV);
    4164 #endif
     4432  //intvec* extra_curr_weight = new intvec(nV);
    41654433  //intvec* hilb_func;
    41664434  intvec* exivlp = Mivlp(nV);
    4167 
    41684435  ring XXRing = currRing;
    41694436
    41704437  //Print("\n// ring r_input = %s;", rString(currRing));
     4438#ifdef TIME_TEST
    41714439  to = clock();
     4440#endif
    41724441  /* compute the reduced Groebner basis of the given ideal w.r.t.
    41734442     a "fast" monomial order, e.g. degree reverse lex. order (dp) */
    41744443  G = MstdCC(Go);
     4444#ifdef TIME_TEST
    41754445  tostd=clock()-to;
    41764446
    4177   /*
    41784447  Print("\n// Computation of the first std took = %.2f sec",
    41794448        ((double) tostd)/1000000);
    4180   */
     4449#endif
    41814450  if(currRing->order[0] == ringorder_a)
    41824451  {
     
    41874456    nwalk ++;
    41884457    nstep ++;
     4458#ifdef TIME_TEST
    41894459    to = clock();
     4460#endif
    41904461    /* compute an initial form ideal of <G> w.r.t. "curr_vector" */
    41914462    Gomega = MwalkInitialForm(G, curr_weight);
     4463#ifdef TIME_TEST
    41924464    xtif=xtif+clock()-to;
    4193 #if 0
     4465#endif
     4466/*
    41944467    if(Overflow_Error == TRUE)
    41954468    {
     
    41994472      goto LAST_GB_ALT2;
    42004473    }
    4201 #endif
     4474*/
    42024475    oldRing = currRing;
    42034476
     
    42134486    newRing = currRing;
    42144487    Gomega1 = idrMoveR(Gomega, oldRing,currRing);
     4488#ifdef TIME_TEST
    42154489    to = clock();
     4490#endif
    42164491    /* compute a reduced Groebner basis of <Gomega> w.r.t. "newRing" */
    42174492    M = MstdhomCC(Gomega1);
     4493#ifdef TIME_TEST
    42184494    xtstd=xtstd+clock()-to;
     4495#endif
    42194496    /* change the ring to oldRing */
    42204497    rChangeCurrRing(oldRing);
    42214498    M1 =  idrMoveR(M, newRing,currRing);
    42224499    Gomega2 =  idrMoveR(Gomega1, newRing,currRing);
    4223 
     4500#ifdef TIME_TEST
    42244501    to = clock();
     4502#endif
    42254503    /* compute the reduced Groebner basis of <G> w.r.t. "newRing"
    42264504       by the liftig process */
    42274505    F = MLifttwoIdeal(Gomega2, M1, G);
     4506#ifdef TIME_TEST
    42284507    xtlift=xtlift+clock()-to;
     4508#endif
    42294509    idDelete(&M1);
    42304510    idDelete(&Gomega2);
     
    42344514    rChangeCurrRing(newRing);
    42354515    F1 = idrMoveR(F, oldRing,currRing);
    4236 
     4516#ifdef TIME_TEST
    42374517    to = clock();
     4518#endif
    42384519    /* reduce the Groebner basis <G> w.r.t. newRing */
    42394520    G = kInterRedCC(F1, NULL);
     4521#ifdef TIME_TEST
    42404522    xtred=xtred+clock()-to;
     4523#endif
    42414524    idDelete(&F1);
    42424525
     
    42454528
    42464529  NEXT_VECTOR:
     4530#ifdef TIME_TEST
    42474531    to = clock();
     4532#endif
    42484533    /* compute a next weight vector */
    42494534    next_weight = MkInterRedNextWeight(curr_weight,target_weight, G);
     4535#ifdef TIME_TEST
    42504536    xtnw=xtnw+clock()-to;
     4537#endif
    42514538#ifdef PRINT_VECTORS
    42524539    MivString(curr_weight, target_weight, next_weight);
     
    42924579     // LAST_GB_ALT2:
    42934580        //nOverflow_Error = Overflow_Error;
     4581#ifdef TIME_TEST
    42944582        tproc = clock()-xftinput;
     4583#endif
    42954584        //Print("\n// takes %d steps and calls the recursion of level 2:",  nwalk);
    42964585        /* call the changed perturbation walk algorithm with degree 2 */
     
    43194608
    43204609#ifdef TIME_TEST
    4321  // Print("\n// \"Main procedure\"  took %d steps dnd %.2f sec. Overflow_Error (%d)", nwalk, ((double) tproc)/1000000, nOverflow_Error);
     4610  Print("\n// \"Main procedure\"  took %d steps dnd %.2f sec. Overflow_Error (%d)",
     4611        nwalk, ((double) tproc)/1000000, nOverflow_Error);
    43224612
    43234613  TimeStringFractal(xftinput, tostd, xtif, xtstd, xtextra,xtlift, xtred,xtnw);
     
    43554645 * compute a next weight vector *
    43564646 ********************************/
    4357 static intvec* MWalkRandomNextWeight(ideal G, intvec* curr_weight,
    4358                intvec* target_weight, int weight_rad, int pert_deg)
     4647static intvec* MWalkRandomNextWeight(ideal G, intvec* orig_M, intvec* target_weight,
     4648       int weight_rad, int pert_deg)
    43594649{
    4360   assume(currRing != NULL && curr_weight != NULL &&
     4650  assume(currRing != NULL && orig_M != NULL &&
    43614651         target_weight != NULL && G->m[0] != NULL);
    43624652
    4363   int i,weight_norm,nV = currRing->N;
    4364   intvec* next_weight2;
     4653  //BOOLEAN nError = Overflow_Error;
     4654  Overflow_Error = FALSE;
     4655
     4656  BOOLEAN found_random_weight = FALSE;
     4657  int i,nV = currRing->N;
     4658  intvec* curr_weight = new intvec(nV);
     4659
     4660  for(i=0; i<nV; i++)
     4661  {
     4662    (*curr_weight)[i] = (*orig_M)[i];
     4663  }
     4664
     4665  int k=0,weight_norm;
     4666  intvec* next_weight;
     4667  intvec* next_weight1 = MkInterRedNextWeight(curr_weight,target_weight,G);
     4668  intvec* next_weight2 = new intvec(nV);
    43654669  intvec* next_weight22 = new intvec(nV);
    43664670  intvec* result = new intvec(nV);
    4367 
    4368   intvec* next_weight1 =MkInterRedNextWeight(curr_weight,target_weight,G);
    4369   //compute a random next weight vector "next_weight2"
    4370   while(1)
     4671  intvec* curr_weight1;
     4672  ideal G_test, G_test1, G_test2;
     4673
     4674  //try to find a random next weight vector "next_weight2"
     4675  if(weight_rad > 0){ while(k<10)
    43714676  {
    43724677    weight_norm = 0;
     
    43764681      for(i=0; i<nV; i++)
    43774682      {
    4378         (*next_weight22)[i] = rand() % 60000 - 30000;
    4379         weight_norm = weight_norm + (*next_weight22)[i]*(*next_weight22)[i];
     4683        (*next_weight2)[i] = rand() % 60000 - 30000;
     4684        weight_norm = weight_norm + (*next_weight2)[i]*(*next_weight2)[i];
    43804685      }
    43814686      weight_norm = 1 + floor(sqrt(weight_norm));
     
    43844689    for(i=0; i<nV; i++)
    43854690    {
    4386       if((*next_weight22)[i] < 0)
    4387       {
    4388         (*next_weight22)[i] = 1 + (*curr_weight)[i] + floor(weight_rad*(*next_weight22)[i]/weight_norm);
     4691      if((*next_weight2)[i] < 0)
     4692      {
     4693        (*next_weight2)[i] = 1 + (*curr_weight)[i] + floor(weight_rad*(*next_weight2)[i]/weight_norm);
    43894694      }
    43904695      else
    43914696      {
    4392         (*next_weight22)[i] = (*curr_weight)[i] + floor(weight_rad*(*next_weight22)[i]/weight_norm);
    4393       }
    4394     }
    4395 
    4396     if(test_w_in_ConeCC(G, next_weight22) == 1)
    4397     {
    4398       next_weight2 = MkInterRedNextWeight(next_weight22,target_weight,G);
     4697        (*next_weight2)[i] = (*curr_weight)[i] + floor(weight_rad*(*next_weight2)[i]/weight_norm);
     4698      }
     4699    }
     4700   
     4701    if(test_w_in_ConeCC(G,next_weight2) == 1)
     4702    {
     4703      if(maxlengthpoly(MwalkInitialForm(G,next_weight2))<2)
     4704      {
     4705        next_weight2 = MkInterRedNextWeight(next_weight2,target_weight,G);
     4706      }
     4707/*
    43994708      if(MivAbsMax(next_weight2)>1147483647)
    44004709      {
     
    44044713        }
    44054714        i = 0;
    4406         /* reduce the size of the maximal entry of the vector*/
    4407         while(test_w_in_ConeCC(G,next_weight22))
     4715        // reduce the size of the maximal entry of the vector
     4716        while(test_w_in_ConeCC(G,next_weight22) == 1)
    44084717        {
    44094718          (*next_weight2)[i] = (*next_weight22)[i];
     
    44114720          (*next_weight22)[i] = floor(0.1*(*next_weight22)[i] + 0.5);
    44124721        }
    4413       }
    4414       delete next_weight22;
     4722        delete next_weight22;
     4723      }
     4724*/
     4725      G_test2 = MwalkInitialForm(G, next_weight2);
     4726      found_random_weight = TRUE;
    44154727      break;
    44164728    }
    4417   }
    4418  
    4419   // compute "usual" next weight vector
    4420   intvec* next_weight = MwalkNextWeightCC(curr_weight,target_weight, G);
    4421   ideal G_test = MwalkInitialForm(G, next_weight);
    4422   ideal G_test2 = MwalkInitialForm(G, next_weight2);
    4423 
     4729    k++;
     4730  }}
     4731Print("\n MWalkRandomNextWeight: compute perurbation...\n");
     4732  // compute "perturbed" next weight vector
     4733  if(pert_deg > 1)
     4734  {
     4735    curr_weight1 = MPertVectors(G,orig_M,pert_deg);
     4736    next_weight = MkInterRedNextWeight(curr_weight1,target_weight,G);
     4737    delete curr_weight1;
     4738  }
     4739  else
     4740  {
     4741    next_weight = MkInterRedNextWeight(curr_weight,target_weight,G);
     4742  }
     4743  if(MivSame(curr_weight,next_weight)==1 || Overflow_Error == TRUE)
     4744  {
     4745    Overflow_Error = FALSE;
     4746    delete next_weight;
     4747    next_weight = MkInterRedNextWeight(curr_weight,target_weight,G);
     4748  }
     4749  G_test=MwalkInitialForm(G,next_weight);
     4750  G_test1=MwalkInitialForm(G,next_weight1);
     4751Print("\n MWalkRandomNextWeight: finished...\n");
    44244752  // compare next weights
    44254753  if(Overflow_Error == FALSE)
    44264754  {
    4427     ideal G_test1 = MwalkInitialForm(G, next_weight1);
    4428     if(G_test1->m[0] != NULL && maxlengthpoly(G_test1) < maxlengthpoly(G_test))//if(IDELEMS(G_test1) < IDELEMS(G_test))
    4429     {
    4430       if(G_test2->m[0] != NULL && maxlengthpoly(G_test2) < maxlengthpoly(G_test1))//if(IDELEMS(G_test2) < IDELEMS(G_test1))
    4431       {
    4432         for(i=0; i<nV; i++)
     4755    if(found_random_weight == TRUE)
     4756    {
     4757    // random next weight vector found
     4758      if(G_test1->m[0] != NULL && maxlengthpoly(G_test1) < maxlengthpoly(G_test))
     4759      {
     4760        if(G_test2->m[0] != NULL && maxlengthpoly(G_test2) < maxlengthpoly(G_test1))
    44334761        {
    4434           (*result)[i] = (*next_weight2)[i];
     4762          for(i=0; i<nV; i++)
     4763          {
     4764            (*result)[i] = (*next_weight2)[i];
     4765          }
    44354766        }
     4767        else
     4768        {
     4769          for(i=0; i<nV; i++)
     4770          {
     4771            (*result)[i] = (*next_weight1)[i];
     4772          }
     4773        }   
    44364774      }
    44374775      else
    44384776      {
    4439         for(i=0; i<nV; i++)
     4777        if(G_test2->m[0] != NULL && maxlengthpoly(G_test2) < maxlengthpoly(G_test))
     4778        {
     4779          for(i=0; i<nV; i++)
     4780          {
     4781            (*result)[i] = (*next_weight2)[i];
     4782          }
     4783        }
     4784        else
     4785        {
     4786          for(i=0; i<nV; i++)
     4787          {
     4788            (*result)[i] = (*next_weight)[i];
     4789          }
     4790        }
     4791      }
     4792    }
     4793    else
     4794    {
     4795      // no random next weight vector found
     4796      if(G_test1->m[0] != NULL && maxlengthpoly(G_test1) < maxlengthpoly(G_test))
     4797      {
     4798       for(i=0; i<nV; i++)
    44404799        {
    44414800          (*result)[i] = (*next_weight1)[i];
    4442         }
    4443       }   
    4444     }
    4445     else
    4446     {
    4447       if(G_test2->m[0] != NULL && maxlengthpoly(G_test2) < maxlengthpoly(G_test))//if(IDELEMS(G_test2) < IDELEMS(G_test)) // |G_test2| < |G_test| <= |G_test1|
    4448       {
    4449         for(i=0; i<nV; i++)
    4450         {
    4451           (*result)[i] = (*next_weight2)[i];
    44524801        }
    44534802      }
     
    44604809      }
    44614810    }
    4462     idDelete(&G_test1);
    44634811  }
    44644812  else
    44654813  {
    44664814    Overflow_Error = FALSE;
    4467     if(G_test2->m[0] != NULL && maxlengthpoly(G_test2) < maxlengthpoly(G_test))//if(IDELEMS(G_test2) < IDELEMS(G_test))
    4468     {
    4469       for(i=1; i<nV; i++)
    4470       {
    4471         (*result)[i] = (*next_weight2)[i];
     4815    if(found_random_weight == TRUE)
     4816    {
     4817      if(G_test2->m[0] != NULL && maxlengthpoly(G_test2) < maxlengthpoly(G_test))
     4818      {
     4819        for(i=1; i<nV; i++)
     4820        {
     4821          (*result)[i] = (*next_weight2)[i];
     4822        }
     4823      }
     4824      else
     4825      {
     4826        for(i=0; i<nV; i++)
     4827        {
     4828          (*result)[i] = (*next_weight)[i];
     4829        }
    44724830      }
    44734831    }
     
    44804838    }
    44814839  }
    4482   //PrintS("\n MWalkRandomNextWeight: Ende ok!\n");
     4840 // delete curr_weight1;
     4841  delete next_weight;
     4842  delete next_weight2;
    44834843  idDelete(&G_test);
    4484   idDelete(&G_test2);
    4485   if(test_w_in_ConeCC(G, result) == 1)
    4486   {
    4487     delete next_weight2;
    4488     delete next_weight;
     4844  idDelete(&G_test1);
     4845  if(found_random_weight == TRUE)
     4846  {
     4847    idDelete(&G_test2);
     4848  }
     4849  if(test_w_in_ConeCC(G, result) == 1 && MivSame(curr_weight,result)==0)
     4850  {
     4851    delete curr_weight;
    44894852    delete next_weight1;
    44904853    return result;
     
    44924855  else
    44934856  {
     4857    delete curr_weight;
    44944858    delete result;
    4495     delete next_weight2;
    4496     delete next_weight1;
    4497     return next_weight;
     4859    return next_weight1;
    44984860  }
    44994861}
     
    45034865 * The procedur REC_GB_Mwalk computes a GB for <G> w.r.t. the weight order *
    45044866 * otw, where G is a reduced GB w.r.t. the weight order cw.                *
    4505  * The new procedur Mwalk calls REC_GB.                                    *
     4867 * The new procedure Mwalk calls REC_GB.                                   *
    45064868 ***************************************************************************/
    45074869static ideal REC_GB_Mwalk(ideal G, intvec* curr_weight, intvec* orig_target_weight,
     
    48065168
    48075169  ideal Gomega, M, F, Gomega1, Gomega2, M1, F1, G;
    4808   //ideal G1;
    4809   //ring endRing;
     5170
    48105171  ring newRing, oldRing;
    48115172  intvec* ivNull = new intvec(nV);
     
    48495210         the recursive changed perturbation walk alg. */
    48505211      tim = clock();
    4851       /*
     5212#ifdef CHECK_IDEAL_MWALK
    48525213        Print("\n// **** Groebnerwalk took %d steps and ", nwalk);
    48535214        PrintS("\n// **** call the rec. Pert. Walk to compute a red GB of:");
    4854         idElements(Gomega, "G_omega");
    4855       */
     5215        idString(Gomega, "Gomega");
     5216#endif
    48565217
    48575218      if(MivSame(exivlp, target_weight)==1)
     
    48595220      else
    48605221        goto NORMAL_GW;
    4861       /*
     5222#ifdef TIME_TEST
    48625223        Print("\n//  time for the last std(Gw)  = %.2f sec",
    48635224        ((double) (clock()-tim)/1000000));
    4864         PrintS("\n// ***************************************************\n");
    4865       */
     5225#endif
     5226/*
    48665227#ifdef CHECK_IDEAL_MWALK
    48675228      idElements(Gomega, "G_omega");
     
    48705231      //headidString(M, "M");
    48715232#endif
     5233*/
    48725234      to = clock();
    48735235      F = MLifttwoIdeal(Gomega, M, G);
     
    50295391}
    50305392
    5031 
    50325393/*******************************
    50335394 * THE GROEBNER WALK ALGORITHM *
     
    50875448#endif
    50885449  rComplete(currRing);
    5089 //#ifdef CHECK_IDEAL_MWALK
     5450#ifdef CHECK_IDEAL_MWALK
    50905451  if(printout > 2)
    50915452  {
    50925453    idString(Go,"//** Mwalk: Go");
    50935454  }
    5094 //#endif
     5455#endif
    50955456
    50965457  if(target_M->length() == nV)
     
    51175478  to = clock();
    51185479#endif
    5119 
    51205480  ideal G = MstdCC(idrMoveR(Go,baseRing,currRing));
    5121 
    51225481#ifdef TIME_TEST
    51235482  tostd = clock()-to;
     
    51315490    nwalk ++;
    51325491    nstep ++;
    5133 
     5492    //compute an initial form ideal of <G> w.r.t. "curr_vector"
    51345493#ifdef TIME_TEST
    51355494    to = clock();
    51365495#endif
    5137     // compute an initial form ideal of <G> w.r.t. "curr_vector"
    51385496    Gomega = MwalkInitialForm(G, curr_weight);
    51395497#ifdef TIME_TEST
     
    51415499#endif
    51425500
    5143 //#ifdef CHECK_IDEAL_MWALK
     5501#ifdef CHECK_IDEAL_MWALK
    51445502    if(printout > 1)
    51455503    {
    51465504      idString(Gomega,"//** Mwalk: Gomega");
    51475505    }
    5148 //#endif
     5506#endif
    51495507
    51505508    if(reduction == 0)
    51515509    {
    51525510      FF = middleOfCone(G,Gomega);
    5153       if( FF != NULL)
     5511      if(FF != NULL)
    51545512      {
    51555513        idDelete(&G);
     
    52135571#endif
    52145572    idSkipZeroes(M);
    5215 //#ifdef CHECK_IDEAL_MWALK
     5573#ifdef CHECK_IDEAL_MWALK
    52165574    if(printout > 2)
    52175575    {
    52185576      idString(M, "//** Mwalk: M");
    52195577    }
    5220 //#endif
     5578#endif
    52215579    //change the ring to baseRing
    52225580    rChangeCurrRing(baseRing);
     
    52315589    // where Gomega is a reduced Groebner basis w.r.t. the current ring
    52325590    F = MLifttwoIdeal(Gomega2, M1, G);
    5233 
    52345591#ifdef TIME_TEST
    52355592    tlift = tlift + clock() - to;
    52365593#endif
    5237 //#ifdef CHECK_IDEAL_MWALK
     5594#ifdef CHECK_IDEAL_MWALK
    52385595    if(printout > 2)
    52395596    {
    52405597      idString(F, "//** Mwalk: F");
    52415598    }
    5242 //#endif
     5599#endif
    52435600    idDelete(&Gomega2);
    52445601    idDelete(&M1);
     
    52495606    idSkipZeroes(G);
    52505607
    5251 //#ifdef CHECK_IDEAL_MWALK
     5608#ifdef CHECK_IDEAL_MWALK
    52525609    if(printout > 2)
    52535610    {
    52545611      idString(G, "//** Mwalk: G");
    52555612    }
    5256 //#endif
     5613#endif
    52575614
    52585615    rChangeCurrRing(targetRing);
     
    52705627    baseRing = currRing;
    52715628
     5629    NEXT_VECTOR:
     5630#ifdef TIME_TEST
     5631    to = clock();
     5632#endif
     5633    intvec* next_weight = MwalkNextWeightCC(curr_weight,target_weight,G);
     5634#ifdef TIME_TEST
     5635    tnw = tnw + clock() - to;
     5636#endif
     5637#ifdef PRINT_VECTORS
     5638    if(printout > 0)
     5639    {
     5640      MivString(curr_weight, target_weight, next_weight);
     5641    }
     5642#endif
     5643    if(MivComp(target_weight,curr_weight) == 1)// || endwalks == TRUE)
     5644    {
    52725645/*
    5273 #ifdef TIME_TEST
    5274     to = clock();
    5275 #endif
    5276 
    5277 #ifdef TIME_TEST
    5278     tstd = tstd + clock() - to;
    5279 #endif
    5280 */
    5281 
    5282 
    5283 #ifdef TIME_TEST
    5284     to = clock();
    5285 #endif
    5286     NEXT_VECTOR:
    5287     intvec* next_weight = MwalkNextWeightCC(curr_weight,target_weight,G);
    5288 #ifdef TIME_TEST
    5289     tnw = tnw + clock() - to;
    5290 #endif
    5291 //#ifdef PRINT_VECTORS
    5292     if(printout > 0)
    5293     {
    5294       MivString(curr_weight, target_weight, next_weight);
    5295     }
    5296 //#endif
    5297     if(MivComp(target_weight,curr_weight) == 1)// || endwalks == TRUE)
    5298     {/*
    5299 //#ifdef CHECK_IDEAL_MWALK
     5646#ifdef CHECK_IDEAL_MWALK
    53005647      if(printout > 0)
    53015648      {
    53025649        PrintS("\n//** Mwalk: entering last cone.\n");
    53035650      }
    5304 //#endif
     5651#endif
    53055652
    53065653      Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector"
     
    53165663      Gomega1 = idrMoveR(Gomega, baseRing,currRing);
    53175664      idDelete(&Gomega);
    5318 //#ifdef CHECK_IDEAL_MWALK
     5665#ifdef CHECK_IDEAL_MWALK
    53195666      if(printout > 1)
    53205667      {
     
    53225669      }
    53235670      PrintS("\n //** Mwalk: kStd(Gomega)");
    5324 //#endif
     5671#endif
    53255672      M = kStd(Gomega1,NULL,testHomog,NULL,NULL,0,0,NULL);
    5326 //#ifdef CHECK_IDEAL_MWALK
     5673#ifdef CHECK_IDEAL_MWALK
    53275674      if(printout > 1)
    53285675      {
    53295676        idString(M,"//** Mwalk: M");
    53305677      }
    5331 //#endif
     5678#endif
    53325679      rChangeCurrRing(baseRing);
    53335680      M1 =  idrMoveR(M, newRing,currRing);
     
    53375684      //PrintS("\n //** Mwalk: MLifttwoIdeal");
    53385685      F = MLifttwoIdeal(Gomega2, M1, G);
    5339 //#ifdef CHECK_IDEAL_MWALK
     5686#ifdef CHECK_IDEAL_MWALK
    53405687      if(printout > 2)
    53415688      {
    53425689        idString(F,"//** Mwalk: F");
    53435690      }
    5344 //#endif
     5691#endif
    53455692      idDelete(&Gomega2);
    53465693      idDelete(&M1);
     
    53495696      idDelete(&F);
    53505697      baseRing = currRing;
    5351       si_opt_1 = save1; //set original options, e. g. option(RedSB)
    53525698      idSkipZeroes(G);
    53535699#ifdef TIME_TEST
     
    53615707#endif
    53625708      idSkipZeroes(G);
    5363       delete next_weight; */
     5709      delete next_weight;
     5710*/
    53645711      break;
    53655712    }
     
    53885735#endif
    53895736  Print("\n//** Mwalk: Groebner Walk took %d steps.\n", nstep);
     5737  si_opt_1 = save1; //set original options
    53905738  return(result);
    53915739}
     
    54015749    si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions
    54025750  }
     5751
    54035752  Set_Error(FALSE);
    54045753  Overflow_Error = FALSE;
    5405   //BOOLEAN endwalks = FALSE;
     5754  BOOLEAN endwalks = FALSE;
    54065755#ifdef TIME_TEST
    54075756  clock_t tinput, tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0;
     
    54115760#endif
    54125761  nstep=0;
    5413   int i,polylength,nwalk;
     5762  int i,nwalk;//polylength;
    54145763  int nV = currRing->N;
     5764
     5765  //check that weight radius is valid
     5766  if(weight_rad < 0)
     5767  {
     5768    Werror("Invalid radius.\n");
     5769    return NULL;
     5770  }
     5771
     5772  //check that perturbation degree is valid
     5773  if(pert_deg > nV || pert_deg < 1)
     5774  {
     5775    Werror("Invalid perturbation degree.\n");
     5776    return NULL;
     5777  }
    54155778
    54165779  ideal Gomega, M, F,FF, Gomega1, Gomega2, M1;
     
    54195782  ring baseRing = currRing;
    54205783  ring XXRing = currRing;
     5784  intvec* iv_M;
    54215785  intvec* ivNull = new intvec(nV);
    54225786  intvec* curr_weight = new intvec(nV);
    54235787  intvec* target_weight = new intvec(nV);
    5424   intvec* exivlp = Mivlp(nV);
    54255788  intvec* next_weight= new intvec(nV);
    5426 /*
    5427   intvec* tmp_weight = new intvec(nV);
    5428   for(i=0; i<nV; i++)
    5429   {
    5430     (*tmp_weight)[i] = (*target_M)[i];
    5431   }
    5432 */
     5789
    54335790  for(i=0; i<nV; i++)
    54345791  {
     
    54365793    (*target_weight)[i] = (*target_M)[i];
    54375794  }
     5795
    54385796#ifndef BUCHBERGER_ALG
    54395797  intvec* hilb_func;
     
    54475805#endif
    54485806  rComplete(currRing);
     5807
     5808  if(target_M->length() == nV)
     5809  {
     5810    targetRing = VMrDefault(target_weight); // define the target ring
     5811  }
     5812  else
     5813  {
     5814    targetRing = VMatrDefault(target_M);
     5815  }
     5816  if(orig_M->length() == nV)
     5817  {
     5818    newRing = VMrDefault(curr_weight); // define a new ring with ordering "(a(curr_weight),lp)
     5819  }
     5820  else
     5821  {
     5822    newRing = VMatrDefault(orig_M);
     5823  }
     5824  rChangeCurrRing(newRing);
    54495825#ifdef TIME_TEST
    54505826  to = clock();
    54515827#endif
    5452 
    5453   if(target_M->length() == nV)
    5454   {
    5455    // define the target ring
    5456     targetRing = VMrDefault(target_weight);
    5457   }
    5458   else
    5459   {
    5460     targetRing = VMatrDefault(target_M);
    5461   }
    5462   if(orig_M->length() == nV)
    5463   {
    5464     newRing = VMrDefault(curr_weight); // define a new ring with ordering "(a(curr_weight),lp)
    5465   }
    5466   else
    5467   {
    5468     newRing = VMatrDefault(orig_M);
    5469   }
    5470   rChangeCurrRing(newRing);
    54715828  ideal G = MstdCC(idrMoveR(Go,baseRing,currRing));
     5829#ifdef TIME_TEST
     5830  tostd = clock()-to;
     5831#endif
    54725832  baseRing = currRing;
    5473 #ifdef TIME_TEST
    5474   tostd = clock()-to;
    5475 #endif
    5476 
    54775833  nwalk = 0;
     5834
     5835#ifdef TIME_TEST
     5836  to = clock();
     5837#endif
     5838  Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector"
     5839#ifdef TIME_TEST
     5840  tif = tif + clock()-to; //time for computing initial form ideal
     5841#endif
     5842
    54785843  while(1)
    54795844  {
    54805845    nwalk ++;
    54815846    nstep ++;
    5482 #ifdef TIME_TEST
    5483     to = clock();
    5484 #endif
    5485 
    5486     Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector"
    5487     //polylength = 1 if there is a polynomial in Gomega with at least 3 monomials and 0 otherwise
    5488     polylength = lengthpoly(Gomega);
    5489 #ifdef TIME_TEST
    5490     tif = tif + clock()-to; //time for computing initial form ideal
    5491 #endif
    5492 //#ifdef CHECK_IDEAL_MWALK
     5847#ifdef CHECK_IDEAL_MWALK
    54935848    if(printout > 1)
    54945849    {
    54955850      idString(Gomega,"//** Mrwalk: Gomega");
    54965851    }
    5497 //#endif
    5498     // test whether target cone is reached
    5499 /*    if(test_w_in_ConeCC(G,target_weight) == 1)
    5500     {
    5501       endwalks = TRUE;
    5502     }*/
     5852#endif
    55035853    if(reduction == 0)
    55045854    {
    5505      
    55065855      FF = middleOfCone(G,Gomega);
    5507      
    55085856      if(FF != NULL)
    55095857      {
     
    55115859        G = idCopy(FF);
    55125860        idDelete(&FF);
    5513        
    55145861        goto NEXT_VECTOR;
    55155862      }
     
    55415888     {
    55425889       newRing = VMrDefault(curr_weight); // define a new ring with ordering "(a(curr_weight),lp)
    5543        //newRing = VMrRefine(curr_weight,target_weight); //define a new ring with ordering "(a(curr_weight),Wp(target_weight))"
    55445890     }
    55455891     else
     
    55555901    to = clock();
    55565902#endif
    5557 #ifndef  BUCHBERGER_ALG
     5903#ifndef BUCHBERGER_ALG
    55585904    M=kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight);
    55595905    delete hilb_func;
     
    55655911#endif
    55665912    idSkipZeroes(M);
    5567 //#ifdef CHECK_IDEAL_MWALK
     5913#ifdef CHECK_IDEAL_MWALK
    55685914    if(printout > 2)
    55695915    {
    55705916      idString(M, "//** Mrwalk: M");
    55715917    }
    5572 //#endif
     5918#endif
    55735919    //change the ring to baseRing
    55745920    rChangeCurrRing(baseRing);
     
    55865932    tlift = tlift + clock() - to;
    55875933#endif
    5588 //#ifdef CHECK_IDEAL_MWALK
     5934#ifdef CHECK_IDEAL_MWALK
    55895935    if(printout > 2)
    55905936    {
    5591       idString(F, "//** Mrwalk: F");
    5592     }
    5593 //#endif
     5937      idString(F,"//** Mrwalk: F");
     5938    }
     5939#endif
    55945940    idDelete(&Gomega2);
    55955941    idDelete(&M1);
     
    56035949#endif
    56045950    idSkipZeroes(G);
    5605 //#ifdef CHECK_IDEAL_MWALK
     5951#ifdef CHECK_IDEAL_MWALK
    56065952    if(printout > 2)
    56075953    {
    5608       idString(G, "//** Mrwalk: G");
    5609     }
    5610 //#endif
     5954      idString(G,"//** Mrwalk: G");
     5955    }
     5956#endif
    56115957
    56125958    rChangeCurrRing(targetRing);
    56135959    G = idrMoveR(G,newRing,currRing);
     5960
    56145961    // test whether target cone is reached
    56155962    if(reduction !=0 && test_w_in_ConeCC(G,curr_weight) == 1)
     
    56235970    baseRing = currRing;
    56245971
    5625 
    56265972    NEXT_VECTOR:
    56275973#ifdef TIME_TEST
     
    56295975#endif
    56305976    next_weight = MwalkNextWeightCC(curr_weight,target_weight,G);
    5631     if(polylength > 0)
     5977#ifdef TIME_TEST
     5978    tnw = tnw + clock() - to;
     5979#endif
     5980
     5981#ifdef TIME_TEST
     5982    to = clock();
     5983#endif
     5984    Gomega = MwalkInitialForm(G, next_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector"
     5985#ifdef TIME_TEST
     5986    tif = tif + clock()-to; //time for computing initial form ideal
     5987#endif
     5988
     5989    //lengthpoly(Gomega) = 1 if there is a polynomial in Gomega with at least 3 monomials and 0 otherwise
     5990    //polylength = lengthpoly(Gomega);
     5991    if(lengthpoly(Gomega) > 0)
    56325992    {
    56335993      //there is a polynomial in Gomega with at least 3 monomials,
    56345994      //low-dimensional facet of the cone
    56355995      delete next_weight;
    5636       next_weight = MWalkRandomNextWeight(G, curr_weight, target_weight, weight_rad, pert_deg);
    5637     }
    5638 #ifdef TIME_TEST
    5639     tnw = tnw + clock() - to;
    5640 #endif
    5641 //#ifdef PRINT_VECTORS
     5996      if(target_M->length() == nV)
     5997      {
     5998        iv_M = MivMatrixOrder(curr_weight);
     5999      }
     6000      else
     6001      {
     6002        iv_M = MivMatrixOrderRefine(curr_weight,target_M);
     6003      }
     6004#ifdef TIME_TEST
     6005      to = clock();
     6006#endif
     6007      next_weight = MWalkRandomNextWeight(G, iv_M, target_weight, weight_rad, pert_deg);
     6008#ifdef TIME_TEST
     6009      tnw = tnw + clock() - to;
     6010#endif
     6011      idDelete(&Gomega);
     6012#ifdef TIME_TEST
     6013      to = clock();
     6014#endif
     6015      Gomega = MwalkInitialForm(G, next_weight);
     6016#ifdef TIME_TEST
     6017      tif = tif + clock()-to; //time for computing initial form ideal
     6018#endif
     6019      delete iv_M;
     6020    }
     6021
     6022    // test whether target weight vector is reached
     6023    if(MivComp(next_weight, ivNull) == 1 || MivComp(target_weight,curr_weight) == 1)
     6024    {
     6025      baseRing = currRing;
     6026      delete next_weight;
     6027      break;
     6028    }
     6029
     6030#ifdef PRINT_VECTORS
    56426031    if(printout > 0)
    56436032    {
    56446033      MivString(curr_weight, target_weight, next_weight);
    56456034    }
    5646 //#endif
    5647     if(MivComp(next_weight, ivNull) == 1 || MivComp(target_weight,curr_weight) == 1)// || endwalks == TRUE)
    5648     {/*
    5649 //#ifdef CHECK_IDEAL_MWALK
    5650       if(printout > 0)
    5651       {
    5652         PrintS("\n//** Mrwalk: entering last cone.\n");
    5653       }
    5654 //#endif
    5655 
    5656       Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector"
    5657       if(target_M->length() == nV)
    5658       {
    5659         newRing = VMrDefault(target_weight); // define a new ring with ordering "(a(curr_weight),lp)
    5660       }
    5661       else
    5662       {
    5663         newRing = VMatrDefault(target_M);
    5664       }
    5665       rChangeCurrRing(newRing);
    5666       Gomega1 = idrMoveR(Gomega, baseRing,currRing);
    5667       idDelete(&Gomega);
    5668 //#ifdef CHECK_IDEAL_MWALK
    5669       if(printout > 1)
    5670       {
    5671         idString(Gomega1, "//** Mrwalk: Gomega");
    5672       }
    5673       PrintS("\n //** Mrwalk: kStd(Gomega)");
    5674 //#endif
    5675       M = kStd(Gomega1,NULL,testHomog,NULL,NULL,0,0,NULL);
    5676 //#ifdef CHECK_IDEAL_MWALK
    5677       if(printout > 1)
    5678       {
    5679         idString(M,"//** Mrwalk: M");
    5680       }
    5681 //#endif
    5682       rChangeCurrRing(baseRing);
    5683       M1 =  idrMoveR(M, newRing,currRing);
    5684       idDelete(&M);
    5685       Gomega2 = idrMoveR(Gomega1, newRing,currRing);
    5686       idDelete(&Gomega1);
    5687       //PrintS("\n //** Mrwalk: MLifttwoIdeal");
    5688       F = MLifttwoIdeal(Gomega2, M1, G);
    5689 //#ifdef CHECK_IDEAL_MWALK
    5690       if(printout > 2)
    5691       {
    5692         idString(F,"//** Mrwalk: F");
    5693       }
    5694 //#endif
    5695       idDelete(&Gomega2);
    5696       idDelete(&M1);
    5697       rChangeCurrRing(newRing); // change the ring to newRing
    5698       G = idrMoveR(F,baseRing,currRing);
    5699       idDelete(&F);
    5700       baseRing = currRing;
    5701       si_opt_1 = save1; //set original options, e. g. option(RedSB)
    5702       idSkipZeroes(G);
    5703 #ifdef TIME_TEST
    5704       to = clock();
    5705 #endif
    5706       //PrintS("\n //**Mrwalk: Interreduce");
    5707       //interreduce the Groebner basis <G> w.r.t. currRing
    5708       //G = kInterRedCC(G,NULL);
    5709 #ifdef TIME_TEST
    5710       tred = tred + clock() - to;
    5711 #endif
    5712       idSkipZeroes(G);
    5713       delete next_weight;*/
    5714       break;
    5715     }
     6035#endif
    57166036
    57176037    for(i=nV-1; i>=0; i--)
    57186038    {
    5719       //(*tmp_weight)[i] = (*curr_weight)[i];
    57206039      (*curr_weight)[i] = (*next_weight)[i];
    57216040    }
     
    57266045  ideal result = idrMoveR(G,baseRing,currRing);
    57276046  idDelete(&G);
    5728   si_opt_1 = save1; //set original options, e. g. option(RedSB)
    5729   //delete tmp_weight;
    57306047  delete ivNull;
    5731   delete exivlp;
    57326048#ifndef BUCHBERGER_ALG
    57336049  delete last_omega;
     
    57396055  //Print("\n// Overflow_Error? (%d)\n", Overflow_Error);
    57406056#endif
     6057  si_opt_1 = save1; //set original options
    57416058  return(result);
    57426059}
    5743 
    5744 //unused
    5745 #if 0
    5746 ideal Mwalk_tst(ideal Go, intvec* curr_weight, intvec* target_weight)
    5747 {
    5748   //clock_t tinput=clock();
    5749   //idString(Go,"Ginp");
    5750   int i, nV = currRing->N;
    5751   int nwalk=0, endwalks=0;
    5752 
    5753   ideal Gomega, M, F, Gomega1, Gomega2, M1, F1, G;
    5754   // ideal G1; ring endRing;
    5755   ring newRing, oldRing;
    5756   intvec* ivNull = new intvec(nV);
    5757   ring XXRing = currRing;
    5758 
    5759   intvec* tmp_weight = new intvec(nV);
    5760   for(i=nV-1; i>=0; i--)
    5761   {
    5762     (*tmp_weight)[i] = (*curr_weight)[i];
    5763   }
    5764   /* the monomial ordering of this current ring would be "dp" */
    5765   G = MstdCC(Go);
    5766 #ifndef BUCHBERGER_ALG
    5767   intvec* hilb_func;
    5768 #endif
    5769   /* to avoid (1,0,...,0) as the target vector */
    5770   intvec* last_omega = new intvec(nV);
    5771   for(i=nV-1; i>0; i--)
    5772     (*last_omega)[i] = 1;
    5773   (*last_omega)[0] = 10000;
    5774 
    5775   while(1)
    5776   {
    5777     nwalk ++;
    5778     //Print("\n// Entering the %d-th step:", nwalk);
    5779     //Print("\n// ring r[%d] = %s;", nwalk, rString(currRing));
    5780     idString(G,"G");
    5781     /* compute an initial form ideal of <G> w.r.t. "curr_vector" */
    5782     Gomega = MwalkInitialForm(G, curr_weight);
    5783     //ivString(curr_weight, "omega");
    5784     idString(Gomega,"Gw");
    5785 
    5786 #ifndef  BUCHBERGER_ALG
    5787     if(isNolVector(curr_weight) == 0)
    5788       hilb_func = hFirstSeries(Gomega,NULL,NULL,curr_weight,currRing);
    5789     else
    5790       hilb_func = hFirstSeries(Gomega,NULL,NULL,last_omega,currRing);
    5791 #endif // BUCHBERGER_ALG
    5792 
    5793 
    5794     oldRing = currRing;
    5795 
    5796     /* define a new ring that its ordering is "(a(curr_weight),lp) */
    5797     VMrDefault(curr_weight);
    5798     newRing = currRing;
    5799 
    5800     Gomega1 = idrMoveR(Gomega, oldRing,currRing);
    5801 
    5802     /* compute a reduced Groebner basis of <Gomega> w.r.t. "newRing" */
    5803 #ifdef  BUCHBERGER_ALG
    5804     M = MstdhomCC(Gomega1);
    5805 #else
    5806     M=kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight);
    5807     delete hilb_func;
    5808 #endif // BUCHBERGER_ALG
    5809 
    5810     idString(M,"M");
    5811 
    5812       /* change the ring to oldRing */
    5813     rChangeCurrRing(oldRing);
    5814     M1 =  idrMoveR(M, newRing,currRing);
    5815     Gomega2 =  idrMoveR(Gomega1, newRing,currRing);
    5816 
    5817       /* compute a representation of the generators of submod (M)
    5818          with respect to those of mod (Gomega).
    5819          Gomega is a reduced Groebner basis w.r.t. the current ring */
    5820     F = MLifttwoIdeal(Gomega2, M1, G);
    5821     idDelete(&M1);
    5822     idDelete(&Gomega2);
    5823     idDelete(&G);
    5824     idString(F,"F");
    5825 
    5826     /* change the ring to newRing */
    5827     rChangeCurrRing(newRing);
    5828     F1 = idrMoveR(F, oldRing,currRing);
    5829 
    5830     /* reduce the Groebner basis <G> w.r.t. new ring */
    5831     G = kInterRedCC(F1, NULL);
    5832     //idSkipZeroes(G);//done by kInterRed
    5833     idDelete(&F1);
    5834     idString(G,"G");
    5835     if(endwalks == 1)
    5836       break;
    5837 
    5838     /* compute a next weight vector */
    5839     intvec* next_weight = MkInterRedNextWeight(curr_weight,target_weight,G);
    5840 #ifdef PRINT_VECTORS
    5841     MivString(curr_weight, target_weight, next_weight);
    5842 #endif
    5843 
    5844     if(MivComp(next_weight, ivNull) == 1)
    5845     {
    5846       delete next_weight;
    5847       break;
    5848     }
    5849     if(MivComp(next_weight, target_weight) == 1)
    5850       endwalks = 1;
    5851 
    5852     for(i=nV-1; i>=0; i--)
    5853       (*tmp_weight)[i] = (*curr_weight)[i];
    5854 
    5855     /* 06.11.01 to free the memory: NOT Changed!!*/
    5856     for(i=nV-1; i>=0; i--)
    5857       (*curr_weight)[i] = (*next_weight)[i];
    5858     delete next_weight;
    5859   }
    5860   rChangeCurrRing(XXRing);
    5861   G = idrMoveR(G, newRing,currRing);
    5862 
    5863   delete tmp_weight;
    5864   delete ivNull;
    5865   PrintLn();
    5866   return(G);
    5867 }
    5868 #endif
    58696060
    58706061/**************************************************************/
     
    58806071   2) the changed perturbation walk algorithm with a decreased degree.
    58816072*/
    5882 // use kStd, if nP = 0, else call LastGB
     6073// if nP = 0 use kStd, else call LastGB
    58836074ideal Mpwalk(ideal Go, int op_deg, int tp_deg,intvec* curr_weight,
    58846075             intvec* target_weight, int nP, int reduction, int printout)
     
    58886079  {
    58896080    si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis
    5890     //si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions
    5891     //si_opt_1|=(Sy_bit(OPT_REDTAIL)|Sy_bit(OPT_REDSB));
     6081    si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions
    58926082  }
    58936083  Set_Error(FALSE  );
    58946084  Overflow_Error = FALSE;
    58956085  //Print("// pSetm_Error = (%d)", ErrorCheck());
    5896 
     6086#ifdef TIME_TEST
    58976087  clock_t  tinput, tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0;
    58986088  xtextra=0;
     
    59016091
    59026092  clock_t tim;
    5903 
     6093#endif
    59046094  nstep = 0;
    59056095  int i, ntwC=1, ntestw=1,  nV = currRing->N;
     6096
     6097  //check that perturbation degree is valid
     6098  if(op_deg < 1 || tp_deg < 1 || op_deg > nV || tp_deg > nV)
     6099  {
     6100    Werror("Invalid perturbation degree.\n");
     6101    return NULL;
     6102  }
     6103
    59066104  BOOLEAN endwalks = FALSE;
    5907 
    59086105  ideal Gomega, M, F, FF, G, Gomega1, Gomega2, M1,F1,Eresult,ssG;
    59096106  ring newRing, oldRing, TargetRing;
     
    59276124
    59286125  ring XXRing = currRing;
    5929 
     6126#ifdef TIME_TEST
    59306127  to = clock();
     6128#endif
    59316129  // perturbs the original vector
    59326130  if(MivComp(curr_weight, iv_dp) == 1) //rOrdStr(currRing) := "dp"
    59336131  {
    59346132    G = MstdCC(Go);
     6133#ifdef TIME_TEST
    59356134    tostd = clock()-to;
     6135#endif
    59366136    if(op_deg != 1){
    59376137      iv_M_dp = MivMatrixOrderdp(nV);
     
    59506150    G = idrMoveR(Go, XXRing,currRing);
    59516151    G = MstdCC(G);
     6152#ifdef TIME_TEST
    59526153    tostd = clock()-to;
     6154#endif
    59536155    if(op_deg != 1){
    59546156      iv_M_dp = MivMatrixOrder(curr_weight);
     
    59866188    G = idrMoveR(ssG, TargetRing,currRing);
    59876189  }
    5988     if(printout > 0)
    5989     {
    5990       Print("\n//** Mpwalk: Perturbation Walk of degree (%d,%d):",op_deg,tp_deg);
    5991       ivString(curr_weight, "//** Mpwalk: new current weight");
    5992       ivString(target_weight, "//** Mpwalk: new target weight");
    5993     }
     6190  if(printout > 0)
     6191  {
     6192    Print("\n//** Mpwalk: Perturbation Walk of degree (%d,%d):",op_deg,tp_deg);
     6193#ifdef PRINT_VECTORS
     6194    ivString(curr_weight, "//** Mpwalk: new current weight");
     6195    ivString(target_weight, "//** Mpwalk: new target weight");
     6196#endif
     6197  }
    59946198  while(1)
    59956199  {
    59966200    nstep ++;
     6201#ifdef TIME_TEST
    59976202    to = clock();
     6203#endif
    59986204    // compute an initial form ideal of <G> w.r.t. the weight vector
    59996205    // "curr_weight"
    60006206    Gomega = MwalkInitialForm(G, curr_weight);
    6001 //#ifdef CHECK_IDEAL_MWALK
     6207#ifdef TIME_TEST
     6208    tif = tif + clock()-to;
     6209#endif
     6210#ifdef CHECK_IDEAL_MWALK
    60026211    if(printout > 1)
    60036212    {
    60046213      idString(Gomega,"//** Mpwalk: Gomega");
    60056214    }
    6006 //#endif
     6215#endif
    60076216    if(reduction == 0 && nstep > 1)
    60086217    {
     6218/*
    60096219      // check whether weight vector is in the interior of the cone
    60106220      while(1)
     
    60176227          idDelete(&FF);
    60186228          next_weight = MwalkNextWeightCC(curr_weight,target_weight,G);
     6229#ifdef PRINT_VECTORS
    60196230          if(printout > 0)
    60206231          {
    60216232            MivString(curr_weight, target_weight, next_weight);
    60226233          }
     6234#endif
    60236235        }
    60246236        else
     
    60316243        }
    60326244        Gomega = MwalkInitialForm(G, curr_weight);
     6245#ifdef CHECK_IDEAL_MWALK
    60336246        if(printout > 1)
    60346247        {
    60356248          idString(Gomega,"//** Mpwalk: Gomega");
    60366249        }
     6250#endif
     6251      }
     6252*/
     6253      FF = middleOfCone(G,Gomega);
     6254      if(FF != NULL)
     6255      {
     6256        idDelete(&G);
     6257        G = idCopy(FF);
     6258        idDelete(&FF);
     6259        goto NEXT_VECTOR;
    60376260      }
    60386261    }
     
    60426265    {
    60436266      Print("\n// ring r%d = %s;\n", nstep, rString(currRing));
     6267/*
    60446268      idElements(G, "G");
    60456269      headidString(G, "G");
    6046     }
    6047 #endif
    6048 
    6049     tif = tif + clock()-to;
     6270*/
     6271    }
     6272#endif
    60506273
    60516274#ifndef  BUCHBERGER_ALG
     
    60716294    {
    60726295      Print("\n// ring r%d = %s;\n", nstep, rString(currRing));
     6296/*
    60736297      idElements(Gomega1, "Gw");
    60746298      headidString(Gomega1, "headGw");
     6299*/
    60756300      PrintS("\n// compute a rGB of Gw:\n");
    6076 
    60776301#ifndef  BUCHBERGER_ALG
    60786302      ivString(hilb_func, "w");
     
    60806304    }
    60816305#endif
    6082 
     6306#ifdef TIME_TEST
    60836307    tim = clock();
    60846308    to = clock();
     6309#endif
    60856310    // compute a reduced Groebner basis of <Gomega> w.r.t. "newRing"
    60866311#ifdef  BUCHBERGER_ALG
     
    60906315    delete hilb_func;
    60916316#endif
    6092 //#ifdef CHECK_IDEAL_MWALK
    6093       if(printout > 2)
    6094       {
    6095         idString(M,"//** Mpwalk: M");
    6096       }
    6097 //#endif
    6098 
    6099     if(endwalks == TRUE){
     6317
     6318    if(endwalks == TRUE)
     6319    {
     6320#ifdef TIME_TEST
    61006321      xtstd = xtstd+clock()-to;
     6322#endif
    61016323#ifdef ENDWALKS
    61026324      Print("\n// time for the last std(Gw)  = %.2f sec\n",
     
    61056327    }
    61066328    else
     6329    {
     6330#ifdef TIME_TEST
    61076331      tstd=tstd+clock()-to;
    6108 
     6332#endif
     6333    }
     6334#ifdef CHECK_IDEAL_MWALK
     6335    if(printout > 2)
     6336    {
     6337      idString(M,"//** Mpwalk: M");
     6338    }
     6339#endif
    61096340    // change the ring to oldRing
    61106341    rChangeCurrRing(oldRing);
    61116342    M1 =  idrMoveR(M, newRing,currRing);
    61126343    Gomega2 =  idrMoveR(Gomega1, newRing,currRing);
    6113 
     6344#ifdef TIME_TEST
    61146345    to=clock();
     6346#endif
    61156347    /* compute a representation of the generators of submod (M)
    61166348       with respect to those of mod (Gomega).
    61176349       Gomega is a reduced Groebner basis w.r.t. the current ring */
    61186350    F = MLifttwoIdeal(Gomega2, M1, G);
     6351#ifdef TIME_TEST
    61196352    if(endwalks == FALSE)
    61206353      tlift = tlift+clock()-to;
    61216354    else
    61226355      xtlift=clock()-to;
    6123 
    6124 //#ifdef CHECK_IDEAL_MWALK
     6356#endif
     6357#ifdef CHECK_IDEAL_MWALK
    61256358    if(printout > 2)
    61266359    {
    61276360      idString(F,"//** Mpwalk: F");
    61286361    }
    6129 //#endif
     6362#endif
    61306363
    61316364    idDelete(&M1);
     
    61466379        PrintS("\n //** Mpwalk: reduce the Groebner basis.\n");
    61476380      }
     6381#ifdef TIME_TEST
    61486382      to=clock();
     6383#endif
    61496384      G = kInterRedCC(F1, NULL);
     6385#ifdef TIME_TEST
    61506386      if(endwalks == FALSE)
    61516387        tred = tred+clock()-to;
    61526388      else
    61536389        xtred=clock()-to;
     6390#endif
    61546391      idDelete(&F1);
    61556392    }
     
    61576394      break;
    61586395
     6396    NEXT_VECTOR:
     6397#ifdef TIME_TEST
    61596398    to=clock();
     6399#endif
    61606400    // compute a next weight vector
    61616401    next_weight = MkInterRedNextWeight(curr_weight,target_weight, G);
     6402#ifdef TIME_TEST
    61626403    tnw=tnw+clock()-to;
    6163 //#ifdef PRINT_VECTORS
     6404#endif
     6405#ifdef PRINT_VECTORS
    61646406    if(printout > 0)
    61656407    {
    61666408      MivString(curr_weight, target_weight, next_weight);
    61676409    }
    6168 //#endif
     6410#endif
    61696411
    61706412    if(Overflow_Error == TRUE)
     
    62086450    TargetRing=currRing;
    62096451    F1 = idrMoveR(G, newRing,currRing);
    6210 #ifdef CHECK_IDEAL
     6452/*
     6453#ifdef CHECK_IDEAL_MWALK
    62116454      headidString(G, "G");
    62126455#endif
    6213 
     6456*/
    62146457
    62156458    // check whether the pertubed target vector stays in the correct cone
     
    62896532  {
    62906533    si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis
    6291     //si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions
    6292     //si_opt_1|=(Sy_bit(OPT_REDTAIL)|Sy_bit(OPT_REDSB));
     6534    si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions
    62936535  }
    62946536  Set_Error(FALSE);
    62956537  Overflow_Error = FALSE;
    62966538  //Print("// pSetm_Error = (%d)", ErrorCheck());
    6297 
     6539#ifdef TIME_TEST
    62986540  clock_t  tinput, tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0;
    62996541  xtextra=0;
     
    63026544
    63036545  clock_t tim;
    6304 
     6546#endif
    63056547  nstep = 0;
    6306   int i, ntwC=1, ntestw=1, polylength, nV = currRing->N;
     6548  int i, ntwC=1, ntestw=1, nV = currRing->N; //polylength
     6549
     6550  //check that weight radius is valid
     6551  if(weight_rad < 0)
     6552  {
     6553    Werror("Invalid radius.\n");
     6554    return NULL;
     6555  }
     6556
     6557  //check that perturbation degree is valid
     6558  if(op_deg < 1 || tp_deg < 1 || op_deg > nV || tp_deg > nV)
     6559  {
     6560    Werror("Invalid perturbation degree.\n");
     6561    return NULL;
     6562  }
     6563
    63076564  BOOLEAN endwalks = FALSE;
    63086565
    63096566  ideal Gomega, M, F, FF, G, Gomega1, Gomega2, M1,F1,Eresult,ssG;
    63106567  ring newRing, oldRing, TargetRing;
     6568  intvec* iv_M;
    63116569  intvec* iv_M_dp;
    63126570  intvec* iv_M_lp;
     
    63366594  ring XXRing = currRing;
    63376595
    6338   to = clock();
    63396596  // perturbs the original vector
    63406597  if(orig_M->length() == nV)
     
    63426599    if(MivComp(curr_weight, iv_dp) == 1) //rOrdStr(currRing) := "dp"
    63436600    {
     6601#ifdef TIME_TEST
     6602  to = clock();
     6603#endif
    63446604      G = MstdCC(Go);
     6605#ifdef TIME_TEST
    63456606      tostd = clock()-to;
     6607#endif
    63466608      if(op_deg != 1)
    63476609      {
     
    63596621
    63606622      G = idrMoveR(Go, XXRing,currRing);
     6623#ifdef TIME_TEST
     6624  to = clock();
     6625#endif
    63616626      G = MstdCC(G);
     6627#ifdef TIME_TEST
    63626628      tostd = clock()-to;
     6629#endif
    63636630      if(op_deg != 1)
    63646631      {
     
    63726639    rChangeCurrRing(VMatrDefault(orig_M));
    63736640    G = idrMoveR(Go, XXRing,currRing);
     6641#ifdef TIME_TEST
     6642    to = clock();
     6643#endif
    63746644    G = MstdCC(G);
     6645#ifdef TIME_TEST
    63756646    tostd = clock()-to;
     6647#endif
    63766648    if(op_deg != 1)
    63776649    {
     
    64296701    ivString(target_weight, "//** Mprwalk: new target weight");
    64306702  }
     6703
     6704#ifdef TIME_TEST
     6705  to = clock();
     6706#endif
     6707  Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector"
     6708#ifdef TIME_TEST
     6709  tif = tif + clock()-to; //time for computing initial form ideal
     6710#endif
     6711
    64316712  while(1)
    64326713  {
    64336714    nstep ++;
    6434     to = clock();
    6435     // compute an initial form ideal of <G> w.r.t. the weight vector
    6436     // "curr_weight"
    6437     Gomega = MwalkInitialForm(G, curr_weight);
    6438     polylength = lengthpoly(Gomega);
    6439 //#ifdef CHECK_IDEAL_MWALK
     6715#ifdef CHECK_IDEAL_MWALK
    64406716    if(printout > 1)
    64416717    {
    64426718      idString(Gomega,"//** Mprwalk: Gomega");
    64436719    }
    6444 //#endif
     6720#endif
    64456721
    64466722    if(reduction == 0 && nstep > 1)
    64476723    {
     6724/*
    64486725      // check whether weight vector is in the interior of the cone
    64496726      while(1)
     
    64566733          idDelete(&FF);
    64576734          next_weight = MwalkNextWeightCC(curr_weight,target_weight,G);
     6735#ifdef PRINT_VECTORS
    64586736          if(printout > 0)
    64596737          {
    64606738            MivString(curr_weight, target_weight, next_weight);
    64616739          }
     6740#endif
    64626741        }
    64636742        else
     
    64706749        }
    64716750        Gomega = MwalkInitialForm(G, curr_weight);
     6751#ifdef CHECK_IDEAL_MWALK
    64726752        if(printout > 1)
    64736753        {
    64746754          idString(Gomega,"//** Mprwalk: Gomega");
    64756755        }
    6476       }
     6756#endif
     6757      }
     6758*/
     6759      FF = middleOfCone(G,Gomega);
     6760      if(FF != NULL)
     6761      {
     6762        idDelete(&G);
     6763        G = idCopy(FF);
     6764        idDelete(&FF);
     6765        goto NEXT_VECTOR;
     6766      }
    64776767    }
    64786768
     
    64816771    {
    64826772      Print("\n// ring r%d = %s;\n", nstep, rString(currRing));
     6773/*
    64836774      idElements(G, "G");
    64846775      headidString(G, "G");
    6485     }
    6486 #endif
    6487 
    6488     tif = tif + clock()-to;
     6776*/
     6777    }
     6778#endif
    64896779
    64906780#ifndef  BUCHBERGER_ALG
     
    65156805    {
    65166806      Print("\n// ring r%d = %s;\n", nstep, rString(currRing));
     6807/*
    65176808      idElements(Gomega1, "Gw");
    65186809      headidString(Gomega1, "headGw");
     6810*/
    65196811      PrintS("\n// compute a rGB of Gw:\n");
    65206812
     
    65246816    }
    65256817#endif
    6526 
     6818#ifdef TIME_TEST
    65276819    tim = clock();
    65286820    to = clock();
     6821#endif
    65296822    // compute a reduced Groebner basis of <Gomega> w.r.t. "newRing"
    65306823#ifdef  BUCHBERGER_ALG
     
    65346827    delete hilb_func;
    65356828#endif
    6536 //#ifdef CHECK_IDEAL_MWALK
     6829#ifdef CHECK_IDEAL_MWALK
    65376830    if(printout > 2)
    65386831    {
    65396832      idString(M,"//** Mprwalk: M");
    65406833    }
    6541 //#endif
    6542 
     6834#endif
     6835#ifdef TIME_TEST
    65436836    if(endwalks == TRUE)
    65446837    {
     
    65516844    else
    65526845      tstd=tstd+clock()-to;
    6553 
     6846#endif
    65546847    /* change the ring to oldRing */
    65556848    rChangeCurrRing(oldRing);
    65566849    M1 =  idrMoveR(M, newRing,currRing);
    65576850    Gomega2 =  idrMoveR(Gomega1, newRing,currRing);
    6558 
     6851#ifdef TIME_TEST
    65596852    to=clock();
     6853#endif
    65606854    /* compute a representation of the generators of submod (M)
    65616855       with respect to those of mod (Gomega).
    65626856       Gomega is a reduced Groebner basis w.r.t. the current ring */
    65636857    F = MLifttwoIdeal(Gomega2, M1, G);
     6858#ifdef TIME_TEST
    65646859    if(endwalks == FALSE)
    65656860      tlift = tlift+clock()-to;
    65666861    else
    65676862      xtlift=clock()-to;
    6568 
    6569 //#ifdef CHECK_IDEAL_MWALK
     6863#endif
     6864#ifdef CHECK_IDEAL_MWALK
    65706865    if(printout > 2)
    65716866    {
    65726867      idString(F,"//** Mprwalk: F");
    65736868    }
    6574 //#endif
     6869#endif
    65756870
    65766871    idDelete(&M1);
     
    65916886        PrintS("\n //** Mprwalk: reduce the Groebner basis.\n");
    65926887      }
     6888#ifdef TIME_TEST
    65936889      to=clock();
     6890#endif
    65946891      G = kInterRedCC(F1, NULL);
     6892#ifdef TIME_TEST
    65956893      if(endwalks == FALSE)
    65966894        tred = tred+clock()-to;
    65976895      else
    65986896        xtred=clock()-to;
     6897#endif
    65996898      idDelete(&F1);
    66006899    }
     
    66036902      break;
    66046903
     6904    NEXT_VECTOR:
     6905#ifdef TIME_TEST
     6906    to = clock();
     6907#endif
     6908    next_weight = next_weight = MkInterRedNextWeight(curr_weight,target_weight, G);
     6909#ifdef TIME_TEST
     6910    tnw = tnw + clock() - to;
     6911#endif
     6912
     6913#ifdef TIME_TEST
     6914    to = clock();
     6915#endif
     6916    // compute an initial form ideal of <G> w.r.t. "next_vector"
     6917    Gomega = MwalkInitialForm(G, next_weight);
     6918#ifdef TIME_TEST
     6919    tif = tif + clock()-to; //time for computing initial form ideal
     6920#endif
     6921
     6922    //lengthpoly(Gomega) = 1 if there is a polynomial in Gomega with at least 3 monomials and 0 otherwise
     6923    if(lengthpoly(Gomega) > 0)
     6924    {
     6925      Print("\n there is a polynomial in Gomega with at least 3 monomials,\n");
     6926      // low-dimensional facet of the cone
     6927      delete next_weight;
     6928      if(target_M->length() == nV)
     6929      {
     6930        iv_M = MivMatrixOrder(curr_weight);
     6931      }
     6932      else
     6933      {
     6934        iv_M = MivMatrixOrderRefine(curr_weight,target_M);
     6935      }
     6936#ifdef TIME_TEST
     6937      to = clock();
     6938#endif
     6939      next_weight = MWalkRandomNextWeight(G, iv_M, target_weight, weight_rad, op_deg);
     6940#ifdef TIME_TEST
     6941      tnw = tnw + clock() - to;
     6942#endif
     6943      idDelete(&Gomega);
     6944#ifdef TIME_TEST
     6945      to = clock();
     6946#endif
     6947      Gomega = MwalkInitialForm(G, next_weight);
     6948#ifdef TIME_TEST
     6949      tif = tif + clock()-to; //time for computing initial form ideal
     6950#endif
     6951  Print("delete\n");
     6952      delete iv_M;
     6953    }
     6954
     6955/*
    66056956    to=clock();
    6606 
    66076957    next_weight = MkInterRedNextWeight(curr_weight,target_weight, G);
    66086958    if(polylength > 0)
     
    66166966    }
    66176967    tnw=tnw+clock()-to;
    6618 //#ifdef PRINT_VECTORS
     6968*/
     6969#ifdef PRINT_VECTORS
    66196970    if(printout > 0)
    66206971    {
    66216972      MivString(curr_weight, target_weight, next_weight);
    66226973    }
    6623 //#endif
     6974#endif
    66246975
    66256976    if(Overflow_Error == TRUE)
    66266977    {
    66276978      ntwC = 0;
    6628       //ntestomega = 1;
    66296979      //Print("\n// ring r%d = %s;\n", nstep, rString(currRing));
    66306980      //idElements(G, "G");
     
    66456995
    66466996    delete next_weight;
    6647   }//while
     6997  }// end of while-loop
    66486998
    66496999  if(tp_deg != 1)
     
    66697019    TargetRing=currRing;
    66707020    F1 = idrMoveR(G, newRing,currRing);
    6671 #ifdef CHECK_IDEAL
    6672       headidString(G, "G");
    6673 #endif
    66747021
    66757022    // check whether the pertubed target vector stays in the correct cone
     
    66827029      if(ntestw != 1 && printout > 2)
    66837030      {
     7031#ifdef PRINT_VECTORS
    66847032        ivString(pert_target_vector, "tau");
     7033#endif
    66857034        PrintS("\n// **Mprwalk: perturbed target vector doesn't stay in cone.");
    66867035        Print("\n// ring r%d = %s;\n", nstep, rString(currRing));
     
    66887037      }
    66897038      // LastGB is "better" than the kStd subroutine
     7039#ifdef TIME_TEST
    66907040      to=clock();
     7041#endif
    66917042      ideal eF1;
    66927043      if(nP == 0 || tp_deg == 1 || MivSame(orig_target, exivlp) != 1 || target_M->length() != nV)
     
    67107061        F2=NULL;
    67117062      }
     7063#ifdef TIME_TEST
    67127064      xtextra=clock()-to;
     7065#endif
    67137066      ring exTargetRing = currRing;
    67147067
     
    67167069      Eresult = idrMoveR(eF1, exTargetRing,currRing);
    67177070    }
    6718     else{
     7071    else
     7072    {
    67197073      rChangeCurrRing(XXRing);
    67207074      Eresult = idrMoveR(F1, TargetRing,currRing);
    67217075    }
    67227076  }
    6723   else {
     7077  else
     7078  {
    67247079    rChangeCurrRing(XXRing);
    67257080    Eresult = idrMoveR(G, newRing,currRing);
     
    67867141  intvec* hilb_func;
    67877142#endif
    6788 //  intvec* extXtau;
     7143  //intvec* extXtau;
    67897144  intvec* next_vect;
    67907145  intvec* omega2 = new intvec(nV);
     
    68357190    nwalks ++;
    68367191    NEXT_VECTOR_FRACTAL:
     7192#ifdef TIME_TEST
    68377193    to=clock();
     7194#endif
    68387195    // determine the next border
    68397196    next_vect = MkInterRedNextWeight(omega,omega2,G);
     7197#ifdef TIME_TEST
    68407198    xtnw=xtnw+clock()-to;
    6841 
     7199#endif
    68427200    oRing = currRing;
    68437201
     
    68977255
    68987256        delete next_vect;
     7257#ifdef TIME_TEST
    68997258        to=clock();
    6900 
     7259#endif
    69017260        // to avoid the value of Overflow_Error that occur in Mfpertvector
    69027261        Overflow_Error = FALSE;
    69037262        next_vect = MkInterRedNextWeight(omega,omega2,G);
     7263#ifdef TIME_TEST
    69047264        xtnw=xtnw+clock()-to;
     7265#endif
    69057266      }// end of (if MivComp(next_vect, omega2) == 1)
    69067267
    6907 //#ifdef PRINT_VECTORS
     7268#ifdef PRINT_VECTORS
    69087269      if(printout > 0)
    69097270      {
    69107271        MivString(omega, omega2, next_vect);
    69117272      }
    6912 //#endif
     7273#endif
    69137274
    69147275    // check whether the the computed vector is in the correct cone.
     
    69387299              rString(currRing));
    69397300      }
     7301#ifdef TIME_TEST
    69407302      to=clock();
     7303#endif
    69417304      Gt = idrMoveR(G, oRing,currRing);
    69427305      G1 = MstdCC(Gt);
     7306#ifdef TIME_TEST
    69437307      xtextra=xtextra+clock()-to;
     7308#endif
    69447309      Gt = NULL;
    69457310
     
    69577322      return (G1);
    69587323    }
    6959 
    69607324
    69617325    /* If the perturbed target vector stays in the correct cone,
     
    70457409                rString(currRing));
    70467410        }
     7411#ifdef TIME_TEST
    70477412        to=clock();
     7413#endif
    70487414        G = MstdCC(Gt);
     7415#ifdef TIME_TEST
    70497416        xtextra=xtextra+clock()-to;
    7050 
     7417#endif
    70517418        oRing = currRing;
    70527419
     
    71097476    }
    71107477    delete next_vect;
    7111 
     7478#ifdef TIME_TEST
    71127479    to=clock();
     7480#endif
    71137481    // Take the initial form of <G> w.r.t. omega
    71147482    Gomega = MwalkInitialForm(G, omega);
     7483#ifdef TIME_TEST
    71157484    xtif=xtif+clock()-to;
     7485#endif
     7486#ifdef CHECK_IDEAL_MWALK
    71167487    if(printout > 1)
    71177488    {
    71187489      idString(Gomega,"//** rec_fractal_call: Gomega");
    71197490    }
    7120 
     7491#endif
    71217492    if(reduction == 0)
    71227493    {
     
    71637534        Print("\n//** rec_fractal_call: Maximal recursion depth.\n");
    71647535      }
    7165 
     7536#ifdef TIME_TEST
    71667537      to=clock();
     7538#endif
    71677539#ifdef  BUCHBERGER_ALG
    71687540      Gresult = MstdhomCC(Gomega1);
     
    71717543      delete hilb_func;
    71727544#endif
     7545#ifdef TIME_TEST
    71737546      xtstd=xtstd+clock()-to;
     7547#endif
    71747548    }
    71757549    else
     
    71797553      Gresult = rec_fractal_call(idCopy(Gomega1),nlev+1,omega,reduction,printout);
    71807554    }
     7555#ifdef CHECK_IDEAL_MWALK
    71817556    if(printout > 2)
    71827557    {
    71837558      idString(Gresult,"//** rec_fractal_call: M");
    71847559    }
     7560#endif
    71857561    //convert a Groebner basis from a ring to another ring
    71867562    new_ring = currRing;
     
    71897565    Gresult1 = idrMoveR(Gresult, new_ring,currRing);
    71907566    Gomega2 = idrMoveR(Gomega1, new_ring,currRing);
    7191 
     7567#ifdef TIME_TEST
    71927568    to=clock();
     7569#endif
    71937570    // Lifting process
    71947571    F = MLifttwoIdeal(Gomega2, Gresult1, G);
     7572#ifdef TIME_TEST
    71957573    xtlift=xtlift+clock()-to;
     7574#endif
     7575#ifdef CHECK_IDEAL_MWALK
    71967576    if(printout > 2)
    71977577    {
    71987578      idString(F,"//** rec_fractal_call: F");
    71997579    }
     7580#endif
    72007581    idDelete(&Gresult1);
    72017582    idDelete(&Gomega2);
     
    72037584
    72047585    rChangeCurrRing(new_ring);
    7205     //F1 = idrMoveR(F, oRing,currRing);
    72067586    G = idrMoveR(F,oRing,currRing);
     7587/*
     7588    F1 = idrMoveR(F, oRing,currRing);
     7589#ifdef TIME_TEST
    72077590    to=clock();
     7591#endif
    72087592    // Interreduce G
    7209     // G = kInterRedCC(F1, NULL);
     7593    G = kInterRedCC(F1, NULL);
     7594#ifdef TIME_TEST
    72107595    xtred=xtred+clock()-to;
    7211     //idDelete(&F1);
     7596#endif
     7597    idDelete(&F1);
     7598*/
    72127599  }
    72137600}
     
    72227609  //Print("\n\n// Entering the %d-th recursion:", nlev);
    72237610
    7224   int i, polylength, nV = currRing->N;
     7611  int nwalks = 0,i,nV=currRing->N;//polylength
    72257612  ring new_ring, testring;
    72267613  //ring extoRing;
    72277614  ideal Gomega, Gomega1, Gomega2, F, FF, F1, Gresult, Gresult1, G1, Gt;
    7228   int nwalks = 0;
    72297615  intvec* Mwlp;
    72307616#ifndef BUCHBERGER_ALG
     
    72337619//  intvec* extXtau;
    72347620  intvec* next_vect;
     7621  intvec* iv_M;
    72357622  intvec* omega2 = new intvec(nV);
    72367623  intvec* omtmp = new intvec(nV);
     
    72827669    nwalks ++;
    72837670    NEXT_VECTOR_FRACTAL:
     7671#ifdef TIME_TEST
    72847672    to=clock();
     7673#endif
    72857674    /* determine the next border */
    72867675    next_vect = MkInterRedNextWeight(omega,omega2,G);
    7287     if(polylength > 0 && G->m[0] != NULL)
    7288     {
    7289      
    7290       PrintS("\n**// rec_r_fractal_call: there is a polynomial in Gomega with at least 3 monomials, low-dimensional facet of the cone.\n");
    7291      
     7676#ifdef TIME_TEST
     7677    xtnw=xtnw+clock()-to;
     7678#endif
     7679    if(lengthpoly(MwalkInitialForm(G, next_vect)) > 0 && G->m[0] != NULL)
     7680    {
     7681      if(printout > 0)
     7682      {
     7683        PrintS("\n**// rec_r_fractal_call: there is a polynomial in Gomega with at least 3 monomials.\n");
     7684      }
    72927685      delete next_vect;
    7293       next_vect = MWalkRandomNextWeight(G,omega,omega2,weight_rad,nlev);
    7294       if(isNegNolVector(next_vect)==1)
     7686      iv_M = MivMatrixOrder(omega);
     7687#ifdef TIME_TEST
     7688      to=clock();
     7689#endif
     7690      next_vect = MWalkRandomNextWeight(G,iv_M,omega2,weight_rad,nlev);
     7691#ifdef TIME_TEST
     7692      xtnw=xtnw+clock()-to;
     7693#endif
     7694      if(isNegNolVector(next_vect) == 1)
    72957695      {
    72967696        delete next_vect;
     7697#ifdef TIME_TEST
     7698        to=clock();
     7699#endif
    72977700        next_vect = MkInterRedNextWeight(omega,omega2,G);
    7298       }
    7299     }
    7300     xtnw=xtnw+clock()-to;
    7301 
     7701#ifdef TIME_TEST
     7702        xtnw=xtnw+clock()-to;
     7703#endif
     7704      }
     7705    }
    73027706    oRing = currRing;
    73037707
     
    73547758        delete Mwlp;
    73557759
    7356         for(i=nV-1; i>=0; i--) {
     7760        for(i=nV-1; i>=0; i--)
     7761        {
    73577762          (*omega2)[i] = (*Xtau)[nV+i];
    73587763          (*omega)[i] = (*Xsigma)[nV+i];
     
    73607765
    73617766        delete next_vect;
     7767
     7768   //to avoid the value of Overflow_Error that occur in Mfpertvector
     7769        Overflow_Error = FALSE;
     7770#ifdef TIME_TEST
    73627771        to=clock();
    7363 
    7364         /*
    7365         to avoid the value of Overflow_Error that occur in
    7366         Mfpertvector
    7367         */
    7368         Overflow_Error = FALSE;
    7369 
     7772#endif
    73707773        next_vect = MkInterRedNextWeight(omega,omega2,G);
    7371         if(G->m[0] != NULL && polylength > 0)
     7774#ifdef TIME_TEST
     7775        xtnw=xtnw+clock()-to;
     7776#endif
     7777        if(lengthpoly(MwalkInitialForm(G, next_vect)) > 0 && G->m[0] != NULL)
    73727778        {
    7373          
    7374           PrintS("//** rec_r_fractal_call: there is a polynomial in Gomega with at least 3 monomials, low-dimensional facet of the cone");
    7375          
     7779          // there is a polynomial in Gomega with at least 3 monomials
     7780          iv_M = MivMatrixOrder(omega);
    73767781          delete next_vect;
    7377           next_vect = MWalkRandomNextWeight(G,omega,omega2,weight_rad,nlev);
    7378           if(isNegNolVector(next_vect)==1)
     7782#ifdef TIME_TEST
     7783          to=clock();
     7784#endif
     7785          next_vect = MWalkRandomNextWeight(G,iv_M,omega2,weight_rad,nlev);
     7786#ifdef TIME_TEST
     7787          xtnw=xtnw+clock()-to;
     7788#endif
     7789          delete iv_M;
     7790          if(isNegNolVector(next_vect) == 1)
    73797791          {
    73807792            delete next_vect;
     7793#ifdef TIME_TEST
     7794            to=clock();
     7795#endif
    73817796            next_vect = MkInterRedNextWeight(omega,omega2,G);
     7797#ifdef TIME_TEST
     7798        xtnw=xtnw+clock()-to;
     7799#endif
    73827800          }
    73837801        }
    7384         xtnw=xtnw+clock()-to;
    7385       }
    7386 //#ifdef PRINT_VECTORS
     7802      }
     7803#ifdef PRINT_VECTORS
    73877804      if(printout > 0)
    73887805      {
    73897806        MivString(omega, omega2, next_vect);
    73907807      }
    7391 //#endif
    7392 
    7393     /* check whether the the computed vector is in the correct cone
     7808#endif
     7809
     7810/*    check whether the the computed vector is in the correct cone
    73947811       If no, the reduced GB of an omega-homogeneous ideal will be
    7395        computed by Buchberger algorithm and stop this recursion step*/
    7396     //if(test_w_in_ConeCC(G, next_vect) != 1) //e.g. Example s7, cyc6
    7397     if(Overflow_Error == TRUE || test_w_in_ConeCC(G,next_vect) != 1)
     7812       computed by Buchberger algorithm and stop this recursion step
     7813*/
     7814    if(Overflow_Error == TRUE || test_w_in_ConeCC(G,next_vect) != 1)//e.g. Example s7, cyc6
    73987815    {
    73997816      delete next_vect;
     
    74237840              rString(currRing));
    74247841      }
     7842      Gt = idrMoveR(G, oRing,currRing);
     7843#ifdef TIME_TEST
    74257844      to=clock();
    7426       Gt = idrMoveR(G, oRing,currRing);
     7845#endif
    74277846      G1 = MstdCC(Gt);
     7847#ifdef TIME_TEST
    74287848      xtextra=xtextra+clock()-to;
     7849#endif
    74297850      Gt = NULL;
    74307851
     
    74877908
    74887909#ifndef  MSTDCC_FRACTAL
    7489         //ivString(Xtau, "old Xtau");
     7910#ifdef PRINT_VECTORS
     7911        if(printout > 0)
     7912        {
     7913          ivString(Xtau, "old Xtau");
     7914        }
     7915#endif
    74907916        intvec* Xtautmp;
    74917917        if(ivtarget->length() == nV)
     
    75117937        Xtau = Xtautmp;
    75127938        Xtautmp = NULL;
    7513         //ivString(Xtau, "new  Xtau");
     7939#ifdef PRINT_VECTORS
     7940        if(printout > 0)
     7941        {
     7942          ivString(Xtau, "new  Xtau");
     7943        }
     7944#endif
    75147945
    75157946        for(i=nV-1; i>=0; i--)
     
    75297960                rString(currRing));
    75307961        }
     7962#ifdef TIME_TEST
    75317963        to=clock();
     7964#endif
    75327965        G = MstdCC(Gt);
     7966#ifdef TIME_TEST
    75337967        xtextra=xtextra+clock()-to;
    7534 
     7968#endif
    75357969        oRing = currRing;
    75367970
     
    75948028    }
    75958029    delete next_vect;
    7596 
     8030#ifdef TIME_TEST
    75978031    to=clock();
     8032#endif
    75988033    // Take the initial form of <G> w.r.t. omega
    75998034    Gomega = MwalkInitialForm(G, omega);
     8035#ifdef TIME_TEST
    76008036    xtif=xtif+clock()-to;
     8037#endif
    76018038    //polylength = 1 if there is a polynomial in Gomega with at least 3 monomials and 0 otherwise
    7602     polylength = lengthpoly(Gomega);
     8039    //polylength = lengthpoly(Gomega);
     8040#ifdef CHECK_IDEAL_MWALK
    76038041    if(printout > 1)
    76048042    {
    76058043      idString(Gomega,"//** rec_r_fractal_call: Gomega");
    76068044    }
    7607 
     8045#endif
    76088046    if(reduction == 0)
    76098047    {
     
    76458083    if(nlev == Xnlev || lengthpoly(Gomega1) == 0)
    76468084    {
     8085#ifdef TIME_TEST
    76478086      to=clock();
     8087#endif
    76488088#ifdef  BUCHBERGER_ALG
    76498089      Gresult = MstdhomCC(Gomega1);
     
    76528092      delete hilb_func;
    76538093#endif
     8094#ifdef TIME_TEST
    76548095      xtstd=xtstd+clock()-to;
     8096#endif
    76558097    }
    76568098    else
     
    76608102      Gresult = rec_r_fractal_call(idCopy(Gomega1),nlev+1,omega,weight_rad,reduction,printout);
    76618103    }
     8104#ifdef CHECK_IDEAL_MWALK
    76628105    if(printout > 2)
    76638106    {
    76648107      idString(Gresult,"//** rec_r_fractal_call: M");
    76658108    }
     8109#endif
    76668110    //convert a Groebner basis from a ring to another ring
    76678111    new_ring = currRing;
     
    76708114    Gresult1 = idrMoveR(Gresult, new_ring,currRing);
    76718115    Gomega2 = idrMoveR(Gomega1, new_ring,currRing);
    7672 
     8116#ifdef TIME_TEST
    76738117    to=clock();
     8118#endif
    76748119    // Lifting process
    76758120    F = MLifttwoIdeal(Gomega2, Gresult1, G);
     8121#ifdef TIME_TEST
    76768122    xtlift=xtlift+clock()-to;
    7677 
     8123#endif
     8124#ifdef CHECK_IDEAL_MWALK
    76788125    if(printout > 2)
    76798126    {
    76808127      idString(F,"//** rec_r_fractal_call: F");
    76818128    }
    7682 
     8129#endif
    76838130    idDelete(&Gresult1);
    76848131    idDelete(&Gomega2);
     
    76888135    //F1 = idrMoveR(F, oRing,currRing);
    76898136    G = idrMoveR(F,oRing,currRing);
     8137/*
     8138#ifdef TIME_TEST
    76908139    to=clock();
     8140#endif
    76918141    // Interreduce G
    7692     //G = kInterRedCC(F1, NULL);
     8142    G = kInterRedCC(F1, NULL);
     8143#ifdef TIME_TEST
    76938144    xtred=xtred+clock()-to;
    7694     //idDelete(&F1);
     8145#endif
     8146    idDelete(&F1);
     8147*/
    76958148  }
    76968149}
     
    77238176  Xngleich = 0;
    77248177  Xcall = 0;
     8178#ifdef TIME_TEST
    77258179  xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0; xtextra=0;
    77268180  xftinput = clock();
    7727 
     8181#endif
    77288182  ring  oldRing = currRing;
    77298183  int i, nV = currRing->N;
     
    77318185  Xivinput = ivtarget;
    77328186  ngleich = 0;
     8187#ifdef TIME_TEST
    77338188  to=clock();
     8189#endif
    77348190  ideal I = MstdCC(G);
    77358191  G = NULL;
     8192#ifdef TIME_TEST
    77368193  xftostd=clock()-to;
     8194#endif
    77378195  Xsigma = ivstart;
    77388196
     
    78298287
    78308288  I = idrMoveR(I1,tRing,currRing);
     8289#ifdef TIME_TEST
    78318290  to=clock();
     8291#endif
    78328292  ideal J = MstdCC(I);
    78338293  idDelete(&I);
     8294#ifdef TIME_TEST
    78348295  xftostd=xftostd+clock()-to;
    7835 
     8296#endif
    78368297  ideal resF;
    78378298  ring helpRing = currRing;
     
    78758336{
    78768337  BITSET save1 = si_opt_1; // save current options
     8338  //check that weight radius is valid
     8339  if(weight_rad < 0)
     8340  {
     8341    Werror("Invalid radius.\n");
     8342    return NULL;
     8343  }
    78778344  if(reduction == 0)
    78788345  {
    78798346    si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis
    7880     //si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions
     8347    si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions
    78818348  }
    78828349  Set_Error(FALSE);
     
    78888355  Xngleich = 0;
    78898356  Xcall = 0;
     8357#ifdef TIME_TEST
    78908358  xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0; xtextra=0;
    78918359  xftinput = clock();
    7892 
     8360#endif
    78938361  ring  oldRing = currRing;
    78948362  int i, nV = currRing->N;
     
    78968364  Xivinput = ivtarget;
    78978365  ngleich = 0;
     8366#ifdef TIME_TEST
    78988367  to=clock();
     8368#endif
    78998369  ideal I = MstdCC(G);
    79008370  G = NULL;
     8371#ifdef TIME_TEST
    79018372  xftostd=clock()-to;
     8373#endif
    79028374  Xsigma = ivstart;
    79038375
     
    79948466
    79958467  I = idrMoveR(I1,tRing,currRing);
     8468#ifdef TIME_TEST
    79968469  to=clock();
     8470#endif
    79978471  ideal J = MstdCC(I);
    79988472  idDelete(&I);
     8473#ifdef TIME_TEST
    79998474  xftostd=xftostd+clock()-to;
    8000 
     8475#endif
    80018476  ideal resF;
    80028477  ring helpRing = currRing;
     
    82198694      goto  BE_FINISH;
    82208695#endif
    8221 
     8696/*
    82228697#ifdef CHECK_IDEAL_MWALK
    82238698      idElements(G, "G");
    82248699      //headidString(G, "G");
    82258700#endif
    8226 
     8701*/
    82278702      if(MivSame(target_tmp, iv_lp) == 1)
    82288703        if (rParameter(currRing) != NULL)
     
    89589433  clock_t tinput=clock();
    89599434  int i, nV = currRing->N;
     9435
     9436  //check that perturbation degree is valid
     9437  if(tp_deg < 1 || tp_deg > nV)
     9438  {
     9439    Werror("Invalid perturbation degree.\n");
     9440    return NULL;
     9441  }
     9442
    89609443  int nwalk=0, endwalks=0, ntestwinC=1;
    89619444  int tp_deg_tmp = tp_deg;
     
    90679550    {
    90689551      Print("\n//  it is  %d-th step!!", nwalk);
    9069       idElements(Gomega1, "Gw");
     9552      idString(Gomega1, "Gw");
    90709553      PrintS("\n//  compute a rGB of Gw:");
    90719554    }
Note: See TracChangeset for help on using the changeset viewer.