Changeset 4052dc in git


Ignore:
Timestamp:
Feb 6, 2015, 10:25:18 AM (9 years ago)
Author:
Stephan Oberfranz <oberfran@…>
Branches:
(u'spielwiese', '17f1d200f27c5bd38f5dfc6e8a0879242279d1d8')
Children:
99f4c6811eadeb02db7dd8cfde8940b9519df3c1e05649bb049ee8f1b6dfccd3446c63020e099649
Parents:
dbf60932968d7dd0d5f400c4209b39e40b442f58
Message:
---
Location:
Singular
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • Singular/LIB/grwalk.lib

    rdbf609 r4052dc  
    274274   string ord_str =   OSCTW[2];
    275275   intvec curr_weight   =   OSCTW[3]; /* original weight vector */
    276    intvec target_weight =   OSCTW[4]; /* terget weight vector */
     276   intvec target_weight =   OSCTW[4]; /* target weight vector */
    277277   kill OSCTW;
    278278   option(redSB);
     
    299299  //** compute a Groebner basis of I w.r.t. lp.
    300300  ring r = 32003,(z,y,x), lp;
    301   ideal I = y3+xyz+y2z+xz3, 3+xy+x2y+y2z;
     301  ideal I = zy2+yx2+yx+3,
     302            z3x+y3+zyx-yx2-yx-3,
     303            z2yx3-y5+z2yx2+y3x2+y2x3+y3x+y2x2+3z2x+3y2+3yx,
     304            zyx5+y6-y4x2-y3x3+2zyx4-y4x-y3x2+zyx3-3z2yx+3zx3-3y3-3y2x+3zx2,
     305            yx7-y7+y5x2+y4x3+3yx6+y5x+y4x2+3yx5-6zyx3+yx4+3x5+3y4+3y3x-6zyx2+6x4+3x3-9zx;
    302306  gwalk(I,0,1);
    303307}
     
    479483  ideal G = fetch(xR, Go);
    480484
    481 <<<<<<< HEAD
    482485  G = system("Mpwalk",G,n1,n2,curr_weight,target_weight,nP,reduction,printout);
    483486 
    484 =======
    485   G = system("Mpwalk", G, n1, n2, curr_weight, target_weight,nP);
    486 
    487 >>>>>>> f533f6f7667328bccb271b19b2f603aaebe41596
    488487  setring xR;
    489   //kill Go;
     488  //kill Go; //unused
    490489
    491490  keepring basering;
  • Singular/walk.cc

    rdbf609 r4052dc  
    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
     29#define MSTDCC_FRACTAL // apply Buchberger alg to compute a red GB, if
    3030//                          tau doesn't stay in the correct cone
    3131
     
    4242#include <Singular/ipshell.h>
    4343#include <Singular/ipconv.h>
     44#include <coeffs/ffields.h>
    4445#include <coeffs/coeffs.h>
    4546#include <Singular/subexpr.h>
     47#include <polys/templates/p_Procs.h>
    4648
    4749#include <polys/monomials/maps.h>
     
    988990intvec* MivMatrixOrderRefine(intvec* iv, intvec* iw)
    989991{
    990 <<<<<<< HEAD
    991992  assume((iv->length())*(iv->length()) == iw->length());
    992993  int i,j, nR = iv->length();
    993994 
    994 =======
    995   assume(iv->length() == iw->length());
    996   int i, nR = iv->length();
    997 
    998 >>>>>>> f533f6f7667328bccb271b19b2f603aaebe41596
    999995  intvec* ivm = new intvec(nR*nR);
    1000996
     
    24602456  //rChangeCurrRing(r);
    24612457}
    2462 //unused
    2463 #if 0
    2464 static ring VMrDefault1(intvec* va)
    2465 {
    2466 
    2467   if ((currRing->ppNoether)!=NULL)
    2468   {
    2469     pDelete(&(currRing->ppNoether));
    2470   }
    2471   if (((sLastPrinted.rtyp>BEGIN_RING) && (sLastPrinted.rtyp<END_RING)) ||
    2472       ((sLastPrinted.rtyp==LIST_CMD)&&(lRingDependend((lists)sLastPrinted.data))))
    2473   {
    2474     sLastPrinted.CleanUp();
    2475   }
    2476 
    2477   ring r = (ring) omAlloc0Bin(sip_sring_bin);
    2478   int i, nv = currRing->N;
    2479 
    2480   r->cf  = currRing->cf;
    2481   r->N   = currRing->N;
    2482 
    2483   int nb = 4;
    2484 
    2485   //names
    2486   char* Q; // In order to avoid the corrupted memory, do not change.
    2487   r->names = (char **) omAlloc0(nv * sizeof(char_ptr));
    2488   for(i=0; i<nv; i++)
    2489   {
    2490     Q = currRing->names[i];
    2491     r->names[i]  = omStrDup(Q);
    2492   }
    2493 
    2494   /*weights: entries for 3 blocks: NULL Made:???*/
    2495   r->wvhdl = (int **)omAlloc0(nb * sizeof(int_ptr));
    2496   r->wvhdl[0] = (int*) omAlloc(nv*sizeof(int));
    2497   for(i=0; i<nv; i++)
    2498     r->wvhdl[0][i] = (*va)[i];
    2499 
    2500   /* order: a,lp,C,0 */
    2501   r->order = (int *) omAlloc(nb * sizeof(int *));
    2502   r->block0 = (int *)omAlloc0(nb * sizeof(int *));
    2503   r->block1 = (int *)omAlloc0(nb * sizeof(int *));
    2504 
    2505   // ringorder a for the first block: var 1..nv
    2506   r->order[0]  = ringorder_a;
    2507   r->block0[0] = 1;
    2508   r->block1[0] = nv;
    2509 
    2510   // ringorder lp for the second block: var 1..nv
    2511   r->order[1]  = ringorder_lp;
    2512   r->block0[1] = 1;
    2513   r->block1[1] = nv;
    2514 
    2515   // ringorder C for the third block
    2516   // it is very important within "idLift",
    2517   // especially, by ring syz_ring=rCurrRingAssure_SyzComp();
    2518   // therefore, nb  must be (nBlocks(currRing)  + 1)
    2519   r->order[2]  = ringorder_C;
    2520 
    2521   // the last block: everything is 0
    2522   r->order[3]  = 0;
    2523 
    2524   // polynomial ring
    2525   r->OrdSgn    = 1;
    2526 
    2527   // complete ring intializations
    2528 
    2529   rComplete(r);
    2530 
    2531   //rChangeCurrRing(r);
    2532   return r;
    2533 }
    2534 #endif
     2458
    25352459/****************************************************************
    25362460 * define and execute a new ring with ordering (a(va),Wp(vb),C) *
    25372461 * **************************************************************/
    2538 
    25392462static ring VMrRefine(intvec* va, intvec* vb)
    25402463{
     
    26102533
    26112534  // complete ring intializations
    2612 
     2535 
    26132536  rComplete(r);
    26142537
     
    28402763}
    28412764
    2842 
    2843 /* define a ring with parameters und change to it */
    2844 /* DefRingPar and DefRingParlp corrupt still memory */
     2765/***************************************************
     2766* define a ring with parameters und change to it   *
     2767* DefRingPar and DefRingParlp corrupt still memory *
     2768****************************************************/
    28452769static void DefRingPar(intvec* va)
    28462770{
     
    29902914}
    29912915
    2992 //unused
    2993 /**************************************************************
    2994  * check wheather one or more components of a vector are zero *
    2995  **************************************************************/
    2996 //#if 0
     2916/*************************************************************
     2917 * check whether one or more components of a vector are zero *
     2918 *************************************************************/
    29972919static int isNolVector(intvec* hilb)
    29982920{
     
    30072929  return 0;
    30082930}
    3009 //#endif
     2931
     2932/*************************************************************
     2933 * check whether one or more components of a vector are <= 0 *
     2934 *************************************************************/
     2935static int isNegNolVector(intvec* hilb)
     2936{
     2937  int i;
     2938  for(i=hilb->length()-1; i>=0; i--)
     2939  {
     2940    if((* hilb)[i]<=0)
     2941    {
     2942      return 1;
     2943    }
     2944  }
     2945  return 0;
     2946}
     2947
     2948/**************************************************************************
     2949* Gomega is the initial ideal of G w. r. t. the current weight vector     *
     2950* curr_weight. Check whether curr_weight lies on a border of the Groebner *
     2951* cone, i. e. check whether a monomial is divisible by a leading monomial *
     2952***************************************************************************/
     2953static ideal middleOfCone(ideal G, ideal Gomega)
     2954{
     2955  BOOLEAN middle = FALSE;
     2956  int i,j,N = IDELEMS(Gomega);
     2957  poly p,lm,factor1,factor2;
     2958  PrintS("\n//** idCopy\n");
     2959  ideal Go = idCopy(G);
     2960 
     2961  PrintS("\n//** jetzt for-Loop!\n");
     2962  for(i=0; i<N; i++)
     2963  {
     2964    for(j=0; j<N; j++)
     2965    {
     2966      if(i!=j)
     2967      {
     2968        p = pCopy(Gomega->m[i]);
     2969        lm = pCopy(Gomega->m[j]);
     2970        pIter(p);
     2971        while(p!=NULL)
     2972        {
     2973          if(pDivisibleBy(lm,p))
     2974          {
     2975            if(middle == FALSE)
     2976            {
     2977              middle = TRUE;
     2978            }
     2979            factor1 = singclap_pdivide(pHead(p),lm,currRing);
     2980            factor2 = pMult(pCopy(factor1),pCopy(Go->m[j]));
     2981            pDelete(&factor1);
     2982            Go->m[i] = pAdd((Go->m[i]),pNeg(pCopy(factor2)));
     2983            pDelete(&factor2);
     2984          }
     2985          pIter(p);
     2986        }
     2987        pDelete(&lm);
     2988        pDelete(&p);
     2989      }
     2990    }
     2991  }
     2992 
     2993  //PrintS("\n//** jetzt Delete!\n");
     2994  //pDelete(&p);
     2995  //pDelete(&factor);
     2996  //pDelete(&lm);
     2997  if(middle == TRUE)
     2998  {
     2999    PrintS("\n//** middle TRUE!\n");
     3000    return Go;
     3001  }
     3002  PrintS("\n//** middle FALSE!\n");
     3003  idDelete(&Go);
     3004  return NULL;
     3005}
    30103006
    30113007/******************************  Februar 2002  ****************************
     
    33143310  }
    33153311  return 0;
     3312}
     3313
     3314/*****************************************
     3315 * return maximal polynomial length of G *
     3316 *****************************************/
     3317static int maxlengthpoly(ideal G)
     3318{
     3319  int i,k,length=0;
     3320  for(i=IDELEMS(G)-1; i>=0; i--)
     3321  {
     3322    k = pLength(G->m[i]);
     3323    if(k>length)
     3324    {
     3325      length = k;
     3326    }
     3327  }
     3328  return length;
    33163329}
    33173330
     
    43254338 * compute a next weight vector *
    43264339 ********************************/
    4327 static intvec* MWalkRandomNextWeight(ideal G, intvec* curr_weight, intvec* target_weight, int weight_rad, int pert_deg)
    4328 {
    4329   int i, weight_norm;
    4330   //int randCount=0;
    4331   int nV = currRing->N;
     4340static intvec* MWalkRandomNextWeight(ideal G, intvec* curr_weight,
     4341               intvec* target_weight, int weight_rad, int pert_deg)
     4342{
     4343  assume(currRing != NULL && curr_weight != NULL &&
     4344         target_weight != NULL && G->m[0] != NULL);
     4345
     4346  int i,weight_norm,nV = currRing->N;
    43324347  intvec* next_weight2;
    43334348  intvec* next_weight22 = new intvec(nV);
    43344349  intvec* result = new intvec(nV);
    43354350
    4336   //compute a perturbed next weight vector "next_weight1"
    43374351  intvec* next_weight1 =MkInterRedNextWeight(curr_weight,target_weight,G);
    43384352  //compute a random next weight vector "next_weight2"
     
    43424356    while(weight_norm == 0)
    43434357    {
     4358
    43444359      for(i=0; i<nV; i++)
    43454360      {
     
    43494364      weight_norm = 1 + floor(sqrt(weight_norm));
    43504365    }
     4366
    43514367    for(i=0; i<nV; i++)
    43524368    {
     
    43604376      }
    43614377    }
     4378
    43624379    if(test_w_in_ConeCC(G, next_weight22) == 1)
    43634380    {
     
    43704387        }
    43714388        i = 0;
     4389        /* reduce the size of the maximal entry of the vector*/
    43724390        while(test_w_in_ConeCC(G,next_weight22))
    43734391        {
     
    43814399    }
    43824400  }
     4401 
    43834402  // compute "usual" next weight vector
    43844403  intvec* next_weight = MwalkNextWeightCC(curr_weight,target_weight, G);
     
    43904409  {
    43914410    ideal G_test1 = MwalkInitialForm(G, next_weight1);
    4392     if(IDELEMS(G_test1) < IDELEMS(G_test))
    4393     {
    4394       if(IDELEMS(G_test2) < IDELEMS(G_test1))
     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))
    43954414      {
    43964415        // |G_test2| < |G_test1| < |G_test|
     
    44074426          (*result)[i] = (*next_weight1)[i];
    44084427        }
    4409       }
     4428      }   
    44104429    }
    44114430    else
    44124431    {
    4413       if(IDELEMS(G_test2) < IDELEMS(G_test)) // |G_test2| < |G_test| <= |G_test1|
     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|
    44144433      {
    44154434        for(i=0; i<nV; i++)
     
    44324451  {
    44334452    Overflow_Error = FALSE;
    4434     if(IDELEMS(G_test2) < IDELEMS(G_test))
     4453    if(G_test2->m[0] != NULL && maxlengthpoly(G_test2) < maxlengthpoly(G_test))//if(IDELEMS(G_test2) < IDELEMS(G_test))
    44354454    {
    44364455      for(i=1; i<nV; i++)
     
    44474466    }
    44484467  }
     4468  PrintS("\n MWalkRandomNextWeight: Ende ok!\n");
    44494469  idDelete(&G_test);
    44504470  idDelete(&G_test2);
     
    50235043  int nV = baseRing->N;
    50245044
    5025   ideal Gomega, M, F, Gomega1, Gomega2, M1; //, F1;
     5045  ideal Gomega, M, F, FF, Gomega1, Gomega2, M1; //, F1;
    50265046  ring newRing;
    50275047  ring XXRing = baseRing;
     
    50705090  }
    50715091  rChangeCurrRing(newRing);
    5072   ideal G = MstdCC(idrMoveR(Go,baseRing,currRing));
     5092  //ideal G = MstdCC(idrMoveR(Go,baseRing,currRing));
     5093  ideal G = idrMoveR(Go,baseRing,currRing);
    50735094  baseRing = currRing;
    50745095#ifdef TIME_TEST
     
    51025123    }
    51035124//#endif
     5125
     5126
     5127    if(reduction == 0)
     5128    {
     5129      PrintS("\n//** Mwalk: test middle of cone!\n");
     5130      FF = middleOfCone(G,Gomega);
     5131      PrintS("\n//** Mwalk: Test F!\n");
     5132      if( FF != NULL)
     5133      {
     5134        idDelete(&G);
     5135        G = idCopy(FF);
     5136        idDelete(&FF);
     5137        PrintS("\n//** Mwalk: FF nicht NULL! Compue next vector.\n");
     5138        goto NEXT_VECTOR;
     5139      }
     5140    }
     5141
    51045142#ifndef  BUCHBERGER_ALG
    51055143    if(isNolVector(curr_weight) == 0)
    51065144    {
    51075145      hilb_func = hFirstSeries(Gomega,NULL,NULL,curr_weight,currRing);
    5108     }
     5146    }   
    51095147    else
    51105148    {
     
    52045242    to = clock();
    52055243#endif
     5244    NEXT_VECTOR:
     5245    PrintS("\n//** Mwalk: NEXT_VECTOR!\n");
    52065246    intvec* next_weight = MwalkNextWeightCC(curr_weight,target_weight,G);
    52075247#ifdef TIME_TEST
     
    52395279        idString(Gomega1, "//** Mwalk: Gomega");
    52405280      }
     5281      PrintS("\n //** Mwalk: kStd(Gomega)");
    52415282//#endif
    52425283      M = kStd(Gomega1,NULL,testHomog,NULL,NULL,0,0,NULL);
     
    52525293      Gomega2 = idrMoveR(Gomega1, newRing,currRing);
    52535294      idDelete(&Gomega1);
     5295      PrintS("\n //** Mwalk: MLifttwoIdeal");
    52545296      F = MLifttwoIdeal(Gomega2, M1, G);
    52555297//#ifdef CHECK_IDEAL_MWALK
     
    52705312      to = clock();
    52715313#endif
     5314      //PrintS("\n //**Mwalk: Interreduce");
    52725315      //interreduce the Groebner basis <G> w.r.t. currRing
    5273       G = kInterRedCC(G,NULL);
     5316      //G = kInterRedCC(G,NULL);
    52745317#ifdef TIME_TEST
    52755318      tred = tred + clock() - to;
     
    53695412  }
    53705413  rChangeCurrRing(newRing);
    5371   ideal G = MstdCC(idrMoveR(Go,baseRing,currRing));
     5414  //ideal G = MstdCC(idrMoveR(Go,baseRing,currRing));
     5415  ideal G = idrMoveR(Go,baseRing,currRing);
    53725416  baseRing = currRing;
    53735417#ifdef TIME_TEST
     
    54055449    {
    54065450      hilb_func = hFirstSeries(Gomega,NULL,NULL,curr_weight,currRing);
    5407     }
     5451    }   
    54085452    else
    54095453    {
     
    55145558    }
    55155559//#endif
    5516     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)
     5560    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)
    55175561    {
    55185562#ifdef CHECK_IDEAL_MWALK
     
    55655609        idString(G,"//** Mrwalk: G");
    55665610      }
    5567 /*#endif
     5611///#endif
    55685612      if(si_opt_1 == (Sy_bit(OPT_REDSB)))
    5569       {*/
    5570         G = kInterRedCC(G,NULL); //interreduce the Groebner basis <G> w.r.t. currRing
    5571 //      }
     5613      {
     5614        //G = kInterRedCC(G,NULL); //interreduce the Groebner basis <G> w.r.t. currRing
     5615      }
    55725616#ifdef TIME_TEST
    55735617      tred = tred + clock() - to;
     
    58615905    nstep ++;
    58625906    to = clock();
    5863     /* compute an initial form ideal of <G> w.r.t. the weight vector
    5864        "curr_weight" */
     5907    // compute an initial form ideal of <G> w.r.t. the weight vector
     5908    // "curr_weight"
    58655909    Gomega = MwalkInitialForm(G, curr_weight);
    58665910//#ifdef CHECK_IDEAL_MWALK
    5867       if(printout > 1)
    5868       {
    5869         idString(Gomega,"//** Mpwalk: Gomega");
    5870       }
     5911    if(printout > 1)
     5912    {
     5913      idString(Gomega,"//** Mpwalk: Gomega");
     5914    }
    58715915//#endif
    58725916
     
    59165960    tim = clock();
    59175961    to = clock();
    5918     /* compute a reduced Groebner basis of <Gomega> w.r.t. "newRing" */
     5962    // compute a reduced Groebner basis of <Gomega> w.r.t. "newRing"
    59195963#ifdef  BUCHBERGER_ALG
    59205964    M = MstdhomCC(Gomega1);
     
    59405984      tstd=tstd+clock()-to;
    59415985
    5942     /* change the ring to oldRing */
     5986    // change the ring to oldRing
    59435987    rChangeCurrRing(oldRing);
    59445988    M1 =  idrMoveR(M, newRing,currRing);
     
    59666010    idDelete(&G);
    59676011
    5968     /* change the ring to newRing */
     6012    // change the ring to newRing
    59696013    rChangeCurrRing(newRing);
    59706014    F1 = idrMoveR(F, oldRing,currRing);
    5971 
     6015    //G = idrMoveR(F,oldRing,currRing);
    59726016    to=clock();
    5973     /* reduce the Groebner basis <G> w.r.t. new ring */
     6017    PrintS("\n //** Mpwalk: reduce the Groebner basis.\n");
    59746018    G = kInterRedCC(F1, NULL);
    59756019    if(endwalks != 1)
     
    59886032    tnw=tnw+clock()-to;
    59896033//#ifdef PRINT_VECTORS
    5990     if(printout > 2)
     6034    if(printout > 0)
    59916035    {
    59926036      MivString(curr_weight, target_weight, next_weight);
     
    60166060
    60176061    delete next_weight;
    6018   }//while
     6062  }//end of while-loop
    60196063
    60206064  if(tp_deg != 1)
     
    62646308    nstep ++;
    62656309    to = clock();
    6266     /* compute an initial form ideal of <G> w.r.t. the weight vector
    6267        "curr_weight" */
     6310    // compute an initial form ideal of <G> w.r.t. the weight vector
     6311    // "curr_weight"
    62686312    Gomega = MwalkInitialForm(G, curr_weight);
    62696313//#ifdef CHECK_IDEAL_MWALK
    6270     if(printout > 1)
     6314    if(printout > 0)
    62716315    {
    62726316      idString(Gomega,"//** Mprwalk: Gomega");
     
    63086352    newRing = currRing;
    63096353    Gomega1 = idrMoveR(Gomega, oldRing,currRing);
    6310 
     6354    PrintS("\n //** Mprwalk: Changed ring.\n");
    63116355#ifdef ENDWALKS
    63126356    if(endwalks==1)
     
    63256369    tim = clock();
    63266370    to = clock();
    6327     /* compute a reduced Groebner basis of <Gomega> w.r.t. "newRing" */
     6371    // compute a reduced Groebner basis of <Gomega> w.r.t. "newRing"
    63286372#ifdef  BUCHBERGER_ALG
    63296373    M = MstdhomCC(Gomega1);
     
    63336377#endif
    63346378//#ifdef CHECK_IDEAL_MWALK
     6379    Print("\n //** Mprwalk: M");
    63356380    if(printout > 2)
    63366381    {
     
    63646409    else
    63656410      xtlift=clock()-to;
    6366 
     6411    Print("\n //** Mprwalk: F.\n");
    63676412//#ifdef CHECK_IDEAL_MWALK
    63686413    if(printout > 2)
     
    63766421    idDelete(&G);
    63776422
    6378     /* change the ring to newRing */
     6423    // change the ring to newRing
    63796424    rChangeCurrRing(newRing);
    6380     F1 = idrMoveR(F, oldRing,currRing);
    6381 
     6425    //F1 = idrMoveR(F, oldRing,currRing);
     6426    F1 = idrMoveR(F,oldRing,currRing);
    63826427    to=clock();
    6383     /* reduce the Groebner basis <G> w.r.t. new ring */
     6428    Print("\n //** Mprwalk: reducing the Groebner basis.\n");
    63846429    G = kInterRedCC(F1, NULL);
    63856430    if(endwalks != 1)
     
    63946439
    63956440    to=clock();
    6396     // compute a next weight vector
     6441    Print("\n //** Mprwalk: compute a next weight vector.\n");
    63976442    next_weight = MkInterRedNextWeight(curr_weight,target_weight, G);
    63986443    if(polylength > 0)
    63996444    {
    6400       //there is a polynomial in Gomega with at least 3 monomials,
    6401       //low-dimensional facet of the cone
     6445      Print("\n //**Mprwalk: there is a polynomial in Gomega with at least 3 monomials, low-dimensional facet of the cone.\n");
    64026446      delete next_weight;
    64036447      next_weight = MWalkRandomNextWeight(G, curr_weight, target_weight, weight_rad, op_deg);
     
    64056449    tnw=tnw+clock()-to;
    64066450//#ifdef PRINT_VECTORS
    6407     if(printout > 2)
     6451    if(printout > 0)
    64086452    {
    64096453      MivString(curr_weight, target_weight, next_weight);
     
    67636807      Gt = idrMoveR(G, oRing,currRing);
    67646808
    6765       if(test_w_in_ConeCC(Gt, omega2) == 1) {
     6809      if(test_w_in_ConeCC(Gt, omega2) == 1)
     6810      {
    67666811        delete omega2;
    67676812        delete next_vect;
     
    67716816          Print("\n//** rec_fractal_call: Leaving the %d-th recursion with %d steps.\n",
    67726817              nlev, nwalks);
    6773           //Print(" ** Overflow_Error? (%d)", Overflow_Error);
    67746818        }
    67756819        return (Gt);
     
    67776821      else
    67786822      {
    6779         //ivString(omega2, "tau'");
    6780         //Print("\n//  tau' doesn't stay in the correct cone!!");
    6781 
     6823        if(printout > 0)
     6824        {
     6825          Print("\n//** rec_fractal_call:  tau' doesn't stay in the correct cone!!");
     6826        }
    67826827#ifndef  MSTDCC_FRACTAL
    6783         //07.08.03
    6784         //ivString(Xtau, "old Xtau");
    67856828        intvec* Xtautmp;
    67866829        if(ivtarget->length() == nV)
     
    67996842        if(MivSame(Xtau, Xtautmp) == 1)
    68006843        {
    6801           //PrintS("\n// Update vectors are equal to the old vectors!!");
     6844          if(printout > 0)
     6845          {
     6846            Print("\n//** rec_fractal_call: Update vectors are equal to the old vectors!!");
     6847          }
    68026848          delete Xtautmp;
    68036849          goto FRACTAL_MSTDCC;
     
    68066852        Xtau = Xtautmp;
    68076853        Xtautmp = NULL;
    6808         //ivString(Xtau, "new  Xtau");
    68096854
    68106855        for(i=nV-1; i>=0; i--)
    68116856          (*omega2)[i] = (*Xtau)[(nlev-1)*nV+i];
    68126857
    6813         //Print("\n//  ring tau = %s;", rString(currRing));
    68146858        rChangeCurrRing(oRing);
    68156859        G = idrMoveR(Gt, testring,currRing);
     
    68516895        Gt = idrMoveR(G, oRing,currRing);
    68526896
    6853         delete Xtau;
    6854         Xtau = NewVectorlp(Gt);
     6897        // perturb the original target vector w.r.t. the current GB
     6898        if(ivtarget->length() == nV)
     6899        {
     6900          delete Xtau;
     6901          Xtau = NewVectorlp(Gt);
     6902        }
     6903        else
     6904        {
     6905          delete Xtau;
     6906          Xtau = Mfpertvector(Gt,ivtarget);
     6907        }
    68556908
    68566909        rChangeCurrRing(oRing);
     
    68936946    else
    68946947      hilb_func = hFirstSeries(Gomega,NULL,NULL,last_omega,currRing);
    6895 #endif // BUCHBERGER_ALG
     6948#endif
     6949
    68966950    if(ivtarget->length() == nV)
    68976951    {
     
    69106964    // Fractal walk with the alternative recursion
    69116965    // alternative recursion
    6912     // if(nlev == nV || lengthpoly(Gomega1) == 0)
    69136966    if(nlev == Xnlev || lengthpoly(Gomega1) == 0)
    6914       //if(nlev == nV) // blind recursion
    69156967    {
    69166968      to=clock();
     
    69206972      Gresult =kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,omega);
    69216973      delete hilb_func;
    6922 #endif // BUCHBERGER_ALG
     6974#endif
    69236975      xtstd=xtstd+clock()-to;
    69246976    }
     
    69537005
    69547006    rChangeCurrRing(new_ring);
    6955     F1 = idrMoveR(F, oRing,currRing);
    6956 
     7007    //F1 = idrMoveR(F, oRing,currRing);
     7008    G = idrMoveR(F,oRing,currRing);
    69577009    to=clock();
    69587010    /* Interreduce G */
    6959     G = kInterRedCC(F1, NULL);
     7011   // G = kInterRedCC(F1, NULL);
    69607012    xtred=xtred+clock()-to;
    6961     idDelete(&F1);
     7013    //idDelete(&F1);
    69627014  }
    69637015}
     
    70177069  {
    70187070#ifdef FIRST_STEP_FRACTAL
    7019     // perturb the current weight vector only on the top level or
    7020     // after perturbation of the both vectors, nlev = 2 as the top level
     7071    /*
     7072    perturb the current weight vector only on the top level or
     7073    after perturbation of the both vectors, nlev = 2 as the top level
     7074    */
    70217075    if((nlev == 1 && Xcall == 0) || (nlev == 2 && Xngleich == 1))
    70227076      if(islengthpoly2(G) == 1)
     
    70337087    /* determine the next border */
    70347088    next_vect = MkInterRedNextWeight(omega,omega2,G);
    7035     if(polylength > 0)
    7036     {
    7037       //there is a polynomial in Gomega with at least 3 monomials,
    7038       //low-dimensional facet of the cone
     7089    if(polylength > 0 && G->m[0] != NULL)
     7090    {
     7091      /*
     7092      there is a polynomial in Gomega with at least 3 monomials,
     7093      low-dimensional facet of the cone
     7094      */
    70397095      delete next_vect;
    7040       next_vect = MWalkRandomNextWeight(G,omega,omega2,weight_rad,1+nlev);
    7041       if(isNolVector(next_vect))
     7096      next_vect = MWalkRandomNextWeight(G,omega,omega2,weight_rad,nlev);
     7097      if(isNegNolVector(next_vect)==1)
    70427098      {
    70437099        delete next_vect;
     
    70577113        if(printout > 0)
    70587114        {
    7059           Print("\n//** rec_r_fractal_call: Perturb the both vectors with degree %d.",nlev);
     7115          Print("\n//** rec_r_fractal_call: Perturb both vectors with degree %d.",nlev);
    70607116          //idElements(G, "G");
    70617117        }
     
    71097165        to=clock();
    71107166
    7111         /* to avoid the value of Overflow_Error that occur in Mfpertvector*/
     7167        /*
     7168        to avoid the value of Overflow_Error that occur in
     7169        Mfpertvector
     7170        */
    71127171        Overflow_Error = FALSE;
    71137172
    71147173        next_vect = MkInterRedNextWeight(omega,omega2,G);
    7115         if(polylength > 0)
     7174        if(G->m[0] != NULL && polylength > 0)
    71167175        {
    7117           //there is a polynomial in Gomega with at least 3 monomials,
    7118           //low-dimensional facet of the cone
     7176          /*
     7177          there is a polynomial in Gomega with at least 3 monomials,
     7178          low-dimensional facet of the cone
     7179          */
    71197180          delete next_vect;
    7120           next_vect = MWalkRandomNextWeight(G,omega,omega2,weight_rad,1+nlev);
    7121           if(isNolVector(next_vect))
     7181          next_vect = MWalkRandomNextWeight(G,omega,omega2,weight_rad,nlev);
     7182          if(isNegNolVector(next_vect)==1)
    71227183          {
    71237184            delete next_vect;
     
    72287289          Print("\n//** rec_r_fractal_call: target weight doesn't stay in the correct cone.\n");
    72297290        }
     7291
    72307292#ifndef  MSTDCC_FRACTAL
    72317293        //ivString(Xtau, "old Xtau");
     
    72687330        if(printout > 0)
    72697331        {
    7270           Print("\n//** rec_r_fractal_call: apply Buchberge's algorithm in ring = %s.\n",
     7332          Print("\n//** rec_r_fractal_call: apply Buchberger's algorithm in ring = %s.\n",
    72717333                rString(currRing));
    72727334        }
     
    72987360        Gt = idrMoveR(G, oRing,currRing);
    72997361
    7300         delete Xtau;
    7301         Xtau = NewVectorlp(Gt);
     7362        // perturb the original target vector w.r.t. the current GB
     7363        if(ivtarget->length() == nV)
     7364        {
     7365          delete Xtau;
     7366          Xtau = NewVectorlp(Gt);
     7367        }
     7368        else
     7369        {
     7370          delete Xtau;
     7371          Xtau = Mfpertvector(Gt,ivtarget);
     7372        }
    73027373
    73037374        rChangeCurrRing(oRing);
     
    73197390        return(G);
    73207391      }
    7321     }
    7322 
    7323     for(i=nV-1; i>=0; i--) {
     7392    } //end of if(MivComp(next_vect, XivNull) == 1)
     7393
     7394    for(i=nV-1; i>=0; i--)
     7395    {
    73247396      (*altomega)[i] = (*omega)[i];
    73257397      (*omega)[i] = (*next_vect)[i];
     
    73747446      rChangeCurrRing(oRing);
    73757447      Gomega1 = idrMoveR(Gomega1, oRing,currRing);
    7376       Gresult = rec_fractal_call(idCopy(Gomega1),nlev+1,omega,printout);
     7448      Gresult = rec_r_fractal_call(idCopy(Gomega1),nlev+1,omega,weight_rad,printout);
    73777449    }
    73787450    if(printout > 2)
     
    74027474
    74037475    rChangeCurrRing(new_ring);
    7404     F1 = idrMoveR(F, oRing,currRing);
    7405 
     7476    //F1 = idrMoveR(F, oRing,currRing);
     7477    G = idrMoveR(F,oRing,currRing);
    74067478    to=clock();
    74077479    // Interreduce G
    7408     G = kInterRedCC(F1, NULL);
     7480    //G = kInterRedCC(F1, NULL);
    74097481    xtred=xtred+clock()-to;
    7410     idDelete(&F1);
     7482    //idDelete(&F1);
    74117483  }
    74127484}
     
    89168988
    89178989  //Print("\n// \"Mpwalk\" (1,%d) took %d steps and %.2f sec. Overflow_Error (%d)", tp_deg, nwalk, ((double) clock()-tinput)/1000000, nOverflow_Error);
    8918 <<<<<<< HEAD
    8919 =======
    8920 
    8921   return(result);
    8922 }
    8923 
    8924 /*******************************************************
    8925  * THE PERTURBATION WALK ALGORITHM WITH RANDOM ELEMENT *
    8926  *******************************************************/
    8927 ideal Mprwalk(ideal Go, intvec* curr_weight, intvec* target_weight, int weight_rad, int op_deg, int tp_deg, ring baseRing)
    8928 {
    8929   BITSET save1 = si_opt_1; // save current options
    8930   si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis
    8931   Set_Error(FALSE);
    8932   Overflow_Error = FALSE;
    8933 #ifdef TIME_TEST
    8934   clock_t tinput=0, tostd=0, tif=0, tstd=0, tlift=0, tred=0, tnw=0;
    8935   xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0;
    8936   tinput = clock();
    8937   clock_t tim;
    8938 #endif
    8939   int i,nwalk,nV = baseRing->N;
    8940 
    8941   ideal G, Gomega, M, F, Gomega1, Gomega2, M1;
    8942   ring newRing;
    8943   ring XXRing = baseRing;
    8944   intvec* exivlp = Mivlp(nV);
    8945   intvec* orig_target = target_weight;
    8946   intvec* pert_target_vector = target_weight;
    8947   intvec* ivNull = new intvec(nV);
    8948   intvec* tmp_weight = new intvec(nV);
    8949 #ifdef CHECK_IDEAL_MWALK
    8950   poly p;
    8951 #endif
    8952   for(i=0; i<nV; i++)
    8953   {
    8954     (*tmp_weight)[i] = (*curr_weight)[i];
    8955   }
    8956 #ifndef BUCHBERGER_ALG
    8957   intvec* hilb_func;
    8958    // to avoid (1,0,...,0) as the target vector
    8959   intvec* last_omega = new intvec(nV);
    8960   for(i=0 i<nV; i++)
    8961   {
    8962     (*last_omega)[i] = 1;
    8963   }
    8964   (*last_omega)[0] = 10000;
    8965 #endif
    8966   baseRing = currRing;
    8967   newRing = VMrDefault(curr_weight);
    8968   rChangeCurrRing(newRing);
    8969   G = idrMoveR(Go,baseRing,currRing);
    8970 #ifdef TIME_TEST
    8971   to = clock();
    8972 #endif
    8973   G = kStd(G,NULL,testHomog,NULL,NULL,0,0,NULL);
    8974   idSkipZeroes(G);
    8975 #ifdef TIME_TEST
    8976   tostd = tostd + to - clock();
    8977 #endif
    8978 #ifdef CHECK_IDEAL_MWALK
    8979   idString(G,"G");
    8980 #endif
    8981   if(op_deg >1)
    8982   {
    8983     if(MivComp(curr_weight,MivUnit(nV)) == 1) //ring order is "dp"
    8984     {
    8985       curr_weight = MPertVectors(G, MivMatrixOrderdp(nV), op_deg);
    8986     }
    8987     else //ring order is not "dp"
    8988     {
    8989       curr_weight = MPertVectors(G, MivMatrixOrder(curr_weight), op_deg);
    8990     }
    8991   }
    8992   baseRing = currRing;
    8993   if(tp_deg > 1 && tp_deg <= nV)
    8994   {
    8995     pert_target_vector = target_weight;
    8996   }
    8997 #ifdef CHECK_IDEAL_MWALK
    8998   ivString(curr_weight, "new curr_weight");
    8999   ivString(target_weight, "new target_weight");
    9000 #endif
    9001   nwalk = 0;
    9002   while(1)
    9003   {
    9004     nwalk ++;
    9005 #ifdef TIME_TEST
    9006     to = clock();
    9007 #endif
    9008     Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector"
    9009 #ifdef TIME_TEST
    9010     tif = tif + clock()-to; //time for computing initial form ideal
    9011 #endif
    9012 #ifdef CHECK_IDEAL_MWALK
    9013     idString(Gomega,"Gomega");
    9014 #endif
    9015 #ifndef  BUCHBERGER_ALG
    9016     if(isNolVector(curr_weight) == 0)
    9017     {
    9018       hilb_func = hFirstSeries(Gomega,NULL,NULL,curr_weight,currRing);
    9019     }
    9020     else
    9021     {
    9022       hilb_func = hFirstSeries(Gomega,NULL,NULL,last_omega,currRing);
    9023     }
    9024 #endif
    9025     if(nwalk == 1)
    9026     {
    9027       newRing = VMrDefault(curr_weight); // define a new ring with ordering "(a(curr_weight),lp)
    9028     }
    9029     else
    9030     {
    9031       newRing = VMrRefine(curr_weight,target_weight); //define a new ring with ordering "(a(curr_weight),Wp(target_weight))"
    9032     }
    9033     rChangeCurrRing(newRing);
    9034     Gomega1 = idrMoveR(Gomega, baseRing,currRing);
    9035     idDelete(&Gomega);
    9036     // compute a Groebner basis of <Gomega> w.r.t. "newRing"
    9037 #ifdef TIME_TEST
    9038     to = clock();
    9039 #endif
    9040 #ifndef  BUCHBERGER_ALG
    9041     M=kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight);
    9042     delete hilb_func;
    9043 #else
    9044     M = kStd(Gomega1,NULL,testHomog,NULL,NULL,0,0,NULL);
    9045 #endif
    9046     idSkipZeroes(M);
    9047 #ifdef TIME_TEST
    9048     tstd = tstd + clock() - to;
    9049 #endif
    9050 #ifdef CHECK_IDEAL_MWALK
    9051     idString(M, "M");
    9052 #endif
    9053     //change the ring to baseRing
    9054     rChangeCurrRing(baseRing);
    9055     M1 =  idrMoveR(M, newRing,currRing);
    9056     idDelete(&M);
    9057     Gomega2 = idrMoveR(Gomega1, newRing,currRing);
    9058     idDelete(&Gomega1);
    9059     to = clock();
    9060     // compute a representation of the generators of submod (M) with respect to those of mod (Gomega), where Gomega is a reduced Groebner basis w.r.t. the current ring
    9061     F = MLifttwoIdeal(Gomega2, M1, G);
    9062     idSkipZeroes(F);
    9063 #ifdef TIME_TEST
    9064     tlift = tlift + clock() - to;
    9065 #endif
    9066 #ifdef CHECK_IDEAL_MWALK
    9067     idString(F,"F");
    9068 #endif
    9069     rChangeCurrRing(newRing); // change the ring to newRing
    9070     G = idrMoveR(F,baseRing,currRing);
    9071     idDelete(&F);
    9072     baseRing = currRing; // set baseRing equal to newRing
    9073 #ifdef CHECK_IDEAL_MWALK
    9074     idString(G,"G");
    9075 #endif
    9076 #ifdef TIME_TEST
    9077     to = clock();
    9078 #endif
    9079     intvec* next_weight = MWalkRandomNextWeight(G, curr_weight, target_weight, weight_rad, op_deg);
    9080 #ifdef TIME_TEST
    9081     tnw = tnw + clock() - to;
    9082 #endif
    9083 #ifdef PRINT_VECTORS
    9084     MivString(curr_weight, target_weight, next_weight);
    9085 #endif
    9086     if(Overflow_Error == TRUE)
    9087     {
    9088       PrintS("\n//**Mprwalk: OVERFLOW: The computed vector does not stay in cone, the result may be wrong.\n");
    9089       delete next_weight;
    9090       break;
    9091     }
    9092 
    9093     if(test_w_in_ConeCC(G,target_weight) == 1 || MivComp(next_weight, ivNull) == 1)
    9094     {
    9095       delete next_weight;
    9096       break;
    9097     }
    9098     //update tmp_weight and curr_weight
    9099     for(i=nV-1; i>=0; i--)
    9100     {
    9101       (*tmp_weight)[i] = (*curr_weight)[i];
    9102       (*curr_weight)[i] = (*next_weight)[i];
    9103     }
    9104     delete next_weight;
    9105   } //end of while-loop
    9106 >>>>>>> f533f6f7667328bccb271b19b2f603aaebe41596
    91078990  Print("\n// Mprwalk took %d steps. Ring= %s;\n", nwalk, rString(currRing));
    91088991  return(result);
  • Singular/walk.h

    rdbf609 r4052dc  
    5252
    5353/* Okt -- Nov'01 */
    54 // compute a Groebner basis of an ideal G w.r.t. lexicographic order
     54// compute a Groebner basis of an ideal G w.r.t. lexicographic order 
    5555//ideal Mwalk(ideal Go, intvec* orig_M, intvec* target_M);
    5656ideal Mwalk(ideal Go, intvec* orig_M, intvec* target_M, ring baseRing, int reduction, int printout);
Note: See TracChangeset for help on using the changeset viewer.