Changeset 1b0fdf in git for Singular/walk.cc


Ignore:
Timestamp:
May 6, 2015, 3:45:32 PM (9 years ago)
Author:
Stephan Oberfranz <oberfran@…>
Branches:
(u'spielwiese', '2a584933abf2a2d3082034c7586d38bb6de1a30a')
Children:
20357b2d3e79a043b31e25be30cdcf08dbc6b37e
Parents:
07f91e61990361e7f50ab5976d0c92e77fbaf4ae
Message:
update
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/walk.cc

    r07f91e r1b0fdf  
    512512}
    513513
     514//unused
     515//#if 0
    514516static void MivString(intvec* iva, intvec* ivb, intvec* ivc)
    515517{
     
    534536  Print("%d)", (*ivc)[nV]);
    535537}
     538//#endif
    536539
    537540/********************************************************************
     
    11031106  if(pdeg > nV || pdeg <= 0)
    11041107  {
    1105     WerrorS("//**MPertVectors: The perturbed degree is wrong!!");
     1108    WerrorS("//** The perturbed degree is wrong!!");
    11061109    return v_null;
    11071110  }
     
    11131116  }
    11141117  mpz_t *pert_vector = (mpz_t*)omAlloc(nV*sizeof(mpz_t));
     1118  //mpz_t *pert_vector1 = (mpz_t*)omAlloc(nV*sizeof(mpz_t));
    11151119
    11161120  for(i=0; i<nV; i++)
     
    11191123   // mpz_init_set_si(pert_vector1[i], (*ivtarget)[i]);
    11201124  }
    1121   // Compute max1 = Max(A2)+Max(A3)+...+Max(Apdeg),
     1125  // Calculate max1 = Max(A2)+Max(A3)+...+Max(Apdeg),
    11221126  // where the Ai are the i-te rows of the matrix target_ord.
    11231127  int ntemp, maxAi, maxA=0;
     
    11441148  }
    11451149
    1146   // Compute inveps = 1/eps, where 1/eps > totaldeg(p)*max1 for all p in G.
     1150  // Calculate inveps = 1/eps, where 1/eps > totaldeg(p)*max1 for all p in G.
    11471151
    11481152  intvec* ivUnit = Mivdp(nV);
     
    11761180  }
    11771181#else
    1178   PrintS("\n //**MPertVectors: the \"big\" inverse epsilon:");
     1182  // PrintS("\n// the \"big\" inverse epsilon: ");
    11791183  mpz_out_str(stdout, 10, inveps);
    11801184#endif
     
    12301234  if(j > nV - 1)
    12311235  {
    1232     //perturbed vector equals zero
     1236    // Print("\n//  MPertVectors: geaenderter vector gleich Null! \n");
    12331237    delete pert_vector1;
    12341238    goto CHECK_OVERFLOW;
    12351239  }
    12361240
    1237   // check that the perturbed weight vector lies in the Groebner cone
     1241// check that the perturbed weight vector lies in the Groebner cone
    12381242  if(test_w_in_ConeCC(G,pert_vector1) != 0)
    12391243  {
     1244    // Print("\n//  MPertVectors: geaenderter vector liegt in Groebnerkegel! \n");
    12401245    for(i=0; i<nV; i++)
    12411246    {
     
    12431248    }
    12441249  }
    1245 
     1250  else
     1251  {
     1252    //Print("\n// MpertVectors: geaenderter vector liegt nicht in Groebnerkegel! \n");
     1253  }
    12461254  delete pert_vector1;
    12471255
     
    12491257  intvec* result = new intvec(nV);
    12501258
    1251   // 2147483647 is max. integer representation in SINGULAR
     1259  /* 2147483647 is max. integer representation in SINGULAR */
    12521260  mpz_t sing_int;
    12531261  mpz_init_set_ui(sing_int,  2147483647);
     
    16361644  {
    16371645    mpz_divexact(pert_vector[i], pert_vector[i], ztmp);
     1646    (* result)[i] = mpz_get_si(pert_vector[i]);
     1647  }
     1648
     1649  j = 0;
     1650  for(i=0; i<nV; i++)
     1651  {
    16381652    (* result1)[i] = mpz_get_si(pert_vector[i]);
    1639   }
    1640   j = 0;
    1641   while(test_w_in_ConeCC(G,result1) && j<nV)
    1642   {
    1643     j = 0;
     1653    (* result1)[i] = 0.1*(* result1)[i];
     1654    (* result1)[i] = floor((* result1)[i] + 0.5);
     1655    if((* result1)[i] == 0)
     1656    {
     1657      j++;
     1658    }
     1659  }
     1660  if(j > nV - 1)
     1661  {
     1662    // Print("\n//  MfPertwalk: geaenderter vector gleich Null! \n");
     1663    delete result1;
     1664    goto CHECK_OVERFLOW;
     1665  }
     1666
     1667// check that the perturbed weight vector lies in the Groebner cone
     1668  if(test_w_in_ConeCC(G,result1) != 0)
     1669  {
     1670    // Print("\n//  MfPertwalk: geaenderter vector liegt in Groebnerkegel! \n");
     1671    delete result;
     1672    result = result1;
    16441673    for(i=0; i<nV; i++)
    16451674    {
    1646       (* result)[i] = (* result1)[i];
    16471675      mpz_set_si(pert_vector[i], (*result1)[i]);
    1648       (* result1)[i] = floor(0.1*(mpz_get_si(pert_vector[i])) + 0.5);
    1649       if((* result1)[i] == 0)
    1650       {
    1651         j++;
    1652       }
    1653     }
    1654   }
    1655   delete result1;
     1676    }
     1677  }
     1678  else
     1679  {
     1680    delete result1;
     1681    // Print("\n// Mfpertwalk: geaenderter vector liegt nicht in Groebnerkegel! \n");
     1682  }
    16561683
    16571684  CHECK_OVERFLOW:
     
    19601987        mpz_set_si(MwWd, MivDotProduct(ivtemp, curr_weight));
    19611988        mpz_sub(s_zaehler, deg_w0_p1, MwWd);
    1962 
    19631989        if(mpz_cmp(s_zaehler, t_null) != 0)
    19641990        {
    19651991          mpz_set_si(MwWd, MivDotProduct(ivtemp, diff_weight));
    19661992          mpz_sub(s_nenner, MwWd, deg_d0_p1);
    1967 
    19681993          // check for 0 < s <= 1
    19691994          if( (mpz_cmp(s_zaehler,t_null) > 0 &&
     
    22782303 * define and execute a new ring which order is (a(vb),a(va),lp,C)  *
    22792304 * ******************************************************************/
    2280 #if 0
    2281 // unused
    22822305static void VMrHomogeneous(intvec* va, intvec* vb)
    22832306{
     
    23572380  rChangeCurrRing(r);
    23582381}
    2359 #endif
     2382
    23602383
    23612384/**************************************************************
     
    29312954  int i,j,N = IDELEMS(Gomega);
    29322955  poly p,lm,factor1,factor2;
    2933   PrintS("\n//** idCopy\n");
     2956  //PrintS("\n//** idCopy\n");
    29342957  ideal Go = idCopy(G);
    29352958 
    2936   PrintS("\n//** jetzt for-Loop!\n");
     2959  //PrintS("\n//** jetzt for-Loop!\n");
    29372960  for(i=0; i<N; i++)
    29382961  {
     
    29722995  if(middle == TRUE)
    29732996  {
    2974     PrintS("\n//** middle TRUE!\n");
     2997    //PrintS("\n//** middle TRUE!\n");
    29752998    return Go;
    29762999  }
    2977   PrintS("\n//** middle FALSE!\n");
     3000  //PrintS("\n//** middle FALSE!\n");
    29783001  idDelete(&Go);
    29793002  return NULL;
     
    43184341  assume(currRing != NULL && curr_weight != NULL &&
    43194342         target_weight != NULL && G->m[0] != NULL);
    4320   //PrintS("\n //**MWalkRandomNextWeight: Anfang ok!\n");
    4321   int i,k,nV = currRing->N;
    4322   long weight_norm;
     4343
     4344  int i,weight_norm,nV = currRing->N;
    43234345  intvec* next_weight2;
    4324   //intvec* next_weight22 = new intvec(nV);
     4346  intvec* next_weight22 = new intvec(nV);
    43254347  intvec* result = new intvec(nV);
    4326   ideal G_test;
    4327   ideal G_test2;
    4328   BOOLEAN random = FALSE;
    43294348
    43304349  intvec* next_weight1 =MkInterRedNextWeight(curr_weight,target_weight,G);
    43314350  //compute a random next weight vector "next_weight2"
    4332   k = 1;
    4333   while(k<4)
    4334   {
    4335     k++;
     4351  while(1)
     4352  {
    43364353    weight_norm = 0;
    4337     intvec* next_weight22 = new intvec(nV);
    43384354    while(weight_norm == 0)
    43394355    {
    4340       //PrintS("\nWhile WeightNorm\n");
     4356
    43414357      for(i=0; i<nV; i++)
    43424358      {
    4343         (*next_weight22)[i] = rand() % 60000 ;
     4359        (*next_weight22)[i] = rand() % 60000 - 30000;
    43444360        weight_norm = weight_norm + (*next_weight22)[i]*(*next_weight22)[i];
    43454361      }
    4346       //Print("\n// weight_norm vor Wurzel = %d\n", weight_norm);
    43474362      weight_norm = 1 + floor(sqrt(weight_norm));
    4348      
    4349     }
    4350 //Print("\n// weight_norm nach Wurzel = %d\n", weight_norm);
     4363    }
     4364
    43514365    for(i=0; i<nV; i++)
    43524366    {
    43534367      if((*next_weight22)[i] < 0)
    43544368      {
    4355         (*next_weight22)[i] = 1 + (*curr_weight)[i] + floor((weight_rad)*(*next_weight22)[i]/weight_norm);
     4369        (*next_weight22)[i] = 1 + (*curr_weight)[i] + floor(weight_rad*(*next_weight22)[i]/weight_norm);
    43564370      }
    43574371      else
    43584372      {
    4359         (*next_weight22)[i] = (*curr_weight)[i] + floor((weight_rad)*(*next_weight22)[i]/weight_norm);
     4373        (*next_weight22)[i] = (*curr_weight)[i] + floor(weight_rad*(*next_weight22)[i]/weight_norm);
    43604374      }
    43614375    }
     
    43634377    if(test_w_in_ConeCC(G, next_weight22) == 1)
    43644378    {
    4365       //PrintS("\n //** MWalkRandomNextWeight: test ob in Kegel.\n");
    43664379      next_weight2 = MkInterRedNextWeight(next_weight22,target_weight,G);
    43674380      if(MivAbsMax(next_weight2)>1147483647)
     
    43804393        }
    43814394      }
    4382       random = TRUE;
     4395      delete next_weight22;
    43834396      break;
    43844397    }
    4385     delete next_weight22;
    4386   }
    4387   //PrintS("\n //**MWalkRandomNextWeight: Ende while-Schleife!\n");
    4388 
     4398  }
     4399 
    43894400  // compute "usual" next weight vector
    43904401  intvec* next_weight = MwalkNextWeightCC(curr_weight,target_weight, G);
    4391   G_test = MwalkInitialForm(G, next_weight);
    4392   if(random == TRUE)
    4393   {
    4394     G_test2 = MwalkInitialForm(G, next_weight2);
    4395   }
     4402  ideal G_test = MwalkInitialForm(G, next_weight);
     4403  ideal G_test2 = MwalkInitialForm(G, next_weight2);
     4404
    43964405  // compare next weights
    43974406  if(Overflow_Error == FALSE)
    43984407  {
    43994408    ideal G_test1 = MwalkInitialForm(G, next_weight1);
    4400     if(G_test1->m[0] != NULL && maxlengthpoly(G_test1) < maxlengthpoly(G_test))
    4401     {
    4402       if(random == TRUE &&
    4403          G_test2->m[0] != NULL &&
    4404          maxlengthpoly(G_test2) < maxlengthpoly(G_test1))
    4405       {
     4409    if(G_test1->m[0] != NULL && maxlengthpoly(G_test1) < maxlengthpoly(G_test))//if(IDELEMS(G_test1) < IDELEMS(G_test))
     4410    {
     4411      if(G_test2->m[0] != NULL && maxlengthpoly(G_test2) < maxlengthpoly(G_test1)) //if(IDELEMS(G_test2) < IDELEMS(G_test1))
     4412      {
     4413        // |G_test2| < |G_test1| < |G_test|
    44064414        for(i=0; i<nV; i++)
    44074415        {
     
    44114419      else
    44124420      {
     4421        // |G_test1| < |G_test|, |G_test1| <= |G_test2|
    44134422        for(i=0; i<nV; i++)
    44144423        {
     
    44194428    else
    44204429    {
    4421       if(random == TRUE &&
    4422          G_test2->m[0] != NULL &&
    4423          maxlengthpoly(G_test2) < maxlengthpoly(G_test))
     4430      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|
    44244431      {
    44254432        for(i=0; i<nV; i++)
     
    44304437      else
    44314438      {
     4439        // |G_test| < |G_test1|, |G_test| <= |G_test2|
    44324440        for(i=0; i<nV; i++)
    44334441        {
     
    44414449  {
    44424450    Overflow_Error = FALSE;
    4443     if(random == TRUE &&
    4444        G_test2->m[0] != NULL &&
    4445        maxlengthpoly(G_test2) < maxlengthpoly(G_test))
     4451    if(G_test2->m[0] != NULL && maxlengthpoly(G_test2) < maxlengthpoly(G_test))//if(IDELEMS(G_test2) < IDELEMS(G_test))
    44464452    {
    44474453      for(i=1; i<nV; i++)
     
    44584464    }
    44594465  }
    4460   //PrintS("\n MWalkRandomNextWeight: Ende ok!\n");
     4466  PrintS("\n MWalkRandomNextWeight: Ende ok!\n");
    44614467  idDelete(&G_test);
    4462   if(random == TRUE)
    4463   {
    4464     idDelete(&G_test2);
    4465   }
     4468  idDelete(&G_test2);
    44664469  if(test_w_in_ConeCC(G, result) == 1)
    44674470  {
    4468     if(random == TRUE)
    4469     {
    4470       delete next_weight2;
    4471     }
     4471    delete next_weight2;
    44724472    delete next_weight;
    44734473    delete next_weight1;
     
    44774477  {
    44784478    delete result;
    4479     if(random == TRUE)
    4480     {
    4481       delete next_weight2;
    4482     }
     4479    delete next_weight2;
    44834480    delete next_weight1;
    44844481    return next_weight;
     
    51245121    }
    51255122//#endif
    5126 
    5127 
    51285123    if(reduction == 0)
    51295124    {
     
    51405135      }
    51415136    }
    5142 
    51435137#ifndef  BUCHBERGER_ALG
    51445138    if(isNolVector(curr_weight) == 0)
     
    52625256        PrintS("\n//** Mwalk: entering last cone.\n");
    52635257      }
     5258      if(reduction == 0)
     5259      {
     5260        if(MivComp(next_weight, ivNull) == 1 || MivComp(target_weight,curr_weight) == 1)
     5261        {
     5262          delete next_weight;
     5263          baseRing = currRing;
     5264          si_opt_1 = save1; //set original options, e. g. option(RedSB)
     5265          break;
     5266        }
     5267      }
     5268      else
     5269      {
    52645270//#endif
    5265       Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector"
    5266       if(target_M->length() == nV)
    5267       {
    5268         newRing = VMrDefault(target_weight); // define a new ring with ordering "(a(curr_weight),lp)
    5269       }
    5270       else
    5271       {
    5272         newRing = VMatrDefault(target_M);
    5273       }
    5274       rChangeCurrRing(newRing);
    5275       Gomega1 = idrMoveR(Gomega, baseRing,currRing);
    5276       idDelete(&Gomega);
     5271        Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector"
     5272        if(target_M->length() == nV)
     5273        {
     5274          newRing = VMrDefault(target_weight); // define a new ring with ordering "(a(curr_weight),lp)
     5275        }
     5276        else
     5277        {
     5278          newRing = VMatrDefault(target_M);
     5279        }
     5280        rChangeCurrRing(newRing);
     5281        Gomega1 = idrMoveR(Gomega, baseRing,currRing);
     5282        idDelete(&Gomega);
    52775283//#ifdef CHECK_IDEAL_MWALK
    5278       if(printout > 1)
    5279       {
    5280         idString(Gomega1, "//** Mwalk: Gomega");
    5281       }
    5282       PrintS("\n //** Mwalk: kStd(Gomega)");
     5284        if(printout > 1)
     5285        {
     5286          idString(Gomega1, "//** Mwalk: Gomega");
     5287        }
     5288        PrintS("\n //** Mwalk: kStd(Gomega)");
    52835289//#endif
    5284       M = kStd(Gomega1,NULL,testHomog,NULL,NULL,0,0,NULL);
     5290        M = kStd(Gomega1,NULL,testHomog,NULL,NULL,0,0,NULL);
    52855291//#ifdef CHECK_IDEAL_MWALK
    5286       if(printout > 1)
    5287       {
    5288         idString(M,"//** Mwalk: M");
    5289       }
     5292        if(printout > 1)
     5293        {
     5294          idString(M,"//** Mwalk: M");
     5295        }
    52905296//#endif
    5291       rChangeCurrRing(baseRing);
    5292       M1 =  idrMoveR(M, newRing,currRing);
    5293       idDelete(&M);
    5294       Gomega2 = idrMoveR(Gomega1, newRing,currRing);
    5295       idDelete(&Gomega1);
    5296       PrintS("\n //** Mwalk: MLifttwoIdeal");
    5297       F = MLifttwoIdeal(Gomega2, M1, G);
     5297        rChangeCurrRing(baseRing);
     5298        M1 =  idrMoveR(M, newRing,currRing);
     5299        idDelete(&M);
     5300        Gomega2 = idrMoveR(Gomega1, newRing,currRing);
     5301        idDelete(&Gomega1);
     5302        PrintS("\n //** Mwalk: MLifttwoIdeal");
     5303        F = MLifttwoIdeal(Gomega2, M1, G);
    52985304//#ifdef CHECK_IDEAL_MWALK
    5299     if(printout > 2)
    5300     {
    5301       idString(F,"//** Mwalk: F");
    5302     }
     5305        if(printout > 2)
     5306        {
     5307          idString(F,"//** Mwalk: F");
     5308        }
    53035309//#endif
    5304       idDelete(&Gomega2);
    5305       idDelete(&M1);
    5306       rChangeCurrRing(newRing); // change the ring to newRing
    5307       G = idrMoveR(F,baseRing,currRing);
    5308       idDelete(&F);
    5309       baseRing = currRing;
    5310       si_opt_1 = save1; //set original options, e. g. option(RedSB)
    5311       idSkipZeroes(G);
     5310        idDelete(&Gomega2);
     5311        idDelete(&M1);
     5312        rChangeCurrRing(newRing); // change the ring to newRing
     5313        G = idrMoveR(F,baseRing,currRing);
     5314        idDelete(&F);
     5315        baseRing = currRing;
     5316        si_opt_1 = save1; //set original options, e. g. option(RedSB)
     5317        idSkipZeroes(G);
    53125318#ifdef TIME_TEST
    5313       to = clock();
    5314 #endif
    5315       //PrintS("\n //**Mwalk: Interreduce");
    5316       //interreduce the Groebner basis <G> w.r.t. currRing
    5317       //G = kInterRedCC(G,NULL);
     5319        to = clock();
     5320#endif
     5321        //PrintS("\n //**Mwalk: Interreduce");
     5322        //interreduce the Groebner basis <G> w.r.t. currRing
     5323        //G = kInterRedCC(G,NULL);
    53185324#ifdef TIME_TEST
    5319       tred = tred + clock() - to;
    5320 #endif
    5321       idSkipZeroes(G);
    5322       delete next_weight;
    5323       break;
     5325        tred = tred + clock() - to;
     5326#endif
     5327        idSkipZeroes(G);
     5328        delete next_weight;
     5329        break;
     5330      }
    53245331    }
    53255332    for(i=nV-1; i>=0; i--)
     
    53715378  int nV = currRing->N;
    53725379
    5373   ideal Gomega, M, F, Gomega1, Gomega2, M1; //, F1;
     5380  ideal Gomega, M, F,FF, Gomega1, Gomega2, M1; //, F1;
    53745381  ring newRing;
    53755382  ring baseRing = currRing;
     
    54465453    }
    54475454//#endif
     5455    if(reduction == 0)
     5456    {
     5457      PrintS("\n//** Mrwalk: test middle of cone!\n");
     5458      FF = middleOfCone(G,Gomega);
     5459      PrintS("\n//** Mrwalk: Test F!\n");
     5460      if( FF != NULL)
     5461      {
     5462        idDelete(&G);
     5463        G = idCopy(FF);
     5464        idDelete(&FF);
     5465        PrintS("\n//** Mrwalk: FF nicht NULL! Compue next vector.\n");
     5466        goto NEXT_VECTOR;
     5467      }
     5468    }
    54485469#ifndef  BUCHBERGER_ALG
    54495470    if(isNolVector(curr_weight) == 0)
     
    55395560    }
    55405561//#endif
     5562    NEXT_VECTOR:
    55415563#ifdef TIME_TEST
    55425564    to = clock();
     
    55595581    }
    55605582//#endif
    5561     if(MivComp(next_weight, ivNull) == 1 || MivComp(target_weight,curr_weight) == 1 || test_w_in_ConeCC(G, target_weight) == 1) // || MivComp(next_weight,curr_weight) == 1)
    5562     {
    5563 #ifdef CHECK_IDEAL_MWALK
    5564       PrintS("\n//** Mwalk: entering last cone.\n");
    5565 #endif
    5566       Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector"
     5583    if(MivComp(next_weight, ivNull) == 1 || MivComp(target_weight,curr_weight) == 1 || test_w_in_ConeCC(G, target_weight) == 1)
     5584    {
    55675585//#ifdef CHECK_IDEAL_MWALK
    5568       if(printout > 1)
    5569       {
    5570         idString(Gomega, "//** Mrwalk: Gomega");
    5571       }
     5586      if(printout > 0)
     5587      {
     5588        PrintS("\n//** Mrwalk: entering last cone.\n");
     5589      }
     5590      if(reduction == 0)
     5591      {
     5592        if(MivComp(next_weight, ivNull) == 1 || MivComp(target_weight,curr_weight) == 1)
     5593        {
     5594          delete next_weight;
     5595          baseRing = currRing;
     5596          si_opt_1 = save1; //set original options, e. g. option(RedSB)
     5597          break;
     5598        }
     5599      }
     5600      else
     5601      {
    55725602//#endif
    5573       if(target_M->length() == nV)
    5574       {
    5575         newRing = VMrDefault(target_weight); // define a new ring with ordering "(a(curr_weight),lp)
    5576       }
    5577       else
    5578       {
    5579         newRing = VMatrDefault(target_M);
    5580       }
    5581       rChangeCurrRing(newRing);
    5582       Gomega1 = idrMoveR(Gomega, baseRing,currRing);
    5583       idDelete(&Gomega);
    5584       M = kStd(Gomega1,NULL,testHomog,NULL,NULL,0,0,NULL);
     5603        Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector"
     5604        if(target_M->length() == nV)
     5605        {
     5606          newRing = VMrDefault(target_weight); // define a new ring with ordering "(a(curr_weight),lp)
     5607        }
     5608        else
     5609        {
     5610          newRing = VMatrDefault(target_M);
     5611        }
     5612        rChangeCurrRing(newRing);
     5613        Gomega1 = idrMoveR(Gomega, baseRing,currRing);
     5614        idDelete(&Gomega);
    55855615//#ifdef CHECK_IDEAL_MWALK
    5586       if(printout > 2)
    5587       {
    5588         idString(M,"//** Mrwalk: M");
    5589       }
     5616        if(printout > 1)
     5617        {
     5618          idString(Gomega1, "//** Mrwalk: Gomega");
     5619        }
     5620        PrintS("\n //** Mrwalk: kStd(Gomega)");
    55905621//#endif
    5591       rChangeCurrRing(baseRing);
    5592       M1 =  idrMoveR(M, newRing,currRing);
    5593       idDelete(&M);
    5594       Gomega2 = idrMoveR(Gomega1, newRing,currRing);
    5595       idDelete(&Gomega1);
    5596       F = MLifttwoIdeal(Gomega2, M1, G);
    5597       idDelete(&Gomega2);
    5598       idDelete(&M1);
    5599       rChangeCurrRing(newRing); // change the ring to newRing
    5600       G = idrMoveR(F,baseRing,currRing);
    5601       idDelete(&F);
    5602       baseRing = currRing;
    5603       idSkipZeroes(G);
     5622        M = kStd(Gomega1,NULL,testHomog,NULL,NULL,0,0,NULL);
     5623//#ifdef CHECK_IDEAL_MWALK
     5624        if(printout > 1)
     5625        {
     5626          idString(M,"//** Mrwalk: M");
     5627        }
     5628//#endif
     5629        rChangeCurrRing(baseRing);
     5630        M1 =  idrMoveR(M, newRing,currRing);
     5631        idDelete(&M);
     5632        Gomega2 = idrMoveR(Gomega1, newRing,currRing);
     5633        idDelete(&Gomega1);
     5634        PrintS("\n //** Mrwalk: MLifttwoIdeal");
     5635        F = MLifttwoIdeal(Gomega2, M1, G);
     5636//#ifdef CHECK_IDEAL_MWALK
     5637        if(printout > 2)
     5638        {
     5639          idString(F,"//** Mrwalk: F");
     5640        }
     5641//#endif
     5642        idDelete(&Gomega2);
     5643        idDelete(&M1);
     5644        rChangeCurrRing(newRing); // change the ring to newRing
     5645        G = idrMoveR(F,baseRing,currRing);
     5646        idDelete(&F);
     5647        baseRing = currRing;
     5648        si_opt_1 = save1; //set original options, e. g. option(RedSB)
     5649        idSkipZeroes(G);
    56045650#ifdef TIME_TEST
    5605       to = clock();
    5606 #endif
    5607 //#ifdef CHECK_IDEAL_MWALK
    5608       if(printout > 2)
    5609       {
    5610         idString(G,"//** Mrwalk: G");
    5611       }
    5612 ///#endif
    5613       if(si_opt_1 == (Sy_bit(OPT_REDSB)))
    5614       {
    5615         //G = kInterRedCC(G,NULL); //interreduce the Groebner basis <G> w.r.t. currRing
    5616       }
     5651        to = clock();
     5652#endif
     5653        //PrintS("\n //**Mrwalk: Interreduce");
     5654        //interreduce the Groebner basis <G> w.r.t. currRing
     5655        //G = kInterRedCC(G,NULL);
    56175656#ifdef TIME_TEST
    5618       tred = tred + clock() - to;
    5619 #endif
    5620       idSkipZeroes(G);
    5621       delete next_weight;
    5622       break;
     5657        tred = tred + clock() - to;
     5658#endif
     5659        idSkipZeroes(G);
     5660        delete next_weight;
     5661        break;
     5662      }
    56235663    }
    56245664    for(i=nV-1; i>=0; i--)
     
    58135853  int endwalks=0;
    58145854
    5815   ideal Gomega, M, F, G, Gomega1, Gomega2, M1,F1,Eresult,ssG;
     5855  ideal Gomega, M, F, FF, G, Gomega1, Gomega2, M1,F1,Eresult,ssG;
    58165856  ring newRing, oldRing, TargetRing;
    58175857  intvec* iv_M_dp;
     
    58815921    {
    58825922      iv_M_lp = MivMatrixOrderlp(nV);
    5883       //ivString(iv_M_lp, "iv_M_lp");
    5884       //target_weight = MPertVectorslp(ssG, iv_M_lp, tp_deg);
    58855923      target_weight = MPertVectors(ssG, iv_M_lp, tp_deg);
    58865924    }
     
    58885926    {
    58895927      iv_M_lp = MivMatrixOrder(target_weight);
    5890       //target_weight = MPertVectorslp(ssG, iv_M_lp, tp_deg);
    58915928      target_weight = MPertVectors(ssG, iv_M_lp, tp_deg);
    58925929    }
     
    59155952    }
    59165953//#endif
     5954    if(reduction == 0 && nstep > 1)
     5955    {
     5956      // check whether weight vector is in the interior of the cone
     5957      while(1)
     5958      {
     5959        FF = middleOfCone(G,Gomega);
     5960        if(FF != NULL)
     5961        {
     5962          idDelete(&G);
     5963          G = idCopy(FF);
     5964          idDelete(&FF);
     5965          next_weight = MwalkNextWeightCC(curr_weight,target_weight,G);
     5966          if(printout > 0)
     5967          {
     5968            MivString(curr_weight, target_weight, next_weight);
     5969          }
     5970        }
     5971        else
     5972        {
     5973          break;
     5974        }
     5975        for(i=nV-1; i>=0; i--)
     5976        {
     5977          (*curr_weight)[i] = (*next_weight)[i];
     5978        }
     5979        Gomega = MwalkInitialForm(G, curr_weight);
     5980        if(printout > 1)
     5981        {
     5982          idString(Gomega,"//** Mpwalk: Gomega");
     5983        }
     5984      }
     5985    }
    59175986
    59185987#ifdef ENDWALKS
     
    59966065    F = MLifttwoIdeal(Gomega2, M1, G);
    59976066    if(endwalks != 1)
    5998     {
    59996067      tlift = tlift+clock()-to;
    6000     }
    60016068    else
    6002     {
    60036069      xtlift=clock()-to;
    6004     }
     6070
     6071//#ifdef CHECK_IDEAL_MWALK
    60056072    if(printout > 2)
    60066073    {
    60076074      idString(F,"//** Mpwalk: F");
    60086075    }
     6076//#endif
    60096077
    60106078    idDelete(&M1);
     
    60146082    // change the ring to newRing
    60156083    rChangeCurrRing(newRing);
    6016     F1 = idrMoveR(F, oldRing,currRing);
    6017     to=clock();
    6018     if(printout > 0)
    6019     {
    6020       PrintS("\n //** Mpwalk: reduce the Groebner basis.\n");
    6021     }
    6022     G = kInterRedCC(F1, NULL);
    6023     if(endwalks != 1)
    6024     {
    6025       tred = tred+clock()-to;
     6084    if(reduction == 0)
     6085    {
     6086      G = idrMoveR(F,oldRing,currRing);
    60266087    }
    60276088    else
    60286089    {
    6029       xtred=clock()-to;
    6030     }
    6031     idDelete(&F1);
    6032 
     6090      F1 = idrMoveR(F, oldRing,currRing);
     6091      if(printout > 2)
     6092      {
     6093        PrintS("\n //** Mpwalk: reduce the Groebner basis.\n");
     6094      }
     6095      to=clock();
     6096      G = kInterRedCC(F1, NULL);
     6097      if(endwalks != 1)
     6098        tred = tred+clock()-to;
     6099      else
     6100        xtred=clock()-to;
     6101      idDelete(&F1);
     6102    }
    60336103    if(endwalks == 1)
    60346104      break;
     
    60366106    to=clock();
    60376107    // compute a next weight vector
    6038     //next_weight = MwalkNextWeightCC(curr_weight,target_weight,G);
    60396108    next_weight = MkInterRedNextWeight(curr_weight,target_weight, G);
    60406109    tnw=tnw+clock()-to;
    6041 
     6110//#ifdef PRINT_VECTORS
    60426111    if(printout > 0)
    60436112    {
    60446113      MivString(curr_weight, target_weight, next_weight);
    60456114    }
    6046 
     6115//#endif
    60476116
    60486117    if(Overflow_Error == TRUE)
    60496118    {
    60506119      ntwC = 0;
     6120      //ntestomega = 1;
     6121      //Print("\n// ring r%d = %s;\n", nstep, rString(currRing));
     6122      //idElements(G, "G");
    60516123      delete next_weight;
    6052       break;
    6053       //goto FINISH_160302;
    6054     }
    6055     if(MivComp(next_weight, ivNull) == 1)
    6056     {
     6124      goto FINISH_160302;
     6125    }
     6126    if(MivComp(next_weight, ivNull) == 1){
    60576127      newRing = currRing;
    60586128      delete next_weight;
     6129      //Print("\n// ring r%d = %s;\n", nstep, rString(currRing));
    60596130      break;
    60606131    }
    6061     if(MivComp(next_weight, target_weight) == 1 || test_w_in_ConeCC(G, target_weight)==1) //AENDERUNG!!
    6062     {
     6132    if(MivComp(next_weight, target_weight) == 1)
    60636133      endwalks = 1;
    6064     }
     6134
    60656135    for(i=nV-1; i>=0; i--)
    6066     {
    60676136      (*curr_weight)[i] = (*next_weight)[i];
    6068     }
     6137
    60696138    delete next_weight;
    60706139  }//end of while-loop
     
    60906159#endif
    60916160
     6161
    60926162    // check whether the pertubed target vector stays in the correct cone
    60936163    if(ntwC != 0){
     
    60976167    if( ntestw != 1 || ntwC == 0)
    60986168    {
    6099       if(printout > 0)
    6100       {
    6101         if(printout > 1)
    6102         {
    6103           ivString(pert_target_vector, "tau");
    6104         }
    6105         PrintS("\n //** Mpwalk: perturbed target vector doesn't stay in cone. \n");
    6106         if(printout > 2)
    6107         {
    6108           Print("\n// ring r%d = %s;\n", nstep, rString(currRing));
    6109           //idElements(F1, "G");
    6110         }
    6111       }
    6112 
     6169      if(ntestw != 1 && printout >2)
     6170      {
     6171        ivString(pert_target_vector, "tau");
     6172        PrintS("\n// ** perturbed target vector doesn't stay in cone!!");
     6173        Print("\n// ring r%d = %s;\n", nstep, rString(currRing));
     6174        //idElements(F1, "G");
     6175      }
    61136176      // LastGB is "better" than the kStd subroutine
    61146177      to=clock();
    61156178      ideal eF1;
    6116       if(nP == 0 || tp_deg == 1 || MivSame(orig_target, exivlp) != 1)
    6117       {
    6118         if(printout > 1)
    6119         {
    6120           PrintS("\n //** Mpwalk: call \"std\" to compute a GB.\n");
    6121         }
     6179      if(nP == 0 || tp_deg == 1 || MivSame(orig_target, exivlp) != 1){
     6180        // PrintS("\n// ** calls \"std\" to compute a GB");
    61226181        eF1 = MstdCC(F1);
    61236182        idDelete(&F1);
    61246183      }
    6125       else
    6126       {
    6127         if(printout > 1)
    6128         {
    6129           PrintS("\n //** Mpwalk: call \"LastGB\" to compute a GB.\n");
    6130         }
     6184      else {
     6185        // PrintS("\n// ** calls \"LastGB\" to compute a GB");
    61316186        rChangeCurrRing(newRing);
    61326187        ideal F2 = idrMoveR(F1, TargetRing,currRing);
    61336188        eF1 = LastGB(F2, curr_weight, tp_deg-1);
    6134         idDelete(&F2);
    6135         //F2=NULL;
     6189        F2=NULL;
    61366190      }
    61376191      xtextra=clock()-to;
     
    61406194      rChangeCurrRing(XXRing);
    61416195      Eresult = idrMoveR(eF1, exTargetRing,currRing);
    6142       idDelete(&eF1);
    6143     }
    6144     else
    6145     {
     6196    }
     6197    else{
    61466198      rChangeCurrRing(XXRing);
    61476199      Eresult = idrMoveR(F1, TargetRing,currRing);
    6148       idDelete(&F1);
    6149     }
    6150   }
    6151   else
    6152   {
     6200    }
     6201  }
     6202  else {
    61536203    rChangeCurrRing(XXRing);
    61546204    Eresult = idrMoveR(G, newRing,currRing);
    6155     idDelete(&G);
    61566205  }
    61576206  si_opt_1 = save1; //set original options, e. g. option(RedSB)
    61586207  delete ivNull;
    61596208  if(tp_deg != 1)
    6160   {
    61616209    delete target_weight;
    6162   }
     6210
    61636211  if(op_deg != 1 )
    6164   {
    61656212    delete curr_weight;
    6166   }
     6213
    61676214  delete exivlp;
    61686215  delete last_omega;
     
    61906237    si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis
    61916238    //si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions
     6239    //si_opt_1|=(Sy_bit(OPT_REDTAIL)|Sy_bit(OPT_REDSB));
    61926240  }
    61936241  Set_Error(FALSE);
     
    62066254  int endwalks=0;
    62076255
    6208   ideal Gomega, M, F, G, Gomega1, Gomega2, M1,F1,Eresult,ssG;
     6256  ideal Gomega, M, F, FF, G, Gomega1, Gomega2, M1,F1,Eresult,ssG;
    62096257  ring newRing, oldRing, TargetRing;
    62106258  intvec* iv_M_dp;
     
    62466294      {
    62476295        iv_M_dp = MivMatrixOrderdp(nV);
    6248         //ivString(iv_M_dp, "iv_M_dp");
    62496296        curr_weight = MPertVectors(G, iv_M_dp, op_deg);
    62506297      }
     
    63006347      {
    63016348        iv_M_lp = MivMatrixOrderlp(nV);
    6302         //ivString(iv_M_lp, "iv_M_lp");
    6303         //target_weight = MPertVectorslp(ssG, iv_M_lp, tp_deg);
    63046349        target_weight = MPertVectors(ssG, iv_M_lp, tp_deg);
    63056350      }
     
    63076352      {
    63086353        iv_M_lp = MivMatrixOrder(target_weight);
    6309         //target_weight = MPertVectorslp(ssG, iv_M_lp, tp_deg);
    63106354        target_weight = MPertVectors(ssG, iv_M_lp, tp_deg);
    63116355      }
     
    63396383    // "curr_weight"
    63406384    Gomega = MwalkInitialForm(G, curr_weight);
     6385    polylength = lengthpoly(Gomega);
    63416386//#ifdef CHECK_IDEAL_MWALK
    63426387    if(printout > 0)
     
    63456390    }
    63466391//#endif
    6347     polylength = lengthpoly(Gomega);
     6392    if(reduction == 0 && nstep > 1)
     6393    {
     6394      while(1)
     6395      {
     6396        // check whether weight vector is in the interior of the cone
     6397        FF = middleOfCone(G,Gomega);
     6398        if(FF != NULL)
     6399        {
     6400          idDelete(&G);
     6401          G = idCopy(FF);
     6402          idDelete(&FF);
     6403          next_weight = MwalkNextWeightCC(curr_weight,target_weight,G);
     6404          if(printout > 0)
     6405          {
     6406            MivString(curr_weight, target_weight, next_weight);
     6407          }
     6408        }
     6409        else
     6410        {
     6411          if(polylength > 0)
     6412          {
     6413            Print("\n //**Mprwalk: there is a polynomial in Gomega with at least 3 monomials, low-dimensional facet of the cone.\n");
     6414            delete next_weight;
     6415            next_weight = MWalkRandomNextWeight(G, curr_weight, target_weight, weight_rad, op_deg);
     6416          }
     6417          break;
     6418        }
     6419        for(i=nV-1; i>=0; i--)
     6420        {
     6421          (*curr_weight)[i] = (*next_weight)[i];
     6422        }
     6423        Gomega = MwalkInitialForm(G, curr_weight);
     6424        polylength = lengthpoly(Gomega);
     6425        if(printout > 1)
     6426        {
     6427          idString(Gomega,"//** Mprwalk: Gomega");
     6428        }
     6429      }
     6430    }
    63486431#ifdef ENDWALKS
    63496432    if(endwalks == 1)
     
    64376520    else
    64386521      xtlift=clock()-to;
    6439     Print("\n //** Mprwalk: F.\n");
     6522
    64406523//#ifdef CHECK_IDEAL_MWALK
    64416524    if(printout > 2)
     
    64516534    // change the ring to newRing
    64526535    rChangeCurrRing(newRing);
    6453     //F1 = idrMoveR(F, oldRing,currRing);
    6454     F1 = idrMoveR(F,oldRing,currRing);
    6455     to=clock();
    6456     Print("\n //** Mprwalk: reducing the Groebner basis.\n");
    6457     G = kInterRedCC(F1, NULL);
    6458     if(endwalks != 1)
    6459       tred = tred+clock()-to;
     6536    if(reduction == 0)
     6537    {
     6538      G = idrMoveR(F,oldRing,currRing);
     6539    }
    64606540    else
    6461       xtred=clock()-to;
    6462 
    6463     idDelete(&F1);
     6541    {
     6542      F1 = idrMoveR(F, oldRing,currRing);
     6543      if(printout > 2)
     6544      {
     6545        PrintS("\n //** Mprwalk: reduce the Groebner basis.\n");
     6546      }
     6547      to=clock();
     6548      G = kInterRedCC(F1, NULL);
     6549      if(endwalks != 1)
     6550        tred = tred+clock()-to;
     6551      else
     6552        xtred=clock()-to;
     6553      idDelete(&F1);
     6554    }
    64646555
    64656556    if(endwalks == 1)
     
    64676558
    64686559    to=clock();
    6469     Print("\n //** Mprwalk: compute a next weight vector.\n");
     6560
    64706561    next_weight = MkInterRedNextWeight(curr_weight,target_weight, G);
    64716562    if(polylength > 0)
    64726563    {
    6473       Print("\n //**Mprwalk: there is a polynomial in Gomega with at least 3 monomials, low-dimensional facet of the cone.\n");
     6564      if(printout > 2)
     6565      {
     6566        Print("\n //**Mprwalk: there is a polynomial in Gomega with at least 3 monomials, low-dimensional facet of the cone.\n");
     6567      }
    64746568      delete next_weight;
    64756569      next_weight = MWalkRandomNextWeight(G, curr_weight, target_weight, weight_rad, op_deg);
     
    65346628
    65356629    // check whether the pertubed target vector stays in the correct cone
    6536     if(ntwC != 0){
     6630    if(ntwC != 0)
     6631    {
    65376632      ntestw = test_w_in_ConeCC(F1, pert_target_vector);
    65386633    }
    6539 
    6540     if( ntestw != 1 || ntwC == 0)
    6541     {
    6542       /*
    6543       if(ntestw != 1){
     6634    if(ntestw != 1 || ntwC == 0)
     6635    {
     6636      if(ntestw != 1 && printout > 2)
     6637      {
    65446638        ivString(pert_target_vector, "tau");
    6545         PrintS("\n// ** perturbed target vector doesn't stay in cone!!");
     6639        PrintS("\n// **Mprwalk: perturbed target vector doesn't stay in cone.");
    65466640        Print("\n// ring r%d = %s;\n", nstep, rString(currRing));
    6547         idElements(F1, "G");
    6548       }
    6549       */
     6641        //idElements(F1, "G");
     6642      }
    65506643      // LastGB is "better" than the kStd subroutine
    65516644      to=clock();
    65526645      ideal eF1;
    6553       if(nP == 0 || tp_deg == 1 || MivSame(orig_target, exivlp) != 1 || target_M->length() != nV){
    6554         // PrintS("\n// ** calls \"std\" to compute a GB");
     6646      if(nP == 0 || tp_deg == 1 || MivSame(orig_target, exivlp) != 1 || target_M->length() != nV)
     6647      {
     6648        if(printout > 2)
     6649        {
     6650          PrintS("\n// ** Mprwalk: Call \"std\" to compute a Groebner basis.\n");
     6651        }
    65556652        eF1 = MstdCC(F1);
    65566653        idDelete(&F1);
    65576654      }
    6558       else {
    6559         // PrintS("\n// ** calls \"LastGB\" to compute a GB");
     6655      else
     6656      {
     6657        if(printout > 2)
     6658        {
     6659          PrintS("\n// **Mprwalk: Call \"LastGB\" to compute a Groebner basis.\n");
     6660        }
    65606661        rChangeCurrRing(newRing);
    65616662        ideal F2 = idrMoveR(F1, TargetRing,currRing);
     
    70477148 ************************************************************************/
    70487149static ideal rec_r_fractal_call(ideal G, int nlev, intvec* ivtarget,
    7049                 int weight_rad, int printout)
     7150                int weight_rad, int reduction, int printout)
    70507151{
    70517152  Overflow_Error =  FALSE;
     
    70557156  ring new_ring, testring;
    70567157  //ring extoRing;
    7057   ideal Gomega, Gomega1, Gomega2, F, F1, Gresult, Gresult1, G1, Gt;
     7158  ideal Gomega, Gomega1, Gomega2, F, FF, F1, Gresult, Gresult1, G1, Gt;
    70587159  int nwalks = 0;
    70597160  intvec* Mwlp;
     
    71237224      delete next_vect;
    71247225      next_vect = MWalkRandomNextWeight(G,omega,omega2,weight_rad,nlev);
    7125       if(isNegNolVector(next_vect)==1 || MivSame(omega,next_vect) == 1)
     7226      if(isNegNolVector(next_vect)==1)
    71267227      {
    71277228        delete next_vect;
     
    72087309          delete next_vect;
    72097310          next_vect = MWalkRandomNextWeight(G,omega,omega2,weight_rad,nlev);
    7210           if(isNegNolVector(next_vect)==1 || MivSame(omega,next_vect) == 1)
     7311          if(isNegNolVector(next_vect)==1)
    72117312          {
    72127313            delete next_vect;
     
    72677368        Print("\n//** rec_r_fractal_call: Leaving the %d-th recursion with %d steps.\n",
    72687369              nlev, nwalks);
    7269       /*
    7270         Print(" ** Overflow_Error? (%d)", Overflow_Error);
    7271         idString(G1,"//** rec_r_fractal_call: G1");
    7272       */
     7370        //Print(" ** Overflow_Error? (%d)", Overflow_Error);
    72737371      }
    72747372      nnflow ++;
     
    73107408          Print("\n//** rec_r_fractal_call: Leaving the %d-th recursion with %d steps.\n",
    73117409                nlev, nwalks);
    7312         /*
    7313           Print(" ** Overflow_Error? (%d)", Overflow_Error);
    7314           idString(Gt,"//** rec_r_fractal_call: Gt");
    7315         */
     7410          //Print(" ** Overflow_Error? (%d)", Overflow_Error);
    73167411        }
    73177412        return (Gt);
     
    74167511          Print("\n//** rec_r_fractal_call: Leaving the %d-th recursion with %d steps.\n",
    74177512                nlev,nwalks);
    7418          /*
    7419           Print(" ** Overflow_Error? (%d)", Overflow_Error);
    7420           idString(G,"//** rec_r_fractal_call: G");
    7421          */
     7513          //Print(" ** Overflow_Error? (%d)", Overflow_Error);
    74227514        }
    74237515        if(Overflow_Error == TRUE)
     
    74467538      idString(Gomega,"//** rec_r_fractal_call: Gomega");
    74477539    }
     7540
     7541
     7542//////////////////////////////////// hier neu!!
     7543
     7544
     7545   if(reduction == 0)
     7546    {
     7547      //PrintS("\n//** rec_r_fractal_call: test middle of cone!\n");
     7548      FF = middleOfCone(G,Gomega);
     7549      //PrintS("\n//** rec_r_fractal_call: Test F!\n");
     7550      if( FF != NULL)
     7551      {
     7552        idDelete(&G);
     7553        G = idCopy(FF);
     7554        idDelete(&FF);
     7555        PrintS("\n//** rec_r_fractal_call: FF nicht NULL! Compue next vector.\n");
     7556        goto NEXT_VECTOR_FRACTAL;
     7557      }
     7558    }
     7559
     7560
     7561
     7562///////////////////////////////////////////////////
     7563
     7564
    74487565#ifndef  BUCHBERGER_ALG
    74497566    if(isNolVector(omega) == 0)
     
    74837600      rChangeCurrRing(oRing);
    74847601      Gomega1 = idrMoveR(Gomega1, oRing,currRing);
    7485       Gresult = rec_r_fractal_call(idCopy(Gomega1),nlev+1,omega,weight_rad,printout);
     7602      Gresult = rec_r_fractal_call(idCopy(Gomega1),nlev+1,omega,weight_rad,reduction,printout);
    74867603    }
    74877604    if(printout > 2)
     
    78277944  ring helpRing = currRing;
    78287945
    7829   J = rec_r_fractal_call(J,1,ivtarget,weight_rad,printout);
     7946  J = rec_r_fractal_call(J,1,ivtarget,weight_rad,reduction,printout);
    78307947
    78317948  rChangeCurrRing(oldRing);
Note: See TracChangeset for help on using the changeset viewer.