Changeset 0001f9 in git


Ignore:
Timestamp:
Jan 5, 2006, 7:32:19 PM (18 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
44f7bcdefb6eab48841c3b44943126dc814d480e
Parents:
f764969054eb825a57286a74a605b9a43ee1a84c
Message:
*hannes: sun port, memory leaks


git-svn-id: file:///usr/local/Singular/svn/trunk@8883 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/walk.cc

    rf76496 r0001f9  
    22*  Computer Algebra System SINGULAR      *
    33*****************************************/
    4 /* $Id: walk.cc,v 1.8 2005-05-31 07:42:20 bricken Exp $ */
     4/* $Id: walk.cc,v 1.9 2006-01-05 18:32:19 Singular Exp $ */
    55/*
    66* ABSTRACT: Implementation of the Groebner walk
     
    1313
    1414//#define UPPER_BOUND //for the original "Tran" algorithm
    15 //#define REPRESENTATION_OF_SIGMA //if one perturbs sigma in Tran 
     15//#define REPRESENTATION_OF_SIGMA //if one perturbs sigma in Tran
    1616
    1717//#define TEST_OVERFLOW
     
    108108clock_t xtif, xtstd, xtlift, xtred, xtnw;
    109109clock_t xftostd, xtextra, xftinput, to;
    110  
     110
    111111/*2
    112112*utilities for TSet, LSet
     
    307307  strat->sevT        = initsevT();
    308308  if (pOrdSgn == -1)   strat->honey = TRUE;
    309  
    310  
     309
     310
    311311  //initSCC(F,Q,strat);
    312312  initS(F,Q,strat);
     
    354354}
    355355
    356 static void TimeString(clock_t tinput, clock_t tostd, clock_t tif,clock_t tstd, 
    357                        clock_t tlf,clock_t tred, clock_t tnw, int step)
    358 {
    359   double totm = ((double) (clock() - tinput))/1000000; 
     356static void TimeString(clock_t tinput, clock_t tostd, clock_t tif,clock_t tstd,
     357                       clock_t tlf,clock_t tred, clock_t tnw, int step)
     358{
     359  double totm = ((double) (clock() - tinput))/1000000;
    360360  double ostd,mostd, mif, mstd, mextra, mlf, mred, mnw, mxif,mxstd,mxlf,mxred,mxnw,tot;
    361361
     
    388388  double res = (double) 100 - tot;
    389389  Print("\n// &%d&%.2f&%.2f&%.2f&%.2f&%.2f&%.2f&%.2f&%.2f&%.2f&%.2f&%.2f&%.2f&%.2f&%.2f&%.2f(%.2f)\\ \\",
    390         step, ostd, totm, mostd,mif,mstd,mlf,mred,mnw,mxif,mxstd,mxlf,mxred,mxnw,tot,res,
    391         ((((double) xtextra)/1000000)/totm)*100);
    392 }
    393 
    394 static void TimeStringFractal(clock_t tinput, clock_t tostd, clock_t tif,clock_t tstd, 
    395                        clock_t textra, clock_t tlf,clock_t tred, clock_t tnw)
    396 {
    397  
     390        step, ostd, totm, mostd,mif,mstd,mlf,mred,mnw,mxif,mxstd,mxlf,mxred,mxnw,tot,res,
     391        ((((double) xtextra)/1000000)/totm)*100);
     392}
     393
     394static void TimeStringFractal(clock_t tinput, clock_t tostd, clock_t tif,clock_t tstd,
     395                       clock_t textra, clock_t tlf,clock_t tred, clock_t tnw)
     396{
     397
    398398  double totm = ((double) (clock() - tinput))/1000000;
    399399  double ostd, mostd, mif, mstd, mextra, mlf, mred, mnw, tot, res;
     
    415415  tot = mostd+mif+mstd+mextra+mlf+mred+mnw;
    416416  res = (double) 100.00-tot;
    417   Print("\n// &%.2f &%.2f&%.2f &%.2f &%.2f &%.2f &%.2f &%.2f &%.2f&%.2f&%.2f\\ \\ ", 
    418         ostd,totm,mostd,mif,mstd,mextra,mlf,mred,mnw,tot,res);
     417  Print("\n// &%.2f &%.2f&%.2f &%.2f &%.2f &%.2f &%.2f &%.2f &%.2f&%.2f&%.2f\\ \\ ",
     418        ostd,totm,mostd,mif,mstd,mextra,mlf,mred,mnw,tot,res);
    419419}
    420420
    421421static void idString(ideal L, char* st)
    422422{
    423   int i, nL = IDELEMS(L); 
     423  int i, nL = IDELEMS(L);
    424424
    425425  Print("\n//  ideal %s =  ", st);
    426426  for(i=0; i<nL-1; i++)
    427427    Print(" %s, ", pString(L->m[i]));
    428    
     428
    429429  Print(" %s;", pString(L->m[nL-1]));
    430430}
     
    432432static void headidString(ideal L, char* st)
    433433{
    434   int i, nL = IDELEMS(L); 
     434  int i, nL = IDELEMS(L);
    435435
    436436  Print("\n//  ideal %s =  ", st);
    437437  for(i=0; i<nL-1; i++)
    438438    Print(" %s, ", pString(pHead(L->m[i])));
    439    
     439
    440440  Print(" %s;", pString(pHead(L->m[nL-1])));
    441441}
     
    443443static void idElements(ideal L, char* st)
    444444{
    445   int i, nL = IDELEMS(L); 
    446   int K[nL];
     445  int i, nL = IDELEMS(L);
     446  int *K=(int *)omAlloc(nL*sizeof(int));
    447447
    448448  Print("\n//  #monoms of %s =  ", st);
     
    457457      nsame = 1;
    458458      for(j=i+1; j<nL; j++){
    459         if(K[j]==K[i]){
    460           nsame ++;
    461           K[j]=0;         
    462         }
     459        if(K[j]==K[i]){
     460          nsame ++;
     461          K[j]=0;
     462        }
    463463      }
    464464      if(nsame == 1)
    465         Print("%d, ",K[i]);
     465        Print("%d, ",K[i]);
    466466      else
    467         Print("%d[%d], ", K[i], nsame);
    468     }
    469   }
     467        Print("%d[%d], ", K[i], nsame);
     468    }
     469  }
     470  omFree(K);
    470471}
    471472
     
    495496    Print("%d, ", (*ivb)[i]);
    496497  Print("%d) := (", (*ivb)[nV]);
    497  
     498
    498499  for(i=0; i<nV; i++)
    499500    Print("%d, ", (*ivc)[i]);
     
    558559
    559560  int i, wgrad;
    560  
     561
    561562  mpz_t zmul;
    562563  mpz_init(zmul);
     
    565566  mpz_t zsum;
    566567  mpz_init(zsum);
    567  
     568
    568569  for (i=pVariables; i>0; i--)
    569570  {
     
    585586    }
    586587  }
    587  
     588
    588589  return wgrad;
    589590}
     
    602603    pIter(p);
    603604
    604     if (maxtemp > max) 
     605    if (maxtemp > max)
    605606      max = maxtemp;
    606607  }
     
    619620
    620621  int i, wgrad;
    621  
     622
    622623  mpz_t zmul;
    623624  mpz_init(zmul);
     
    634635  }
    635636  mpz_init_set(result, ztmp);
     637  mpz_clear(ztmp);
     638  mpz_clear(sing_int);
     639  mpz_clear(zvec);
     640  mpz_clear(zmul);
    636641}
    637642
     
    647652  mpz_t max; mpz_init(max);
    648653  mpz_t maxtmp; mpz_init(maxtmp);
    649  
    650   poly hg, in_w_g = NULL;   
     654
     655  poly hg, in_w_g = NULL;
    651656
    652657  while(g != NULL)
     
    656661    MLmWeightedDegree_gmp(maxtmp, hg, curr_weight);
    657662
    658     if(mpz_cmp(maxtmp, max)>0) 
     663    if(mpz_cmp(maxtmp, max)>0)
    659664    {
    660665      mpz_init_set(max, maxtmp);
    661666      pDelete(&in_w_g);
    662667      in_w_g = pHead(hg);
    663     } 
     668    }
    664669    else {
    665670      if(mpz_cmp(maxtmp, max)==0)
     
    713718    mi = MpolyInitialForm(G->m[i], iv);
    714719    gi = G->m[i];
    715    
     720
    716721    if(mi == NULL)
    717722    {
    718723      pDelete(&mi);
    719  
     724
    720725      if(Overflow_Error == FALSE)
    721726        Overflow_Error = nError;
    722      
     727
    723728      return 0;
    724     } 
     729    }
    725730    if(!pLmEqual(mi, gi))
    726731    {
    727732      pDelete(&mi);
    728      
     733
    729734      if(Overflow_Error == FALSE)
    730735        Overflow_Error = nError;
    731      
     736
    732737      return 0;
    733738    }
    734    
     739
    735740    pDelete(&mi);
    736741  }
     
    739744    Overflow_Error = nError;
    740745
    741   return 1; 
     746  return 1;
    742747}
    743748
     
    746751static inline long Mlcm(long &i1, long &i2)
    747752{
    748   long temp = gcd(i1, i2); 
     753  long temp = gcd(i1, i2);
    749754  return ((i1 / temp)* i2);
    750755}
     
    759764  int i, n = a->length();
    760765  long result = 0;
    761  
     766
    762767  for(i=n-1; i>=0; i--)
    763768    result += (*a)[i] * (*b)[i];
     
    770775{
    771776  assume( a->length() ==  b->length());
    772   int i, n = a->length(); 
    773   intvec* result = new intvec(n); 
    774  
     777  int i, n = a->length();
     778  intvec* result = new intvec(n);
     779
    775780  for(i=n-1; i>=0; i--)
    776781    (*result)[i] = (*a)[i] - (*b)[i];
     
    786791  int i, nR = currRing->N;
    787792  intvec* result = new intvec(nR);
    788  
     793
    789794  for(i=nR-1; i>=0; i--)
    790795    (*result)[i] = pGetExp(f,i+1);
     
    795800/* return 1, if two given intvecs are the same, otherwise 0*/
    796801int MivSame(intvec* u , intvec* v)
    797 { 
     802{
    798803  assume(u->length() == v->length());
    799804
    800805  int i, niv = u->length();
    801  
     806
    802807  for (i=0; i<niv; i++)
    803808    if ((*u)[i] != (*v)[i])
    804809      return 0;
    805810
    806   return 1; 
     811  return 1;
    807812}
    808813
    809814int M3ivSame(intvec* temp, intvec* u , intvec* v)
    810 { 
     815{
    811816  assume(temp->length() == u->length() && u->length() == v->length());
    812817
    813818  if((MivSame(temp, u)) == 1)
    814     return 0; 
     819    return 0;
    815820
    816821  if((MivSame(temp, v)) == 1)
    817822    return 1;
    818823
    819   return 2; 
     824  return 2;
    820825}
    821826
     
    828833  ideal G1 = kStd(G, NULL, testHomog, NULL);
    829834  test=save_test;
    830  
     835
    831836  idSkipZeroes(G1);
    832837  return G1;
     
    842847  test=save_test;
    843848
    844   idSkipZeroes(G1); 
     849  idSkipZeroes(G1);
    845850  return G1;
    846851}
     
    852857intvec* MivMatrixOrder(intvec* iv)
    853858{
    854   int i,j, nR = iv->length(); 
     859  int i,j, nR = iv->length();
    855860  intvec* ivm = new intvec(nR*nR);
    856861
     
    867872intvec* Mivdp(int nR)
    868873{
    869   int i; 
     874  int i;
    870875  intvec* ivm = new intvec(nR);
    871876
     
    879884intvec* Mivlp(int nR)
    880885{
    881   int i; 
     886  int i;
    882887  intvec* ivm = new intvec(nR);
    883888  (*ivm)[0] = 1;
    884889
    885   return ivm; 
     890  return ivm;
    886891}
    887892
     
    891896  int nV = currRing->N;
    892897  int nG = IDELEMS(G);
    893   intvec* ivUnit = Mivdp(nV);//19.02 
     898  intvec* ivUnit = Mivdp(nV);//19.02
    894899  int i,j, tmpdeg, maxdeg=0;
    895900  number tmpcoeff , maxcoeff=nNULL;
     
    898903  {
    899904    tmpdeg = MwalkWeightDegree(G->m[i], ivUnit);
    900     if (tmpdeg > maxdeg ) 
     905    if (tmpdeg > maxdeg )
    901906      maxdeg = tmpdeg;
    902907  }
     
    910915      tmpcoeff = pGetCoeff(p);
    911916      if(nGreater(tmpcoeff,maxcoeff))
    912         maxcoeff = nCopy(tmpcoeff);
     917        maxcoeff = nCopy(tmpcoeff);
    913918      pIter(p);
    914919    }
     
    934939* basering.                                                                  *
    935940* This programm computes a perturbated vector with a p_deg perturbation      *
    936 * degree which smaller than the numbers of variables                         * 
     941* degree which smaller than the numbers of variables                         *
    937942******************************************************************************/
    938943/* ivtarget is a matrix order of a degree reverse lex. order */
     
    945950  intvec* v_null =  new intvec(nV);
    946951
    947  
     952
    948953  //Checking that the perturbed degree is valid
    949954  if(pdeg > nV || pdeg <= 0)
    950   { 
     955  {
    951956    WerrorS("//** The perturbed degree is wrong!!");
    952957    return v_null;
    953958  }
    954959  delete v_null;
    955  
     960
    956961  if(pdeg == 1)
    957962    return ivtarget;
    958963
    959   mpz_t pert_vector[nV];
    960  
     964  mpz_t *pert_vector=(mpz_t*)omAlloc(nV*sizeof(mpz_t));
     965
    961966  for(i=0; i<nV; i++)
    962967    mpz_init_set_si(pert_vector[i], (*ivtarget)[i]);
    963  
    964      
     968
     969
    965970  // Calculate max1 = Max(A2)+Max(A3)+...+Max(Apdeg),
    966971  // where the Ai are the i-te rows of the matrix target_ord.
    967972
    968973  int ntemp, maxAi, maxA=0;
    969   for(i=1; i<pdeg; i++) 
     974  for(i=1; i<pdeg; i++)
    970975  {
    971976    maxAi = (*ivtarget)[i*nV];
    972977    if(maxAi<0) maxAi = -maxAi;
    973    
     978
    974979    for(j=i*nV+1; j<(i+1)*nV; j++)
    975980    {
    976981      ntemp = (*ivtarget)[j];
    977982      if(ntemp < 0) ntemp = -ntemp;
    978      
     983
    979984      if(ntemp > maxAi)
    980985        maxAi = ntemp;
    981986    }
    982     maxA += maxAi;   
     987    maxA += maxAi;
    983988  }
    984989
     
    986991
    987992  intvec* ivUnit = Mivdp(nV);
    988  
     993
    989994  mpz_t tot_deg; mpz_init(tot_deg);
    990995  mpz_t maxdeg; mpz_init(maxdeg);
    991996  mpz_t inveps; mpz_init(inveps);
    992  
     997
    993998
    994999  for(i=nG-1; i>=0; i--)
    9951000  {
    9961001    mpz_set_ui(maxdeg, MwalkWeightDegree(G->m[i], ivUnit));
    997     if (mpz_cmp(maxdeg,  tot_deg) > 0 ) 
     1002    if (mpz_cmp(maxdeg,  tot_deg) > 0 )
    9981003      mpz_set(tot_deg, maxdeg);
    9991004  }
    1000  
    1001   delete ivUnit; 
     1005
     1006  delete ivUnit;
    10021007  mpz_mul_ui(inveps, tot_deg, maxA);
    10031008  mpz_add_ui(inveps, inveps, 1);
     
    10051010
    10061011  //xx1.06.02 takes  "small" inveps
    1007 #ifdef INVEPS_SMALL_IN_MPERTVECTOR 
    1008   if(mpz_cmp_ui(inveps, pdeg)>0 && pdeg > 3) 
     1012#ifdef INVEPS_SMALL_IN_MPERTVECTOR
     1013  if(mpz_cmp_ui(inveps, pdeg)>0 && pdeg > 3)
    10091014  {
    10101015    /*
    1011       Print("\n// choose the\"small\" inverse epsilon := %d / %d = ", 
    1012       mpz_get_si(inveps), pdeg); 
     1016      Print("\n// choose the\"small\" inverse epsilon := %d / %d = ",
     1017      mpz_get_si(inveps), pdeg);
    10131018    */
    1014     mpz_fdiv_q_ui(inveps, inveps, pdeg); 
     1019    mpz_fdiv_q_ui(inveps, inveps, pdeg);
    10151020    //mpz_out_str(stdout, 10, inveps);
    10161021  }
    10171022#else
    1018   //PrintS("\n// the \"big\" inverse epsilon: "); 
     1023  //PrintS("\n// the \"big\" inverse epsilon: ");
    10191024  mpz_out_str(stdout, 10, inveps);
    1020 #endif 
     1025#endif
    10211026
    10221027  // pert(A1) = inveps^(pdeg-1)*A1 + inveps^(pdeg-2)*A2+...+A_pdeg,
     
    10311036        mpz_add_ui(pert_vector[j], pert_vector[j],(*ivtarget)[i*nV+j]);
    10321037    }
    1033  
     1038
    10341039  mpz_t ztemp;
    10351040  mpz_init(ztemp);
     
    10541059  {
    10551060    (*result)[i] = mpz_get_si(pert_vector[i]);
    1056  
    1057     if(mpz_cmp(pert_vector[i], sing_int)>=0) 
    1058     {   
     1061
     1062    if(mpz_cmp(pert_vector[i], sing_int)>=0)
     1063    {
    10591064      ntrue++;
    10601065      if(Overflow_Error == FALSE)
     
    10621067        Overflow_Error = TRUE;
    10631068        PrintS("\n// ** OVERFLOW in \"MPertvectors\": ");
    1064         mpz_out_str( stdout, 10, pert_vector[i]);
     1069        mpz_out_str( stdout, 10, pert_vector[i]);
    10651070        PrintS(" is greater than 2147483647 (max. integer representation)");
    10661071        Print("\n//  So vector[%d] := %d is wrong!!", i+1, (*result)[i]);
    1067       } 
    1068     }   
    1069   }   
    1070  
    1071   if(Overflow_Error == TRUE) 
     1072      }
     1073    }
     1074  }
     1075
     1076  if(Overflow_Error == TRUE)
    10721077  {
    10731078    ivString(result, "pert_vector");
    10741079    Print("\n// %d element(s) of it is overflow!!", ntrue);
    10751080  }
    1076  
     1081
     1082  mpz_clear(ztemp);
     1083  mpz_clear(sing_int);
     1084  omFree(pert_vector);
    10771085  return result;
    10781086}
     
    10871095  int i, j, nG = IDELEMS(G);
    10881096  intvec* pert_vector =  new intvec(nV);
    1089  
     1097
    10901098  //Checking that the perturbated degree is valid
    10911099  if(pdeg > nV || pdeg <= 0)
    1092   { 
     1100  {
    10931101    WerrorS("//** The perturbed degree is wrong!!");
    10941102    return pert_vector;
     
    10991107  if(pdeg == 1)
    11001108    return pert_vector;
    1101      
     1109
    11021110  // Calculate max1 = Max(A2)+Max(A3)+...+Max(Apdeg),
    11031111  // where the Ai are the i-te rows of the matrix target_ord.
     
    11051113  for(i=1; i<pdeg; i++)
    11061114  {
    1107     maxAi = (*ivtarget)[i*nV]; 
     1115    maxAi = (*ivtarget)[i*nV];
    11081116    for(j=i*nV+1; j<(i+1)*nV; j++)
    11091117    {
     
    11121120        maxAi = ntemp;
    11131121    }
    1114     maxA += maxAi;   
    1115   }
    1116  
     1122    maxA += maxAi;
     1123  }
     1124
    11171125  // Calculate inveps := 1/eps, where 1/eps > deg(p)*max1 for all p in G.
    11181126  int inveps, tot_deg = 0, maxdeg;
    11191127
    1120   intvec* ivUnit = Mivdp(nV);//19.02 
     1128  intvec* ivUnit = Mivdp(nV);//19.02
    11211129  for(i=nG-1; i>=0; i--)
    11221130  {
    11231131    //maxdeg = pTotaldegree(G->m[i], currRing); //it's wrong for ex1,2,rose
    11241132    maxdeg = MwalkWeightDegree(G->m[i], ivUnit);
    1125     if (maxdeg > tot_deg ) 
     1133    if (maxdeg > tot_deg )
    11261134      tot_deg = maxdeg;
    11271135  }
     
    11291137
    11301138  inveps = (tot_deg * maxA) + 1;
    1131    
     1139
    11321140  //9.10.01
    1133 #ifdef INVEPS_SMALL_IN_FRACTAL 
     1141#ifdef INVEPS_SMALL_IN_FRACTAL
    11341142  /*
    1135     Print("\n// choose the\"small\" inverse epsilon := %d / %d = ", 
    1136     inveps, pdeg); 
     1143    Print("\n// choose the\"small\" inverse epsilon := %d / %d = ",
     1144    inveps, pdeg);
    11371145  */
    1138   if(inveps > pdeg && pdeg > 3) 
     1146  if(inveps > pdeg && pdeg > 3)
    11391147    inveps = inveps / pdeg;
    11401148
    11411149  //Print(" %d", inveps);
    11421150#else
    1143   PrintS("\n// the \"big\" inverse epsilon %d", inveps); 
     1151  PrintS("\n// the \"big\" inverse epsilon %d", inveps);
    11441152#endif
    1145  
     1153
    11461154  // Pert(A1) = inveps^(pdeg-1)*A1 + inveps^(pdeg-2)*A2+...+A_pdeg,
    11471155  for ( i=1; i < pdeg; i++ )
    11481156    for(j=0; j<nV; j++)
    11491157      (*pert_vector)[j] = inveps*((*pert_vector)[j]) + (*ivtarget)[i*nV+j];
    1150    
     1158
    11511159  int temp = (*pert_vector)[0];
    11521160  for(i=1; i<nV; i++)
     
    11711179  int i;
    11721180  intvec* ivM = new intvec(nV*nV);
    1173      
     1181
    11741182  for(i=0; i<nV; i++)
    11751183    (*ivM)[i*nV + i] = 1;
    1176  
     1184
    11771185  return(ivM);
    11781186}
     
    11831191  int i;
    11841192  intvec* ivM = new intvec(nV*nV);
    1185      
     1193
    11861194  for(i=0; i<nV; i++)
    11871195    (*ivM)[i] = 1;
     
    11891197  for(i=1; i<nV; i++)
    11901198    (*ivM)[(i+1)*nV - i] = -1;
    1191    
     1199
    11921200  return(ivM);
    11931201}
     
    11991207  int nV = ivstart->length();
    12001208  intvec* ivM = new intvec(nV*nV);
    1201      
     1209
    12021210  for(i=0; i<nV; i++)
    12031211    (*ivM)[i] = (*ivstart)[i];
     
    12051213  for(i=1; i<nV; i++)
    12061214    (*ivM)[i*nV + i-1] = 1;
    1207  
     1215
    12081216  return(ivM);
    12091217}
     
    12141222  int nV = ivstart->length();
    12151223  intvec* ivM = new intvec(nV*nV);
    1216      
     1224
    12171225  for(i=0; i<nV; i++)
    12181226    (*ivM)[i] = (*ivstart)[i];
     
    12231231  for(i=2; i<nV; i++)
    12241232    (*ivM)[(i+1)*nV - i] = -1;
    1225  
     1233
    12261234  return(ivM);
    12271235}
     
    12311239  int i;
    12321240  intvec* ivM = new intvec(nV*nV);
    1233      
     1241
    12341242  for(i=0; i<nV; i++)
    12351243    (*ivM)[i] = 1;
     
    12371245  for(i=1; i<nV; i++)
    12381246    (*ivM)[(i+1)*nV - i] = -1;
    1239  
     1247
    12401248  return(ivM);
    12411249}
     
    12451253  int i;
    12461254  intvec* ivM = new intvec(nV);
    1247      
     1255
    12481256  for(i=nV-1; i>=0; i--)
    12491257    (*ivM)[i] = 1;
    1250  
     1258
    12511259  return(ivM);
    12521260}
     
    12671275  // where the Ai are the i-te rows of the matrix 'targer_ord'.
    12681276  int ntemp, maxAi, maxA=0;
    1269   for(i=1; i<nV; i++) 
     1277  for(i=1; i<nV; i++)
    12701278  {
    12711279    maxAi = (*ivtarget)[i*nV];
     
    12801288        maxAi = ntemp;
    12811289    }
    1282     maxA = maxA + maxAi;   
     1290    maxA = maxA + maxAi;
    12831291  }
    12841292  intvec* ivUnit = Mivdp(nV);
    1285  
     1293
    12861294  // Calculate inveps = 1/eps, where 1/eps > deg(p)*max1 for all p in G.
    12871295  mpz_t tot_deg; mpz_init(tot_deg);
    12881296  mpz_t maxdeg; mpz_init(maxdeg);
    12891297  mpz_t inveps; mpz_init(inveps);
    1290  
     1298
    12911299
    12921300  for(i=nG-1; i>=0; i--)
    12931301  {
    12941302    mpz_set_ui(maxdeg, MwalkWeightDegree(G->m[i], ivUnit));
    1295     if (mpz_cmp(maxdeg,  tot_deg) > 0 ) 
     1303    if (mpz_cmp(maxdeg,  tot_deg) > 0 )
    12961304      mpz_set(tot_deg, maxdeg);
    12971305  }
    1298  
    1299   delete ivUnit; 
    1300   //inveps = (tot_deg * maxA) + 1; 
     1306
     1307  delete ivUnit;
     1308  //inveps = (tot_deg * maxA) + 1;
    13011309  mpz_mul_ui(inveps, tot_deg, maxA);
    13021310  mpz_add_ui(inveps, inveps, 1);
    13031311
    13041312  //xx1.06.02 takes  "small" inveps
    1305 #ifdef INVEPS_SMALL_IN_FRACTAL 
     1313#ifdef INVEPS_SMALL_IN_FRACTAL
    13061314  if(mpz_cmp_ui(inveps, nV)>0 && nV > 3)
    13071315    mpz_cdiv_q_ui(inveps, inveps, nV);
    13081316
    13091317  //PrintS("\n// choose the \"small\" inverse epsilon!");
    1310 #endif 
     1318#endif
    13111319
    13121320  // PrintLn();  mpz_out_str(stdout, 10, inveps);
    1313  
     1321
    13141322  // Calculate the perturbed target orders:
    1315   mpz_t ivtemp[nV];
    1316   mpz_t pert_vector[niv];
    1317  
     1323  mpz_t *ivtemp=(mpz_t *)omAlloc(nV*sizeof(mpz_t));
     1324  mpz_t *pert_vector=(mpz_t *)omAlloc(niv*sizeof(mpz_t));
     1325
    13181326  for(i=0; i<nV; i++)
    13191327  {
     
    13211329    mpz_init_set_si(pert_vector[i], (*ivtarget)[i]);
    13221330  }
    1323  
     1331
    13241332  mpz_t ztmp; mpz_init(ztmp);
    13251333  BOOLEAN isneg = FALSE;
     
    13301338    {
    13311339      mpz_mul(ztmp, inveps, ivtemp[j]);
    1332      
     1340
    13331341      if((*ivtarget)[i*nV+j]<0)
    1334         mpz_sub_ui(ivtemp[j], ztmp, -(*ivtarget)[i*nV+j]); 
    1335       else 
     1342        mpz_sub_ui(ivtemp[j], ztmp, -(*ivtarget)[i*nV+j]);
     1343      else
    13361344        mpz_add_ui(ivtemp[j], ztmp,(*ivtarget)[i*nV+j]);
    13371345    }
    13381346
    1339     for(j=0; j<nV; j++) 
    1340       mpz_init_set(pert_vector[i*nV+j],ivtemp[j]);   
    1341   }
    1342  
     1347    for(j=0; j<nV; j++)
     1348      mpz_init_set(pert_vector[i*nV+j],ivtemp[j]);
     1349  }
     1350
    13431351  /* 2147483647 is max. integer representation in SINGULAR */
    13441352  mpz_t sing_int;
     
    13471355  intvec* result = new intvec(niv);
    13481356  BOOLEAN nflow = FALSE;
    1349  
    1350   // computes gcd 
    1351   mpz_set(ztmp, pert_vector[0]); 
     1357
     1358  // computes gcd
     1359  mpz_set(ztmp, pert_vector[0]);
    13521360  for(i=0; i<niv; i++)
    13531361  {
     
    13581366
    13591367  for(i=0; i<niv; i++)
    1360   { 
     1368  {
    13611369    mpz_divexact(pert_vector[i], pert_vector[i], ztmp);
    13621370    (* result)[i] = mpz_get_si(pert_vector[i]);
    1363    
     1371
    13641372    if(mpz_cmp(pert_vector[i], sing_int)>0)
    13651373      if(nflow == FALSE)
     
    13791387  if(Overflow_Error == TRUE)
    13801388    ivString(result, "new_vector");
    1381  
     1389
     1390  omFree(pert_vector);
     1391  omFree(ivtemp);
     1392  mpz_clear(ztmp);
     1393
    13821394  return result;
    13831395}
     
    13951407    return NULL;
    13961408
    1397   if(mB < mA)   
     1409  if(mB < mA)
    13981410    mA = mB;
    13991411
     
    14021414  int i, k=0;
    14031415  for(i=0; i<mA; i++)
    1404     { 
     1416    {
    14051417      result->m[k] = pMult(A->m[i], pCopy(B->m[i]));
    14061418      A->m[i]=NULL;
    14071419      if (result->m[k]!=NULL) k++;
    14081420    }
    1409  
     1421
    14101422  idDelete(&A);
    14111423  idSkipZeroes(result);
    1412   return result; 
     1424  return result;
    14131425}
    14141426
     
    14221434 ********************************************************************/
    14231435static ideal MLifttwoIdeal(ideal Gw, ideal M, ideal G)
    1424 {     
     1436{
    14251437  ideal Mtmp = idLift(Gw, M, NULL, FALSE, TRUE, TRUE, NULL);
    14261438
     
    14281440  //So, it is better, if one tests whether Gw is a GB
    14291441  //in ideals.cc:
    1430   //idLift (ideal mod, ideal submod,ideal * rest, BOOLEAN goodShape, 
     1442  //idLift (ideal mod, ideal submod,ideal * rest, BOOLEAN goodShape,
    14311443  //           BOOLEAN isSB,BOOLEAN divide,matrix * unit)
    1432  
     1444
    14331445  /* Let be Mtmp = {m1,...,ms}, where mi=sum hij.in_gj, for all i=1,...,s
    14341446     We compute F = {f1,...,fs}, where fi=sum hij.gj */
     
    14361448  ideal idpol, idLG;
    14371449  ideal F = idInit(nM, 1);
    1438  
     1450
    14391451  for(i=0; i<nM; i++)
    14401452  {
    14411453     idpol = idVec2Ideal(Mtmp->m[i]);
    14421454     idLG = MidMult(idpol, G);
    1443      idpol = NULL; 
     1455     idpol = NULL;
    14441456     F->m[i] = NULL;
    14451457     for(j=IDELEMS(idLG)-1; j>=0; j--)
     
    14611473  int n = nG-1;
    14621474  Print("\n//** Ideal %s besteht aus %d Polynomen mit ", Ch, nG);
    1463  
     1475
    14641476  for(i=0; i<nG; i++)
    14651477  {
     
    14771489}
    14781490
    1479 static void HeadidString(ideal L, char* st) 
    1480 { 
    1481   int i, nL = IDELEMS(L)-1; 
     1491static void HeadidString(ideal L, char* st)
     1492{
     1493  int i, nL = IDELEMS(L)-1;
    14821494
    14831495  Print("//  The head terms of the ideal %s = ", st);
    14841496  for(i=0; i<nL; i++)
    14851497    Print(" %s, ", pString(pHead(L->m[i])));
    1486    
     1498
    14871499  Print(" %s;\n", pString(pHead(L->m[nL])));
    14881500}
     
    15051517  with respect to an ideal G.
    15061518*/
    1507 static intvec* MwalkNextWeightCC(intvec* curr_weight, intvec* target_weight, 
     1519static intvec* MwalkNextWeightCC(intvec* curr_weight, intvec* target_weight,
    15081520                                 ideal G)
    15091521{
     
    15111523  Overflow_Error = FALSE;
    15121524
    1513   assume(currRing != NULL && curr_weight != NULL && 
     1525  assume(currRing != NULL && curr_weight != NULL &&
    15141526         target_weight != NULL && G != NULL);
    15151527
     
    15221534  mpz_init(t_nenner);
    15231535
    1524   mpz_t s_zaehler, s_nenner, temp, MwWd; 
     1536  mpz_t s_zaehler, s_nenner, temp, MwWd;
    15251537  mpz_init(s_zaehler);
    15261538  mpz_init(s_nenner);
     
    15291541
    15301542
    1531   mpz_t deg_w0_p1, deg_d0_p1; 
     1543  mpz_t deg_w0_p1, deg_d0_p1;
    15321544  mpz_init(deg_w0_p1);
    15331545  mpz_init(deg_d0_p1);
     
    15401552
    15411553  mpz_t ggt;
    1542  
     1554
    15431555  int tn0, tn1, tz1, ncmp, gcd_tmp, ntmp;
    15441556  intvec* diff_weight = MivSub(target_weight, curr_weight);
    1545  
     1557
    15461558  poly g, gw;
    15471559  for (j=0; j<nG; j++)
    15481560  {
    1549     g = G->m[j]; 
    1550     if (g != NULL) 
     1561    g = G->m[j];
     1562    if (g != NULL)
    15511563    {
    15521564      ivtemp = MExpPol(g);
     
    15541566      mpz_set_si(deg_d0_p1, MivDotProduct(ivtemp, diff_weight));
    15551567      delete ivtemp;
    1556      
     1568
    15571569      pIter(g);
    15581570      while (g != NULL)
     
    15661578          mpz_set_si(MwWd, MivDotProduct(ivtemp, diff_weight));
    15671579          mpz_sub(s_nenner, MwWd, deg_d0_p1);
    1568          
     1580
    15691581          // check for 0 < s <= 1
    1570           if( (mpz_cmp(s_zaehler,t_null) > 0 && 
     1582          if( (mpz_cmp(s_zaehler,t_null) > 0 &&
    15711583               mpz_cmp(s_nenner, s_zaehler)>=0) ||
    1572               (mpz_cmp(s_zaehler, t_null) < 0 && 
     1584              (mpz_cmp(s_zaehler, t_null) < 0 &&
    15731585               mpz_cmp(s_nenner, s_zaehler)<=0))
    15741586          {
     
    15791591              mpz_neg(s_nenner, s_nenner);
    15801592            }
    1581        
     1593
    15821594            //compute a simply fraction of s
    15831595            cancel(s_zaehler, s_nenner);
    1584            
     1596
    15851597            if(mpz_cmp(t_nenner, t_null) != 0)
    1586             { 
     1598            {
    15871599              mpz_mul(sztn, s_zaehler, t_nenner);
    15881600              mpz_mul(sntz, s_nenner, t_zaehler);
    1589                    
     1601
    15901602              if(mpz_cmp(sztn,sntz) < 0)
    1591               { 
     1603              {
    15921604                mpz_add(t_nenner, t_null, s_nenner);
    15931605                mpz_add(t_zaehler,t_null, s_zaehler);
    1594               }       
     1606              }
    15951607            }
    15961608            else
     
    16071619  }
    16081620
    1609   mpz_t vec[nRing];
    1610 
    1611   /* there is no 0<t<1 and define the next weight vector that is equal to 
     1621  mpz_t *vec=(mpz_t*)omAlloc(nRing*sizeof(mpz_t));
     1622
     1623  /* there is no 0<t<1 and define the next weight vector that is equal to
    16121624     the current weight vector */
    16131625  if(mpz_cmp(t_nenner, t_null) == 0)
    1614   {   
    1615     delete diff_weight; 
     1626  {
     1627    delete diff_weight;
    16161628    diff_weight = ivCopy(curr_weight);//take memory
    16171629    goto FINISH;
    16181630  }
    16191631
    1620   /* define the target vector as the next weight vector, if t = 1 */ 
     1632  /* define the target vector as the next weight vector, if t = 1 */
    16211633  if(mpz_cmp_si(t_nenner, 1)==0 && mpz_cmp_si(t_zaehler,1)==0)
    16221634  {
    1623     delete diff_weight; 
     1635    delete diff_weight;
    16241636    diff_weight = ivCopy(target_weight); //this takes memory
    16251637    goto FINISH;
     
    16291641  //14.08.03 simplify the both vectors  curr_weight and diff_weight (C-int)
    16301642  gcd_tmp = (*curr_weight)[0];
    1631  
     1643
    16321644  for (j=1; j<nRing; j++)
    16331645  {
     
    16361648      break;
    16371649  }
    1638  
     1650
    16391651  if(gcd_tmp != 1)
    16401652    for (j=0; j<nRing; j++)
     
    16581670  PrintS("\n// t_zaehler: ");  mpz_out_str( stdout, 10, t_zaehler);
    16591671  PrintS(", t_nenner: ");  mpz_out_str( stdout, 10, t_nenner);
    1660 #endif   
     1672#endif
    16611673
    16621674  mpz_t ddf; mpz_init(ddf);
    16631675  mpz_t dcw; mpz_init(dcw);
    16641676  BOOLEAN isdwpos;
    1665  
     1677
    16661678  // construct a new weight vector
    16671679  for (j=0; j<nRing; j++)
    1668   { 
     1680  {
    16691681    mpz_set_si(dcw, (*curr_weight)[j]);
    16701682    mpz_mul(s_nenner, t_nenner, dcw);
    16711683
    16721684    if( (*diff_weight)[j]>0)
    1673       mpz_mul_ui(s_zaehler, t_zaehler, (*diff_weight)[j]); 
     1685      mpz_mul_ui(s_zaehler, t_zaehler, (*diff_weight)[j]);
    16741686    else
    16751687    {
    1676       mpz_mul_ui(s_zaehler, t_zaehler, -(*diff_weight)[j]); 
    1677       mpz_neg(s_zaehler, s_zaehler);   
    1678     }
    1679    
    1680     mpz_add(sntz, s_nenner, s_zaehler); 
     1688      mpz_mul_ui(s_zaehler, t_zaehler, -(*diff_weight)[j]);
     1689      mpz_neg(s_zaehler, s_zaehler);
     1690    }
     1691
     1692    mpz_add(sntz, s_nenner, s_zaehler);
    16811693
    16821694    mpz_init_set(vec[j], sntz);
     
    16851697    Print("\n//   j = %d ==> ", j);
    16861698    PrintS("(");
    1687     mpz_out_str( stdout, 10, t_nenner); 
    1688     Print(" * %d)", (*curr_weight)[j]); 
    1689     Print(" + ("); mpz_out_str( stdout, 10, t_zaehler); 
     1699    mpz_out_str( stdout, 10, t_nenner);
     1700    Print(" * %d)", (*curr_weight)[j]);
     1701    Print(" + ("); mpz_out_str( stdout, 10, t_zaehler);
    16901702    Print(" * %d) =  ",  (*diff_weight)[j]);
    16911703    mpz_out_str( stdout, 10, s_nenner);
    16921704    PrintS(" + ");
    16931705    mpz_out_str( stdout, 10, s_zaehler);
    1694     PrintS(" = "); mpz_out_str( stdout, 10, sntz); 
     1706    PrintS(" = "); mpz_out_str( stdout, 10, sntz);
    16951707    Print(" ==> vector[%d]: ", j); mpz_out_str(stdout, 10, vec[j]);
    1696 #endif   
    1697  
    1698     if(j==0) 
     1708#endif
     1709
     1710    if(j==0)
    16991711      mpz_init_set(ggt, sntz);
    1700     else   
     1712    else
    17011713      if(mpz_cmp_si(ggt,1) != 0)
    1702         mpz_gcd(ggt, ggt, sntz); 
    1703    
     1714        mpz_gcd(ggt, ggt, sntz);
     1715
    17041716  }
    17051717
    17061718#ifdef  NEXT_VECTORS_CC
    17071719  PrintS("\n// gcd of elements of the vector: ");
    1708   mpz_out_str( stdout, 10, ggt);         
    1709 #endif   
    1710  
     1720  mpz_out_str( stdout, 10, ggt);
     1721#endif
     1722
    17111723  mpz_t omega;
    17121724  mpz_t sing_int;
    17131725  mpz_init_set_ui(sing_int,  2147483647);
    1714  
    1715   /* construct a new weight vector and check whether vec[j] is overflow!! 
     1726
     1727  /* construct a new weight vector and check whether vec[j] is overflow!!
    17161728     i.e. vec[j] > 2^31.
    17171729     If vec[j] doesn't overflow, define a weight vector
    1718      otherwise, report that overflow appears.   
    1719      In the second case test whether the defined new vector correct is 
     1730     otherwise, report that overflow appears.
     1731     In the second case test whether the defined new vector correct is
    17201732     plays an important rolle */
    17211733
     
    17281740      mpz_divexact(vec[j], vec[j], ggt);
    17291741      (*diff_weight)[j] = mpz_get_si(vec[j]);
    1730     } 
    1731 
    1732     if(mpz_cmp(vec[j], sing_int)>=0) 
     1742    }
     1743
     1744    if(mpz_cmp(vec[j], sing_int)>=0)
    17331745      if(Overflow_Error == FALSE)
    17341746      {
    1735         Overflow_Error = TRUE;
    1736        
    1737         PrintS("\n// ** OVERFLOW in \"NextVector\": ");
    1738         mpz_out_str( stdout, 10, vec[j]);
    1739         PrintS(" is greater than 2147483647 (max. integer representation)");
    1740         Print("\n//  So vector[%d] := %d is wrong!!\n",j+1, (*diff_weight)[j]);
    1741       } 
    1742   } 
    1743  
     1747        Overflow_Error = TRUE;
     1748
     1749        PrintS("\n// ** OVERFLOW in \"NextVector\": ");
     1750        mpz_out_str( stdout, 10, vec[j]);
     1751        PrintS(" is greater than 2147483647 (max. integer representation)");
     1752        Print("\n//  So vector[%d] := %d is wrong!!\n",j+1, (*diff_weight)[j]);
     1753      }
     1754  }
     1755
    17441756 FINISH:
    17451757
     
    17521764   mpz_clear(deg_w0_p1);
    17531765   mpz_clear(deg_d0_p1);
     1766   omFree(vec);
    17541767
    17551768  if(Overflow_Error == FALSE)
     
    17591772}
    17601773
    1761 /* 
    1762    compute an intermediate weight vector from iva to ivb w.r.t. 
     1774/*
     1775   compute an intermediate weight vector from iva to ivb w.r.t.
    17631776   the reduced Groebner basis G.
    1764    Return NULL, if it is equal to iva or iva = avb. 
     1777   Return NULL, if it is equal to iva or iva = avb.
    17651778*/
    17661779intvec* MkInterRedNextWeight(intvec* iva, intvec* ivb, ideal G)
     
    17821795    return tmp;
    17831796  }
    1784  
     1797
    17851798  delete tmp;
    1786   return result; 
     1799  return result;
    17871800}
    17881801
     
    17941807  //3.11.01
    17951808
    1796   if (ppNoether!=NULL) 
    1797     pDelete(&ppNoether); 
    1798      
    1799   if (((sLastPrinted.rtyp>BEGIN_RING) && (sLastPrinted.rtyp<END_RING)) || 
    1800       ((sLastPrinted.rtyp==LIST_CMD)&&(lRingDependend((lists)sLastPrinted.data)))) 
    1801 
    1802   {
    1803     sLastPrinted.CleanUp(); 
    1804     memset(&sLastPrinted,0,sizeof(sleftv)); 
    1805   } 
     1809  if (ppNoether!=NULL)
     1810    pDelete(&ppNoether);
     1811
     1812  if (((sLastPrinted.rtyp>BEGIN_RING) && (sLastPrinted.rtyp<END_RING)) ||
     1813      ((sLastPrinted.rtyp==LIST_CMD)&&(lRingDependend((lists)sLastPrinted.data))))
     1814
     1815  {
     1816    sLastPrinted.CleanUp();
     1817    memset(&sLastPrinted,0,sizeof(sleftv));
     1818  }
    18061819
    18071820  ring r = IDRING(tmp);
     
    18341847
    18351848  /* ringorder a for the first block: var 1..nv */
    1836   r->order[0]  = ringorder_a; 
     1849  r->order[0]  = ringorder_a;
    18371850  r->block0[0] = 1;
    18381851  r->block1[0] = nv;
    1839  
     1852
    18401853  /* ringorder lp for the second block: var 1..nv */
    18411854  r->order[1]  = ringorder_lp;
    18421855  r->block0[1] = 1;
    18431856  r->block1[1] = nv;
    1844  
    1845   /* ringorder C for the third block */ 
    1846   // it is very important within "idLift", 
     1857
     1858  /* ringorder C for the third block */
     1859  // it is very important within "idLift",
    18471860  // especially, by ring syz_ring=rCurrRingAssure_SyzComp();
    18481861  // therefore, nb  must be (nBlocks(currRing)  + 1)
    1849   r->order[2]  = ringorder_C; 
     1862  r->order[2]  = ringorder_C;
    18501863
    18511864  /* the last block: everything is 0 */
     
    18571870  /* complete ring intializations */
    18581871  rComplete(r);
    1859  
     1872
    18601873  rChangeCurrRing(r);
    18611874  currRingHdl = tmp;
     
    18671880{
    18681881  idhdl tmp = enterid(IDID(currRingHdl),IDLEV(currRingHdl)+1,RING_CMD,&IDROOT,TRUE);
    1869  
    1870 
    1871   if (ppNoether!=NULL) 
    1872     pDelete(&ppNoether); 
    1873      
    1874   if (((sLastPrinted.rtyp>BEGIN_RING) && (sLastPrinted.rtyp<END_RING)) || 
    1875       ((sLastPrinted.rtyp==LIST_CMD)&&(lRingDependend((lists)sLastPrinted.data)))) 
    1876 
    1877   {
    1878     sLastPrinted.CleanUp(); 
    1879     memset(&sLastPrinted,0,sizeof(sleftv)); 
    1880   } 
     1882
     1883
     1884  if (ppNoether!=NULL)
     1885    pDelete(&ppNoether);
     1886
     1887  if (((sLastPrinted.rtyp>BEGIN_RING) && (sLastPrinted.rtyp<END_RING)) ||
     1888      ((sLastPrinted.rtyp==LIST_CMD)&&(lRingDependend((lists)sLastPrinted.data))))
     1889
     1890  {
     1891    sLastPrinted.CleanUp();
     1892    memset(&sLastPrinted,0,sizeof(sleftv));
     1893  }
    18811894
    18821895  ring r = IDRING(tmp);
     
    18971910
    18981911  /*weights: entries for 3 blocks: NULL Made:???*/
    1899  
     1912
    19001913  r->wvhdl = (int **)omAlloc0(nb * sizeof(int_ptr));
    19011914
     
    19091922  r->block0[0] = 1;
    19101923  r->block1[0] = nv;
    1911  
    1912   /* ringorder C for the second block */ 
    1913   r->order[1]  = ringorder_C; 
     1924
     1925  /* ringorder C for the second block */
     1926  r->order[1]  = ringorder_C;
    19141927
    19151928  /* the last block: everything is 0 */
     
    19211934  /* complete ring intializations */
    19221935  rComplete(r);
    1923  
     1936
    19241937  //rSetHdl(tmp);
    19251938
     
    19351948  int i, nv = currRing->N;
    19361949  int nb = rBlocks(currRing) + 1;
    1937    
     1950
    19381951  ring res=(ring)omAllocBin(ip_sring_bin);
    1939  
     1952
    19401953  memcpy4(res,currRing,sizeof(ip_sring));
    1941  
     1954
    19421955  res->VarOffset = NULL;
    19431956  res->ref=0;
     
    19501963    int l=rPar(currRing);
    19511964    res->parameter=(char **)omAlloc(l*sizeof(char_ptr));
    1952    
     1965
    19531966    for(i=l-1;i>=0;i--)
    19541967      res->parameter[i]=omStrDup(currRing->parameter[i]);
    19551968  }
    19561969
    1957   intvec* iva = va; 
     1970  intvec* iva = va;
    19581971
    19591972  /*weights: entries for 3 blocks: NULL Made:???*/
     
    19671980  res->block0 = (int *)omAlloc0(nb * sizeof(int *));
    19681981  res->block1 = (int *)omAlloc0(nb * sizeof(int *));
    1969  
     1982
    19701983  /* ringorder a for the first block: var 1..nv */
    1971   res->order[0]  = ringorder_a; 
     1984  res->order[0]  = ringorder_a;
    19721985  res->block0[0] = 1;
    19731986  res->block1[0] = nv;
    1974  
     1987
    19751988  /* ringorder lp for the second block: var 1..nv */
    19761989  res->order[1]  = ringorder_lp;
    19771990  res->block0[1] = 1;
    19781991  res->block1[1] = nv;
    1979  
    1980   /* ringorder C for the third block */ 
    1981   // it is very important within "idLift", 
     1992
     1993  /* ringorder C for the third block */
     1994  // it is very important within "idLift",
    19821995  // especially, by ring syz_ring=rCurrRingAssure_SyzComp();
    19831996  // therefore, nb  must be (nBlocks(currRing)  + 1)
    1984   res->order[2]  = ringorder_C; 
     1997  res->order[2]  = ringorder_C;
    19851998
    19861999  /* the last block: everything is 0 */
     
    19902003  res->OrdSgn    = 1;
    19912004
    1992  
     2005
    19932006  res->names   = (char **)omAlloc0(nv * sizeof(char_ptr));
    19942007  for (i=nv-1; i>=0; i--)
     
    19972010  /* complete ring intializations */
    19982011   rComplete(res);
    1999  
    2000    
     2012
     2013
    20012014  // clean up history
    20022015  if (sLastPrinted.RingDependend())
     
    20052018    memset(&sLastPrinted,0,sizeof(sleftv));
    20062019  }
    2007  
     2020
    20082021
    20092022  /* execute the created ring */
     
    20172030
    20182031  ring r=(ring)omAllocBin(ip_sring_bin);
    2019  
     2032
    20202033  memcpy4(r,currRing,sizeof(ip_sring));
    2021  
     2034
    20222035  r->VarOffset = NULL;
    20232036  r->ref=0;
     
    20302043    int l=rPar(currRing);
    20312044    r->parameter=(char **)omAlloc(l*sizeof(char_ptr));
    2032    
     2045
    20332046    for(i=l-1;i>=0;i--)
    20342047      r->parameter[i]=omStrDup(currRing->parameter[i]);
     
    20502063
    20512064  /*weights: entries for 3 blocks: NULL Made:???*/
    2052  
     2065
    20532066  r->wvhdl = (int **)omAlloc0(nb * sizeof(int_ptr));
    20542067
     
    20622075  r->block0[0] = 1;
    20632076  r->block1[0] = nv;
    2064  
    2065   /* ringorder C for the second block */ 
    2066   r->order[1]  = ringorder_C; 
     2077
     2078  /* ringorder C for the second block */
     2079  r->order[1]  = ringorder_C;
    20672080
    20682081  /* the last block: everything is 0 */
     
    20782091    int l=rPar(currRing);
    20792092    r->parameter=(char **)omAlloc(l*sizeof(char_ptr));
    2080    
     2093
    20812094    for(i=l-1;i>=0;i--)
    20822095      r->parameter[i]=omStrDup(currRing->parameter[i]);
     
    20852098  /* complete ring intializations */
    20862099  rComplete(r);
    2087  
     2100
    20882101  // clean up history
    20892102  if (sLastPrinted.RingDependend())
     
    21042117    if((* hilb)[i]==0)
    21052118      return 1;
    2106  
     2119
    21072120  return 0;
    21082121}
     
    21192132 **************************************************************************/
    21202133
    2121 static ideal LastGB(ideal G, intvec* curr_weight,int tp_deg) 
     2134static ideal LastGB(ideal G, intvec* curr_weight,int tp_deg)
    21222135{
    21232136  BOOLEAN nError = Overflow_Error;
     
    21322145  intvec* target_weight;
    21332146  intvec* iv_lp = Mivlp(nV); //define (1,0,...,0)
    2134   intvec* pert_target_vector; 
     2147  intvec* pert_target_vector;
    21352148  intvec* ivNull = new intvec(nV);
    21362149  intvec* extra_curr_weight = new intvec(nV);
     
    21722185
    21732186  while(1)
    2174   { 
     2187  {
    21752188    nwalk++;
    21762189    nstep++;
     
    21792192    next_weight = MkInterRedNextWeight(curr_weight,target_weight, G);
    21802193    xtnw=xtnw+clock()-to;
    2181 #ifdef PRINT_VECTORS 
     2194#ifdef PRINT_VECTORS
    21822195    MivString(curr_weight, target_weight, next_weight);
    21832196#endif
     
    21892202        nlast = 1;
    21902203      delete next_weight;
    2191      
     2204
    21922205      //idElements(G, "G");
    21932206      //Print("\n// ring r%d_%d = %s;\n", tp_deg, nwalk, rString(currRing));
    2194      
     2207
    21952208      break;
    21962209    }
     
    22192232    xtif=xtif+clock()-to;
    22202233
    2221 #ifdef ENDWALKS   
    2222     if(endwalks == 1){ 
    2223       Print("\n// ring r%d_%d = %s;\n", tp_deg, nwalk, rString(currRing)); 
    2224       idElements(Gomega, "Gw"); 
    2225       headidString(Gomega, "Gw"); 
    2226     }
    2227 #endif   
    2228    
     2234#ifdef ENDWALKS
     2235    if(endwalks == 1){
     2236      Print("\n// ring r%d_%d = %s;\n", tp_deg, nwalk, rString(currRing));
     2237      idElements(Gomega, "Gw");
     2238      headidString(Gomega, "Gw");
     2239    }
     2240#endif
     2241
    22292242#ifndef  BUCHBERGER_ALG
    22302243    if(isNolVector(curr_weight) == 0)
     
    22332246      hilb_func = hFirstSeries(Gomega,NULL,NULL,last_omega,currRing);
    22342247#endif // BUCHBERGER_ALG
    2235    
     2248
    22362249    /* define a new ring that its ordering is "(a(curr_weight),lp) */
    22372250    //..25.03.03 VMrDefault(curr_weight);
     
    22412254      VMrDefault(curr_weight);
    22422255
    2243     newRing = currRing; 
     2256    newRing = currRing;
    22442257    Gomega1 = idrMoveR(Gomega, oldRing);
    22452258
     
    22502263#else
    22512264    M=kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight);
    2252     delete hilb_func;   
     2265    delete hilb_func;
    22532266#endif // BUCHBERGER_ALG
    22542267    xtstd=xtstd+clock()-to;
    2255     /* change the ring to oldRing */ 
     2268    /* change the ring to oldRing */
    22562269    rChangeCurrRing(oldRing);
    22572270    M1 =  idrMoveR(M, newRing);
    2258     Gomega2 =  idrMoveR(Gomega1, newRing); 
    2259    
     2271    Gomega2 =  idrMoveR(Gomega1, newRing);
     2272
    22602273    to=clock();
    22612274    /* compute a reduced Groebner basis of <G> w.r.t. "newRing" */
     
    22632276    xtlift=xtlift+clock()-to;
    22642277
    2265     idDelete(&M1); 
     2278    idDelete(&M1);
    22662279    idDelete(&G);
    22672280
    2268     /* change the ring to newRing */ 
     2281    /* change the ring to newRing */
    22692282    rChangeCurrRing(newRing);
    22702283    F1 = idrMoveR(F, oldRing);
    22712284
    22722285    to=clock();
    2273     /* reduce the Groebner basis <G> w.r.t. new ring */   
     2286    /* reduce the Groebner basis <G> w.r.t. new ring */
    22742287    G = kInterRedCC(F1, NULL);
    22752288    xtred=xtred+clock()-to;
    22762289    idDelete(&F1);
    2277    
     2290
    22782291    if(endwalks == 1){
    22792292      //Print("\n// ring r%d_%d = %s;\n", tp_deg, nwalk, rString(currRing));
     
    22952308
    22962309    F1 = idrMoveR(G, newRing);
    2297    
     2310
    22982311    if(nnwinC == 0 || test_w_in_ConeCC(F1, pert_target_vector) != 1)
    22992312    {
     
    23012314      rChangeCurrRing(newRing);
    23022315      G = idrMoveR(F1, oldRing);
    2303       Print("\n// takes %d steps and calls the recursion of level %d:", 
    2304              nwalk, tp_deg-1);
     2316      Print("\n// takes %d steps and calls the recursion of level %d:",
     2317             nwalk, tp_deg-1);
    23052318
    23062319      F1 = LastGB(G,curr_weight, tp_deg-1);
    23072320    }
    2308    
     2321
    23092322    TargetRing = currRing;
    23102323    rChangeCurrRing(EXXRing);
     
    23142327  {
    23152328    if(nlast == 1)
    2316     {           
     2329    {
    23172330      //OMEGA_OVERFLOW_LASTGB:
    23182331      /*
    2319       if(MivSame(curr_weight, iv_lp) == 1) 
    2320         if (currRing->parameter != NULL) 
    2321           DefRingParlp(); 
    2322         else 
     2332      if(MivSame(curr_weight, iv_lp) == 1)
     2333        if (currRing->parameter != NULL)
     2334          DefRingParlp();
     2335        else
    23232336          VMrDefaultlp();
    2324       else 
    2325         if (currRing->parameter != NULL) 
    2326           DefRingPar(curr_weight); 
    2327         else 
    2328           VMrDefault(curr_weight); 
     2337      else
     2338        if (currRing->parameter != NULL)
     2339          DefRingPar(curr_weight);
     2340        else
     2341          VMrDefault(curr_weight);
    23292342      */
    2330      
    2331         //..25.03.03 VMrDefaultlp();//define and execute the ring "lp"
    2332         if (currRing->parameter != NULL) 
    2333           DefRingParlp(); 
    2334         else 
    2335           VMrDefaultlp(); 
    2336        
    2337      
     2343
     2344        //..25.03.03 VMrDefaultlp();//define and execute the ring "lp"
     2345        if (currRing->parameter != NULL)
     2346          DefRingParlp();
     2347        else
     2348          VMrDefaultlp();
     2349
     2350
    23382351      F1 = idrMoveR(G, newRing);
    23392352      //Print("\n// Apply \"std\" in ring r%d_%d = %s;\n", tp_deg, nwalk, rString(currRing));
     
    23462359    rChangeCurrRing(EXXRing);
    23472360    result = idrMoveR(G, newRing);
    2348   } 
     2361  }
    23492362  delete target_weight;
    23502363  delete last_omega;
     
    23542367    Overflow_Error = nError;
    23552368
    2356   return(result); 
     2369  return(result);
    23572370}
    23582371
     
    23632376  int i;
    23642377  for(i=IDELEMS(G)-1; i>=0; i--)
    2365 #if 0 
     2378#if 0
    23662379    if(pLength(G->m[i])>2)
    23672380      return 1;
     
    23732386      //&& (G->m[i]->next->next->next->next!=NULL) /* len >=4 */
    23742387       ) return 1;
    2375 #endif   
     2388#endif
    23762389  return 0;
    23772390}
     
    23922405
    23932406
    2394 /* Implementation of the improved Groebner walk algorithm which is written 
     2407/* Implementation of the improved Groebner walk algorithm which is written
    23952408   by Quoc-Nam Tran (2000).
    2396    One perturbs the original target weight vector, only if 
    2397    the next intermediate weight vector is equal to the current target weight 
     2409   One perturbs the original target weight vector, only if
     2410   the next intermediate weight vector is equal to the current target weight
    23982411   vector. This must be repeated until the wanted reduced Groebner basis
    23992412   to reach.
    2400    If the numbers of variables is big enough, the representation of the origin 
    2401    weight vector may be very big. Therefore, it is possible the intermediate 
    2402    weight vector doesn't stay in the correct Groebner cone. 
    2403    In this case we have just a reduced Groebner basis of the given ideal 
    2404    with respect to another monomial order. Then we have to compute 
     2413   If the numbers of variables is big enough, the representation of the origin
     2414   weight vector may be very big. Therefore, it is possible the intermediate
     2415   weight vector doesn't stay in the correct Groebner cone.
     2416   In this case we have just a reduced Groebner basis of the given ideal
     2417   with respect to another monomial order. Then we have to compute
    24052418   a wanted reduced Groebner basis of it with respect to the given order.
    24062419   At the following subroutine we use the improved Buchberger algorithm or
     
    24142427{
    24152428  int i, nH =IDELEMS(h);
    2416  
     2429
    24172430  ideal m = idInit(nH,h->rank);
    2418  
     2431
    24192432  for (i=nH-1;i>=0; i--)
    24202433  {
    2421     if (h->m[i]!=NULL) 
     2434    if (h->m[i]!=NULL)
    24222435      m->m[i]=pHead(h->m[i]);
    24232436  }
     
    24322445  if(nG != IDELEMS(H1))
    24332446    return 0;
    2434  
     2447
    24352448  for(i=nG-1; i>=0; i--)
    2436   { 
    2437 #if 0   
     2449  {
     2450#if 0
    24382451    poly t;
    24392452    if((t=pSub(pCopy(H0->m[i]), pCopy(H1->m[i]))) != NULL)
     
    24462459    if(!pEqualPolys(H0->m[i],H1->m[i]))
    24472460      return 0;
    2448 #endif   
     2461#endif
    24492462  }
    24502463
     
    24602473  int degtmp, result = 0;
    24612474  intvec* ivUnit = Mivdp(nV);
    2462    
     2475
    24632476  for(i=nG-1; i>=0; i--)
    24642477  {
     
    24722485}
    24732486
    2474 /* perturb the weight vector iva w.r.t. the ideal G. 
     2487/* perturb the weight vector iva w.r.t. the ideal G.
    24752488   the monomial order of the current ring is the w_1 weight lex. order.
    24762489   define w := d^(n-1)w_1+ d^(n-2)w_2, ...+ dw_(n-1)+ w_n
     
    24902503  // define the sequence which expresses the current monomial ordering
    24912504  // w_1 = iva; w_2 = (1,0,..,0); w_n = (0,...,0,1,0)
    2492   intvec* ivMat = MivMatrixOrder(iva); 
     2505  intvec* ivMat = MivMatrixOrder(iva);
    24932506
    24942507  int  mtmp, m=(*iva)[0];
     
    24972510  {
    24982511    mtmp = (*ivMat)[i];
    2499    
     2512
    25002513    if(mtmp <0) mtmp = -mtmp;
    25012514
     
    25032516      m = mtmp;
    25042517  }
    2505  
     2518
    25062519  /* define the maximal total degree of polynomials of G */
    25072520  mpz_t ndeg;
     
    25202533  //ndeg = (2*maxdeg*maxdeg + (nV+1)*maxdeg)*m;//Kalkbrenner (1999)
    25212534  mpz_pow_ui(ztmp, maxdeg, 2);
    2522   mpz_mul_ui(ztmp, ztmp, 2); 
     2535  mpz_mul_ui(ztmp, ztmp, 2);
    25232536  mpz_mul_ui(maxdeg, maxdeg, nV+1);
    25242537  mpz_add(ndeg, ztmp, maxdeg);
    25252538  mpz_mul_ui(ndeg, ndeg, m);
    2526  
     2539
    25272540  //PrintS("\n// with the new upper degree bound (2d^2+(n+1)d)*m ");
    25282541  //Print("\n//         where d = %d, n = %d and bound = %d", maxdeg, nV, ndeg);
     
    25302543
    25312544  /* 29.08.03*/
    2532 #ifdef INVEPS_SMALL_IN_TRAN 
     2545#ifdef INVEPS_SMALL_IN_TRAN
    25332546 if(mpz_cmp_ui(ndeg, nV)>0 && nV > 3)
    25342547    mpz_cdiv_q_ui(ndeg, ndeg, nV);
     
    25392552  mpz_t deg_tmp;
    25402553  mpz_init_set(deg_tmp, ndeg);
    2541  
    2542   mpz_t ivres[nV];
     2554
     2555  mpz_t *ivres=( mpz_t *) omAlloc(nV*sizeof(mpz_t));
    25432556  mpz_init_set_si(ivres[nV-1],1);
    2544  
     2557
    25452558  for(i=nV-2; i>=0; i--)
    25462559  {
     
    25492562  }
    25502563
    2551   mpz_t ivtmp[nV];
     2564  mpz_t *ivtmp=(mpz_t *)omAlloc(nV*sizeof(mpz_t));
    25522565  for(i=0; i<nV; i++)
    25532566    mpz_init(ivtmp[i]);
    2554  
     2567
    25552568  mpz_t sing_int;
    25562569  mpz_init_set_ui(sing_int,  2147483647);
    25572570
    25582571  intvec* repr_vector = new intvec(nV);
    2559  
     2572
    25602573  /* define ivtmp := ndeg^(n-1).w_1 + ndeg^(n-2).w_2 + ... + w_n */
    25612574  for(i=0; i<nV; i++)
     
    25842597      {
    25852598        Overflow_Error = TRUE;
    2586        
     2599
    25872600        PrintS("\n// ** OVERFLOW in \"Repr.Vector\": ");
    25882601        mpz_out_str( stdout, 10, ivtmp[i]);
     
    25922605    }
    25932606  }
    2594   if(Overflow_Error == TRUE) 
     2607  if(Overflow_Error == TRUE)
    25952608  {
    25962609    ivString(repr_vector, "repvector");
     
    25982611  }
    25992612
    2600   if(Overflow_Error == FALSE) 
     2613  if(Overflow_Error == FALSE)
    26012614    Overflow_Error=nError;
    26022615
     2616  omFree(ivres);
     2617  omFree(ivtmp);
    26032618  return repr_vector;
    26042619}
     
    26302645  //ndeg = (2*maxdeg*maxdeg + (nV+1)*maxdeg);//Kalkbrenner (1999)
    26312646  mpz_pow_ui(ztmp, maxdeg, 2);
    2632   mpz_mul_ui(ztmp, ztmp, 2); 
     2647  mpz_mul_ui(ztmp, ztmp, 2);
    26332648  mpz_mul_ui(maxdeg, maxdeg, nV+1);
    26342649  mpz_add(ndeg, ztmp, maxdeg);
    26352650  /*
    26362651    PrintS("\n// with the new upper degree bound (2d^2+(n+1)d)*m ");
    2637     Print("\n//         where d = %d, n = %d and bound = %d", 
     2652    Print("\n//         where d = %d, n = %d and bound = %d",
    26382653    mpz_get_si(maxdeg), nV, mpz_get_si(ndeg));
    26392654  */
    26402655#endif //UPPER_BOUND
    26412656
    2642 #ifdef INVEPS_SMALL_IN_TRAN 
     2657#ifdef INVEPS_SMALL_IN_TRAN
    26432658 if(mpz_cmp_ui(ndeg, nV)>0 && nV > 3)
    26442659    mpz_cdiv_q_ui(ndeg, ndeg, nV);
     
    26502665  mpz_t deg_tmp;
    26512666  mpz_init_set(deg_tmp, ndeg);
    2652  
    2653   mpz_t ivres[nV];
     2667
     2668  mpz_t *ivres=(mpz_t *)omAlloc(nV*sizeof(mpz_t));
    26542669  mpz_init_set_si(ivres[nV-1], 1);
    2655  
     2670
    26562671  for(i=nV-2; i>=0; i--)
    26572672  {
     
    26802695        Print("\n//  So vector[%d] := %d is wrong!!\n",i+1,(*repr_vector)[i]);
    26812696      }
    2682     }   
    2683   }
    2684   if(Overflow_Error == TRUE) 
     2697    }
     2698  }
     2699  if(Overflow_Error == TRUE)
    26852700  {
    26862701    ivString(repr_vector, "repvector");
    26872702    Print("\n// %d element(s) of it are overflow!!", ntrue);
    26882703  }
    2689   if(Overflow_Error == FALSE) 
     2704  if(Overflow_Error == FALSE)
    26902705    Overflow_Error = nError;
    26912706
     2707  omFree(ivres);
    26922708  return repr_vector;
    26932709}
     
    27052721  intvec* ivUnit = Mivdp(nV);
    27062722  int degtmp, maxdeg = 0;
    2707  
     2723
    27082724  for(i=IDELEMS(G)-1; i>=0; i--)
    27092725  {
     
    27162732  mpz_t ztmp;
    27172733  mpz_init_set_si(ztmp, maxdeg);
    2718   mpz_t ivres[nV];
     2734  mpz_t *ivres=(mpz_t *)omAlloc(nV*sizeof(mpz_t));
    27192735  mpz_init_set_si(ivres[nV-1], 1); // (*ivres)[nV-1] = 1;
    27202736
     
    27252741  }
    27262742
    2727   mpz_t ivtmp[nV];
     2743  mpz_t *ivtmp=(mpz_t*)omAlloc(nV*sizeof(mpz_t));
    27282744  for(i=0; i<nV; i++)
    27292745    mpz_init(ivtmp[i]);
     
    27382754        mpz_neg(ztmp, ztmp);
    27392755      }
    2740       else 
     2756      else
    27412757        mpz_mul_ui(ztmp, ivres[i], (*M)[i*nV+j]);
    27422758
    2743       mpz_add(ivtmp[j], ivtmp[j], ztmp);   
     2759      mpz_add(ivtmp[j], ivtmp[j], ztmp);
    27442760    }
    27452761
     
    27622778        PrintS(" is greater than 2147483647 (max. integer representation)");
    27632779        Print("\n//  So vector[%d] := %d is wrong!!\n",i+1,(*repvector)[i]);
    2764       }   
    2765     }
    2766   }
    2767   if(Overflow_Error == TRUE) 
     2780      }
     2781    }
     2782  }
     2783  if(Overflow_Error == TRUE)
    27682784  {
    27692785    ivString(repvector, "repvector");
     
    27712787  }
    27722788
    2773   if(Overflow_Error == FALSE) 
     2789  if(Overflow_Error == FALSE)
    27742790    Overflow_Error = nError;
    27752791
     2792  mpz_clear(ztmp);
     2793  omFree(ivtmp);
     2794  omFree(ivres);
    27762795  return repvector;
    27772796}
     
    27812800
    27822801
    2783 /* The following subroutine is the implementation of our first improved 
     2802/* The following subroutine is the implementation of our first improved
    27842803   Groebner walk algorithm, i.e. the first altervative algorithm.
    27852804   First we use the Grobner walk algorithm and then we call the changed
    27862805   perturbation walk algorithm with decreased degree, if an intermediate
    2787    weight vector is equal to the current target weight vector. 
    2788    This call will be only repeated until we get the wanted reduced Groebner 
     2806   weight vector is equal to the current target weight vector.
     2807   This call will be only repeated until we get the wanted reduced Groebner
    27892808   basis or n times, where n is the numbers of variables.
    27902809*/
     
    28052824/* 7 Februar 2002 */
    28062825/* npwinc = 0, if curr_weight doesn't stay in the correct Groebner cone */
    2807 static ideal Rec_LastGB(ideal G, intvec* curr_weight, 
    2808                         intvec* orig_target_weight, int tp_deg, int npwinc)
     2826static ideal Rec_LastGB(ideal G, intvec* curr_weight,
     2827                        intvec* orig_target_weight, int tp_deg, int npwinc)
    28092828{
    28102829  BOOLEAN nError = Overflow_Error;
     
    28292848
    28302849  //08 Juli 03
    2831   intvec* hilb_func; 
     2850  intvec* hilb_func;
    28322851  /* to avoid (1,0,...,0) as the target vector */
    28332852  intvec* last_omega = new intvec(nV);
     
    28562875       cone(k-1) is equal to cone(k) */
    28572876    if(test_G_GB_walk(H0_tmp,H1)==1) {
    2858       idDelete(&H0_tmp); 
     2877      idDelete(&H0_tmp);
    28592878      idDelete(&H1);
    28602879      G = ssG;
     
    28622881      newRing = currRing;
    28632882      delete ivNull;
    2864    
     2883
    28652884      if(npwinc != 0)
    28662885        goto LastGB_Finish;
     
    28702889      }
    28712890    }
    2872     idDelete(&H0_tmp);   
     2891    idDelete(&H0_tmp);
    28732892    idDelete(&H1);
    2874    
     2893
    28752894    iv_M_lp = MivMatrixOrderlp(nV);
    28762895    target_weight  = MPertVectors(ssG, iv_M_lp, tp_deg);
     
    28812900
    28822901    if(Overflow_Error == TRUE)  {
    2883       nOverflow_Error = Overflow_Error; 
     2902      nOverflow_Error = Overflow_Error;
    28842903      NEG = 1;
    28852904      newRing = currRing;
     
    28892908
    28902909  while(1)
    2891   { 
     2910  {
    28922911    nwalk ++;
    28932912    nstep++;
    28942913
    2895     if(nwalk==1) 
     2914    if(nwalk==1)
    28962915      goto FIRST_STEP;
    28972916
     
    29092928
    29102929    oldRing = currRing;
    2911    
     2930
    29122931    /* defiNe a new ring that its ordering is "(a(curr_weight),lp) */
    29132932    if (currRing->parameter != NULL)
     
    29162935      VMrDefault(curr_weight);
    29172936
    2918     newRing = currRing; 
     2937    newRing = currRing;
    29192938    Gomega1 = idrMoveR(Gomega, oldRing);
    29202939    to=clock();
     
    29242943#else
    29252944    M=kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight);
    2926     delete hilb_func;   
     2945    delete hilb_func;
    29272946#endif // BUCHBERGER_ALG
    29282947    xtstd=xtstd+clock()-to;
    2929     /* change the ring to oldRing */ 
     2948    /* change the ring to oldRing */
    29302949    rChangeCurrRing(oldRing);
    29312950    M1 =  idrMoveR(M, newRing);
    2932     Gomega2 =  idrMoveR(Gomega1, newRing); 
    2933    
     2951    Gomega2 =  idrMoveR(Gomega1, newRing);
     2952
    29342953     to=clock();
    2935     /* compute a reduced Groebner basis of <G> w.r.t. "newRing" by the 
     2954    /* compute a reduced Groebner basis of <G> w.r.t. "newRing" by the
    29362955       lifting process*/
    29372956    F = MLifttwoIdeal(Gomega2, M1, G);
    29382957    xtlift=xtlift+clock()-to;
    2939     idDelete(&M1); 
    2940     idDelete(&Gomega2); 
     2958    idDelete(&M1);
     2959    idDelete(&Gomega2);
    29412960    idDelete(&G);
    2942    
    2943     /* change the ring to newRing */ 
     2961
     2962    /* change the ring to newRing */
    29442963    rChangeCurrRing(newRing);
    29452964    F1 = idrMoveR(F, oldRing);
    29462965
    29472966    to=clock();
    2948     /* reduce the Groebner basis <G> w.r.t. new ring */   
     2967    /* reduce the Groebner basis <G> w.r.t. new ring */
    29492968    G = kInterRedCC(F1, NULL);
    29502969    xtred=xtred+clock()-to;
    29512970    idDelete(&F1);
    2952    
     2971
    29532972    if(endwalks == 1)
    29542973      break;
     
    29602979    next_weight = MkInterRedNextWeight(curr_weight,target_weight, G);
    29612980    xtnw=xtnw+clock()-to;
    2962 #ifdef PRINT_VECTORS 
     2981#ifdef PRINT_VECTORS
    29632982    MivString(curr_weight, target_weight, next_weight);
    29642983#endif
    2965  
     2984
    29662985    if(Overflow_Error == TRUE) {
    29672986      //PrintS("\n// ** The next vector does NOT stay in Cone!!\n");
     
    29732992      if(tp_deg == nV)
    29742993        nlast = 1;
    2975      
     2994
    29762995      delete next_weight;
    29772996      break;
     
    29833002      break;
    29843003    }
    2985    
     3004
    29863005    if(MivComp(next_weight, target_weight) == 1)  {
    29873006      if(tp_deg == nV)
     
    29893008      else {
    29903009      REC_LAST_GB_ALT2:
    2991         nOverflow_Error = Overflow_Error;
    2992         tproc=tproc+clock()-tinput;
    2993         /*
    2994           Print("\n// takes %d steps and calls \"Rec_LastGB\" (%d):",
    2995           nwalk, tp_deg+1);
    2996         */
     3010        nOverflow_Error = Overflow_Error;
     3011        tproc=tproc+clock()-tinput;
     3012        /*
     3013          Print("\n// takes %d steps and calls \"Rec_LastGB\" (%d):",
     3014          nwalk, tp_deg+1);
     3015        */
    29973016        G = Rec_LastGB(G,curr_weight, orig_target_weight, tp_deg+1,nnwinC);
    29983017        newRing = currRing;
     
    30013020      }
    30023021    }
    3003    
     3022
    30043023    for(i=nV-1; i>=0; i--) {
    30053024      //(*extra_curr_weight)[i] = (*curr_weight)[i];
    30063025      (*curr_weight)[i] = (*next_weight)[i];
    3007     }   
    3008     delete next_weight; 
    3009   }//while 
     3026    }
     3027    delete next_weight;
     3028  }//while
    30103029
    30113030  delete ivNull;
     
    30203039
    30213040    F1 = idrMoveR(G, newRing);
    3022    
     3041
    30233042    if(nnwinC == 0 || test_w_in_ConeCC(F1, target_weight) != 1 ) {
    30243043      nOverflow_Error = Overflow_Error;
    30253044      //Print("\n//  takes %d steps and calls \"Rec_LastGB (%d):", tp_deg+1);
    30263045      tproc=tproc+clock()-tinput;
    3027       F1 = Rec_LastGB(F1,curr_weight, orig_target_weight, tp_deg+1,nnwinC); 
    3028     }   
     3046      F1 = Rec_LastGB(F1,curr_weight, orig_target_weight, tp_deg+1,nnwinC);
     3047    }
    30293048    delete target_weight;
    30303049
     
    30343053  }
    30353054  else  {
    3036     if(nlast == 1) {     
     3055    if(nlast == 1) {
    30373056      JUNI_STD:
    3038      
     3057
    30393058      newRing = currRing;
    30403059      if (currRing->parameter != NULL)
     
    30543073      xtextra=xtextra+clock()-to;
    30553074
    3056      
     3075
    30573076      idDelete(&F1);
    30583077      newRing = currRing;
    30593078    }
    3060    
     3079
    30613080    LastGB_Finish:
    30623081    rChangeCurrRing(EXXRing);
    3063     result = idrMoveR(G, newRing); 
    3064   } 
    3065 
    3066   if(Overflow_Error == FALSE) 
     3082    result = idrMoveR(G, newRing);
     3083  }
     3084
     3085  if(Overflow_Error == FALSE)
    30673086    Overflow_Error=nError;
    30683087  /*
    30693088  Print("\n// \"Rec_LastGB\" (%d) took %d steps and %.2f sec.Overflow_Error (%d)", tp_deg,
    3070         nwalk, ((double) tproc)/1000000, nOverflow_Error);
     3089        nwalk, ((double) tproc)/1000000, nOverflow_Error);
    30713090  */
    3072   return(result); 
    3073 }
    3074 
    3075 /* The following subroutine is the implementation of our second improved 
     3091  return(result);
     3092}
     3093
     3094/* The following subroutine is the implementation of our second improved
    30763095   Groebner walk algorithm, i.e. the second altervative algorithm.
    30773096   First we use the Grobner walk algorithm and then we call the changed
    30783097   perturbation walk algorithm with increased degree, if an intermediate
    3079    weight vector is equal to the current target weight vector. 
    3080    This call will be only repeated until we get the wanted reduced Groebner 
     3098   weight vector is equal to the current target weight vector.
     3099   This call will be only repeated until we get the wanted reduced Groebner
    30813100   basis or n times, where n is the numbers of variables.
    30823101*/
     
    30963115  int i, nV = currRing->N;
    30973116  int nwalk=0, endwalks=0, nhilb=1;
    3098  
     3117
    30993118  ideal Gomega, M, F, Gomega1, Gomega2, M1, F1, G, G1;
    31003119  ring endRing, newRing, oldRing;
     
    31063125
    31073126  ring XXRing = currRing;
    3108        
     3127
    31093128  //Print("\n// ring r_input = %s;", rString(currRing));
    3110   to = clock(); 
    3111   /* compute the reduced Groebner basis of the given ideal w.r.t. 
    3112      a "fast" monomial order, e.g. degree reverse lex. order (dp) */ 
     3129  to = clock();
     3130  /* compute the reduced Groebner basis of the given ideal w.r.t.
     3131     a "fast" monomial order, e.g. degree reverse lex. order (dp) */
    31133132  G = MstdCC(Go);
    31143133  tostd=clock()-to;
    3115  
     3134
    31163135  /*
    3117   Print("\n// Computation of the first std took = %.2f sec", 
     3136  Print("\n// Computation of the first std took = %.2f sec",
    31183137        ((double) tostd)/1000000);
    31193138  */
    31203139  if(currRing->order[0] == ringorder_a)
    31213140    goto NEXT_VECTOR;
    3122  
     3141
    31233142  while(1)
    3124   { 
     3143  {
    31253144    nwalk ++;
    31263145    nstep ++;
    3127     to = clock(); 
     3146    to = clock();
    31283147    /* compute an initial form ideal of <G> w.r.t. "curr_vector" */
    31293148    Gomega = MwalkInitialForm(G, curr_weight);
     
    31373156      goto LAST_GB_ALT2;
    31383157    }
    3139 #endif 
     3158#endif
    31403159    oldRing = currRing;
    3141    
     3160
    31423161    /* define a new ring that its ordering is "(a(curr_weight),lp) */
    31433162    if (currRing->parameter != NULL)
     
    31463165      VMrDefault(curr_weight);
    31473166
    3148     newRing = currRing; 
     3167    newRing = currRing;
    31493168    Gomega1 = idrMoveR(Gomega, oldRing);
    3150     to = clock(); 
     3169    to = clock();
    31513170    /* compute a reduced Groebner basis of <Gomega> w.r.t. "newRing" */
    31523171    M = MstdhomCC(Gomega1);
    31533172    xtstd=xtstd+clock()-to;
    3154     /* change the ring to oldRing */ 
     3173    /* change the ring to oldRing */
    31553174    rChangeCurrRing(oldRing);
    31563175    M1 =  idrMoveR(M, newRing);
    31573176    Gomega2 =  idrMoveR(Gomega1, newRing);
    31583177
    3159     to = clock(); 
    3160     /* compute the reduced Groebner basis of <G> w.r.t. "newRing" 
     3178    to = clock();
     3179    /* compute the reduced Groebner basis of <G> w.r.t. "newRing"
    31613180       by the liftig process */
    31623181    F = MLifttwoIdeal(Gomega2, M1, G);
    31633182    xtlift=xtlift+clock()-to;
    3164     idDelete(&M1); 
    3165     idDelete(&Gomega2); 
    3166     idDelete(&G); 
    3167 
    3168     /* change the ring to newRing */ 
     3183    idDelete(&M1);
     3184    idDelete(&Gomega2);
     3185    idDelete(&G);
     3186
     3187    /* change the ring to newRing */
    31693188    rChangeCurrRing(newRing);
    3170     F1 = idrMoveR(F, oldRing); 
    3171 
    3172     to = clock(); 
    3173     /* reduce the Groebner basis <G> w.r.t. newRing */   
     3189    F1 = idrMoveR(F, oldRing);
     3190
     3191    to = clock();
     3192    /* reduce the Groebner basis <G> w.r.t. newRing */
    31743193    G = kInterRedCC(F1, NULL);
    31753194    xtred=xtred+clock()-to;
    31763195    idDelete(&F1);
    3177        
     3196
    31783197    if(endwalks == 1)
    31793198      break;
    31803199
    31813200  NEXT_VECTOR:
    3182     to = clock(); 
     3201    to = clock();
    31833202    /* compute a next weight vector */
    31843203    next_weight = MkInterRedNextWeight(curr_weight,target_weight, G);
    31853204    xtnw=xtnw+clock()-to;
    3186 #ifdef PRINT_VECTORS 
     3205#ifdef PRINT_VECTORS
    31873206    MivString(curr_weight, target_weight, next_weight);
    31883207#endif
    3189    
     3208
    31903209    if(Overflow_Error == TRUE)
    31913210    {
    31923211      /*
    3193         ivString(next_weight, "omega");
    3194         PrintS("\n// ** The weight vector does NOT stay in Cone!!\n");
     3212        ivString(next_weight, "omega");
     3213        PrintS("\n// ** The weight vector does NOT stay in Cone!!\n");
    31953214      */
    31963215#ifdef TEST_OVERFLOW
     
    31983217#endif
    31993218
    3200    
     3219
    32013220      newRing = currRing;
    32023221      if (currRing->parameter != NULL)
     
    32053224        VMrDefault(target_weight);
    32063225
    3207       F1 = idrMoveR(G, newRing); 
     3226      F1 = idrMoveR(G, newRing);
    32083227      G = MstdCC(F1);
    32093228      idDelete(&F1);
     
    32183237      break;
    32193238    }
    3220    
     3239
    32213240    if(MivComp(next_weight, target_weight) == 1)
    32223241    {
    32233242      if(MivSame(target_weight, exivlp)==1)
    32243243      {
    3225       LAST_GB_ALT2: 
    3226         nOverflow_Error = Overflow_Error;
    3227         tproc = clock()-xftinput;
     3244      LAST_GB_ALT2:
     3245        nOverflow_Error = Overflow_Error;
     3246        tproc = clock()-xftinput;
    32283247        //Print("\n// takes %d steps and calls the recursion of level 2:",  nwalk);
    32293248        /* call the changed perturbation walk algorithm with degree 2 */
     
    32353254      endwalks = 1;
    32363255    }
    3237    
     3256
    32383257    for(i=nV-1; i>=0; i--)
    32393258    {
     
    32513270#ifdef TIME_TEST
    32523271  Print("\n// \"Main procedure\"  took %d steps dnd %.2f sec. Overflow_Error (%d)", nwalk,
    3253         ((double) tproc)/1000000, nOverflow_Error);
     3272        ((double) tproc)/1000000, nOverflow_Error);
    32543273
    32553274  TimeStringFractal(xftinput, tostd, xtif, xtstd, xtextra,xtlift, xtred,xtnw);
     
    32593278  Print("\n// Awalk2 took %d steps!!", nstep);
    32603279#endif
    3261  
     3280
    32623281  return(G);
    32633282}
     
    32673286/* The implementation of the fractal walk algorithmus */
    32683287
    3269 /* The main procedur Mfwalk calls the recursive Subroutine 
     3288/* The main procedur Mfwalk calls the recursive Subroutine
    32703289   rec_fractal_call to compute the wanted Gröbner basis.
    32713290   At the main procedur we compute the reduced Gröbner basis w.r.t. a "fast"
    3272    order, e.g. "dp" and a sequence of weight vectors which are row vectors 
     3291   order, e.g. "dp" and a sequence of weight vectors which are row vectors
    32733292   of a matrix. This matrix defines the given monomial order, e.g. "lp"
    32743293*/
     
    32973316
    32983317/***********************************************************************
    3299   The procedur REC_GB_Mwalk computes a GB for <G> w.r.t. the weight order 
     3318  The procedur REC_GB_Mwalk computes a GB for <G> w.r.t. the weight order
    33003319  otw, where G is a reduced GB w.r.t. the weight order cw.
    33013320  The new procedur Mwalk calls REC_GB.
    33023321************************************************************************/
    3303 static ideal REC_GB_Mwalk(ideal G, intvec* curr_weight, intvec* orig_target_weight, 
    3304                           int tp_deg, int npwinc)
     3322static ideal REC_GB_Mwalk(ideal G, intvec* curr_weight, intvec* orig_target_weight,
     3323                          int tp_deg, int npwinc)
    33053324{
    33063325  BOOLEAN nError = Overflow_Error;
    33073326  Overflow_Error = FALSE;
    3308  
     3327
    33093328  int i,  nV = currRing->N, ntwC,  npwinC;
    33103329  int nwalk=0, endwalks=0, nnwinC=1, nlast = 0;
     
    33133332  intvec* iv_M_lp;
    33143333  intvec* target_weight;
    3315   intvec* ivNull = new intvec(nV); 
     3334  intvec* ivNull = new intvec(nV);
    33163335  intvec* hilb_func;
    33173336  BOOLEAN isGB = FALSE;
     
    33363355    TargetRing = currRing;
    33373356    ssG = idrMoveR(G,EXXRing);
    3338    
     3357
    33393358    ideal H0_tmp = idrMoveR(H0,EXXRing);
    33403359    ideal H1 = idHeadCC(ssG);
     
    33563375      else
    33573376        goto LastGB_Finish;
    3358     }   
     3377    }
    33593378    idDelete(&H0_tmp);   idDelete(&H1);
    3360    
     3379
    33613380    intvec* ivlp = Mivlp(nV);
    33623381    if( MivSame(orig_target_weight, ivlp)==1 )
     
    33673386    //target_weight  = MPertVectorslp(ssG, iv_M_lp, tp_deg);
    33683387    target_weight  = MPertVectors(ssG, iv_M_lp, tp_deg);
    3369    
     3388
    33703389    delete ivlp;
    33713390    delete iv_M_lp;
     
    33743393    G = idrMoveR(ssG, TargetRing);
    33753394  }
    3376  
     3395
    33773396  while(1)
    3378   { 
     3397  {
    33793398    nwalk ++;
    33803399    nstep++;
     
    33943413      hilb_func = hFirstSeries(Gomega,NULL,NULL,last_omega,currRing);
    33953414#endif // BUCHBERGER_ALG
    3396    
     3415
    33973416    oldRing = currRing;
    33983417
     
    34033422      VMrDefault(curr_weight);
    34043423
    3405     newRing = currRing; 
     3424    newRing = currRing;
    34063425    Gomega1 = idrMoveR(Gomega, oldRing);
    34073426
     
    34123431#else
    34133432    M=kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight);
    3414     delete hilb_func;   
     3433    delete hilb_func;
    34153434#endif // BUCHBERGER_ALG
    34163435    xtstd = xtstd + clock() - to;
    34173436
    3418     /* change the ring to oldRing */ 
     3437    /* change the ring to oldRing */
    34193438    rChangeCurrRing(oldRing);
    3420    
     3439
    34213440    M1 =  idrMoveR(M, newRing);
    3422     Gomega2 =  idrMoveR(Gomega1, newRing); 
    3423    
     3441    Gomega2 =  idrMoveR(Gomega1, newRing);
     3442
    34243443    to = clock();
    34253444    F = MLifttwoIdeal(Gomega2, M1, G);
    34263445    xtlift = xtlift + clock() -to;
    34273446
    3428     idDelete(&M1); 
    3429     idDelete(&Gomega2); 
     3447    idDelete(&M1);
     3448    idDelete(&Gomega2);
    34303449    idDelete(&G);
    34313450
    34323451
    3433     /* change the ring to newRing */ 
     3452    /* change the ring to newRing */
    34343453    rChangeCurrRing(newRing);
    34353454    F1 = idrMoveR(F, oldRing);
    34363455
    3437     to = clock(); 
    3438     /* reduce the Groebner basis <G> w.r.t. new ring */   
     3456    to = clock();
     3457    /* reduce the Groebner basis <G> w.r.t. new ring */
    34393458    G = kInterRedCC(F1, NULL);
    34403459    xtred = xtred + clock() -to;
     
    34513470    xtnw = xtnw + clock() - to;
    34523471
    3453 #ifdef PRINT_VECTORS 
     3472#ifdef PRINT_VECTORS
    34543473    MivString(curr_weight, target_weight, next_weight);
    34553474#endif
    34563475
    3457     /*check whether the computed vector does in the correct cone */ 
     3476    /*check whether the computed vector does in the correct cone */
    34583477    //ntwC = test_w_in_ConeCC(G, next_weight);
    34593478    //if(ntwC != 1)
     
    34733492      break;
    34743493    }
    3475    
     3494
    34763495    if(MivComp(next_weight, target_weight) == 1)
    34773496    {
     
    34903509      (*curr_weight)[i] = (*next_weight)[i];
    34913510
    3492     delete next_weight; 
    3493   }//while 
     3511    delete next_weight;
     3512  }//while
    34943513
    34953514  delete ivNull;
     
    34993518    //28.07.03
    35003519    newRing = currRing;
    3501    
     3520
    35023521    if (currRing->parameter != NULL)
    35033522      //  DefRingParlp(); //
     
    35083527
    35093528    F1 = idrMoveR(G, newRing);
    3510    
     3529
    35113530    if(nnwinC == 0)
    35123531      F1 = REC_GB_Mwalk(F1,curr_weight, orig_target_weight, tp_deg+1,nnwinC);
     
    35143533      if(test_w_in_ConeCC(F1, target_weight) != 1)
    35153534        F1 = REC_GB_Mwalk(F1,curr_weight, orig_target_weight,tp_deg+1,nnwinC);
    3516    
     3535
    35173536    delete target_weight;
    35183537
     
    35243543  {
    35253544    if(nlast == 1)
    3526     {           
     3545    {
    35273546      if (currRing->parameter != NULL)
    35283547        DefRingPar(orig_target_weight);
     
    35433562      newRing = currRing;
    35443563    }
    3545    
     3564
    35463565  LastGB_Finish:
    35473566    rChangeCurrRing(EXXRing);
    35483567    result = idrMoveR(G, newRing);
    3549   } 
    3550  
     3568  }
     3569
    35513570  if(Overflow_Error == FALSE)
    35523571    Overflow_Error = nError;
    3553  
    3554   return(result); 
     3572
     3573  return(result);
    35553574}
    35563575
     
    35583577/* 08.09.02 */
    35593578/******** THE NEW GRÖBNER WALK ALGORITHM **********/
    3560 /* Gröbnerwalk with a recursive "second" alternative GW, REC_GB_Mwalk 
     3579/* Gröbnerwalk with a recursive "second" alternative GW, REC_GB_Mwalk
    35613580   that only computes the last reduced GB */
    35623581ideal Mwalk(ideal Go, intvec* curr_weight, intvec* target_weight)
     
    35893608    (*last_omega)[i] = 1;
    35903609  (*last_omega)[0] = 10000;
    3591  
     3610
    35923611  ring XXRing = currRing;
    35933612
     
    35993618  if(currRing->order[0] == ringorder_a)
    36003619    goto NEXT_VECTOR;
    3601  
     3620
    36023621  while(1)
    3603   { 
     3622  {
    36043623    nwalk ++;
    36053624    nstep ++;
     
    36163635      tim = clock();
    36173636      /*
    3618         Print("\n// **** Gröbnerwalk took %d steps and ", nwalk);
    3619         PrintS("\n// **** call the rec. Pert. Walk to compute a red GB of:");
    3620         idElements(Gomega, "G_omega");
     3637        Print("\n// **** Gröbnerwalk took %d steps and ", nwalk);
     3638        PrintS("\n// **** call the rec. Pert. Walk to compute a red GB of:");
     3639        idElements(Gomega, "G_omega");
    36213640      */
    36223641
    36233642      if(MivSame(exivlp, target_weight)==1)
    3624         M = REC_GB_Mwalk(idCopy(Gomega), tmp_weight, curr_weight, 2,1); 
     3643        M = REC_GB_Mwalk(idCopy(Gomega), tmp_weight, curr_weight, 2,1);
    36253644      else
    36263645        goto NORMAL_GW;
    36273646      /*
    3628         Print("\n//  time for the last std(Gw)  = %.2f sec",
    3629         ((double) (clock()-tim)/1000000));
    3630         PrintS("\n// ***************************************************\n");
     3647        Print("\n//  time for the last std(Gw)  = %.2f sec",
     3648        ((double) (clock()-tim)/1000000));
     3649        PrintS("\n// ***************************************************\n");
    36313650      */
    3632 #ifdef CHECK_IDEAL_MWALK 
     3651#ifdef CHECK_IDEAL_MWALK
    36333652      idElements(Gomega, "G_omega");
    36343653      headidString(Gomega, "Gw");
    36353654      idElements(M, "M");
    36363655      //headidString(M, "M");
    3637 #endif     
     3656#endif
    36383657      to = clock();
    36393658      F = MLifttwoIdeal(Gomega, M, G);
     
    36463665      oldRing = currRing;
    36473666
    3648       /* create a new ring newRing */ 
     3667      /* create a new ring newRing */
    36493668       if (currRing->parameter != NULL)
    36503669         DefRingPar(curr_weight);
     
    36523671         VMrDefault(curr_weight);
    36533672
    3654       newRing = currRing;       
    3655       F1 = idrMoveR(F, oldRing); 
     3673      newRing = currRing;
     3674      F1 = idrMoveR(F, oldRing);
    36563675    }
    36573676    else
     
    36603679#ifndef  BUCHBERGER_ALG
    36613680      if(isNolVector(curr_weight) == 0)
    3662         hilb_func = hFirstSeries(Gomega,NULL,NULL,curr_weight,currRing);
     3681        hilb_func = hFirstSeries(Gomega,NULL,NULL,curr_weight,currRing);
    36633682      else
    3664         hilb_func = hFirstSeries(Gomega,NULL,NULL,last_omega,currRing);
     3683        hilb_func = hFirstSeries(Gomega,NULL,NULL,last_omega,currRing);
    36653684#endif // BUCHBERGER_ALG
    36663685
    36673686      /* define a new ring that its ordering is "(a(curr_weight),lp) */
    36683687      if (currRing->parameter != NULL)
    3669         DefRingPar(curr_weight);
     3688        DefRingPar(curr_weight);
    36703689      else
    3671         VMrDefault(curr_weight);
    3672 
    3673       newRing = currRing;       
     3690        VMrDefault(curr_weight);
     3691
     3692      newRing = currRing;
    36743693      Gomega1 = idrMoveR(Gomega, oldRing);
    3675  
     3694
    36763695      to = clock();
    36773696      /* compute a reduced Groebner basis of <Gomega> w.r.t. "newRing" */
     
    36803699#else
    36813700      M=kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight);
    3682       delete hilb_func;   
     3701      delete hilb_func;
    36833702#endif // BUCHBERGER_ALG
    36843703      tstd = tstd + clock() - to;
    36853704
    3686       /* change the ring to oldRing */ 
     3705      /* change the ring to oldRing */
    36873706      rChangeCurrRing(oldRing);
    36883707      M1 =  idrMoveR(M, newRing);
     
    36913710      to = clock();
    36923711      /* compute a representation of the generators of submod (M)
    3693          with respect to those of mod (Gomega). 
     3712         with respect to those of mod (Gomega).
    36943713         Gomega is a reduced Groebner basis w.r.t. the current ring */
    36953714      F = MLifttwoIdeal(Gomega2, M1, G);
    36963715      tlift = tlift + clock() - to;
    36973716
    3698       idDelete(&M1); 
    3699       idDelete(&Gomega2); 
    3700       idDelete(&G); 
    3701 
    3702       /* change the ring to newRing */ 
     3717      idDelete(&M1);
     3718      idDelete(&Gomega2);
     3719      idDelete(&G);
     3720
     3721      /* change the ring to newRing */
    37033722      rChangeCurrRing(newRing);
    3704       F1 = idrMoveR(F, oldRing); 
     3723      F1 = idrMoveR(F, oldRing);
    37053724    }
    37063725
    37073726    to = clock();
    3708     /* reduce the Groebner basis <G> w.r.t. new ring */   
     3727    /* reduce the Groebner basis <G> w.r.t. new ring */
    37093728    G = kInterRedCC(F1, NULL);
    37103729    if(endwalks != 1)
     
    37163735    if(endwalks == 1)
    37173736      break;
    3718    
     3737
    37193738  NEXT_VECTOR:
    37203739    to = clock();
     
    37223741    intvec* next_weight = MkInterRedNextWeight(curr_weight,target_weight,G);
    37233742    tnw = tnw + clock() - to;
    3724 #ifdef PRINT_VECTORS 
     3743#ifdef PRINT_VECTORS
    37253744    MivString(curr_weight, target_weight, next_weight);
    37263745#endif
     
    37363755      else
    37373756        VMrDefault(target_weight);
    3738      
    3739       F1 = idrMoveR(G, newRing); 
     3757
     3758      F1 = idrMoveR(G, newRing);
    37403759      G = MstdCC(F1);
    37413760      idDelete(&F1);
    3742      
     3761
    37433762      newRing = currRing;
    37443763      break;
     
    37653784  delete tmp_weight;
    37663785  delete ivNull;
    3767   delete exivlp; 
    3768  
     3786  delete exivlp;
     3787
    37693788#ifdef TIME_TEST
    37703789  TimeString(tinput, tostd, tif, tstd, tlift, tred, tnw, nstep);
     
    37833802  int i, nV = currRing->N;
    37843803  int nwalk=0, endwalks=0;
    3785  
     3804
    37863805  ideal Gomega, M, F, Gomega1, Gomega2, M1, F1, G, G1;
    37873806  ring endRing, newRing, oldRing;
     
    38053824
    38063825  while(1)
    3807   { 
     3826  {
    38083827    nwalk ++;
    38093828    //Print("\n// Entering the %d-th step:", nwalk);
    38103829    //Print("\n// ring r[%d] = %s;", nwalk, rString(currRing));
    3811     idString(G,"G"); 
     3830    idString(G,"G");
    38123831    /* compute an initial form ideal of <G> w.r.t. "curr_vector" */
    38133832    Gomega = MwalkInitialForm(G, curr_weight);
    38143833    //ivString(curr_weight, "omega");
    3815     idString(Gomega,"Gw"); 
     3834    idString(Gomega,"Gw");
    38163835
    38173836#ifndef  BUCHBERGER_ALG
     
    38243843
    38253844    oldRing = currRing;
    3826    
     3845
    38273846    /* define a new ring that its ordering is "(a(curr_weight),lp) */
    38283847    VMrDefault(curr_weight);
    3829     newRing = currRing; 
    3830    
     3848    newRing = currRing;
     3849
    38313850    Gomega1 = idrMoveR(Gomega, oldRing);
    3832  
     3851
    38333852    /* compute a reduced Groebner basis of <Gomega> w.r.t. "newRing" */
    38343853#ifdef  BUCHBERGER_ALG
     
    38363855#else
    38373856    M=kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight);
    3838     delete hilb_func;   
     3857    delete hilb_func;
    38393858#endif // BUCHBERGER_ALG
    38403859
    38413860    idString(M,"M");
    38423861
    3843       /* change the ring to oldRing */ 
     3862      /* change the ring to oldRing */
    38443863    rChangeCurrRing(oldRing);
    38453864    M1 =  idrMoveR(M, newRing);
     
    38473866
    38483867      /* compute a representation of the generators of submod (M)
    3849          with respect to those of mod (Gomega).
    3850         Gomega is a reduced Groebner basis w.r.t. the current ring */
     3868         with respect to those of mod (Gomega).
     3869        Gomega is a reduced Groebner basis w.r.t. the current ring */
    38513870    F = MLifttwoIdeal(Gomega2, M1, G);
    3852     idDelete(&M1); 
    3853     idDelete(&Gomega2); 
    3854     idDelete(&G); 
     3871    idDelete(&M1);
     3872    idDelete(&Gomega2);
     3873    idDelete(&G);
    38553874    idString(F,"F");
    3856    
    3857     /* change the ring to newRing */ 
     3875
     3876    /* change the ring to newRing */
    38583877    rChangeCurrRing(newRing);
    3859     F1 = idrMoveR(F, oldRing); 
    3860    
    3861     /* reduce the Groebner basis <G> w.r.t. new ring */   
     3878    F1 = idrMoveR(F, oldRing);
     3879
     3880    /* reduce the Groebner basis <G> w.r.t. new ring */
    38623881    G = kInterRedCC(F1, NULL);
    38633882    //idSkipZeroes(G);//done by kInterRed
     
    38663885    if(endwalks == 1)
    38673886      break;
    3868    
     3887
    38693888    /* compute a next weight vector */
    38703889    intvec* next_weight = MkInterRedNextWeight(curr_weight,target_weight,G);
    3871 #ifdef PRINT_VECTORS 
     3890#ifdef PRINT_VECTORS
    38723891    MivString(curr_weight, target_weight, next_weight);
    38733892#endif
     
    39043923/**************************************************************/
    39053924/* If the perturbed target weight vector or an intermediate weight vector
    3906    doesn't stay in the correct Groebner cone, we have only 
    3907    a reduced Groebner basis for the given ideal with respect to 
     3925   doesn't stay in the correct Groebner cone, we have only
     3926   a reduced Groebner basis for the given ideal with respect to
    39083927   a monomial order which differs to the given order.
    39093928   Then we have to compute the wanted  reduced Groebner basis for it.
     
    39143933/* use kStd, if nP = 0, else call LastGB */
    39153934ideal Mpwalk(ideal Go, int op_deg, int tp_deg,intvec* curr_weight,
    3916              intvec* target_weight, int nP)
    3917 { 
     3935             intvec* target_weight, int nP)
     3936{
    39183937  Set_Error(FALSE  );
    39193938  Overflow_Error = FALSE;
     
    39303949  int i, ntwC=1, ntestw=1,  nV = currRing->N, op_tmp = op_deg;
    39313950  int endwalks=0, nhilb=0, ntestomega=0;
    3932  
     3951
    39333952  ideal Gomega, M, F, G, Gomega1, Gomega2, M1,F1,Eresult,ssG;
    39343953  ring newRing, oldRing, TargetRing;
     
    39383957  intvec* orig_target = target_weight;
    39393958  intvec* pert_target_vector = target_weight;
    3940   intvec* ivNull = new intvec(nV); 
     3959  intvec* ivNull = new intvec(nV);
    39413960  intvec* iv_dp = MivUnit(nV);// define (1,1,...,1)
    39423961  intvec* cw_tmp = curr_weight;
     
    39443963  intvec* next_weight;
    39453964  intvec* extra_curr_weight = new intvec(nV);
    3946  
     3965
    39473966  /* to avoid (1,0,...,0) as the target vector */
    39483967  intvec* last_omega = new intvec(nV);
     
    39503969    (*last_omega)[i] = 1;
    39513970  (*last_omega)[0] = 10000;
    3952  
     3971
    39533972  ring XXRing = currRing;
    39543973
     
    39653984      curr_weight = MPertVectors(G, iv_M_dp, op_deg);
    39663985    }
    3967   }     
     3986  }
    39683987  else
    39693988  {
    3970     //ring order := (a(curr_weight),lp); 
     3989    //ring order := (a(curr_weight),lp);
    39713990    if (currRing->parameter != NULL)
    39723991      DefRingPar(curr_weight);
    39733992    else
    39743993      VMrDefault(curr_weight);
    3975    
     3994
    39763995    G = idrMoveR(Go, XXRing);
    39773996    G = MstdCC(G);
     
    39844003  delete iv_dp;
    39854004  if(op_deg != 1) delete iv_M_dp;
    3986  
     4005
    39874006  ring HelpRing = currRing;
    39884007
     
    40084027      iv_M_lp = MivMatrixOrder(target_weight);
    40094028      //target_weight = MPertVectorslp(ssG, iv_M_lp, tp_deg);
    4010       target_weight = MPertVectors(ssG, iv_M_lp, tp_deg); 
    4011     } 
     4029      target_weight = MPertVectors(ssG, iv_M_lp, tp_deg);
     4030    }
    40124031    delete iv_M_lp;
    40134032    pert_target_vector = target_weight; //vor 19. mai 2003//test 19 Junu 03
     
    40214040  */
    40224041  while(1)
    4023   { 
     4042  {
    40244043    nstep ++;
    40254044    to = clock();
    4026     /* compute an initial form ideal of <G> w.r.t. the weight vector 
     4045    /* compute an initial form ideal of <G> w.r.t. the weight vector
    40274046       "curr_weight" */
    40284047    Gomega = MwalkInitialForm(G, curr_weight);
    4029    
     4048
    40304049
    40314050#ifdef ENDWALKS
    4032     if(endwalks == 1){ 
    4033       Print("\n// ring r%d = %s;\n", nstep, rString(currRing)); 
     4051    if(endwalks == 1){
     4052      Print("\n// ring r%d = %s;\n", nstep, rString(currRing));
    40344053      idElements(G, "G");
    40354054      // idElements(Gomega, "Gw");
     
    40564075      VMrDefault(curr_weight);
    40574076
    4058     newRing = currRing; 
     4077    newRing = currRing;
    40594078    Gomega1 = idrMoveR(Gomega, oldRing);
    40604079
    4061 #ifdef ENDWALKS   
     4080#ifdef ENDWALKS
    40624081    if(endwalks==1)
    40634082    {
    40644083      Print("\n// ring r%d = %s;\n", nstep, rString(currRing));
    40654084      idElements(Gomega1, "Gw");
    4066       headidString(Gomega1, "headGw"); 
     4085      headidString(Gomega1, "headGw");
    40674086      PrintS("\n// compute a rGB of Gw:\n");
    40684087
    4069 #ifndef  BUCHBERGER_ALG   
     4088#ifndef  BUCHBERGER_ALG
    40704089      ivString(hilb_func, "w");
    4071 #endif
    4072     }
    40734090#endif
    4074    
     4091    }
     4092#endif
     4093
    40754094    tim = clock();
    40764095    to = clock();
     
    40804099#else
    40814100    M=kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight);
    4082     delete hilb_func;   
     4101    delete hilb_func;
    40834102#endif // BUCHBERGER_ALG
    40844103
    40854104    if(endwalks == 1){
    40864105      xtstd = xtstd+clock()-to;
    4087 #ifdef ENDWALKS   
    4088       Print("\n// time for the last std(Gw)  = %.2f sec\n", 
     4106#ifdef ENDWALKS
     4107      Print("\n// time for the last std(Gw)  = %.2f sec\n",
    40894108            ((double) clock())/1000000 -((double)tim) /1000000);
    40904109#endif
     
    40934112      tstd=tstd+clock()-to;
    40944113
    4095     /* change the ring to oldRing */ 
     4114    /* change the ring to oldRing */
    40964115    rChangeCurrRing(oldRing);
    40974116    M1 =  idrMoveR(M, newRing);
    4098     Gomega2 =  idrMoveR(Gomega1, newRing); 
    4099    
     4117    Gomega2 =  idrMoveR(Gomega1, newRing);
     4118
    41004119    //if(endwalks==1)  PrintS("\n// Lifting is working:..");
    41014120
    41024121    to=clock();
    41034122    /* compute a representation of the generators of submod (M)
    4104        with respect to those of mod (Gomega). 
     4123       with respect to those of mod (Gomega).
    41054124       Gomega is a reduced Groebner basis w.r.t. the current ring */
    41064125    F = MLifttwoIdeal(Gomega2, M1, G);
     
    41104129      xtlift=clock()-to;
    41114130
    4112     idDelete(&M1); 
    4113     idDelete(&Gomega2); 
     4131    idDelete(&M1);
     4132    idDelete(&Gomega2);
    41144133    idDelete(&G);
    41154134
    4116     /* change the ring to newRing */ 
     4135    /* change the ring to newRing */
    41174136    rChangeCurrRing(newRing);
    41184137    F1 = idrMoveR(F, oldRing);
     
    41214140
    41224141    to=clock();
    4123     /* reduce the Groebner basis <G> w.r.t. new ring */   
     4142    /* reduce the Groebner basis <G> w.r.t. new ring */
    41244143    G = kInterRedCC(F1, NULL);
    41254144    if(endwalks != 1)
     
    41294148
    41304149    idDelete(&F1);
    4131    
     4150
    41324151    if(endwalks == 1)
    41334152      break;
    4134    
     4153
    41354154    to=clock();
    41364155    /* compute a next weight vector */
    41374156    next_weight = MkInterRedNextWeight(curr_weight,target_weight, G);
    41384157    tnw=tnw+clock()-to;
    4139 #ifdef PRINT_VECTORS 
     4158#ifdef PRINT_VECTORS
    41404159    MivString(curr_weight, target_weight, next_weight);
    41414160#endif
     
    41454164      ntwC = 0;
    41464165      ntestomega = 1;
    4147       //Print("\n// ring r%d = %s;\n", nstep, rString(currRing)); 
     4166      //Print("\n// ring r%d = %s;\n", nstep, rString(currRing));
    41484167      //idElements(G, "G");
    41494168      delete next_weight;
    4150       goto FINISH_160302; 
     4169      goto FINISH_160302;
    41514170    }
    41524171    if(MivComp(next_weight, ivNull) == 1){
     
    41594178      endwalks = 1;
    41604179
    4161     for(i=nV-1; i>=0; i--) 
     4180    for(i=nV-1; i>=0; i--)
    41624181      (*curr_weight)[i] = (*next_weight)[i];
    4163    
     4182
    41644183    delete next_weight;
    41654184  }//while
     
    41684187  {
    41694188  FINISH_160302://16.03.02
    4170     if(MivSame(orig_target, exivlp) == 1) 
     4189    if(MivSame(orig_target, exivlp) == 1)
    41714190      if (currRing->parameter != NULL)
    41724191        DefRingParlp();
     
    41784197      else
    41794198        VMrDefault(orig_target);
    4180    
     4199
    41814200    TargetRing=currRing;
    41824201    F1 = idrMoveR(G, newRing);
     
    41844203      headidString(G, "G");
    41854204#endif
    4186        
     4205
    41874206
    41884207    // check whether the pertubed target vector stays in the correct cone
     
    41944213    {
    41954214      /*
    4196       if(ntestw != 1){ 
    4197         ivString(pert_target_vector, "tau");
    4198         PrintS("\n// ** perturbed target vector doesn't stay in cone!!"); 
    4199         Print("\n// ring r%d = %s;\n", nstep, rString(currRing)); 
    4200         idElements(F1, "G"); 
     4215      if(ntestw != 1){
     4216        ivString(pert_target_vector, "tau");
     4217        PrintS("\n// ** perturbed target vector doesn't stay in cone!!");
     4218        Print("\n// ring r%d = %s;\n", nstep, rString(currRing));
     4219        idElements(F1, "G");
    42014220      }
    42024221      */
     
    42054224      ideal eF1;
    42064225      if(nP == 0 || tp_deg == 1 || MivSame(orig_target, exivlp) != 1){
    4207         // PrintS("\n// ** calls \"std\" to compute a GB");
     4226        // PrintS("\n// ** calls \"std\" to compute a GB");
    42084227        eF1 = MstdCC(F1);
    42094228        idDelete(&F1);
    42104229      }
    42114230      else {
    4212         // PrintS("\n// ** calls \"LastGB\" to compute a GB");
    4213         rChangeCurrRing(newRing);
    4214         ideal F2 = idrMoveR(F1, TargetRing);
    4215         eF1 = LastGB(F2, curr_weight, tp_deg-1);
    4216         F2=NULL;
     4231        // PrintS("\n// ** calls \"LastGB\" to compute a GB");
     4232        rChangeCurrRing(newRing);
     4233        ideal F2 = idrMoveR(F1, TargetRing);
     4234        eF1 = LastGB(F2, curr_weight, tp_deg-1);
     4235        F2=NULL;
    42174236      }
    42184237      xtextra=clock()-to;
     
    42214240      rChangeCurrRing(XXRing);
    42224241      Eresult = idrMoveR(eF1, exTargetRing);
    4223     }   
     4242    }
    42244243    else{
    42254244      rChangeCurrRing(XXRing);
     
    42304249    rChangeCurrRing(XXRing);
    42314250    Eresult = idrMoveR(G, newRing);
    4232   } 
     4251  }
    42334252  delete ivNull;
    42344253  if(tp_deg != 1)
     
    42424261
    42434262#ifdef TIME_TEST
    4244   TimeStringFractal(tinput, tostd, tif+xtif, tstd+xtstd,0, tlift+xtlift, tred+xtred, 
    4245              tnw+xtnw);
     4263  TimeStringFractal(tinput, tostd, tif+xtif, tstd+xtstd,0, tlift+xtlift, tred+xtred,
     4264             tnw+xtnw);
    42464265
    42474266  Print("\n// pSetm_Error = (%d)", ErrorCheck());
    42484267  Print("\n// It took %d steps and Overflow_Error? (%d)\n", nstep,  Overflow_Error);
    42494268#endif
    4250   return(Eresult); 
     4269  return(Eresult);
    42514270}
    42524271
     
    42584277  int i,j;
    42594278  intvec* ivM = new intvec(nV*nV);
    4260      
     4279
    42614280  for(i=0; i<nV; i++)
    42624281    for(j=0; j<nV; j++)
    42634282    (*ivM)[i*nV + j] = 1;
    4264  
     4283
    42654284  return(ivM);
    42664285}
     
    43034322      (*omega)[i] = (*Xsigma)[(nV*(nlev-1))+i];
    43044323
    4305     (*omega2)[i] = (*Xtau)[(nlev-1)*nV+i]; 
    4306   }
    4307    
     4324    (*omega2)[i] = (*Xtau)[(nlev-1)*nV+i];
     4325  }
     4326
    43084327   if(nlev == 1)  Xcall = 1;
    43094328   else Xcall = 0;
    43104329
    43114330  ring oRing = currRing;
    4312  
     4331
    43134332  while(1)
    43144333  {
    43154334#ifdef FIRST_STEP_FRACTAL
    4316     // perturb the current weight vector only on the top level or 
     4335    // perturb the current weight vector only on the top level or
    43174336    // after perturbation of the both vectors, nlev = 2 as the top level
    43184337    if((nlev == 1 && Xcall == 0) || (nlev == 2 && Xngleich == 1))
    43194338      if(islengthpoly2(G) == 1)
    43204339      {
    4321         Mwlp = MivWeightOrderlp(omega);
    4322         Xsigma = Mfpertvector(G, Mwlp);
    4323         delete Mwlp;
    4324         Overflow_Error = FALSE;
     4340        Mwlp = MivWeightOrderlp(omega);
     4341        Xsigma = Mfpertvector(G, Mwlp);
     4342        delete Mwlp;
     4343        Overflow_Error = FALSE;
    43254344      }
    43264345#endif
     
    43314350    next_vect = MkInterRedNextWeight(omega,omega2,G);
    43324351    xtnw=xtnw+clock()-to;
    4333 #ifdef PRINT_VECTORS 
     4352#ifdef PRINT_VECTORS
    43344353    MivString(omega, omega2, next_vect);
    43354354#endif
    43364355    oRing = currRing;
    4337    
     4356
    43384357    /* We only perturb the current target vector at the recursion  level 1 */
    4339     if(Xngleich == 0 && nlev == 1) //(ngleich == 0) important, e.g. ex2, ex3 
    4340       if (MivComp(next_vect, omega2) == 1) 
     4358    if(Xngleich == 0 && nlev == 1) //(ngleich == 0) important, e.g. ex2, ex3
     4359      if (MivComp(next_vect, omega2) == 1)
    43414360      {
    43424361        /* to dispense with taking initial (and lifting/interreducing
    43434362           after the call of recursion */
    43444363        //Print("\n\n// ** Perturb the both vectors with degree %d with",nlev);
    4345         //idElements(G, "G");
     4364        //idElements(G, "G");
    43464365
    43474366        Xngleich = 1;
     
    43504369        if (currRing->parameter != NULL)
    43514370          DefRingPar(omtmp);
    4352         else   
     4371        else
    43534372          VMrDefault(omtmp);
    43544373
    43554374        testring = currRing;
    43564375        Gt = idrMoveR(G, oRing);
    4357      
     4376
    43584377        /* perturb the original target vector w.r.t. the current GB */
    4359         delete Xtau; 
     4378        delete Xtau;
    43604379        Xtau = NewVectorlp(Gt);
    4361            
    4362         rChangeCurrRing(oRing); 
     4380
     4381        rChangeCurrRing(oRing);
    43634382        G = idrMoveR(Gt, testring);
    43644383
     
    43674386        Xsigma = Mfpertvector(G, Mwlp);
    43684387        delete Mwlp;
    4369        
     4388
    43704389        for(i=nV-1; i>=0; i--) {
    43714390          (*omega2)[i] = (*Xtau)[nV+i];
    43724391          (*omega)[i] = (*Xsigma)[nV+i];
    43734392        }
    4374        
     4393
    43754394        delete next_vect;
    4376         to=clock();
    4377 
    4378         /* to avoid the value of Overflow_Error that occur in Mfpertvector*/
    4379         Overflow_Error = FALSE;
    4380 
    4381         next_vect = MkInterRedNextWeight(omega,omega2,G); 
    4382         xtnw=xtnw+clock()-to;
    4383 
    4384 #ifdef PRINT_VECTORS 
     4395        to=clock();
     4396
     4397        /* to avoid the value of Overflow_Error that occur in Mfpertvector*/
     4398        Overflow_Error = FALSE;
     4399
     4400        next_vect = MkInterRedNextWeight(omega,omega2,G);
     4401        xtnw=xtnw+clock()-to;
     4402
     4403#ifdef PRINT_VECTORS
    43854404        MivString(omega, omega2, next_vect);
    43864405#endif
    43874406      }
    4388    
    4389    
     4407
     4408
    43904409    /* check whether the the computed vector is in the correct cone */
    4391     /* If no, the reduced GB of an omega-homogeneous ideal will be 
     4410    /* If no, the reduced GB of an omega-homogeneous ideal will be
    43924411       computed by Buchberger algorithm and stop this recursion step*/
    43934412    //if(test_w_in_ConeCC(G, next_vect) != 1) //e.g. Example s7, cyc6
     
    44144433      Gt = NULL;
    44154434
    4416       delete omega2;     
    4417       delete altomega; 
     4435      delete omega2;
     4436      delete altomega;
    44184437
    44194438      //Print("\n// Leaving the %d-th recursion with %d steps", nlev, nwalks);
    44204439      //Print("  ** Overflow_Error? (%d)", Overflow_Error);
    44214440      nnflow ++;
    4422      
     4441
    44234442      Overflow_Error = FALSE;
    44244443      return (G1);
    44254444    }
    44264445
    4427  
    4428     /* If the perturbed target vector stays in the correct cone, 
     4446
     4447    /* If the perturbed target vector stays in the correct cone,
    44294448       return the current GB,
    4430        otherwise, return the computed  GB by the Buchberger-algorithm. 
    4431        Then we update the perturbed target vectors w.r.t. this GB. */ 
    4432    
     4449       otherwise, return the computed  GB by the Buchberger-algorithm.
     4450       Then we update the perturbed target vectors w.r.t. this GB. */
     4451
    44334452    /* the computed vector is equal to the origin vector, since
    44344453       t is not defined */
    4435     if (MivComp(next_vect, XivNull) == 1) 
     4454    if (MivComp(next_vect, XivNull) == 1)
    44364455    {
    44374456      if (currRing->parameter != NULL)
     
    44444463
    44454464      if(test_w_in_ConeCC(Gt, omega2) == 1) {
    4446         delete omega2;   
     4465        delete omega2;
    44474466        delete next_vect;
    44484467        delete altomega;
    44494468        //Print("\n// Leaving the %d-th recursion with %d steps ",nlev, nwalks);
    44504469        //Print(" ** Overflow_Error? (%d)", Overflow_Error);
    4451        
     4470
    44524471        return (Gt);
    44534472      }
     
    44564475        //ivString(omega2, "tau'");
    44574476        //Print("\n//  tau' doesn't stay in the correct cone!!");
    4458  
     4477
    44594478#ifndef  MSTDCC_FRACTAL
    44604479        //07.08.03
     
    44754494        Xtau = Xtautmp;
    44764495        Xtautmp = NULL;
    4477         //ivString(Xtau, "new  Xtau");   
    4478        
    4479         for(i=nV-1; i>=0; i--) 
     4496        //ivString(Xtau, "new  Xtau");
     4497
     4498        for(i=nV-1; i>=0; i--)
    44804499          (*omega2)[i] = (*Xtau)[(nlev-1)*nV+i];
    4481  
     4500
    44824501        //Print("\n//  ring tau = %s;", rString(currRing));
    44834502        rChangeCurrRing(oRing);
     
    44914510        to=clock();
    44924511        G = MstdCC(Gt);
    4493         xtextra=xtextra+clock()-to;
    4494 
    4495         oRing = currRing; 
    4496 
    4497         // update the original target vector w.r.t. the current GB 
     4512        xtextra=xtextra+clock()-to;
     4513
     4514        oRing = currRing;
     4515
     4516        // update the original target vector w.r.t. the current GB
    44984517        if(MivSame(Xivinput, Xivlp) == 1)
    44994518          if (currRing->parameter != NULL)
     
    45154534        rChangeCurrRing(oRing);
    45164535        G = idrMoveR(Gt, testring);
    4517                
    4518         delete omega2;   
     4536
     4537        delete omega2;
    45194538        delete next_vect;
    4520         delete altomega; 
    4521         /*   
    4522           Print("\n// Leaving the %d-th recursion with %d steps,", nlev,nwalks);
    4523           Print(" ** Overflow_Error? (%d)", Overflow_Error);
    4524         */
     4539        delete altomega;
     4540        /*
     4541          Print("\n// Leaving the %d-th recursion with %d steps,", nlev,nwalks);
     4542          Print(" ** Overflow_Error? (%d)", Overflow_Error);
     4543        */
    45254544        if(Overflow_Error == TRUE)
    45264545          nnflow ++;
     
    45294548        return(G);
    45304549      }
    4531     }   
    4532 
    4533     for(i=nV-1; i>=0; i--) { 
     4550    }
     4551
     4552    for(i=nV-1; i>=0; i--) {
    45344553      (*altomega)[i] = (*omega)[i];
    45354554      (*omega)[i] = (*next_vect)[i];
     
    45414560    Gomega = MwalkInitialForm(G, omega);
    45424561    xtif=xtif+clock()-to;
    4543    
     4562
    45444563#ifndef  BUCHBERGER_ALG
    45454564    if(isNolVector(omega) == 0)
     
    45484567      hilb_func = hFirstSeries(Gomega,NULL,NULL,last_omega,currRing);
    45494568#endif // BUCHBERGER_ALG
    4550        
     4569
    45514570    if (currRing->parameter != NULL)
    45524571      DefRingPar(omega);
     
    45554574
    45564575    Gomega1 = idrMoveR(Gomega, oRing);
    4557    
    4558     /* Maximal recursion depth, to compute a red. GB */ 
     4576
     4577    /* Maximal recursion depth, to compute a red. GB */
    45594578    /* Fractal walk with the alternative recursion */
    45604579    /* alternative recursion */
     
    45644583    {
    45654584      /*
    4566       if(Xnlev != nV) 
    4567       { 
    4568         Print("\n// ** Xnlev = %d", Xnlev); 
    4569         ivString(Xtau, "Xtau"); 
    4570       } 
     4585      if(Xnlev != nV)
     4586      {
     4587        Print("\n// ** Xnlev = %d", Xnlev);
     4588        ivString(Xtau, "Xtau");
     4589      }
    45714590      */
    45724591      to=clock();
     
    45754594#else
    45764595      Gresult =kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,omega);
    4577       delete hilb_func;   
     4596      delete hilb_func;
    45784597#endif // BUCHBERGER_ALG
    45794598      xtstd=xtstd+clock()-to;
    4580     } 
     4599    }
    45814600    else {
    45824601      rChangeCurrRing(oRing);
     
    45854604    }
    45864605
    4587     //convert a Groebner basis from a ring to another ring, 
     4606    //convert a Groebner basis from a ring to another ring,
    45884607    new_ring = currRing;
    4589    
    4590     rChangeCurrRing(oRing); 
     4608
     4609    rChangeCurrRing(oRing);
    45914610    Gresult1 = idrMoveR(Gresult, new_ring);
    45924611    Gomega2 = idrMoveR(Gomega1, new_ring);
    4593        
     4612
    45944613    to=clock();
    45954614    /* Lifting process */
    45964615    F = MLifttwoIdeal(Gomega2, Gresult1, G);
    45974616    xtlift=xtlift+clock()-to;
    4598     idDelete(&Gresult1); 
    4599     idDelete(&Gomega2); 
     4617    idDelete(&Gresult1);
     4618    idDelete(&Gomega2);
    46004619    idDelete(&G);
    4601    
     4620
    46024621    rChangeCurrRing(new_ring);
    46034622    F1 = idrMoveR(F, oRing);
     
    46084627    xtred=xtred+clock()-to;
    46094628    idDelete(&F1);
    4610   } 
     4629  }
    46114630}
    46124631
     
    46174636  //Print("// pSetm_Error = (%d)", ErrorCheck());
    46184637  //Print("\n// ring ro = %s;", rString(currRing));
    4619  
     4638
    46204639  nnflow = 0;
    46214640  Xngleich = 0;
     
    46234642  xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0; xtextra=0;
    46244643  xftinput = clock();
    4625  
     4644
    46264645  ring  oldRing = currRing;
    46274646  int i, nV = currRing->N;
     
    46444663    && (Gw->m[i]->next!=NULL) /* len >=1 */
    46454664    && (Gw->m[i]->next->next!=NULL)) /* len >=2 */
    4646     { 
     4665    {
    46474666      intvec* iv_dp = MivUnit(nV);// define (1,1,...,1)
    46484667      intvec* Mdp;
    46494668
    46504669      if(MivSame(ivstart, iv_dp) != 1)
    4651         Mdp = MivWeightOrderdp(ivstart);
    4652       else 
    4653         Mdp = MivMatrixOrderdp(nV);
     4670        Mdp = MivWeightOrderdp(ivstart);
     4671      else
     4672        Mdp = MivMatrixOrderdp(nV);
    46544673
    46554674      Xsigma = Mfpertvector(I, Mdp);
     
    46684687  Xivlp = Mivlp(nV);
    46694688
    4670   if(MivComp(ivtarget, Xivlp)  != 1) 
     4689  if(MivComp(ivtarget, Xivlp)  != 1)
    46714690  {
    46724691    if (currRing->parameter != NULL)
     
    46984717  id_Delete(&I, oldRing);
    46994718  ring tRing = currRing;
    4700  
     4719
    47014720  if (currRing->parameter != NULL)
    47024721    DefRingPar(ivstart);
     
    47124731  ideal resF;
    47134732  ring helpRing = currRing;
    4714  
    4715   J = rec_fractal_call(J, 1, ivtarget); 
    4716 
    4717   rChangeCurrRing(oldRing); 
     4733
     4734  J = rec_fractal_call(J, 1, ivtarget);
     4735
     4736  rChangeCurrRing(oldRing);
    47184737  resF = idrMoveR(J, helpRing);
    47194738  idSkipZeroes(resF);
     
    47254744
    47264745#ifdef TIME_TEST
    4727   TimeStringFractal(xftinput, xftostd, xtif, xtstd, xtextra, 
    4728                     xtlift, xtred, xtnw);
     4746  TimeStringFractal(xftinput, xftostd, xtif, xtstd, xtextra,
     4747                    xtlift, xtred, xtnw);
    47294748
    47304749
     
    47324751  Print("\n// Overflow_Error? (%d)\n", Overflow_Error);
    47334752  Print("\n// the numbers of Overflow_Error (%d)", nnflow);
    4734 #endif 
    4735  
     4753#endif
     4754
    47364755  return(resF);
    47374756}
     
    47514770
    47524771  int nsteppert=0, i, nV = currRing->N, nwalk=0, npert_tmp=0;
    4753   int npert[2*nV];
     4772  int *npert=(int*)omAlloc(2*nV*sizeof(int));
    47544773  ideal Gomega, M,F,  G1, Gomega1, Gomega2, M1, F1;
    47554774  ring endRing, newRing, oldRing, lpRing;
     
    47744793  for(i=nV-1; i>=0; i--)
    47754794    (*target_weight)[i] = (*target_tmp)[i];
    4776  
     4795
    47774796  ring XXRing = currRing;
    47784797  newRing = currRing;
     
    47964815#ifdef REPRESENTATION_OF_SIGMA
    47974816  ideal Gw = MwalkInitialForm(G, curr_weight);
    4798    
     4817
    47994818  if(islengthpoly2(Gw)==1)
    48004819  {
    48014820    intvec* MDp;
    48024821    if(MivComp(curr_weight, iv_dp) == 1)
    4803       MDp = MatrixOrderdp(nV); //MivWeightOrderlp(iv_dp); 
     4822      MDp = MatrixOrderdp(nV); //MivWeightOrderlp(iv_dp);
    48044823    else
    48054824      MDp = MivWeightOrderlp(curr_weight);
    4806    
     4825
    48074826    curr_weight = RepresentationMatrix_Dp(G, MDp);
    48084827
     
    48104829
    48114830    ring exring = currRing;
    4812  
     4831
    48134832    if (currRing->parameter != NULL)
    48144833      DefRingPar(curr_weight);
    4815     else 
     4834    else
    48164835      VMrDefault(curr_weight);
    48174836    to=clock();
    48184837    Gw = idrMoveR(G, exring);
    4819     G = MstdCC(Gw); 
     4838    G = MstdCC(Gw);
    48204839    Gw = NULL;
    48214840    tostd=tostd+clock()-to;
     
    48234842    goto COMPUTE_NEW_VECTOR;
    48244843  }
    4825    
     4844
    48264845  idDelete(&Gw);
    48274846  delete iv_dp;
     
    48304849
    48314850  while(1)
    4832   { 
     4851  {
    48334852    to=clock();
    48344853    /* compute an initial form ideal of <G> w.r.t. "curr_vector" */
     
    48514870      VMrDefault(curr_weight);
    48524871
    4853     newRing = currRing; 
    4854     Gomega1 = idrMoveR(Gomega, oldRing); 
    4855    
     4872    newRing = currRing;
     4873    Gomega1 = idrMoveR(Gomega, oldRing);
     4874
    48564875    to=clock();
    48574876    /* compute a reduced Groebner basis of <Gomega> w.r.t. "newRing" */
     
    48604879#else
    48614880    M=kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight);
    4862     delete hilb_func;   
     4881    delete hilb_func;
    48634882#endif // BUCHBERGER_ALG
    48644883    tstd=tstd+clock()-to;
    48654884
    4866     /* change the ring to oldRing */ 
     4885    /* change the ring to oldRing */
    48674886    rChangeCurrRing(oldRing);
    48684887    M1 =  idrMoveR(M, newRing);
    4869     Gomega2 =  idrMoveR(Gomega1, newRing); 
     4888    Gomega2 =  idrMoveR(Gomega1, newRing);
    48704889
    48714890    to=clock();
    48724891    /* compute a representation of the generators of submod (M)
    4873        with respect to those of mod (Gomega). 
     4892       with respect to those of mod (Gomega).
    48744893       Gomega is a reduced Groebner basis w.r.t. the current ring */
    48754894    F = MLifttwoIdeal(Gomega2, M1, G);
    48764895    tlift=tlift+clock()-to;
    48774896
    4878     idDelete(&M1);   
    4879     idDelete(&Gomega2); 
     4897    idDelete(&M1);
     4898    idDelete(&Gomega2);
    48804899    idDelete(&G);
    4881    
    4882     /* change the ring to newRing */ 
     4900
     4901    /* change the ring to newRing */
    48834902    rChangeCurrRing(newRing);
    48844903    F1 = idrMoveR(F, oldRing);
    48854904
    48864905    to=clock();
    4887     /* reduce the Groebner basis <G> w.r.t. new ring */   
     4906    /* reduce the Groebner basis <G> w.r.t. new ring */
    48884907    G = kInterRedCC(F1, NULL);
    48894908    tred=tred+clock()-to;
    48904909    idDelete(&F1);
    48914910
    4892    
     4911
    48934912  COMPUTE_NEW_VECTOR:
    48944913    newRing = currRing;
     
    48994918    next_weight = MwalkNextWeightCC(curr_weight,target_weight, G);
    49004919    tnw=tnw+clock()-to;
    4901 #ifdef PRINT_VECTORS 
     4920#ifdef PRINT_VECTORS
    49024921    MivString(curr_weight, target_weight, next_weight);
    49034922#endif
    49044923
    4905  
    4906     /* check whether the computed intermediate weight vector in 
     4924
     4925    /* check whether the computed intermediate weight vector in
    49074926       the correct cone is, since sometimes it is very big e.g. s7, cyc7.
    4908        If it is NOT in the cone, then one has directly to compute 
     4927       If it is NOT in the cone, then one has directly to compute
    49094928       a reduced Groebner basis with respect to the lexicographic ordering
    49104929       for the known Groebner basis that it is computed in the last step.
     
    49424961      /*apply kStd or LastGB to compute  a lex. red. Groebner basis of <G>*/
    49434962      if(nP == 0 || MivSame(target_tmp, iv_lp) == 0){
    4944         //Print("\n\n// calls \"std in ring r_%d = %s;", nwalk, rString(currRing)); 
     4963        //Print("\n\n// calls \"std in ring r_%d = %s;", nwalk, rString(currRing));
    49454964        G = MstdCC(G1);//no result for qnt1
    49464965      }
    49474966      else {
    4948         rChangeCurrRing(newRing);
    4949         G1 = idrMoveR(G1, lpRing);
    4950        
    4951         //Print("\n\n// calls \"LastGB\" (%d) to compute a GB", nV-1);
    4952         G = LastGB(G1, curr_weight, nV-1); //no result for kats7
    4953        
    4954         rChangeCurrRing(lpRing);
    4955         G = idrMoveR(G, newRing);
     4967        rChangeCurrRing(newRing);
     4968        G1 = idrMoveR(G1, lpRing);
     4969
     4970        //Print("\n\n// calls \"LastGB\" (%d) to compute a GB", nV-1);
     4971        G = LastGB(G1, curr_weight, nV-1); //no result for kats7
     4972
     4973        rChangeCurrRing(lpRing);
     4974        G = idrMoveR(G, newRing);
    49564975      }
    49574976      textra=clock()-to;
     
    49594978      npert_tmp = nwalk;
    49604979      endwalks ++;
    4961       break;     
    4962     } 
    4963    
    4964     /* check whether the computed Groebner basis a really Groebner basis is. 
    4965        if no, we perturb the target vector with the maximal "perturbation" 
     4980      break;
     4981    }
     4982
     4983    /* check whether the computed Groebner basis a really Groebner basis is.
     4984       if no, we perturb the target vector with the maximal "perturbation"
    49664985       degree.*/
    4967     if(MivComp(next_weight, target_weight) == 1 || 
     4986    if(MivComp(next_weight, target_weight) == 1 ||
    49684987       MivComp(next_weight, curr_weight) == 1 )
    4969     { 
     4988    {
    49704989      //Print("\n//ring r_%d = %s;", nwalk, rString(currRing));
    49714990
     
    49744993      npert[endwalks]=nwalk-npert_tmp;
    49754994      npert_tmp = nwalk;
    4976      
     4995
    49774996      endwalks ++;
    49784997
    4979       /*it is very important if the walk only uses one step, e.g. Fate, liu*/ 
     4998      /*it is very important if the walk only uses one step, e.g. Fate, liu*/
    49804999      if(endwalks == 1 && MivComp(next_weight, curr_weight) == 1){
    49815000        rChangeCurrRing(XXRing);
     
    49835002        goto FINISH;
    49845003      }
    4985       H0 = idHead(G); 
     5004      H0 = idHead(G);
    49865005
    49875006      if(MivSame(target_tmp, iv_lp) == 1)
     
    49955014        else
    49965015          VMrDefault(target_tmp);
    4997      
    4998       lpRing = currRing; 
    4999       Glp = idrMoveR(G, newRing); 
     5016
     5017      lpRing = currRing;
     5018      Glp = idrMoveR(G, newRing);
    50005019      H2 = idrMoveR(H0, newRing);
    5001      
     5020
    50025021      /* Apply Lemma 2.2 in Collart et. al (1997) to check whether
    50035022         cone(k-1) is equal to cone(k) */
     
    50075026        poly t;
    50085027        if((t=pSub(pHead(Glp->m[i]), pCopy(H2->m[i]))) != NULL)
    5009         {   
     5028        {
    50105029          pDelete(&t);
    50115030          idDelete(&H2);//5.5.02
     
    50195038
    50205039      if(nGB == 1)
    5021       {       
     5040      {
    50225041        G = Glp;
    50235042        Glp = NULL;
     
    50375056        {
    50385057          Overflow_Error = FALSE;
    5039          
    5040           for(i=0; i<nV; i++)
    5041             (*vector_tmp)[i] = (*target_weight)[i];
    5042 
    5043           delete target_weight;
    5044           target_weight = MPertVectors(Glp, Mlp, nV);             
    5045 
    5046           if(MivComp(vector_tmp, target_weight)==1)
    5047           {
    5048             //PrintS("\n// The old and new representaion vector are the same!!");
    5049             G = Glp;
    5050             newRing = currRing;
    5051             goto OMEGA_OVERFLOW_TRAN_NEW;
    5052           }
    5053 
    5054           if(Overflow_Error == TRUE)
     5058
     5059          for(i=0; i<nV; i++)
     5060            (*vector_tmp)[i] = (*target_weight)[i];
     5061
     5062          delete target_weight;
     5063          target_weight = MPertVectors(Glp, Mlp, nV);
     5064
     5065          if(MivComp(vector_tmp, target_weight)==1)
     5066          {
     5067            //PrintS("\n// The old and new representaion vector are the same!!");
     5068            G = Glp;
     5069            newRing = currRing;
     5070            goto OMEGA_OVERFLOW_TRAN_NEW;
     5071           }
     5072
     5073          if(Overflow_Error == TRUE)
    50555074          {
    50565075            rChangeCurrRing(newRing);
    50575076            G = idrMoveR(Glp, lpRing);
    5058             goto OMEGA_OVERFLOW_TRAN_NEW;
     5077            goto OMEGA_OVERFLOW_TRAN_NEW;
    50595078          }
    5060          
     5079
    50615080          plength3 = TRUE;
    50625081          pDelete(&p);
     
    50725091        goto TRAN_LIFTING;
    50735092      }
    5074      
     5093
    50755094
    50765095      npertstep = nwalk;
    50775096      nwalkpert = 1;
    50785097      nsteppert ++;
    5079      
     5098
    50805099      /*
    5081       Print("\n// Subroutine needs (%d) steps.", nwalk); 
    5082       idElements(Glp, "last G in walk:"); 
     5100      Print("\n// Subroutine needs (%d) steps.", nwalk);
     5101      idElements(Glp, "last G in walk:");
    50835102      PrintS("\n//****************************************");
    50845103      Print("\n// Perturb the original target vector (%d): ", nsteppert);
    5085       ivString(target_weight, "new target"); 
    5086       PrintS("\n//****************************************\n"); 
     5104      ivString(target_weight, "new target");
     5105      PrintS("\n//****************************************\n");
    50875106      */
    50885107      rChangeCurrRing(newRing);
     
    50905109
    50915110      delete next_weight;
    5092      
     5111
    50935112      //Print("\n// ring rNEW = %s;", rString(currRing));
    50945113      goto COMPUTE_NEW_VECTOR;
     
    50985117    for(i=nV-1; i>=0; i--)
    50995118      (*curr_weight)[i] = (*next_weight)[i];
    5100    
     5119
    51015120    delete next_weight;
    51025121  }//while
     
    51065125  G = idrMoveR(G, lpRing);
    51075126
    5108  FINISH: 
     5127 FINISH:
    51095128  delete ivNull;
    51105129  delete next_weight;
    51115130  delete iv_lp;
     5131  omFree(npert);
    51125132
    51135133#ifdef TIME_TEST
    5114   Print("\n// Computation took %d steps and %.2f sec", 
     5134  Print("\n// Computation took %d steps and %.2f sec",
    51155135        nwalk, ((double) (clock()-mtim)/1000000));
    51165136
     
    51335153  clock_t tinput=clock();
    51345154  int i, nV = currRing->N;
    5135   int nwalk=0, endwalks=0, ntestwinC=1; 
     5155  int nwalk=0, endwalks=0, ntestwinC=1;
    51365156  int tp_deg_tmp = tp_deg;
    51375157  ideal Gomega, M, F, G, M1, F1, Gomega1, Gomega2, G1;
    51385158  ring endRing, newRing, oldRing, TargetRing;
    51395159  intvec* next_weight;
    5140   intvec* ivNull = new intvec(nV); 
     5160  intvec* ivNull = new intvec(nV);
    51415161  intvec* extra_curr_weight = new intvec(nV);
    51425162
    51435163  ring YXXRing = currRing;
    5144  
     5164
    51455165  intvec* iv_M_dpp = MivMatrixOrderlp(nV);
    51465166  intvec* target_weight;// = Mivlp(nV);
     
    51705190    if(Overflow_Error == FALSE)
    51715191      break;
    5172  
     5192
    51735193    Overflow_Error = TRUE;
    51745194    tp_deg --;
     
    51825202  //  Print("\n// tp_deg = %d", tp_deg);
    51835203  // ivString(target_weight, "pert target");
    5184  
    5185   delete iv_M_dpp; 
     5204
     5205  delete iv_M_dpp;
    51865206  intvec* hilb_func;
    51875207
     
    51965216
    51975217  while(1)
    5198   { 
     5218  {
    51995219    nwalk ++;
    52005220    nstep ++;
    52015221
    5202     if(nwalk==1) 
     5222    if(nwalk==1)
    52035223      goto FIRST_STEP;
    52045224
     
    52315251      VMrDefault(curr_weight);
    52325252
    5233     newRing = currRing; 
     5253    newRing = currRing;
    52345254    Gomega1 = idrMoveR(Gomega, oldRing);
    5235    
    5236 #ifdef ENDWALKS   
    5237     if(endwalks == 1)   
    5238     {   
    5239       Print("\n//  it is  %d-th step!!", nwalk); 
    5240       idElements(Gomega1, "Gw"); 
    5241       PrintS("\n//  compute a rGB of Gw:"); 
    5242     } 
     5255
     5256#ifdef ENDWALKS
     5257    if(endwalks == 1)
     5258    {
     5259      Print("\n//  it is  %d-th step!!", nwalk);
     5260      idElements(Gomega1, "Gw");
     5261      PrintS("\n//  compute a rGB of Gw:");
     5262    }
    52435263#endif
    52445264
     
    52495269#else
    52505270    M=kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight);
    5251     delete hilb_func;   
     5271    delete hilb_func;
    52525272#endif // BUCHBERGER_ALG
    52535273    xtstd=xtstd+clock()-to;
     
    52565276    rChangeCurrRing(oldRing);
    52575277    M1 =  idrMoveR(M, newRing);
    5258     Gomega2 =  idrMoveR(Gomega1, newRing); 
    5259     to=clock();   
     5278    Gomega2 =  idrMoveR(Gomega1, newRing);
     5279    to=clock();
    52605280
    52615281    // if(endwalks == 1) PrintS("\n//  Lifting is still working:");
     
    52665286    xtlift=xtlift+clock()-to;
    52675287
    5268     idDelete(&M1); 
    5269     idDelete(&Gomega2); 
     5288    idDelete(&M1);
     5289    idDelete(&Gomega2);
    52705290    idDelete(&G);
    52715291
    5272     /* change the ring to newRing */ 
     5292    /* change the ring to newRing */
    52735293    rChangeCurrRing(newRing);
    52745294    F1 = idrMoveR(F, oldRing);
     
    52785298    G = kInterRedCC(F1, NULL);
    52795299    xtred=xtred+clock()-to;
    5280     idDelete(&F1); 
     5300    idDelete(&F1);
    52815301
    52825302    if(endwalks == 1)
    52835303      break;
    5284    
     5304
    52855305  FIRST_STEP:
    52865306    Overflow_Error=FALSE;
     
    52895309    next_weight = MkInterRedNextWeight(curr_weight,target_weight, G);
    52905310    xtnw=xtnw+clock()-to;
    5291 #ifdef PRINT_VECTORS 
     5311#ifdef PRINT_VECTORS
    52925312    MivString(curr_weight, target_weight, next_weight);
    52935313#endif
     
    52975317      delete next_weight;
    52985318
    5299       LASTGB_ALT1: 
     5319      LASTGB_ALT1:
    53005320      if(tp_deg > 1){
    5301         nOverflow_Error = Overflow_Error;
    5302         tproc = tproc+clock()-tinput;
     5321        nOverflow_Error = Overflow_Error;
     5322        tproc = tproc+clock()-tinput;
    53035323        /*
    5304           Print("\n// A subroutine takes %d steps and calls \"Mpwalk\" (1,%d):",
    5305           nwalk, tp_deg-1);
    5306         */
     5324          Print("\n// A subroutine takes %d steps and calls \"Mpwalk\" (1,%d):",
     5325          nwalk, tp_deg-1);
     5326        */
    53075327        G1 = Mpwalk_MAltwalk1(G, curr_weight, tp_deg-1);
    53085328        goto MPW_Finish;
     
    53115331        newRing = currRing;
    53125332        ntestwinC = 0;
    5313         break; 
     5333        break;
    53145334      }
    53155335    }
    53165336
    53175337    if(MivComp(next_weight, ivNull) == 1)
    5318     { 
     5338    {
    53195339      newRing = currRing;
    53205340      delete next_weight;
     
    53455365  {
    53465366    PrintS("\n// The perturbed target vector doesn't STAY in the correct cone!!");
    5347     if(tp_deg == 1){ 
     5367    if(tp_deg == 1){
    53485368      //Print("\n// subroutine takes %d steps and applys \"std\"", nwalk);
    53495369      to=clock();
     
    53585378      tproc = tproc+clock()-tinput;
    53595379      /*
    5360         Print("\n// B subroutine takes %d steps and calls \"Mpwalk\" (1,%d) :",
    5361             nwalk,  tp_deg-1);
     5380        Print("\n// B subroutine takes %d steps and calls \"Mpwalk\" (1,%d) :",
     5381            nwalk,  tp_deg-1);
    53625382      */
    53635383      G1 = Mpwalk_MAltwalk1(G1, curr_weight, tp_deg-1);
    53645384    }
    5365   }   
     5385  }
    53665386
    53675387 MPW_Finish:
     
    53695389  rChangeCurrRing(YXXRing);
    53705390  ideal result = idrMoveR(G1, newRing);
    5371    
     5391
    53725392  delete ivNull;
    53735393  delete target_weight;
     
    53755395  /*
    53765396  Print("\n// \"Mpwalk\" (1,%d) took %d steps and %.2f sec. Overflow_Error (%d)", tp_deg,
    5377         nwalk, ((double) clock()-tinput)/1000000, nOverflow_Error);
     5397        nwalk, ((double) clock()-tinput)/1000000, nOverflow_Error);
    53785398  */
    53795399
     
    53975417  int i, nV = currRing->N;
    53985418  int nwalk=0, endwalks=0;
    5399   int op_tmp = op_deg; 
     5419  int op_tmp = op_deg;
    54005420  ideal Gomega, M, F, G, G1, Gomega1, Gomega2, M1, F1;
    54015421  ring endRing, newRing, oldRing, TargetRing;
    54025422  intvec* next_weight;
    54035423  intvec* iv_M_dp;
    5404   intvec* ivNull = new intvec(nV); 
     5424  intvec* ivNull = new intvec(nV);
    54055425  intvec* iv_dp = MivUnit(nV);// define (1,1,...,1)
    54065426  intvec* exivlp = Mivlp(nV);
     
    54155435    (*last_omega)[i] = 1;
    54165436  (*last_omega)[0] = 10000;
    5417  
     5437
    54185438  ring XXRing = currRing;
    5419  
     5439
    54205440  to=clock();
    54215441  /* compute a pertubed weight vector of the original weight vector.
    54225442     The perturbation degree is recursive decrease until that vector
    54235443     stays inn the correct cone. */
    5424   while(1) 
     5444  while(1)
    54255445  {
    54265446    if(Overflow_Error == FALSE)
     
    54415461        else
    54425462          VMrDefault(cw_tmp);
    5443        
     5463
    54445464        G = idrMoveR(Go, XXRing);
    54455465        G = MstdCC(G);
     
    54575477    if(Overflow_Error == FALSE)
    54585478      break;
    5459    
     5479
    54605480    Overflow_Error = TRUE;
    54615481    op_deg --;
     
    54715491
    54725492  while(1)
    5473   { 
     5493  {
    54745494    nwalk ++;
    54755495    nstep ++;
     
    54855505        (*curr_weight)[i] = (*extra_curr_weight)[i];
    54865506      delete extra_curr_weight;
    5487      
     5507
    54885508      newRing = currRing;
    54895509      goto MSTD_ALT1;
     
    55055525      VMrDefault(curr_weight);
    55065526
    5507     newRing = currRing; 
    5508     Gomega1 = idrMoveR(Gomega, oldRing); 
    5509    
     5527    newRing = currRing;
     5528    Gomega1 = idrMoveR(Gomega, oldRing);
     5529
    55105530    to=clock();
    55115531    /* compute a reduced Groebner basis of <Gomega> w.r.t. "newRing" */
     
    55145534#else
    55155535    M=kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight);
    5516     delete hilb_func;   
     5536    delete hilb_func;
    55175537#endif // BUCHBERGER_ALG
    55185538    xtstd=xtstd+clock()-to;
    55195539
    5520     /* change the ring to oldRing */ 
     5540    /* change the ring to oldRing */
    55215541    rChangeCurrRing(oldRing);
    55225542    M1 =  idrMoveR(M, newRing);
     
    55295549    xtlift=xtlift+clock()-to;
    55305550
    5531     idDelete(&M1); 
    5532     idDelete(&Gomega2); 
    5533     idDelete(&G);   
    5534 
    5535    /* change the ring to newRing */ 
     5551    idDelete(&M1);
     5552    idDelete(&Gomega2);
     5553    idDelete(&G);
     5554
     5555   /* change the ring to newRing */
    55365556    rChangeCurrRing(newRing);
    55375557    F1 = idrMoveR(F, oldRing);
    55385558
    55395559    to=clock();
    5540     /* reduce the Groebner basis <G> w.r.t. new ring */   
     5560    /* reduce the Groebner basis <G> w.r.t. new ring */
    55415561    G = kInterRedCC(F1, NULL);
    55425562    xtred=xtred+clock()-to;
     
    55515571    next_weight = MkInterRedNextWeight(curr_weight,target_weight, G);
    55525572    xtnw=xtnw+clock()-to;
    5553 #ifdef PRINT_VECTORS 
     5573#ifdef PRINT_VECTORS
    55545574    MivString(curr_weight, target_weight, next_weight);
    55555575#endif
    5556    
     5576
    55575577    if(Overflow_Error == TRUE)
    55585578    {
    55595579      newRing = currRing;
    5560      
     5580
    55615581      if (currRing->parameter != NULL)
    55625582        DefRingPar(target_weight);
     
    55645584        VMrDefault(target_weight);
    55655585
    5566       F1 = idrMoveR(G, newRing); 
     5586      F1 = idrMoveR(G, newRing);
    55675587      G = MstdCC(F1);
    55685588      idDelete(&F1);
     
    55875607      {
    55885608        MSTD_ALT1:
    5589         nOverflow_Error = Overflow_Error;
    5590         tproc = clock()-xftinput;
    5591         /*
    5592         Print("\n//  main routine takes %d steps and calls \"Mpwalk\" (1,%d):", 
    5593               nwalk,  tp_deg); 
    5594         */
    5595         // compute the red. GB of <G> w.r.t. the lex order by
    5596         // the "recursive-modified" perturbation walk alg (1,tp_deg) 
     5609        nOverflow_Error = Overflow_Error;
     5610        tproc = clock()-xftinput;
     5611        /*
     5612        Print("\n//  main routine takes %d steps and calls \"Mpwalk\" (1,%d):",
     5613              nwalk,  tp_deg);
     5614        */
     5615        // compute the red. GB of <G> w.r.t. the lex order by
     5616        // the "recursive-modified" perturbation walk alg (1,tp_deg)
    55975617        G = Mpwalk_MAltwalk1(G, curr_weight, tp_deg);
    55985618        delete next_weight;
     
    56215641#ifdef TIME_TEST
    56225642
    5623   Print("\n// \"Main procedure\"  took %d steps, %.2f sec. and Overflow_Error(%d)", 
    5624         nwalk, ((double) tproc)/1000000, nOverflow_Error);
     5643  Print("\n// \"Main procedure\"  took %d steps, %.2f sec. and Overflow_Error(%d)",
     5644        nwalk, ((double) tproc)/1000000, nOverflow_Error);
    56255645
    56265646  TimeStringFractal(xftinput, tostd, xtif, xtstd,xtextra, xtlift, xtred, xtnw);
     
    56295649  Print("\n// Overflow_Error? (%d)", Overflow_Error);
    56305650  Print("\n// Awalk1 took %d steps.\n", nstep);
    5631 #endif 
     5651#endif
    56325652  return(result);
    56335653}
Note: See TracChangeset for help on using the changeset viewer.