Changeset a14482 in git for Singular/walk.cc


Ignore:
Timestamp:
Feb 26, 2015, 6:55:30 PM (9 years ago)
Author:
Stephan Oberfranz <oberfran@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'b4f17ed1d25f93d46dbe29e4b499baecc2fd51bb')
Children:
e57a75c6d0050e3db7e1a87294a311d4784df43c
Parents:
eca8d9cc9b3584a2f5741c75f69099751c4cbe8f
Message:
update
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/walk.cc

    reca8d9 ra14482  
    11061106  if(pdeg > nV || pdeg <= 0)
    11071107  {
    1108     WerrorS("//** The perturbed degree is wrong!!");
     1108    WerrorS("//**MPertVectors: The perturbed degree is wrong!!");
    11091109    return v_null;
    11101110  }
     
    11161116  }
    11171117  mpz_t *pert_vector = (mpz_t*)omAlloc(nV*sizeof(mpz_t));
    1118   //mpz_t *pert_vector1 = (mpz_t*)omAlloc(nV*sizeof(mpz_t));
    11191118
    11201119  for(i=0; i<nV; i++)
     
    11231122   // mpz_init_set_si(pert_vector1[i], (*ivtarget)[i]);
    11241123  }
    1125   // Calculate max1 = Max(A2)+Max(A3)+...+Max(Apdeg),
     1124  // Compute max1 = Max(A2)+Max(A3)+...+Max(Apdeg),
    11261125  // where the Ai are the i-te rows of the matrix target_ord.
    11271126  int ntemp, maxAi, maxA=0;
     
    11481147  }
    11491148
    1150   // Calculate inveps = 1/eps, where 1/eps > totaldeg(p)*max1 for all p in G.
     1149  // Compute inveps = 1/eps, where 1/eps > totaldeg(p)*max1 for all p in G.
    11511150
    11521151  intvec* ivUnit = Mivdp(nV);
     
    11801179  }
    11811180#else
    1182   // PrintS("\n// the \"big\" inverse epsilon: ");
     1181  PrintS("\n //**MPertVectors: the \"big\" inverse epsilon:");
    11831182  mpz_out_str(stdout, 10, inveps);
    11841183#endif
     
    12341233  if(j > nV - 1)
    12351234  {
    1236     // Print("\n//  MPertVectors: geaenderter vector gleich Null! \n");
     1235    //perturbed vector equals zero
    12371236    delete pert_vector1;
    12381237    goto CHECK_OVERFLOW;
    12391238  }
    12401239
    1241 // check that the perturbed weight vector lies in the Groebner cone
     1240  // check that the perturbed weight vector lies in the Groebner cone
    12421241  if(test_w_in_ConeCC(G,pert_vector1) != 0)
    12431242  {
    1244     // Print("\n//  MPertVectors: geaenderter vector liegt in Groebnerkegel! \n");
    12451243    for(i=0; i<nV; i++)
    12461244    {
     
    12481246    }
    12491247  }
    1250   else
    1251   {
    1252     //Print("\n// MpertVectors: geaenderter vector liegt nicht in Groebnerkegel! \n");
    1253   }
     1248
    12541249  delete pert_vector1;
    12551250
     
    12571252  intvec* result = new intvec(nV);
    12581253
    1259   /* 2147483647 is max. integer representation in SINGULAR */
     1254  // 2147483647 is max. integer representation in SINGULAR
    12601255  mpz_t sing_int;
    12611256  mpz_init_set_ui(sing_int,  2147483647);
     
    16441639  {
    16451640    mpz_divexact(pert_vector[i], pert_vector[i], ztmp);
    1646     (* result)[i] = mpz_get_si(pert_vector[i]);
    1647   }
    1648 
     1641    (* result1)[i] = mpz_get_si(pert_vector[i]);
     1642  }
    16491643  j = 0;
    1650   for(i=0; i<nV; i++)
    1651   {
    1652     (* result1)[i] = mpz_get_si(pert_vector[i]);
    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;
     1644  while(test_w_in_ConeCC(G,result1) && j<nV)
     1645  {
     1646    j = 0;
    16731647    for(i=0; i<nV; i++)
    16741648    {
     1649      (* result)[i] = (* result1)[i];
    16751650      mpz_set_si(pert_vector[i], (*result1)[i]);
    1676     }
    1677   }
    1678   else
    1679   {
    1680     delete result1;
    1681     // Print("\n// Mfpertwalk: geaenderter vector liegt nicht in Groebnerkegel! \n");
    1682   }
     1651      (* result1)[i] = floor(0.1*(mpz_get_si(pert_vector[i])) + 0.5);
     1652      if((* result1)[i] == 0)
     1653      {
     1654        j++;
     1655      }
     1656    }
     1657  }
     1658  delete result1;
    16831659
    16841660  CHECK_OVERFLOW:
     
    43434319  assume(currRing != NULL && curr_weight != NULL &&
    43444320         target_weight != NULL && G->m[0] != NULL);
    4345 
    4346   int i,weight_norm,nV = currRing->N;
     4321  //PrintS("\n //**MWalkRandomNextWeight: Anfang ok!\n");
     4322  int i,k,nV = currRing->N;
     4323  long weight_norm;
    43474324  intvec* next_weight2;
    4348   intvec* next_weight22 = new intvec(nV);
     4325  //intvec* next_weight22 = new intvec(nV);
    43494326  intvec* result = new intvec(nV);
     4327  ideal G_test;
     4328  ideal G_test2;
     4329  BOOLEAN random = FALSE;
    43504330
    43514331  intvec* next_weight1 =MkInterRedNextWeight(curr_weight,target_weight,G);
    43524332  //compute a random next weight vector "next_weight2"
    4353   while(1)
    4354   {
     4333  k = 1;
     4334  while(k<4)
     4335  {
     4336    k++;
    43554337    weight_norm = 0;
     4338    intvec* next_weight22 = new intvec(nV);
    43564339    while(weight_norm == 0)
    43574340    {
    4358 
     4341      //PrintS("\nWhile WeightNorm\n");
    43594342      for(i=0; i<nV; i++)
    43604343      {
    4361         (*next_weight22)[i] = rand() % 60000 - 30000;
     4344        (*next_weight22)[i] = rand() % 60000 ;
    43624345        weight_norm = weight_norm + (*next_weight22)[i]*(*next_weight22)[i];
    43634346      }
     4347      //Print("\n// weight_norm vor Wurzel = %d\n", weight_norm);
    43644348      weight_norm = 1 + floor(sqrt(weight_norm));
    4365     }
    4366 
     4349     
     4350    }
     4351//Print("\n// weight_norm nach Wurzel = %d\n", weight_norm);
    43674352    for(i=0; i<nV; i++)
    43684353    {
    43694354      if((*next_weight22)[i] < 0)
    43704355      {
    4371         (*next_weight22)[i] = 1 + (*curr_weight)[i] + floor(weight_rad*(*next_weight22)[i]/weight_norm);
     4356        (*next_weight22)[i] = 1 + (*curr_weight)[i] + floor((weight_rad)*(*next_weight22)[i]/weight_norm);
    43724357      }
    43734358      else
    43744359      {
    4375         (*next_weight22)[i] = (*curr_weight)[i] + floor(weight_rad*(*next_weight22)[i]/weight_norm);
     4360        (*next_weight22)[i] = (*curr_weight)[i] + floor((weight_rad)*(*next_weight22)[i]/weight_norm);
    43764361      }
    43774362    }
     
    43794364    if(test_w_in_ConeCC(G, next_weight22) == 1)
    43804365    {
     4366      //PrintS("\n //** MWalkRandomNextWeight: test ob in Kegel.\n");
    43814367      next_weight2 = MkInterRedNextWeight(next_weight22,target_weight,G);
    43824368      if(MivAbsMax(next_weight2)>1147483647)
     
    43954381        }
    43964382      }
    4397       delete next_weight22;
     4383      random = TRUE;
    43984384      break;
    43994385    }
    4400   }
    4401  
     4386    delete next_weight22;
     4387  }
     4388  //PrintS("\n //**MWalkRandomNextWeight: Ende while-Schleife!\n");
     4389
    44024390  // compute "usual" next weight vector
    44034391  intvec* next_weight = MwalkNextWeightCC(curr_weight,target_weight, G);
    4404   ideal G_test = MwalkInitialForm(G, next_weight);
    4405   ideal G_test2 = MwalkInitialForm(G, next_weight2);
    4406 
     4392  G_test = MwalkInitialForm(G, next_weight);
     4393  if(random == TRUE)
     4394  {
     4395    G_test2 = MwalkInitialForm(G, next_weight2);
     4396  }
    44074397  // compare next weights
    44084398  if(Overflow_Error == FALSE)
    44094399  {
    44104400    ideal G_test1 = MwalkInitialForm(G, next_weight1);
    4411     if(G_test1->m[0] != NULL && maxlengthpoly(G_test1) < maxlengthpoly(G_test))//if(IDELEMS(G_test1) < IDELEMS(G_test))
    4412     {
    4413       if(G_test2->m[0] != NULL && maxlengthpoly(G_test2) < maxlengthpoly(G_test1)) //if(IDELEMS(G_test2) < IDELEMS(G_test1))
    4414       {
    4415         // |G_test2| < |G_test1| < |G_test|
     4401    if(G_test1->m[0] != NULL && maxlengthpoly(G_test1) < maxlengthpoly(G_test))
     4402    {
     4403      if(random == TRUE &&
     4404         G_test2->m[0] != NULL &&
     4405         maxlengthpoly(G_test2) < maxlengthpoly(G_test1))
     4406      {
    44164407        for(i=0; i<nV; i++)
    44174408        {
     
    44214412      else
    44224413      {
    4423         // |G_test1| < |G_test|, |G_test1| <= |G_test2|
    44244414        for(i=0; i<nV; i++)
    44254415        {
     
    44304420    else
    44314421    {
    4432       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|
     4422      if(random == TRUE &&
     4423         G_test2->m[0] != NULL &&
     4424         maxlengthpoly(G_test2) < maxlengthpoly(G_test))
    44334425      {
    44344426        for(i=0; i<nV; i++)
     
    44394431      else
    44404432      {
    4441         // |G_test| < |G_test1|, |G_test| <= |G_test2|
    44424433        for(i=0; i<nV; i++)
    44434434        {
     
    44514442  {
    44524443    Overflow_Error = FALSE;
    4453     if(G_test2->m[0] != NULL && maxlengthpoly(G_test2) < maxlengthpoly(G_test))//if(IDELEMS(G_test2) < IDELEMS(G_test))
     4444    if(random == TRUE &&
     4445       G_test2->m[0] != NULL &&
     4446       maxlengthpoly(G_test2) < maxlengthpoly(G_test))
    44544447    {
    44554448      for(i=1; i<nV; i++)
     
    44664459    }
    44674460  }
    4468   PrintS("\n MWalkRandomNextWeight: Ende ok!\n");
     4461  //PrintS("\n MWalkRandomNextWeight: Ende ok!\n");
    44694462  idDelete(&G_test);
    4470   idDelete(&G_test2);
     4463  if(random == TRUE)
     4464  {
     4465    idDelete(&G_test2);
     4466  }
    44714467  if(test_w_in_ConeCC(G, result) == 1)
    44724468  {
    4473     delete next_weight2;
     4469    if(random == TRUE)
     4470    {
     4471      delete next_weight2;
     4472    }
    44744473    delete next_weight;
    44754474    delete next_weight1;
     
    44794478  {
    44804479    delete result;
    4481     delete next_weight2;
     4480    if(random == TRUE)
     4481    {
     4482      delete next_weight2;
     4483    }
    44824484    delete next_weight1;
    44834485    return next_weight;
     
    60296031    to=clock();
    60306032    // compute a next weight vector
    6031     next_weight = MkInterRedNextWeight(curr_weight,target_weight, G);
     6033    next_weight = MwalkNextWeightCC(curr_weight,target_weight,G);//MkInterRedNextWeight(curr_weight,target_weight, G);
    60326034    tnw=tnw+clock()-to;
    60336035//#ifdef PRINT_VECTORS
     
    70957097      delete next_vect;
    70967098      next_vect = MWalkRandomNextWeight(G,omega,omega2,weight_rad,nlev);
    7097       if(isNegNolVector(next_vect)==1)
     7099      if(isNegNolVector(next_vect)==1 || MivSame(omega,next_vect) == 1)
    70987100      {
    70997101        delete next_vect;
     
    71807182          delete next_vect;
    71817183          next_vect = MWalkRandomNextWeight(G,omega,omega2,weight_rad,nlev);
    7182           if(isNegNolVector(next_vect)==1)
     7184          if(isNegNolVector(next_vect)==1 || MivSame(omega,next_vect) == 1)
    71837185          {
    71847186            delete next_vect;
     
    72397241        Print("\n//** rec_r_fractal_call: Leaving the %d-th recursion with %d steps.\n",
    72407242              nlev, nwalks);
    7241         //Print(" ** Overflow_Error? (%d)", Overflow_Error);
     7243      /*
     7244        Print(" ** Overflow_Error? (%d)", Overflow_Error);
     7245        idString(G1,"//** rec_r_fractal_call: G1");
     7246      */
    72427247      }
    72437248      nnflow ++;
     
    72797284          Print("\n//** rec_r_fractal_call: Leaving the %d-th recursion with %d steps.\n",
    72807285                nlev, nwalks);
    7281           //Print(" ** Overflow_Error? (%d)", Overflow_Error);
     7286        /*
     7287          Print(" ** Overflow_Error? (%d)", Overflow_Error);
     7288          idString(Gt,"//** rec_r_fractal_call: Gt");
     7289        */
    72827290        }
    72837291        return (Gt);
     
    73827390          Print("\n//** rec_r_fractal_call: Leaving the %d-th recursion with %d steps.\n",
    73837391                nlev,nwalks);
    7384           //Print(" ** Overflow_Error? (%d)", Overflow_Error);
     7392         /*
     7393          Print(" ** Overflow_Error? (%d)", Overflow_Error);
     7394          idString(G,"//** rec_r_fractal_call: G");
     7395         */
    73857396        }
    73867397        if(Overflow_Error == TRUE)
Note: See TracChangeset for help on using the changeset viewer.