Changeset 74fe358 in git


Ignore:
Timestamp:
Aug 17, 2015, 5:19:52 PM (9 years ago)
Author:
Stephan Oberfranz <oberfran@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '98550b669234b32be762076c32b3be2c35188ac4')
Children:
36b81ac0b97d2f019093a024dc770731cfabfe17
Parents:
654a230847a8318a2a297f1520550f19f34a4401e3e12979d70ffe1c897b47e9826594e9099b886a
Message:
update

Merge branch 'spielwiese' of github.com:Singular/Sources into spielwiese
Files:
6 added
22 edited

Legend:

Unmodified
Added
Removed
  • Singular/LIB/dmodloc.lib

    r654a23 r74fe358  
    6464
    6565dmodGeneralAssumptionCheck();   check general assumptions
    66 safeVarName(s);    finds a free name to use for a new variable
    6766extendWeyl(S);     extends basering (Weyl algebra) by given vars
    6867polyVars(f,v);     checks whether f contains only variables indexed by v
     
    188187
    189188
    190 proc safeVarName (string s)
     189static proc safeVarName (string s)
    191190"
    192191USAGE:    safeVarName(s);  s string
  • Singular/LIB/grwalk.lib

    re3e129 r74fe358  
    255255}
    256256
    257 proc gwalk(ideal Go, list #)
    258 "SYNTAX: gwalk(ideal i);
    259          gwalk(ideal i, intvec v, intvec w);
     257proc gwalk(ideal Go, int reduction,int printout, list #)
     258"SYNTAX: gwalk(ideal i, int reduction, int printout);
     259         gwalk(ideal i, int reduction, int printout, intvec v, intvec w);
    260260TYPE:    ideal
    261261PURPOSE: compute the standard basis of the ideal, calculated via
     
    274274   string ord_str =   OSCTW[2];
    275275   intvec curr_weight   =   OSCTW[3]; /* original weight vector */
    276    intvec target_weight =   OSCTW[4]; /* terget weight vector */
     276   intvec target_weight =   OSCTW[4]; /* target weight vector */
    277277   kill OSCTW;
    278278   option(redSB);
     
    284284   //print("//** help ring = " + string(basering));
    285285   ideal G = fetch(xR, Go);
    286    G = system("Mwalk", G, curr_weight, target_weight,basering);
     286   G = system("Mwalk", G, curr_weight, target_weight,basering,reduction,printout);
    287287
    288288   setring xR;
     
    299299  //** compute a Groebner basis of I w.r.t. lp.
    300300  ring r = 32003,(z,y,x), lp;
    301   ideal I = y3+xyz+y2z+xz3, 3+xy+x2y+y2z;
    302   gwalk(I);
     301  ideal I = zy2+yx2+yx+3,
     302            z3x+y3+zyx-yx2-yx-3,
     303            z2yx3-y5+z2yx2+y3x2+y2x3+y3x+y2x2+3z2x+3y2+3yx,
     304            zyx5+y6-y4x2-y3x3+2zyx4-y4x-y3x2+zyx3-3z2yx+3zx3-3y3-3y2x+3zx2,
     305            yx7-y7+y5x2+y4x3+3yx6+y5x+y4x2+3yx5-6zyx3+yx4+3x5+3y4+3y3x-6zyx2+6x4+3x3-9zx;
     306  gwalk(I,0,1);
    303307}
    304308
     
    346350}
    347351
    348 proc fwalk(ideal Go, list #)
    349 "SYNTAX: fwalk(ideal i);
    350          fwalk(ideal i, intvec v, intvec w);
     352proc fwalk(ideal Go, int reduction, int printout, list #)
     353"SYNTAX: fwalk(ideal i,int reductioin);
     354         fwalk(ideal i, int reduction intvec v, intvec w);
    351355TYPE:    ideal
    352356PURPOSE: compute the standard basis of the ideal w.r.t. the
     
    372376
    373377   ideal G = fetch(xR, Go);
    374    G = system("Mfwalk", G, curr_weight, target_weight);
     378   G = system("Mfwalk", G, curr_weight, target_weight, reduction, printout);
    375379
    376380   setring xR;
     
    387391    ring r = 32003,(z,y,x), lp;
    388392    ideal I = y3+xyz+y2z+xz3, 3+xy+x2y+y2z;
    389     fwalk(I);
     393    int reduction = 1;
     394    int printout = 1;
     395    fwalk(I,reduction,printout);
    390396}
    391397
     
    437443}
    438444
    439 proc pwalk(ideal Go, int n1, int n2, list #)
    440 "SYNTAX: pwalk(int d, ideal i, int n1, int n2);
    441          pwalk(int d, ideal i, int n1, int n2, intvec v, intvec w);
     445proc pwalk(ideal Go, int n1, int n2, int reduction, int printout, list #)
     446"SYNTAX: pwalk(int d, ideal i, int n1, int n2, int reduction, int printout);
     447         pwalk(int d, ideal i, int n1, int n2, int reduction, int printout, intvec v, intvec w);
    442448TYPE:    ideal
    443449PURPOSE: compute the standard basis of the ideal, calculated via
     
    477483  ideal G = fetch(xR, Go);
    478484
    479   G = system("Mpwalk", G, n1, n2, curr_weight, target_weight,nP);
    480 
     485  G = system("Mpwalk",G,n1,n2,curr_weight,target_weight,nP,reduction,printout);
     486 
    481487  setring xR;
    482   //kill Go;
     488  //kill Go; //unused
    483489
    484490  keepring basering;
     
    492498    ring r = 32003,(z,y,x), lp;
    493499    ideal I = y3+xyz+y2z+xz3, 3+xy+x2y+y2z;
    494     //I = std(I);
    495     //ring rr = 32003,(z,y,x),lp;
    496     //ideal I = fetch(r,I);
    497     pwalk(I,2,2);
     500    int reduction = 1;
     501    int printout = 2;
     502    pwalk(I,2,2,reduction,printout);
    498503}
    499504
  • Singular/LIB/modwalk.lib

    • Property mode changed from 100644 to 100755
    re3e129 r74fe358  
    1616
    1717PROCEDURES:
    18 modWalk(ideal,int,int[,int,int,int,int]);        standard basis conversion of I using modular methods (chinese remainder)
     18
     19modWalk(I,#);                   standard basis conversion of I by Groebner Walk using modular methods
     20modrWalk(I,radius,pertdeg,#);   standard basis conversion of I by Random Walk using modular methods
     21modfWalk(I,#);                  standard basis conversion of I by Fractal Walk using modular methods
     22modfrWalk(I,radius,#);          standard basis conversion of I by Random Fractal Walk using modular methods
    1923";
    2024
    21 LIB "poly.lib";
    22 LIB "ring.lib";
    23 LIB "parallel.lib";
    2425LIB "rwalk.lib";
    2526LIB "grwalk.lib";
    26 LIB "modstd.lib";
    27 
    28 
    29 ////////////////////////////////////////////////////////////////////////////////
    30 
    31 static proc modpWalk(def II, int p, int variant, list #)
    32 "USAGE:  modpWalk(I,p,#); I ideal, p integer, variant integer
    33 ASSUME:  If size(#) > 0, then
    34            #[1] is an intvec describing the current weight vector
    35            #[2] is an intvec describing the target weight vector
    36 RETURN:  ideal - a standard basis of I mod p, integer - p
    37 NOTE:    The procedure computes a standard basis of the ideal I modulo p and
    38          fetches the result to the basering.
    39 EXAMPLE: example modpWalk; shows an example
    40 "
    41 {
    42   option(redSB);
    43   int k,nvar@r;
    44   def R0 = basering;
    45   string ordstr_R0 = ordstr(R0);
    46   list rl = ringlist(R0);
    47   int sizerl = size(rl);
    48   int neg = 1 - attrib(R0,"global");
    49   if(typeof(II) == "ideal")
    50   {
    51     ideal I = II;
     27LIB "modular.lib";
     28
     29proc modWalk(ideal I, list #)
     30"USAGE:   modWalk(I, [, v, w]); I ideal, v intvec, w intvec
     31RETURN:   a standard basis of I
     32NOTE:     The procedure computes a standard basis of I (over the rational
     33          numbers) by using modular methods.
     34SEE ALSO: modular
     35EXAMPLE:  example modWalk; shows an example"
     36{
     37    /* read optional parameter */
     38    if (size(#) > 0) {
     39        if (size(#) == 1) {
     40            intvec w = #[1];
     41        }
     42        if (size(#) == 2) {
     43            intvec v = #[1];
     44            intvec w = #[2];
     45        }
     46        if (size(#) > 2 || typeof(#[1]) != "intvec") {
     47            ERROR("wrong optional parameter");
     48        }
     49    }
     50
     51    /* save options */
     52    intvec opt = option(get);
     53    option(redSB);
     54
     55    /* set additional parameters */
     56    int reduction = 1;
     57    int printout = 0;
     58
     59    /* call modular() */
     60    if (size(#) > 0) {
     61        I = modular("gwalk", list(I,reduction,printout,#));
     62    }
     63    else {
     64        I = modular("gwalk", list(I,reduction,printout));
     65    }
     66
     67    /* return the result */
     68    attrib(I, "isSB", 1);
     69    option(set, opt);
     70    return(I);
     71}
     72example
     73{
     74    "EXAMPLE:";
     75    echo = 2;
     76    ring R1 = 0, (x,y,z,t), dp;
     77    ideal I = 3x3+x2+1, 11y5+y3+2, 5z4+z2+4;
     78    I = std(I);
     79    ring R2 = 0, (x,y,z,t), lp;
     80    ideal I = fetch(R1, I);
     81    ideal J = modWalk(I);
     82    J;
     83}
     84
     85proc modrWalk(ideal I, int radius, int pertdeg, list #)
     86"USAGE:   modrWalk(I, radius, pertdeg[, v, w]);
     87          I ideal, radius int, pertdeg int, v intvec, w intvec
     88RETURN:   a standard basis of I
     89NOTE:     The procedure computes a standard basis of I (over the rational
     90          numbers) by using modular methods.
     91SEE ALSO: modular
     92EXAMPLE:  example modrWalk; shows an example"
     93{
     94    /* read optional parameter */
     95    if (size(#) > 0) {
     96        if (size(#) == 1) {
     97            intvec w = #[1];
     98        }
     99        if (size(#) == 2) {
     100            intvec v = #[1];
     101            intvec w = #[2];
     102        }
     103        if (size(#) > 2 || typeof(#[1]) != "intvec") {
     104            ERROR("wrong optional parameter");
     105        }
     106    }
     107
     108    /* save options */
     109    intvec opt = option(get);
     110    option(redSB);
     111
     112    /* set additional parameters */
     113    int reduction = 1;
     114    int printout = 0;
     115
     116    /* call modular() */
     117    if (size(#) > 0) {
     118        I = modular("rwalk", list(I,radius,pertdeg,reduction,printout,#));
     119    }
     120    else {
     121        I = modular("rwalk", list(I,radius,pertdeg,reduction,printout));
     122    }
     123
     124    /* return the result */
     125    attrib(I, "isSB", 1);
     126    option(set, opt);
     127    return(I);
     128}
     129example
     130{
     131    "EXAMPLE:";
     132    echo = 2;
     133    ring R1 = 0, (x,y,z,t), dp;
     134    ideal I = 3x3+x2+1, 11y5+y3+2, 5z4+z2+4;
     135    I = std(I);
     136    ring R2 = 0, (x,y,z,t), lp;
     137    ideal I = fetch(R1, I);
    52138    int radius = 2;
    53     int pert_deg = 2;
    54   }
    55   if(typeof(II) == "list" && typeof(II[1]) == "ideal")
    56   {
    57     ideal I = II[1];
    58     if(size(II) == 2)
    59     {
    60       int radius = II[2];
    61       int pert_deg = 2;
    62     }
    63     if(size(II) == 3)
    64     {
    65       int radius = II[2];
    66       int pert_deg = II[3];
    67     }
    68   }
    69   rl[1] = p;
    70   int h = homog(I);
    71   def @r = ring(rl);
    72   setring @r;
    73   ideal i = fetch(R0,I);
    74   string order;
    75   if(system("nblocks") <= 2)
    76   {
    77     if(find(ordstr_R0, "M") + find(ordstr_R0, "lp") + find(ordstr_R0, "rp") <= 0)
    78     {
    79       order = "simple";
    80     }
    81   }
    82 
    83 //-------------------------  make i homogeneous  -----------------------------
    84   if(!mixedTest() && !h)
    85   {
    86     if(!((find(ordstr_R0, "M") > 0) || (find(ordstr_R0, "a") > 0) || neg))
    87     {
    88       if(!((order == "simple") || (sizerl > 4)))
    89       {
    90         list rl@r = ringlist(@r);
    91         nvar@r = nvars(@r);
    92         intvec w;
    93         for(k = 1; k <= nvar@r; k++)
    94         {
    95           w[k] = deg(var(k));
    96         }
    97         w[nvar@r + 1] = 1;
    98         rl@r[2][nvar@r + 1] = "homvar";
    99         rl@r[3][2][2] = w;
    100         def HomR = ring(rl@r);
    101         setring HomR;
    102         ideal i = imap(@r, i);
    103         i = homog(i, homvar);
    104       }
    105     }
    106   }
    107 
    108 //-------------------------  compute a standard basis mod p  -----------------------------
    109 
    110   if(variant == 1)
    111   {
    112     if(size(#)>0)
    113     {
    114       i = rwalk(i,radius,pert_deg,#);
    115      // rwalk(i,radius,pert_deg,#); std(i);
    116     }
    117     else
    118     {
    119       i = rwalk(i,radius,pert_deg);
    120     }
    121   }
    122   if(variant == 2)
    123   {
    124     if(size(#) == 2)
    125     {
    126       i = gwalk(i,#);
    127     }
    128     else
    129     {
    130       i = gwalk(i);
    131     }
    132   }
    133   if(variant == 3)
    134   {
    135     if(size(#) == 2)
    136     {
    137       i = frandwalk(i,radius,#);
    138     }
    139     else
    140     {
    141       i = frandwalk(i,radius);
    142     }
    143   }
    144   if(variant == 4)
    145   {
    146     if(size(#) == 2)
    147     {
    148       i=fwalk(i,#);
    149     }
    150     else
    151     {
    152       i=fwalk(i);
    153     }
    154   }
    155   if(variant == 5)
    156   {
    157     if(size(#) == 2)
    158     {
    159      i=prwalk(i,radius,pert_deg,pert_deg,#);
    160     }
    161     else
    162     {
    163       i=prwalk(i,radius,pert_deg,pert_deg);
    164     }
    165   }
    166   if(variant == 6)
    167   {
    168     if(size(#) == 2)
    169     {
    170       i=pwalk(i,pert_deg,pert_deg,#);
    171     }
    172     else
    173     {
    174       i=pwalk(i,pert_deg,pert_deg);
    175     }
    176   }
    177 
    178   if(!mixedTest() && !h)
    179   {
    180     if(!((find(ordstr_R0, "M") > 0) || (find(ordstr_R0, "a") > 0) || neg))
    181     {
    182       if(!((order == "simple") || (sizerl > 4)))
    183       {
    184         i = subst(i, homvar, 1);
    185         i = simplify(i, 34);
    186         setring @r;
    187         i = imap(HomR, i);
    188         i = interred(i);
    189         kill HomR;
    190       }
    191     }
    192   }
    193   setring R0;
    194   return(list(fetch(@r,i),p));
    195 }
    196 example
    197 {
    198   "EXAMPLE:"; echo = 2;
    199   option(redSB);
    200 
    201   int p = 181;
    202   intvec a = 2,1,3,4;
    203   intvec b = 1,9,1,1;
    204   ring ra = 0,x(1..4),(a(a),lp);
    205   ideal I = std(cyclic(4));
    206   ring rb = 0,x(1..4),(a(b),lp);
    207   ideal I = imap(ra,I);
    208   modpWalk(I,p,1,a,b);
    209   std(I);
    210 }
    211 
    212 ////////////////////////////////////////////////////////////////////////////////
    213 
    214 proc modWalk(def II, int variant, list #)
    215 "USAGE:  modWalk(II); II ideal or list(ideal,int)
    216 ASSUME:  If variant =
    217 @*       - 1 the Random Walk algorithm with radius II[2] is applied
    218            to II[1] if II = list(ideal, int). It is applied to II with radius 2
    219            if II is an ideal.
    220 @*       - 2, the Groebner Walk algorithm is applied to II[1] or to II, respectively.
    221 @*       - 3, the Fractal Walk algorithm with random element is applied to II[1] or II,
    222            respectively.
    223 @*       - 4, the Fractal Walk algorithm is applied to II[1] or II, respectively.
    224 @*       - 5, the Perturbation Walk algorithm with random element is applied to II[1]
    225            or II, respectively, with radius II[3] and perturbation degree II[2].
    226 @*       - 6, the Perturbation Walk algorithm is applied to II[1] or II, respectively,
    227            with perturbation degree II[3].
    228          If size(#) > 0, then # contains either 1, 2 or 4 integers such that
    229 @*       - #[1] is the number of available processors for the computation,
    230 @*       - #[2] is an optional parameter for the exactness of the computation,
    231                 if #[2] = 1, the procedure computes a standard basis for sure,
    232 @*       - #[3] is the number of primes until the first lifting,
    233 @*       - #[4] is the constant number of primes between two liftings until
    234            the computation stops.
    235 RETURN:  a standard basis of I if no warning appears.
    236 NOTE:    The procedure converts a standard basis of I (over the rational
    237          numbers) from the ordering \"a(v),lp\", "dp\" or \"Dp\" to the ordering
    238          \"(a(w),lp\" or \"a(1,0,...,0),lp\" by using modular methods.
    239          By default the procedure computes a standard basis of I for sure, but
    240          if the optional parameter #[2] = 0, it computes a standard basis of I
    241          with high probability.
    242 EXAMPLE: example modWalk; shows an example
    243 "
    244 {
    245   int TT = timer;
    246   int RT = rtimer;
    247   int i,j,pTest,sizeTest,weighted,n1;
    248   bigint N;
    249 
    250   def R0 = basering;
    251   list rl = ringlist(R0);
    252   if((npars(R0) > 0) || (rl[1] > 0))
    253   {
    254     ERROR("Characteristic of basering should be zero, basering should have no parameters.");
    255   }
    256 
    257   if(typeof(II) == "ideal")
    258   {
    259     ideal I = II;
    260     kill II;
    261     list II;
    262     II[1] = I;
    263     II[2] = 2;
    264     II[3] = 2;
    265   }
    266   else
    267   {
    268     if(typeof(II) == "list" && typeof(II[1]) == "ideal")
    269     {
    270       ideal I = II[1];
    271       if(size(II) == 1)
    272       {
    273         II[2] = 2;
    274         II[3] = 2;
    275       }
    276       if(size(II) == 2)
    277       {
    278         II[3] = 2;
    279       }
    280 
    281     }
    282     else
    283     {
    284       ERROR("Unexpected type of input.");
    285     }
    286   }
    287 
    288 //--------------------  Initialize optional parameters  ------------------------
    289   n1 = system("--cpus");
    290   if(size(#) == 0)
    291   {
    292     int exactness = 1;
    293     int n2 = 10;
    294     int n3 = 10;
    295   }
    296   else
    297   {
    298     if(size(#) == 1)
    299     {
    300       if(typeof(#[1]) == "int")
    301       {
    302         if(#[1] < n1)
    303         {
    304           n1 = #[1];
    305         }
    306         int exactness = 1;
    307         if(n1 >= 10)
    308         {
    309           int n2 = n1 + 1;
    310           int n3 = n1;
    311         }
    312         else
    313         {
    314           int n2 = 10;
    315           int n3 = 10;
    316         }
    317       }
    318       else
    319       {
    320         ERROR("Unexpected type of input.");
    321       }
    322     }
    323     if(size(#) == 2)
    324     {
    325       if(typeof(#[1]) == "int" && typeof(#[2]) == "int")
    326       {
    327         if(#[1] < n1)
    328         {
    329           n1 = #[1];
    330         }
    331         int exactness = #[2];
    332         if(n1 >= 10)
    333         {
    334           int n2 = n1 + 1;
    335           int n3 = n1;
    336         }
    337         else
    338         {
    339           int n2 = 10;
    340           int n3 = 10;
    341         }
    342       }
    343       else
    344       {
    345         if(typeof(#[1]) == "intvec" && typeof(#[2]) == "intvec")
    346         {
    347           intvec curr_weight = #[1];
    348           intvec target_weight = #[2];
    349           weighted = 1;
    350           int n2 = 10;
    351           int n3 = 10;
    352           int exactness = 1;
    353         }
    354         else
    355         {
    356           ERROR("Unexpected type of input.");
    357         }
    358       }
    359     }
    360     if(size(#) == 3)
    361     {
    362       if(typeof(#[1]) == "intvec" && typeof(#[2]) == "intvec" && typeof(#[3]) == "int")
    363       {
    364         intvec curr_weight = #[1];
    365         intvec target_weight = #[2];
    366         weighted = 1;
    367         n1 = #[3];
    368         int n2 = 10;
    369         int n3 = 10;
    370         int exactness = 1;
    371       }
    372       else
    373       {
    374         ERROR("Unexpected type of input.");
    375       }
    376     }
    377     if(size(#) == 4)
    378     {
    379       if(typeof(#[1]) == "intvec" && typeof(#[2]) == "intvec" && typeof(#[3]) == "int"
    380           && typeof(#[4]) == "int")
    381       {
    382         intvec curr_weight = #[1];
    383         intvec target_weight = #[2];
    384         weighted = 1;
    385         if(#[1] < n1)
    386         {
    387           n1 = #[3];
    388         }
    389         int exactness = #[4];
    390         if(n1 >= 10)
    391         {
    392           int n2 = n1 + 1;
    393           int n3 = n1;
    394         }
    395         else
    396         {
    397           int n2 = 10;
    398           int n3 = 10;
    399         }
    400       }
    401       else
    402       {
    403         if(typeof(#[1]) == "int" && typeof(#[2]) == "int" && typeof(#[3]) == "int" && typeof(#[4]) == "int")
    404         {
    405           if(#[1] < n1)
    406           {
    407             n1 = #[1];
    408           }
    409           int exactness = #[2];
    410           if(n1 >= #[3])
    411           {
    412             int n2 = n1 + 1;
    413           }
    414           else
    415           {
    416             int n2 = #[3];
    417           }
    418           if(n1 >= #[4])
    419           {
    420             int n3 = n1;
    421           }
    422           else
    423           {
    424             int n3 = #[4];
    425           }
    426         }
    427         else
    428         {
    429           ERROR("Unexpected type of input.");
    430         }
    431       }
    432     }
    433     if(size(#) == 6)
    434     {
    435       if(typeof(#[1]) == "intvec" && typeof(#[2]) == "intvec" && typeof(#[3]) == "int" && typeof(#[4]) == "int" && typeof(#[5]) == "int" && typeof(#[6]) == "int")
    436       {
    437         intvec curr_weight = #[1];
    438         intvec target_weight = #[2];
    439         weighted = 1;
    440         if(#[3] < n1)
    441         {
    442           n1 = #[3];
    443         }
    444         int exactness = #[4];
    445         if(n1 >= #[5])
    446         {
    447           int n2 = n1 + 1;
    448         }
    449         else
    450         {
    451           int n2 = #[5];
    452         }
    453         if(n1 >= #[6])
    454         {
    455           int n3 = n1;
    456         }
    457         else
    458         {
    459           int n3 = #[6];
    460         }
    461       }
    462       else
    463       {
    464         ERROR("Expected list(intvec,intvec,int,int,int,int) as optional parameter list.");
    465       }
    466     }
    467     if(size(#) == 1 || size(#) == 5 || size(#) > 6)
    468     {
    469       ERROR("Expected 0,2,3,4 or 5 optional arguments.");
    470     }
    471   }
    472   if(printlevel >= 10)
    473   {
    474   "n1 = "+string(n1)+", n2 = "+string(n2)+", n3 = "+string(n3)+", exactness = "+string(exactness);
    475   }
    476 
    477 //-------------------------  Save current options  -----------------------------
    478   intvec opt = option(get);
    479   //option(redSB);
    480 
    481 //--------------------  Initialize the list of primes  -------------------------
    482   int tt = timer;
    483   int rt = rtimer;
    484   int en = 2134567879;
    485   int an = 1000000000;
    486   intvec L = primeList(I,n2);
    487   if(n2 > 4)
    488   {
    489   //  L[5] = prime(random(an,en));
    490   }
    491   if(printlevel >= 10)
    492   {
    493     "CPU-time for primeList: "+string(timer-tt)+" seconds.";
    494     "Real-time for primeList: "+string(rtimer-rt)+" seconds.";
    495   }
    496   int h = homog(I);
    497   list P,T1,T2,LL,Arguments,PP;
    498   ideal J,K,H;
    499 
    500 //-------------------  parallelized Groebner Walk in positive characteristic  --------------------
    501 
    502   if(weighted)
    503   {
    504     for(i=1; i<=size(L); i++)
    505     {
    506       Arguments[i] = list(II,L[i],variant,list(curr_weight,target_weight));
    507     }
    508   }
    509   else
    510   {
    511     for(i=1; i<=size(L); i++)
    512     {
    513       Arguments[i] = list(II,L[i],variant);
    514     }
    515   }
    516   P = parallelWaitAll("modpWalk",Arguments);
    517   for(i=1; i<=size(P); i++)
    518   {
    519     T1[i] = P[i][1];
    520     T2[i] = bigint(P[i][2]);
    521   }
    522 
    523   while(1)
    524   {
    525     LL = deleteUnluckyPrimes(T1,T2,h);
    526     T1 = LL[1];
    527     T2 = LL[2];
    528 //-------------------  Now all leading ideals are the same  --------------------
    529 //-------------------  Lift results to basering via farey  ---------------------
    530 
    531     tt = timer; rt = rtimer;
    532     N = T2[1];
    533     for(i=2; i<=size(T2); i++)
    534     {
    535       N = N*T2[i];
    536     }
    537     H = chinrem(T1,T2);
    538     J = parallelFarey(H,N,n1);
    539     //J=farey(H,N);
    540     if(printlevel >= 10)
    541     {
    542       "CPU-time for lifting-process is "+string(timer - tt)+" seconds.";
    543       "Real-time for lifting-process is "+string(rtimer - rt)+" seconds.";
    544     }
    545 
    546 //----------------  Test if we already have a standard basis of I --------------
    547 
    548     tt = timer; rt = rtimer;
    549     pTest = pTestSB(I,J,L,variant);
    550     //pTest = primeTestSB(I,J,L,variant);
    551     if(printlevel >= 10)
    552     {
    553       "CPU-time for pTest is "+string(timer - tt)+" seconds.";
    554       "Real-time for pTest is "+string(rtimer - rt)+" seconds.";
    555     }
    556     if(pTest)
    557     {
    558       if(printlevel >= 10)
    559       {
    560         "CPU-time for computation without final tests is "+string(timer - TT)+" seconds.";
    561         "Real-time for computation without final tests is "+string(rtimer - RT)+" seconds.";
    562       }
    563       attrib(J,"isSB",1);
    564       if(exactness == 0)
    565       {
    566         option(set, opt);
    567         return(J);
    568       }
    569       else
    570       {
    571         tt = timer;
    572         rt = rtimer;
    573         sizeTest = 1 - isIdealIncluded(I,J,n1);
    574         if(printlevel >= 10)
    575         {
    576           "CPU-time for checking if I subset <G> is "+string(timer - tt)+" seconds.";
    577           "Real-time for checking if I subset <G> is "+string(rtimer - rt)+" seconds.";
    578         }
    579         if(sizeTest == 0)
    580         {
    581           tt = timer;
    582           rt = rtimer;
    583           K = std(J);
    584           if(printlevel >= 10)
    585           {
    586             "CPU-time for last std-computation is "+string(timer - tt)+" seconds.";
    587             "Real-time for last std-computation is "+string(rtimer - rt)+" seconds.";
    588           }
    589           if(size(reduce(K,J)) == 0)
    590           {
    591             option(set, opt);
    592             return(J);
    593           }
    594         }
    595       }
    596     }
    597 //--------------  We do not already have a standard basis of I, therefore do the main computation for more primes  --------------
    598 
    599     T1 = H;
    600     T2 = N;
    601     j = size(L)+1;
    602     tt = timer; rt = rtimer;
    603     L = primeList(I,n3,L,n1);
    604     if(printlevel >= 10)
    605     {
    606       "CPU-time for primeList: "+string(timer-tt)+" seconds.";
    607       "Real-time for primeList: "+string(rtimer-rt)+" seconds.";
    608     }
    609     Arguments = list();
    610     PP = list();
    611     if(weighted)
    612     {
    613       for(i=j; i<=size(L); i++)
    614       {
    615         //Arguments[i-j+1] = list(II,L[i],variant,list(curr_weight,target_weight));
    616         Arguments[size(Arguments)+1] = list(II,L[i],variant,list(curr_weight,target_weight));
    617       }
    618     }
    619     else
    620     {
    621       for(i=j; i<=size(L); i++)
    622       {
    623         //Arguments[i-j+1] = list(II,L[i],variant);
    624         Arguments[size(Arguments)+1] = list(II,L[i],variant);
    625       }
    626     }
    627     PP = parallelWaitAll("modpWalk",Arguments);
    628     if(printlevel >= 10)
    629     {
    630       "parallel modpWalk";
    631     }
    632     for(i=1; i<=size(PP); i++)
    633     {
    634       //P[size(P) + 1] = PP[i];
    635       T1[size(T1) + 1] = PP[i][1];
    636       T2[size(T2) + 1] = bigint(PP[i][2]);
    637     }
    638   }
    639   if(printlevel >= 10)
    640   {
    641     "CPU-time for computation with final tests is "+string(timer - TT)+" seconds.";
    642     "Real-time for computation with final tests is "+string(rtimer - RT)+" seconds.";
    643   }
    644 }
    645 
    646 example
    647 {
    648   "EXAMPLE:";
    649   echo = 2;
    650   ring R=0,(x,y,z),lp;
    651   ideal I=-x+y2z-z,xz+1,x2+y2-1;
    652   // I is a standard basis in dp
    653   ideal J = modWalk(I,1);
    654   J;
    655 }
    656 
    657 ////////////////////////////////////////////////////////////////////////////////
    658 static proc isIdealIncluded(ideal I, ideal J, int n1)
    659 "USAGE:  isIdealIncluded(I,J,int n1); I ideal, J ideal, n1 integer
    660 "
    661 {
    662   if(n1 > 1)
    663   {
    664     int k;
    665     list args,results;
    666     for(k=1; k<=size(I); k++)
    667     {
    668       args[k] = list(ideal(I[k]),J,1);
    669     }
    670     results = parallelWaitAll("reduce",args);
    671     for(k=1; k<=size(results); k++)
    672     {
    673       if(results[k] == 0)
    674       {
    675         return(1);
    676       }
    677     }
    678     return(0);
    679   }
    680   else
    681   {
    682     if(reduce(I,J,1) == 0)
    683     {
    684       return(1);
    685     }
    686     else
    687     {
    688       return(0);
    689     }
    690   }
    691 }
    692 
    693 ////////////////////////////////////////////////////////////////////////////////
    694 static proc parallelChinrem(list T1, list T2, int n1)
    695 "USAGE:  parallelChinrem(T1,T2); T1 list of ideals, T2 list of primes, n1 integer"
    696 {
    697   int i,j,k;
    698 
    699   ideal H,J;
    700 
    701   list arguments_chinrem,results_chinrem;
    702   for(i=1; i<=size(T1); i++)
    703   {
    704     J = ideal(T1[i]);
    705     attrib(J,"isSB",1);
    706     arguments_chinrem[size(arguments_chinrem)+1] = list(list(J),T2);
    707   }
    708   results_chinrem = parallelWaitAll("chinrem",arguments_chinrem);
    709     for(j=1; j <= size(results_chinrem); j++)
    710     {
    711       J = results_chinrem[j];
    712       attrib(J,"isSB",1);
    713       if(isIdealIncluded(J,H,n1) == 0)
    714       {
    715         if(H == 0)
    716         {
    717           H = J;
    718         }
    719         else
    720         {
    721           H = H,J;
    722         }
    723       }
    724     }
    725   return(H);
    726 }
    727 
    728 ////////////////////////////////////////////////////////////////////////////////
    729 static proc parallelFarey(ideal H, bigint N, int n1)
    730 "USAGE:  parallelFarey(H,N,n1); H ideal, N bigint, n1 integer
    731 "
    732 {
    733   int i,j;
    734   int ii = 1;
    735   list arguments_farey,results_farey;
    736   for(i=1; i<=size(H); i++)
    737   {
    738     for(j=1; j<=size(H[i]); j++)
    739     {
    740       arguments_farey[size(arguments_farey)+1] = list(H[i][j],N);
    741     }
    742   }
    743   results_farey = parallelWaitAll("farey",arguments_farey);
    744   ideal J,K;
    745   poly f_farey;
    746   while(ii<=size(results_farey))
    747   {
    748     for(i=1; i<=size(H); i++)
    749     {
    750       f_farey = 0;
    751       for(j=1; j<=size(H[i]); j++)
    752       {
    753         f_farey = f_farey + results_farey[ii][1];
    754         ii++;
    755       }
    756       K = ideal(f_farey);
    757       attrib(K,"isSB",1);
    758       attrib(J,"isSB",1);
    759       if(isIdealIncluded(K,J,n1) == 0)
    760       {
    761         if(J == 0)
    762         {
    763           J = K;
    764         }
    765         else
    766         {
    767           J = J,K;
    768         }
    769       }
    770     }
    771   }
    772   return(J);
    773 }
    774 //////////////////////////////////////////////////////////////////////////////////
    775 static proc primeTestSB(def II, ideal J, list L, int variant, list #)
    776 "USAGE:  primeTestSB(I,J,L,variant,#); I,J ideals, L intvec of primes, variant int
    777 RETURN:  1 (resp. 0) if for a randomly chosen prime p that is not in L
    778          J mod p is (resp. is not) a standard basis of I mod p
    779 EXAMPLE: example primeTestSB; shows an example
    780 "
    781 {
    782 if(typeof(II) == "ideal")
    783   {
    784   ideal I = II;
    785   int radius = 2;
    786   }
    787 if(typeof(II) == "list")
    788   {
    789   ideal I = II[1];
    790   int radius = II[2];
    791   }
    792 
    793 int i,j,k,p;
    794 def R = basering;
    795 list r = ringlist(R);
    796 
    797 while(!j)
    798   {
    799   j = 1;
    800   p = prime(random(1000000000,2134567879));
    801   for(i = 1; i <= size(L); i++)
    802     {
    803     if(p == L[i])
    804       {
    805       j = 0;
    806       break;
    807       }
    808     }
    809   if(j)
    810     {
    811     for(i = 1; i <= ncols(I); i++)
    812       {
    813       for(k = 2; k <= size(I[i]); k++)
    814         {
    815         if((denominator(leadcoef(I[i][k])) mod p) == 0)
    816           {
    817           j = 0;
    818           break;
    819           }
    820         }
    821       if(!j)
    822         {
    823         break;
    824         }
    825       }
    826     }
    827   if(j)
    828     {
    829     if(!primeTest(I,p))
    830       {
    831       j = 0;
    832       }
    833     }
    834   }
    835 r[1] = p;
    836 def @R = ring(r);
    837 setring @R;
    838 ideal I = imap(R,I);
    839 ideal J = imap(R,J);
    840 attrib(J,"isSB",1);
    841 
    842 int t = timer;
    843 j = 1;
    844 if(isIncluded(I,J) == 0)
    845   {
    846   j = 0;
    847   }
    848 if(printlevel >= 11)
    849   {
    850   "isIncluded(I,J) takes "+string(timer - t)+" seconds";
    851   "j = "+string(j);
    852   }
    853 t = timer;
    854 if(j)
    855   {
    856   if(size(#) > 0)
    857     {
    858     ideal K = modpWalk(I,p,variant,#)[1];
    859     }
    860   else
    861     {
    862     ideal K = modpWalk(I,p,variant)[1];
    863     }
    864   t = timer;
    865   if(isIncluded(J,K) == 0)
    866     {
    867     j = 0;
    868     }
    869   if(printlevel >= 11)
    870     {
    871     "isIncluded(K,J) takes "+string(timer - t)+" seconds";
    872     "j = "+string(j);
    873     }
    874   }
    875 setring R;
    876 
    877 return(j);
    878 }
    879 example
    880 { "EXAMPLE:"; echo = 2;
    881    intvec L = 2,3,5;
    882    ring r = 0,(x,y,z),lp;
    883    ideal I = x+1,x+y+1;
    884    ideal J = x+1,y;
    885    primeTestSB(I,I,L,1);
    886    primeTestSB(I,J,L,1);
    887 }
    888 
    889 ////////////////////////////////////////////////////////////////////////////////
    890 static proc pTestSB(ideal I, ideal J, list L, int variant, list #)
    891 "USAGE:  pTestSB(I,J,L,variant,#); I,J ideals, L intvec of primes, variant int
    892 RETURN:  1 (resp. 0) if for a randomly chosen prime p that is not in L
    893          J mod p is (resp. is not) a standard basis of I mod p
    894 EXAMPLE: example pTestSB; shows an example
    895 "
    896 {
    897    int i,j,k,p;
    898    def R = basering;
    899    list r = ringlist(R);
    900 
    901    while(!j)
    902    {
    903       j = 1;
    904       p = prime(random(1000000000,2134567879));
    905       for(i = 1; i <= size(L); i++)
    906       {
    907          if(p == L[i]) { j = 0; break; }
    908       }
    909       if(j)
    910       {
    911          for(i = 1; i <= ncols(I); i++)
    912          {
    913             for(k = 2; k <= size(I[i]); k++)
    914             {
    915                if((denominator(leadcoef(I[i][k])) mod p) == 0) { j = 0; break; }
    916             }
    917             if(!j){ break; }
    918          }
    919       }
    920       if(j)
    921       {
    922          if(!primeTest(I,p)) { j = 0; }
    923       }
    924    }
    925    r[1] = p;
    926    def @R = ring(r);
    927    setring @R;
    928    ideal I = imap(R,I);
    929    ideal J = imap(R,J);
    930    attrib(J,"isSB",1);
    931 
    932    int t = timer;
    933    j = 1;
    934    if(isIncluded(I,J) == 0) { j = 0; }
    935 
    936    if(printlevel >= 11)
    937    {
    938       "isIncluded(I,J) takes "+string(timer - t)+" seconds";
    939       "j = "+string(j);
    940    }
    941 
    942    t = timer;
    943    if(j)
    944    {
    945       if(size(#) > 0)
    946       {
    947          ideal K = modpStd(I,p,variant,#[1])[1];
    948       }
    949       else
    950       {
    951          ideal K = groebner(I);
    952       }
    953       t = timer;
    954       if(isIncluded(J,K) == 0) { j = 0; }
    955 
    956       if(printlevel >= 11)
    957       {
    958          "isIncluded(J,K) takes "+string(timer - t)+" seconds";
    959          "j = "+string(j);
    960       }
    961    }
    962    setring R;
    963    return(j);
    964 }
    965 example
    966 { "EXAMPLE:"; echo = 2;
    967    intvec L = 2,3,5;
    968    ring r = 0,(x,y,z),dp;
    969    ideal I = x+1,x+y+1;
    970    ideal J = x+1,y;
    971    pTestSB(I,I,L,2);
    972    pTestSB(I,J,L,2);
    973 }
    974 ////////////////////////////////////////////////////////////////////////////////
    975 static proc mixedTest()
    976 "USAGE:  mixedTest();
    977 RETURN:  1 if ordering of basering is mixed, 0 else
    978 EXAMPLE: example mixedTest(); shows an example
    979 "
    980 {
    981    int i,p,m;
    982    for(i = 1; i <= nvars(basering); i++)
    983    {
    984       if(var(i) > 1)
    985       {
    986          p++;
    987       }
    988       else
    989       {
    990          m++;
    991       }
    992    }
    993    if((p > 0) && (m > 0)) { return(1); }
    994    return(0);
    995 }
    996 example
    997 { "EXAMPLE:"; echo = 2;
    998    ring R1 = 0,(x,y,z),dp;
    999    mixedTest();
    1000    ring R2 = 31,(x(1..4),y(1..3)),(ds(4),lp(3));
    1001    mixedTest();
    1002    ring R3 = 181,x(1..9),(dp(5),lp(4));
    1003    mixedTest();
    1004 }
     139    int pertdeg = 3;
     140    ideal J = modrWalk(I,radius,pertdeg);
     141    J;
     142}
     143
     144proc modfWalk(ideal I, list #)
     145"USAGE:   modfWalk(I, [, v, w]); I ideal, v intvec, w intvec
     146RETURN:   a standard basis of I
     147NOTE:     The procedure computes a standard basis of I (over the rational
     148          numbers) by using modular methods.
     149SEE ALSO: modular
     150EXAMPLE:  example modfWalk; shows an example"
     151{
     152    /* read optional parameter */
     153    if (size(#) > 0) {
     154        if (size(#) == 1) {
     155            intvec w = #[1];
     156        }
     157        if (size(#) == 2) {
     158            intvec v = #[1];
     159            intvec w = #[2];
     160        }
     161        if (size(#) > 2 || typeof(#[1]) != "intvec") {
     162            ERROR("wrong optional parameter");
     163        }
     164    }
     165
     166    /* save options */
     167    intvec opt = option(get);
     168    option(redSB);
     169
     170    /* set additional parameters */
     171    int reduction = 1;
     172    int printout = 0;
     173
     174    /* call modular() */
     175    if (size(#) > 0) {
     176        I = modular("fwalk", list(I,reduction,printout,#));
     177    }
     178    else {
     179        I = modular("fwalk", list(I,reduction,printout));
     180    }
     181
     182    /* return the result */
     183    attrib(I, "isSB", 1);
     184    option(set, opt);
     185    return(I);
     186}
     187example
     188{
     189    "EXAMPLE:";
     190    echo = 2;
     191    ring R1 = 0, (x,y,z,t), dp;
     192    ideal I = 3x3+x2+1, 11y5+y3+2, 5z4+z2+4;
     193    I = std(I);
     194    ring R2 = 0, (x,y,z,t), lp;
     195    ideal I = fetch(R1, I);
     196    ideal J = modfWalk(I);
     197    J;
     198}
     199
     200proc modfrWalk(ideal I, int radius, list #)
     201"USAGE:   modfrWalk(I, radius [, v, w]); I ideal, radius int, v intvec, w intvec
     202RETURN:   a standard basis of I
     203NOTE:     The procedure computes a standard basis of I (over the rational
     204          numbers) by using modular methods.
     205SEE ALSO: modular
     206EXAMPLE:  example modfrWalk; shows an example"
     207{
     208    /* read optional parameter */
     209    if (size(#) > 0) {
     210        if (size(#) == 1) {
     211            intvec w = #[1];
     212        }
     213        if (size(#) == 2) {
     214            intvec v = #[1];
     215            intvec w = #[2];
     216        }
     217        if (size(#) > 2 || typeof(#[1]) != "intvec") {
     218            ERROR("wrong optional parameter");
     219        }
     220    }
     221
     222    /* save options */
     223    intvec opt = option(get);
     224    option(redSB);
     225
     226    /* set additional parameters */
     227    int reduction = 1;
     228    int printout = 0;
     229
     230    /* call modular() */
     231    if (size(#) > 0) {
     232        I = modular("frandwalk", list(I,radius,reduction,printout,#));
     233    }
     234    else {
     235        I = modular("frandwalk", list(I,radius,reduction,printout));
     236    }
     237
     238    /* return the result */
     239    attrib(I, "isSB", 1);
     240    option(set, opt);
     241    return(I);
     242}
     243example
     244{
     245    "EXAMPLE:";
     246    echo = 2;
     247    ring R1 = 0, (x,y,z,t), dp;
     248    ideal I = 3x3+x2+1, 11y5+y3+2, 5z4+z2+4;
     249    I = std(I);
     250    ring R2 = 0, (x,y,z,t), lp;
     251    ideal I = fetch(R1, I);
     252    int radius = 2;
     253    ideal J = modfrWalk(I,radius);
     254    J;
     255}
  • Singular/LIB/rwalk.lib

    • Property mode changed from 100644 to 100755
    re3e129 r74fe358  
    1010rwalk(ideal,int,int[,intvec,intvec]);   standard basis of ideal via Random Walk algorithm
    1111rwalk(ideal,int[,intvec,intvec]);       standard basis of ideal via Random Perturbation Walk algorithm
    12 frwalk(ideal,int[,intvec,intvec]);      standard basis of ideal via Random Fractal Walk algorithm
     12frandwalk(ideal,int[,intvec,intvec]);      standard basis of ideal via Random Fractal Walk algorithm
    1313";
    1414
     
    141141 * Random Walk  *
    142142 ****************/
    143 proc rwalk(ideal Go, int radius, int pert_deg, list #)
     143proc rwalk(ideal Go, int radius, int pert_deg, int reduction, int printout, list #)
    144144"SYNTAX: rwalk(ideal i, int radius);
    145145         if size(#)>0 then rwalk(ideal i, int radius, intvec v, intvec w);
     146         intermediate Groebner bases are not reduced if reduction = 0
    146147TYPE:    ideal
    147148PURPOSE: compute the standard basis of the ideal, calculated via
     
    178179
    179180ideal G = fetch(xR, Go);
    180 G = system("Mrwalk", G, curr_weight, target_weight, radius, pert_deg, basering);
     181G = system("Mrwalk", G, curr_weight, target_weight, radius, pert_deg, reduction, printout);
    181182
    182183setring xR;
     
    196197  int radius = 1;
    197198  int perturb_deg = 2;
    198   rwalk(I,radius,perturb_deg);
     199  int reduction = 0;
     200  int printout = 1;
     201  rwalk(I,radius,perturb_deg,reduction,printout);
    199202}
    200203
     
    202205 * Perturbation Walk with random element *
    203206 *****************************************/
    204 proc prwalk(ideal Go, int radius, int o_pert_deg, int t_pert_deg, list #)
     207proc prwalk(ideal Go, int radius, int o_pert_deg, int t_pert_deg, int reduction, int printout, list #)
    205208"SYNTAX: rwalk(ideal i, int radius);
    206209         if size(#)>0 then rwalk(ideal i, int radius, intvec v, intvec w);
     
    227230  OSCTW= OrderStringalp_NP("al", #);
    228231  }
     232int nP = OSCTW[1];
    229233string ord_str = OSCTW[2];
    230234intvec curr_weight = OSCTW[3]; // original weight vector
     
    238242
    239243ideal G = fetch(xR, Go);
    240 G = system("Mprwalk", G, curr_weight, target_weight, radius, o_pert_deg, t_pert_deg, basering);
     244G = system("Mprwalk", G, curr_weight, target_weight, radius, o_pert_deg, t_pert_deg,
     245           nP, reduction, printout);
    241246
    242247setring xR;
     
    257262  int o_perturb_deg = 2;
    258263  int t_perturb_deg = 2;
    259   prwalk(I,radius,o_perturb_deg,t_perturb_deg);
     264  int reduction = 0;
     265  int printout = 2;
     266  prwalk(I,radius,o_perturb_deg,t_perturb_deg,reduction,printout);
    260267}
    261268
     
    263270 * Fractal Walk with random element *
    264271 ************************************/
    265 proc frandwalk(ideal Go, int radius, list #)
    266 "SYNTAX: frwalk(ideal i, int radius);
    267          frwalk(ideal i, int radius, intvec v, intvec w);
     272proc frandwalk(ideal Go, int radius, int reduction, int printout, list #)
     273"SYNTAX: frwalk(ideal i, int radius, int reduction, int printout);
     274         frwalk(ideal i, int radius, int reduction, int printout, intvec v, intvec w);
    268275TYPE:    ideal
    269276PURPOSE: compute the standard basis of the ideal, calculated via
     
    299306   ideal G = fetch(xR, Go);
    300307   int pert_deg = 2;
    301    G = system("Mfrwalk", G, curr_weight, target_weight, radius);
     308
     309   G = system("Mfrwalk", G, curr_weight, target_weight, radius, reduction, printout);
    302310
    303311   setring xR;
     
    314322    ring r = 0,(z,y,x), lp;
    315323    ideal I = y3+xyz+y2z+xz3, 3+xy+x2y+y2z;
    316     frandwalk(I,2);
    317 }
     324    int reduction = 0;
     325    frandwalk(I,2,0,1);
     326}
  • Singular/LIB/swalk.lib

    • Property mode changed from 100644 to 100755
  • Singular/dyn_modules/singmathic/singmathic.cc

    r654a23 r74fe358  
    525525extern "C" int SI_MOD_INIT(singmathic)(SModulFunctions* psModulFunctions)
    526526{
    527   PrintS("Initializing Singular-Mathic interface Singmathic.\n");
    528527  psModulFunctions->iiAddCproc(
    529528    (currPack->libname ? currPack->libname : ""),
  • Singular/extra.cc

    re3e129 r74fe358  
    18641864    if (strcmp(sys_cmd, "Mwalk") == 0)
    18651865    {
    1866       const short t[]={4,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD,RING_CMD};
     1866      const short t[]={6,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD,RING_CMD,INT_CMD,INT_CMD};
    18671867      if (!iiCheckTypes(h,t,1)) return TRUE;
    18681868      if (((intvec*) h->next->Data())->length() != currRing->N &&
     
    18751875      ideal arg1 = (ideal) h->Data();
    18761876      intvec* arg2 = (intvec*) h->next->Data();
    1877       intvec* arg3   =  (intvec*) h->next->next->Data();
    1878       ring arg4   =  (ring) h->next->next->next->Data();
    1879       ideal result = (ideal) Mwalk(arg1, arg2, arg3,arg4);
     1877      intvec* arg3 = (intvec*) h->next->next->Data();
     1878      ring arg4 = (ring) h->next->next->next->Data();
     1879      int arg5 = (int) (long) h->next->next->next->next->Data();
     1880      int arg6 = (int) (long) h->next->next->next->next->next->Data();
     1881      ideal result = (ideal) Mwalk(arg1, arg2, arg3, arg4, arg5, arg6);
    18801882      res->rtyp = IDEAL_CMD;
    18811883      res->data =  result;
     
    19131915    if (strcmp(sys_cmd, "Mpwalk") == 0)
    19141916    {
    1915       const short t[]={6,IDEAL_CMD,INT_CMD,INT_CMD,INTVEC_CMD,INTVEC_CMD,INT_CMD};
     1917      const short t[]={8,IDEAL_CMD,INT_CMD,INT_CMD,INTVEC_CMD,INTVEC_CMD,INT_CMD,INT_CMD,INT_CMD};
    19161918      if (!iiCheckTypes(h,t,1)) return TRUE;
    19171919      if(((intvec*) h->next->next->next->Data())->length() != currRing->N &&
     
    19271929      intvec* arg5 = (intvec*) h->next->next->next->next->Data();
    19281930      int arg6 = (int) (long) h->next->next->next->next->next->Data();
    1929       ideal result = (ideal) Mpwalk(arg1, arg2, arg3, arg4, arg5,arg6);
     1931      int arg7 = (int) (long) h->next->next->next->next->next->next->Data();
     1932      int arg8 = (int) (long) h->next->next->next->next->next->next->next->Data();
     1933      ideal result = (ideal) Mpwalk(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
    19301934      res->rtyp = IDEAL_CMD;
    19311935      res->data =  result;
     
    19391943    if (strcmp(sys_cmd, "Mrwalk") == 0)
    19401944    {
    1941       const short t[]={6,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD,INT_CMD,INT_CMD,RING_CMD};
     1945      const short t[]={7,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD,INT_CMD,INT_CMD,INT_CMD,INT_CMD};
    19421946      if (!iiCheckTypes(h,t,1)) return TRUE;
    1943       if((((intvec*) h->next->Data())->length() != currRing->N &&
    1944          ((intvec*) h->next->next->Data())->length() != currRing->N ) &&
    1945          (((intvec*) h->next->Data())->length() != (currRing->N)*(currRing->N) &&
    1946          ((intvec*) h->next->next->Data())->length() != (currRing->N)*(currRing->N) ))
     1947      if(((intvec*) h->next->Data())->length() != currRing->N &&
     1948         ((intvec*) h->next->Data())->length() != (currRing->N)*(currRing->N) &&
     1949         ((intvec*) h->next->next->Data())->length() != currRing->N &&
     1950         ((intvec*) h->next->next->Data())->length() != (currRing->N)*(currRing->N) )
    19471951      {
    19481952        Werror("system(\"Mrwalk\" ...) intvecs not of length %d or %d\n",
     
    19551959      int arg4 = (int)(long) h->next->next->next->Data();
    19561960      int arg5 = (int)(long) h->next->next->next->next->Data();
    1957       ring arg6 = (ring) h->next->next->next->next->next->Data();
    1958       ideal result = (ideal) Mrwalk(arg1, arg2, arg3, arg4, arg5, arg6);
     1961      int arg6 = (int)(long) h->next->next->next->next->next->Data();
     1962      int arg7 = (int)(long) h->next->next->next->next->next->next->Data();
     1963      ideal result = (ideal) Mrwalk(arg1, arg2, arg3, arg4, arg5, arg6, arg7);
    19591964      res->rtyp = IDEAL_CMD;
    19601965      res->data =  result;
     
    20182023    if (strcmp(sys_cmd, "Mfwalk") == 0)
    20192024    {
    2020       const short t[]={3,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD};
     2025      const short t[]={5,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD,INT_CMD,INT_CMD};
    20212026      if (!iiCheckTypes(h,t,1)) return TRUE;
    20222027      if (((intvec*) h->next->Data())->length() != currRing->N &&
     
    20252030        Werror("system(\"Mfwalk\" ...) intvecs not of length %d\n",
    20262031                 currRing->N);
    2027         return TRUE;
    2028       }
    2029       ideal arg1 = (ideal) h->Data();
    2030       intvec* arg2 = (intvec*) h->next->Data();
    2031       intvec* arg3   =  (intvec*) h->next->next->Data();
    2032       ideal result = (ideal) Mfwalk(arg1, arg2, arg3);
    2033       res->rtyp = IDEAL_CMD;
    2034       res->data =  result;
    2035       return FALSE;
    2036     }
    2037     else
    2038   #endif
    2039   /*==================== Mfrwalk =================*/
    2040   #ifdef HAVE_WALK
    2041     if (strcmp(sys_cmd, "Mfrwalk") == 0)
    2042     {
    2043       const short t[]={6,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD,INT_CMD,INT_CMD,RING_CMD};
    2044       if (!iiCheckTypes(h,t,1)) return TRUE;
    2045       if (((intvec*) h->next->Data())->length() != currRing->N &&
    2046           ((intvec*) h->next->next->Data())->length() != currRing->N)
    2047       {
    2048         Werror("system(\"Mfrwalk\" ...) intvecs not of length %d\n",currRing->N);
    20492032        return TRUE;
    20502033      }
     
    20532036      intvec* arg3 = (intvec*) h->next->next->Data();
    20542037      int arg4 = (int)(long) h->next->next->next->Data();
    2055       ideal result = (ideal) Mfrwalk(arg1, arg2, arg3, arg4);
     2038      int arg5 = (int)(long) h->next->next->next->next->Data();
     2039      ideal result = (ideal) Mfwalk(arg1, arg2, arg3, arg4, arg5);
    20562040      res->rtyp = IDEAL_CMD;
    20572041      res->data =  result;
     
    20592043    }
    20602044    else
     2045  #endif
     2046  /*==================== Mfrwalk =================*/
     2047  #ifdef HAVE_WALK
     2048    if (strcmp(sys_cmd, "Mfrwalk") == 0)
     2049    {
     2050      const short t[]={6,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD,INT_CMD,INT_CMD,INT_CMD};
     2051      if (!iiCheckTypes(h,t,1)) return TRUE;
     2052/*
     2053      if (((intvec*) h->next->Data())->length() != currRing->N &&
     2054          ((intvec*) h->next->next->Data())->length() != currRing->N)
     2055      {
     2056        Werror("system(\"Mfrwalk\" ...) intvecs not of length %d\n",currRing->N);
     2057        return TRUE;
     2058      }
     2059*/
     2060      if((((intvec*) h->next->Data())->length() != currRing->N &&
     2061         ((intvec*) h->next->next->Data())->length() != currRing->N ) &&
     2062         (((intvec*) h->next->Data())->length() != (currRing->N)*(currRing->N) &&
     2063         ((intvec*) h->next->next->Data())->length() != (currRing->N)*(currRing->N) ))
     2064      {
     2065        Werror("system(\"Mfrwalk\" ...) intvecs not of length %d or %d\n",
     2066               currRing->N,(currRing->N)*(currRing->N));
     2067        return TRUE;
     2068      }
     2069
     2070      ideal arg1 = (ideal) h->Data();
     2071      intvec* arg2 = (intvec*) h->next->Data();
     2072      intvec* arg3 = (intvec*) h->next->next->Data();
     2073      int arg4 = (int)(long) h->next->next->next->Data();
     2074      int arg5 = (int)(long) h->next->next->next->next->Data();
     2075      int arg6 = (int)(long) h->next->next->next->next->next->Data();
     2076      ideal result = (ideal) Mfrwalk(arg1, arg2, arg3, arg4, arg5, arg6);
     2077      res->rtyp = IDEAL_CMD;
     2078      res->data =  result;
     2079      return FALSE;
     2080    }
     2081    else
    20612082  /*==================== Mprwalk =================*/
    20622083    if (strcmp(sys_cmd, "Mprwalk") == 0)
    20632084    {
    2064       const short t[]={7,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD,INT_CMD,INT_CMD,INT_CMD,RING_CMD};
     2085      const short t[]={9,IDEAL_CMD,INTVEC_CMD,INTVEC_CMD,INT_CMD,INT_CMD,INT_CMD,INT_CMD,INT_CMD,INT_CMD};
    20652086      if (!iiCheckTypes(h,t,1)) return TRUE;
    2066       if (((intvec*) h->next->Data())->length() != currRing->N &&
    2067           ((intvec*) h->next->next->Data())->length() != currRing->N )
    2068       {
    2069         Werror("system(\"Mrwalk\" ...) intvecs not of length %d\n",
    2070                currRing->N);
     2087      if((((intvec*) h->next->Data())->length() != currRing->N &&
     2088         ((intvec*) h->next->next->Data())->length() != currRing->N ) &&
     2089         (((intvec*) h->next->Data())->length() != (currRing->N)*(currRing->N) &&
     2090         ((intvec*) h->next->next->Data())->length() != (currRing->N)*(currRing->N) ))
     2091      {
     2092        Werror("system(\"Mrwalk\" ...) intvecs not of length %d or %d\n",
     2093               currRing->N,(currRing->N)*(currRing->N));
    20712094        return TRUE;
    20722095      }
     
    20772100      int arg5 = (int)(long) h->next->next->next->next->Data();
    20782101      int arg6 = (int)(long) h->next->next->next->next->next->Data();
    2079       ring arg7 = (ring) h->next->next->next->next->next->next->Data();
    2080       ideal result = (ideal) Mprwalk(arg1, arg2, arg3, arg4, arg5, arg6, arg7);
     2102      int arg7 = (int)(long) h->next->next->next->next->next->next->Data();
     2103      int arg8 = (int)(long) h->next->next->next->next->next->next->next->Data();
     2104      int arg9 = (int)(long) h->next->next->next->next->next->next->next->next->Data();
     2105      ideal result = (ideal) Mprwalk(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
    20812106      res->rtyp = IDEAL_CMD;
    20822107      res->data =  result;
  • Singular/feOptTab.h

    r654a23 r74fe358  
    108108
    109109  {"allow-net",         no_argument,        LONG_OPTION_RETURN,
    110    0,          "Allow to fetch (html) help pages from the net",                feOptBool,    0,      0},
     110   0,          "Allow one to fetch (html) help pages from the net",    feOptBool,    0,      0},
    111111
    112112  {"browser",           required_argument,  LONG_OPTION_RETURN,
  • Singular/iparith.cc

    r654a23 r74fe358  
    18281828  else
    18291829  {
    1830     xx=(number *)omAlloc(rl*sizeof(number));
    18311830    if (nMap==NULL)
    18321831    {
     
    18341833      return TRUE;
    18351834    }
     1835    xx=(number *)omAlloc(rl*sizeof(number));
    18361836    for(i=rl-1;i>=0;i--)
    18371837    {
     
    18981898    // deletes also x
    18991899    c->Clean();
    1900     if (return_type==POLY_CMD)
     1900    if ((return_type==POLY_CMD) &&(result!=NULL))
    19011901    {
    19021902      res->data=(char *)result->m[0];
     
    19131913  omFree(q);
    19141914  res->rtyp=return_type;
    1915   return FALSE;
     1915  return result==NULL;
    19161916}
    19171917static BOOLEAN jjCOEF(leftv res, leftv u, leftv v)
  • Singular/ipid.cc

    r654a23 r74fe358  
    739739  return NULL;
    740740}
     741
     742BOOLEAN iiAlias(leftv p)
     743{
     744  if (iiCurrArgs==NULL)
     745  {
     746    Werror("not enough arguments for proc %s",VoiceName());
     747    p->CleanUp();
     748    return TRUE;
     749  }
     750  leftv h=iiCurrArgs;
     751  iiCurrArgs=h->next;
     752  h->next=NULL;
     753  if (h->rtyp!=IDHDL)
     754  {
     755    BOOLEAN res=iiAssign(p,h);
     756    h->CleanUp();
     757    omFreeBin((ADDRESS)h, sleftv_bin);
     758    return res;
     759  }
     760  if ((h->Typ()!=p->Typ()) &&(p->Typ()!=DEF_CMD))
     761  {
     762    WerrorS("type mismatch");
     763    return TRUE;
     764  }
     765  idhdl pp=(idhdl)p->data;
     766  switch(pp->typ)
     767  {
     768#ifdef SINGULAR_4_1
     769      case CRING_CMD:
     770        nKillChar((coeffs)pp);
     771        break;
     772#endif
     773      case DEF_CMD:
     774      case INT_CMD:
     775        break;
     776      case INTVEC_CMD:
     777      case INTMAT_CMD:
     778         delete IDINTVEC(pp);
     779         break;
     780      case NUMBER_CMD:
     781         nDelete(&IDNUMBER(pp));
     782         break;
     783      case BIGINT_CMD:
     784         n_Delete(&IDNUMBER(pp),coeffs_BIGINT);
     785         break;
     786      case MAP_CMD:
     787         {
     788           map im = IDMAP(pp);
     789           omFree((ADDRESS)im->preimage);
     790         }
     791         // continue as ideal:
     792      case IDEAL_CMD:
     793      case MODUL_CMD:
     794      case MATRIX_CMD:
     795          idDelete(&IDIDEAL(pp));
     796         break;
     797      case PROC_CMD:
     798      case RESOLUTION_CMD:
     799      case STRING_CMD:
     800         omFree((ADDRESS)IDSTRING(pp));
     801         break;
     802      case LIST_CMD:
     803         IDLIST(pp)->Clean();
     804         break;
     805      case LINK_CMD:
     806         omFreeBin(IDLINK(pp),sip_link_bin);
     807         break;
     808       // case ring: cannot happen
     809       default:
     810         Werror("unknown type %d",p->Typ());
     811         return TRUE;
     812  }
     813  pp->typ=ALIAS_CMD;
     814  IDDATA(pp)=(char*)h->data;
     815  int eff_typ=h->Typ();
     816  if ((RingDependend(eff_typ))
     817  || ((eff_typ==LIST_CMD) && (lRingDependend((lists)h->Data()))))
     818  {
     819    ipSwapId(pp,IDROOT,currRing->idroot);
     820  }
     821  h->CleanUp();
     822  omFreeBin((ADDRESS)h, sleftv_bin);
     823  return FALSE;
     824}
     825
  • Singular/ipshell.cc

    r654a23 r74fe358  
    166166  switch(IDTYP(h))
    167167  {
     168    case ALIAS_CMD: Print(" for %s",IDID((idhdl)IDDATA(h))); break;
    168169    case INT_CMD:   Print(" %d",IDINT(h)); break;
    169170    case INTVEC_CMD:Print(" (%d)",IDINTVEC(h)->length()); break;
     
    783784          v->rtyp=IDEAL_CMD;
    784785          char *tmp = theMap->preimage;
    785           theMap->preimage=(char*)1L;
     786          theMap->preimage=(char*)1L;
    786787          // map gets 1 as its rank (as an ideal)
    787788          v->data=fast_map(IDIDEAL(w), src_ring, (ideal)theMap, currRing);
     
    13261327  return res;
    13271328}
    1328 BOOLEAN iiAlias(leftv p)
    1329 {
    1330   if (iiCurrArgs==NULL)
    1331   {
    1332     Werror("not enough arguments for proc %s",VoiceName());
    1333     p->CleanUp();
    1334     return TRUE;
    1335   }
    1336   leftv h=iiCurrArgs;
    1337   iiCurrArgs=h->next;
    1338   h->next=NULL;
    1339   if (h->rtyp!=IDHDL)
    1340   {
    1341     BOOLEAN res=iiAssign(p,h);
    1342     h->CleanUp();
    1343     omFreeBin((ADDRESS)h, sleftv_bin);
    1344     return res;
    1345   }
    1346   if (h->Typ()!=p->Typ())
    1347   {
    1348     WerrorS("type mismatch");
    1349     return TRUE;
    1350   }
    1351   idhdl pp=(idhdl)p->data;
    1352   switch(pp->typ)
    1353   {
    1354 #ifdef SINGULAR_4_1
    1355       case CRING_CMD:
    1356         nKillChar((coeffs)pp);
    1357         break;
    1358 #endif
    1359       case INT_CMD:
    1360         break;
    1361       case INTVEC_CMD:
    1362       case INTMAT_CMD:
    1363          delete IDINTVEC(pp);
    1364          break;
    1365       case NUMBER_CMD:
    1366          nDelete(&IDNUMBER(pp));
    1367          break;
    1368       case BIGINT_CMD:
    1369          n_Delete(&IDNUMBER(pp),coeffs_BIGINT);
    1370          break;
    1371       case MAP_CMD:
    1372          {
    1373            map im = IDMAP(pp);
    1374            omFree((ADDRESS)im->preimage);
    1375          }
    1376          // continue as ideal:
    1377       case IDEAL_CMD:
    1378       case MODUL_CMD:
    1379       case MATRIX_CMD:
    1380           idDelete(&IDIDEAL(pp));
    1381          break;
    1382       case PROC_CMD:
    1383       case RESOLUTION_CMD:
    1384       case STRING_CMD:
    1385          omFree((ADDRESS)IDSTRING(pp));
    1386          break;
    1387       case LIST_CMD:
    1388          IDLIST(pp)->Clean();
    1389          break;
    1390       case LINK_CMD:
    1391          omFreeBin(IDLINK(pp),sip_link_bin);
    1392          break;
    1393        // case ring: cannot happen
    1394        default:
    1395          Werror("unknown type %d",p->Typ());
    1396          return TRUE;
    1397   }
    1398   pp->typ=ALIAS_CMD;
    1399   IDDATA(pp)=(char*)h->data;
    1400   h->CleanUp();
    1401   omFreeBin((ADDRESS)h, sleftv_bin);
    1402   return FALSE;
    1403 }
    1404 
    14051329static BOOLEAN iiInternalExport (leftv v, int toLev)
    14061330{
  • Singular/walk.cc

    • Property mode changed from 100644 to 100755
    re3e129 r74fe358  
    1616
    1717//#define TEST_OVERFLOW
    18 //#define CHECK_IDEAL
    19 //#define CHECK_IDEAL_MWALK
     18
     19#define CHECK_IDEAL_MWALK //to print intermediate results
    2020
    2121//#define NEXT_VECTORS_CC
    22 //#define PRINT_VECTORS //to print vectors (sigma, tau, omega)
     22#define PRINT_VECTORS //to print weight vectors
    2323
    2424#define INVEPS_SMALL_IN_FRACTAL  //to choose the small invers of epsilon
     
    2727
    2828#define FIRST_STEP_FRACTAL // to define the first step of the fractal
    29 //#define MSTDCC_FRACTAL // apply Buchberger alg to compute a red GB, if
    30 //                          tau doesn't stay in the correct cone
     29#define MSTDCC_FRACTAL // apply Buchberger alg to compute a red GB, if tau doesn't stay in the correct cone
    3130
    3231//#define TIME_TEST // print the used time of each subroutine
     
    4241#include <Singular/ipshell.h>
    4342#include <Singular/ipconv.h>
     43#include <coeffs/ffields.h>
    4444#include <coeffs/coeffs.h>
    4545#include <Singular/subexpr.h>
     46#include <polys/templates/p_Procs.h>
    4647
    4748#include <polys/monomials/maps.h>
     
    120121 ************************************/
    121122// unused
    122 #if 0
     123/*
    123124static void initSSpecialCC (ideal F, ideal Q, ideal P,kStrategy strat)
    124125{
     
    268269#endif
    269270}
    270 #endif
     271*/
    271272
    272273/*****************
     
    277278  int j;
    278279  kStrategy strat = new skStrategy;
    279 
    280 //  if (TEST_OPT_PROT)
    281 //  {
    282 //    writeTime("start InterRed:");
    283 //    mflush();
    284 //  }
    285   //strat->syzComp     = 0;
     280/*
     281  if (TEST_OPT_PROT)
     282  {
     283    writeTime("start InterRed:");
     284    mflush();
     285  }
     286  strat->syzComp     = 0;
     287*/
    286288  strat->kHEdgeFound = (currRing->ppNoether) != NULL;
    287289  strat->kNoether=pCopy((currRing->ppNoether));
     
    346348    strat->fromQ = NULL;
    347349  }
    348 //  if (TEST_OPT_PROT)
    349 //  {
    350 //    writeTime("end Interred:");
    351 //    mflush();
    352 //  }
     350/*
     351  if (TEST_OPT_PROT)
     352  {
     353    writeTime("end Interred:");
     354    mflush();
     355  }
     356*/
    353357  ideal shdl=strat->Shdl;
    354358  idSkipZeroes(shdl);
     
    358362}
    359363
    360 //unused
    361 #if 0
     364#ifdef TIME_TEST
    362365static void TimeString(clock_t tinput, clock_t tostd, clock_t tif,clock_t tstd,
    363366                       clock_t tlf,clock_t tred, clock_t tnw, int step)
     
    397400        ((((double) xtextra)/1000000)/totm)*100);
    398401}
    399 #endif
    400 
    401 //unused
    402 #if 0
     402
    403403static void TimeStringFractal(clock_t tinput, clock_t tostd, clock_t tif,clock_t tstd,
    404404                       clock_t textra, clock_t tlf,clock_t tred, clock_t tnw)
     
    442442}
    443443#endif
    444 
     444/*
    445445#if defined(CHECK_IDEAL_MWALK) || defined(ENDWALKS)
    446446static void headidString(ideal L, char* st)
     
    496496}
    497497#endif
    498 
     498*/
    499499
    500500static void ivString(intvec* iv, const char* ch)
     
    510510}
    511511
    512 //unused
    513 #if 0
     512#ifdef PRINT_VECTORS
    514513static void MivString(intvec* iva, intvec* ivb, intvec* ivc)
    515514{
     
    558557  }
    559558  return p0;
     559}
     560
     561/*****************************************************************************
     562 * compute the gcd of the entries of the vectors curr_weight and diff_weight *
     563 *****************************************************************************/
     564static int simplify_gcd(intvec* curr_weight, intvec* diff_weight)
     565{
     566  int j;
     567  int nRing = currRing->N;
     568  int gcd_tmp = (*curr_weight)[0];
     569  for (j=1; j<nRing; j++)
     570  {
     571    gcd_tmp = gcd(gcd_tmp, (*curr_weight)[j]);
     572    if(gcd_tmp == 1)
     573    {
     574      break;
     575    }
     576  }
     577  if(gcd_tmp != 1)
     578  {
     579    for (j=0; j<nRing; j++)
     580    {
     581    gcd_tmp = gcd(gcd_tmp, (*diff_weight)[j]);
     582    if(gcd_tmp == 1)
     583      {
     584        break;
     585      }
     586    }
     587  }
     588  return gcd_tmp;
    560589}
    561590
     
    774803  for(i=nG-1; i>=0; i--)
    775804  {
    776     mi = MpolyInitialForm(G->m[i], iv);
    777     gi = G->m[i];
    778 
     805    mi = pHead(MpolyInitialForm(G->m[i], iv));
     806    //Print("\n **// test_w_in_ConeCC: lm(initial)= %s \n",pString(mi));
     807    gi = pHead(G->m[i]);
     808    //Print("\n **// test_w_in_ConeCC: lm(ideal)= %s \n",pString(gi));
    779809    if(mi == NULL)
    780810    {
     
    953983}
    954984
    955 /*****************************************************************************
    956 * create a weight matrix order as intvec of an extra weight vector (a(iv),lp)*
    957 ******************************************************************************/
     985/*********************************************************************************
     986* create a weight matrix order as intvec of an extra weight vector (a(iv),M(iw)) *
     987**********************************************************************************/
    958988intvec* MivMatrixOrderRefine(intvec* iv, intvec* iw)
    959989{
    960   assume(iv->length() == iw->length());
    961   int i, nR = iv->length();
    962 
     990  assume((iv->length())*(iv->length()) == iw->length());
     991  int i,j, nR = iv->length();
     992 
    963993  intvec* ivm = new intvec(nR*nR);
    964994
     
    966996  {
    967997    (*ivm)[i] = (*iv)[i];
    968     (*ivm)[i+nR] = (*iw)[i];
    969   }
    970   for(i=2; i<nR; i++)
    971   {
    972     (*ivm)[i*nR+i-2] = 1;
     998  }
     999  for(i=1; i<nR; i++)
     1000  {
     1001    for(j=0; j<nR; j++)
     1002    {
     1003      (*ivm)[j+i*nR] = (*iw)[j+i*nR];
     1004    }
    9731005  }
    9741006  return ivm;
     
    10051037 * print the max total degree and the max coefficient of G                   *
    10061038 *****************************************************************************/
    1007 #if 0
     1039/*
    10081040static void checkComplexity(ideal G, char* cG)
    10091041{
     
    10461078  PrintLn();
    10471079}
    1048 #endif
     1080*/
    10491081
    10501082/*****************************************************************************
     
    10681100  intvec* v_null =  new intvec(nV);
    10691101
    1070 
    10711102  // Check that the perturbed degree is valid
    10721103  if(pdeg > nV || pdeg <= 0)
     
    10821113  }
    10831114  mpz_t *pert_vector = (mpz_t*)omAlloc(nV*sizeof(mpz_t));
    1084   //mpz_t *pert_vector1 = (mpz_t*)omAlloc(nV*sizeof(mpz_t));
     1115  mpz_t *pert_vector1 = (mpz_t*)omAlloc(nV*sizeof(mpz_t));
    10851116
    10861117  for(i=0; i<nV; i++)
    10871118  {
    10881119    mpz_init_set_si(pert_vector[i], (*ivtarget)[i]);
    1089    // mpz_init_set_si(pert_vector1[i], (*ivtarget)[i]);
     1120    mpz_init_set_si(pert_vector1[i], (*ivtarget)[i]);
    10901121  }
    10911122  // Calculate max1 = Max(A2)+Max(A3)+...+Max(Apdeg),
     
    11671198    }
    11681199  }
     1200
     1201  // 2147483647 is max. integer representation in SINGULAR
     1202  mpz_t sing_int;
     1203  mpz_init_set_ui(sing_int,  2147483647);
     1204
     1205  mpz_t check_int;
     1206  mpz_init_set_ui(check_int,  100000);
     1207
    11691208  mpz_t ztemp;
    11701209  mpz_init(ztemp);
     
    11861225  }
    11871226
    1188   intvec *pert_vector1= new intvec(nV);
    1189   j = 0;
    11901227  for(i=0; i<nV; i++)
    11911228  {
    1192     (* pert_vector1)[i] = mpz_get_si(pert_vector[i]);
    1193     (* pert_vector1)[i] = 0.1*(* pert_vector1)[i];
    1194     (* pert_vector1)[i] = floor((* pert_vector1)[i] + 0.5);
    1195     if((* pert_vector1)[i] == 0)
    1196     {
    1197       j++;
    1198     }
    1199   }
    1200   if(j > nV - 1)
    1201   {
    1202     // Print("\n//  MPertVectors: geaenderter vector gleich Null! \n");
    1203     delete pert_vector1;
    1204     goto CHECK_OVERFLOW;
    1205   }
    1206 
    1207 // check that the perturbed weight vector lies in the Groebner cone
    1208   if(test_w_in_ConeCC(G,pert_vector1) != 0)
    1209   {
    1210     // Print("\n//  MPertVectors: geaenderter vector liegt in Groebnerkegel! \n");
     1229    if(mpz_cmp(pert_vector[i], check_int)>=0)
     1230    {
     1231      for(j=0; j<nV; j++)
     1232      {
     1233        mpz_fdiv_q_ui(pert_vector1[j], pert_vector[j], 100);
     1234      }
     1235    }
     1236  }
     1237
     1238  intvec* result = new intvec(nV);
     1239
     1240  int ntrue=0;
     1241
     1242  for(i=0; i<nV; i++)
     1243  {
     1244    (*result)[i] = mpz_get_si(pert_vector1[i]);
     1245    if(mpz_cmp(pert_vector1[i], sing_int)>=0)
     1246    {
     1247      ntrue++;
     1248    }
     1249  }
     1250  if(ntrue > 0 || test_w_in_ConeCC(G,result)==0)
     1251  {
     1252    ntrue=0;
    12111253    for(i=0; i<nV; i++)
    12121254    {
    1213       mpz_set_si(pert_vector[i], (*pert_vector1)[i]);
    1214     }
    1215   }
    1216   else
    1217   {
    1218     //Print("\n// MpertVectors: geaenderter vector liegt nicht in Groebnerkegel! \n");
    1219   }
    1220   delete pert_vector1;
    1221 
    1222   CHECK_OVERFLOW:
    1223   intvec* result = new intvec(nV);
    1224 
    1225   /* 2147483647 is max. integer representation in SINGULAR */
    1226   mpz_t sing_int;
    1227   mpz_init_set_ui(sing_int,  2147483647);
    1228 
    1229   int ntrue=0;
    1230   for(i=0; i<nV; i++)
    1231   {
    1232     (*result)[i] = mpz_get_si(pert_vector[i]);
    1233     if(mpz_cmp(pert_vector[i], sing_int)>=0)
    1234     {
    1235       ntrue++;
    1236       if(Overflow_Error == FALSE)
    1237       {
    1238         Overflow_Error = TRUE;
    1239         PrintS("\n// ** OVERFLOW in \"MPertvectors\": ");
    1240         mpz_out_str( stdout, 10, pert_vector[i]);
    1241         PrintS(" is greater than 2147483647 (max. integer representation)");
    1242         Print("\n//  So vector[%d] := %d is wrong!!", i+1, (*result)[i]);
    1243       }
    1244     }
    1245   }
    1246 
    1247   if(Overflow_Error == TRUE)
    1248   {
    1249     ivString(result, "pert_vector");
    1250     Print("\n// %d element(s) of it is overflow!!", ntrue);
     1255      (*result)[i] = mpz_get_si(pert_vector[i]);
     1256      if(mpz_cmp(pert_vector[i], sing_int)>=0)
     1257      {
     1258        ntrue++;
     1259        if(Overflow_Error == FALSE)
     1260        {
     1261          Overflow_Error = TRUE;
     1262          PrintS("\n// ** OVERFLOW in \"MPertvectors\": ");
     1263          mpz_out_str( stdout, 10, pert_vector[i]);
     1264          PrintS(" is greater than 2147483647 (max. integer representation)");
     1265          Print("\n//  So vector[%d] := %d is wrong!!", i+1, (*result)[i]);
     1266        }
     1267      }
     1268    }
     1269
     1270    if(Overflow_Error == TRUE)
     1271    {
     1272      ivString(result, "pert_vector");
     1273      Print("\n// %d element(s) of it is overflow!!", ntrue);
     1274    }
    12511275  }
    12521276
    12531277  mpz_clear(ztemp);
    12541278  mpz_clear(sing_int);
     1279  mpz_clear(check_int);
    12551280  omFree(pert_vector);
    1256   //omFree(pert_vector1);
     1281  omFree(pert_vector1);
    12571282  mpz_clear(tot_deg);
    12581283  mpz_clear(maxdeg);
     
    14561481
    14571482//unused
    1458 #if 0
     1483/*
    14591484static intvec* MatrixOrderdp(int nV)
    14601485{
     
    14721497  return(ivM);
    14731498}
    1474 #endif
     1499*/
    14751500
    14761501intvec* MivUnit(int nV)
     
    15491574    mpz_cdiv_q_ui(inveps, inveps, nV);
    15501575  }
    1551   //PrintS("\n// choose the \"small\" inverse epsilon!");
     1576  // choose the small inverse epsilon
    15521577#endif
    15531578
     
    15831608
    15841609    for(j=0; j<nV; j++)
    1585       {
     1610    {
    15861611      mpz_init_set(pert_vector[i*nV+j],ivtemp[j]);
    1587       }
    1588   }
    1589 
    1590   /* 2147483647 is max. integer representation in SINGULAR */
     1612    }
     1613  }
     1614
     1615  // 2147483647 is max. integer representation in SINGULAR
    15911616  mpz_t sing_int;
    15921617  mpz_init_set_ui(sing_int,  2147483647);
     
    16111636    mpz_divexact(pert_vector[i], pert_vector[i], ztmp);
    16121637    (* result)[i] = mpz_get_si(pert_vector[i]);
    1613   }
    1614 
    1615   j = 0;
    1616   for(i=0; i<nV; i++)
    1617   {
    1618     (* result1)[i] = mpz_get_si(pert_vector[i]);
    1619     (* result1)[i] = 0.1*(* result1)[i];
    1620     (* result1)[i] = floor((* result1)[i] + 0.5);
    1621     if((* result1)[i] == 0)
    1622     {
    1623       j++;
    1624     }
    1625   }
    1626   if(j > nV - 1)
    1627   {
    1628     // Print("\n//  MfPertwalk: geaenderter vector gleich Null! \n");
    1629     delete result1;
    1630     goto CHECK_OVERFLOW;
    1631   }
    1632 
    1633 // check that the perturbed weight vector lies in the Groebner cone
    1634   if(test_w_in_ConeCC(G,result1) != 0)
    1635   {
    1636     // Print("\n//  MfPertwalk: geaenderter vector liegt in Groebnerkegel! \n");
    1637     delete result;
    1638     result = result1;
    1639     for(i=0; i<nV; i++)
    1640     {
    1641       mpz_set_si(pert_vector[i], (*result1)[i]);
    1642     }
    1643   }
    1644   else
    1645   {
    1646     delete result1;
    1647     // Print("\n// Mfpertwalk: geaenderter vector liegt nicht in Groebnerkegel! \n");
    16481638  }
    16491639
     
    16851675    while(p!=NULL)
    16861676    {
    1687       p_Setm(p,currRing); pIter(p);
     1677      p_Setm(p,currRing);
     1678      pIter(p);
    16881679    }
    16891680  }
     
    17681759
    17691760//unused
    1770 #if 0
     1761/*
    17711762static void checkidealCC(ideal G, char* Ch)
    17721763{
     
    17941785  PrintLn();
    17951786}
    1796 #endif
     1787*/
    17971788
    17981789//unused
    1799 #if 0
     1790/*
    18001791static void HeadidString(ideal L, char* st)
    18011792{
     
    18091800  Print(" %s;\n", pString(pHead(L->m[nL])));
    18101801}
    1811 #endif
    1812 
     1802
     1803*/
    18131804static inline int MivComp(intvec* iva, intvec* ivb)
    18141805{
     
    18591850}
    18601851
     1852
     1853/**************************************************************
     1854 * Look for the position of the smallest absolut value in vec *
     1855 **************************************************************/
     1856static int MivAbsMaxArg(intvec* vec)
     1857{
     1858  int k = MivAbsMax(vec);
     1859  int i=0;
     1860  while(1)
     1861  {
     1862    if((*vec)[i] == k || (*vec)[i] == -k)
     1863    {
     1864      break;
     1865    }
     1866    i++;
     1867  }
     1868  return i;
     1869}
     1870
     1871
    18611872/**********************************************************************
    18621873 * Compute a next weight vector between curr_weight and target_weight *
    18631874 * with respect to an ideal <G>.                                      *
    18641875**********************************************************************/
     1876/*
    18651877static intvec* MwalkNextWeightCC(intvec* curr_weight, intvec* target_weight,
    18661878                                 ideal G)
     
    18731885
    18741886  int nRing = currRing->N;
    1875   int checkRed, j, kkk, nG = IDELEMS(G);
     1887  int checkRed, j, nG = IDELEMS(G);
    18761888  intvec* ivtemp;
    18771889
     
    19111923  mpz_init(dcw);
    19121924
    1913   //int tn0, tn1, tz1, ncmp, gcd_tmp, ntmp;
    19141925  int gcd_tmp;
    19151926  intvec* diff_weight = MivSub(target_weight, curr_weight);
     
    19171928  intvec* diff_weight1 = MivSub(target_weight, curr_weight);
    19181929  poly g;
    1919   //poly g, gw;
     1930
    19201931  for (j=0; j<nG; j++)
    19211932  {
     
    19341945        mpz_set_si(MwWd, MivDotProduct(ivtemp, curr_weight));
    19351946        mpz_sub(s_zaehler, deg_w0_p1, MwWd);
    1936 
    19371947        if(mpz_cmp(s_zaehler, t_null) != 0)
    19381948        {
    19391949          mpz_set_si(MwWd, MivDotProduct(ivtemp, diff_weight));
    19401950          mpz_sub(s_nenner, MwWd, deg_d0_p1);
    1941 
    19421951          // check for 0 < s <= 1
    19431952          if( (mpz_cmp(s_zaehler,t_null) > 0 &&
     
    19791988    }
    19801989  }
    1981 //Print("\n// Alloc Size = %d \n", nRing*sizeof(mpz_t));
     1990  //Print("\n// Alloc Size = %d \n", nRing*sizeof(mpz_t));
    19821991  mpz_t *vec=(mpz_t*)omAlloc(nRing*sizeof(mpz_t));
    19831992
    19841993
    1985   // there is no 0<t<1 and define the next weight vector that is equal to the current weight vector
     1994  // there is no 0<t<1 and define the next weight vector that is equal
     1995  // to the current weight vector
    19861996  if(mpz_cmp(t_nenner, t_null) == 0)
    19871997  {
    1988     #ifndef SING_NDEBUG
    1989     Print("\n//MwalkNextWeightCC: t_nenner ist Null!");
    1990     #endif
     1998#ifndef SING_NDEBUG
     1999    Print("\n//MwalkNextWeightCC: t_nenner=0\n");
     2000#endif
    19912001    delete diff_weight;
    19922002    diff_weight = ivCopy(curr_weight);//take memory
     
    20542064#endif
    20552065
    2056   //  BOOLEAN isdwpos;
    2057 
    2058   // construct a new weight vector
     2066// construct a new weight vector and check whether vec[j] is overflow,
     2067// i.e. vec[j] > 2^31.
     2068// If vec[j] doesn't overflow, define a weight vector. Otherwise,
     2069// report that overflow appears. In the second case, test whether the
     2070// the correctness of the new vector plays an important role
     2071
    20592072  for (j=0; j<nRing; j++)
    20602073  {
     
    21002113    }
    21012114  }
    2102 
     2115  // reduce the vector with the gcd
     2116  if(mpz_cmp_si(ggt,1) != 0)
     2117  {
     2118    for (j=0; j<nRing; j++)
     2119    {
     2120      mpz_divexact(vec[j], vec[j], ggt);
     2121    }
     2122  }
    21032123#ifdef  NEXT_VECTORS_CC
    21042124  PrintS("\n// gcd of elements of the vector: ");
     
    21062126#endif
    21072127
    2108 /**********************************************************************
    2109 * construct a new weight vector and check whether vec[j] is overflow, *
    2110 * i.e. vec[j] > 2^31.                                                 *
    2111 * If vec[j] doesn't overflow, define a weight vector. Otherwise,      *
    2112 * report that overflow appears. In the second case, test whether the  *
    2113 * the correctness of the new vector plays an important role           *
    2114 **********************************************************************/
    2115   kkk=0;
    21162128  for(j=0; j<nRing; j++)
    2117     {
     2129  {
    21182130    if(mpz_cmp(vec[j], sing_int_half) >= 0)
    2119       {
     2131    {
    21202132      goto REDUCTION;
    2121       }
    2122     }
     2133    }
     2134  }
    21232135  checkRed = 1;
    21242136  for (j=0; j<nRing; j++)
     
    21292141
    21302142  REDUCTION:
     2143  checkRed = 1;
    21312144  for (j=0; j<nRing; j++)
    21322145  {
    2133     (*diff_weight)[j] = mpz_get_si(vec[j]);
    2134   }
    2135   while(MivAbsMax(diff_weight) >= 5)
    2136   {
    2137     for (j=0; j<nRing; j++)
    2138     {
    2139       if(mpz_cmp_si(ggt,1)==0)
    2140       {
    2141         (*diff_weight1)[j] = floor(0.1*(*diff_weight)[j] + 0.5);
    2142         // Print("\n//  vector[%d] = %d \n",j+1, (*diff_weight1)[j]);
    2143       }
    2144       else
    2145       {
    2146         mpz_divexact(vec[j], vec[j], ggt);
    2147         (*diff_weight1)[j] = floor(0.1*(*diff_weight)[j] + 0.5);
    2148         // Print("\n//  vector[%d] = %d \n",j+1, (*diff_weight1)[j]);
    2149       }
    2150 /*
    2151       if((*diff_weight1)[j] == 0)
    2152       {
    2153         kkk = kkk + 1;
    2154       }
    2155 */
    2156     }
    2157 
    2158 
    2159 /*
    2160     if(kkk > nRing - 1)
    2161     {
    2162       // diff_weight was reduced to zero
    2163       // Print("\n // MwalkNextWeightCC: geaenderter Vector gleich Null! \n");
    2164       goto TEST_OVERFLOW;
    2165     }
    2166 */
    2167 
    2168     if(test_w_in_ConeCC(G,diff_weight1) != 0)
    2169     {
    2170       Print("\n// MwalkNextWeightCC: geaenderter vector liegt in Groebnerkegel! \n");
    2171       for (j=0; j<nRing; j++)
    2172       {
    2173         (*diff_weight)[j] = (*diff_weight1)[j];
    2174       }
    2175       if(MivAbsMax(diff_weight) < 5)
    2176       {
    2177         checkRed = 1;
    2178         goto SIMPLIFY_GCD;
    2179       }
    2180     }
    2181     else
    2182     {
    2183       // Print("\n// MwalkNextWeightCC: geaenderter vector liegt nicht in Groebnerkegel! \n");
    2184       break;
    2185     }
     2146    (*diff_weight1)[j] = mpz_get_si(vec[j]);
     2147  }
     2148  while(test_w_in_ConeCC(G,diff_weight1))
     2149  {
     2150    for(j=0; j<nRing; j++)
     2151    {
     2152      (*diff_weight)[j] = (*diff_weight1)[j];
     2153      mpz_set_si(vec[j], (*diff_weight)[j]);     
     2154    }
     2155    for(j=0; j<nRing; j++)
     2156    {
     2157      (*diff_weight1)[j] = floor(0.1*(*diff_weight)[j] + 0.5);
     2158    }
     2159  }
     2160  if(MivAbsMax(diff_weight)>10000)
     2161  {
     2162    for(j=0; j<nRing; j++)
     2163    {
     2164      (*diff_weight1)[j] = (*diff_weight)[j];
     2165    }
     2166    j = 0;
     2167    while(test_w_in_ConeCC(G,diff_weight1))
     2168    {
     2169      (*diff_weight)[j] = (*diff_weight1)[j];
     2170      mpz_set_si(vec[j], (*diff_weight)[j]);
     2171      j = MivAbsMaxArg(diff_weight1);
     2172      (*diff_weight1)[j] = floor(0.1*(*diff_weight1)[j] + 0.5);
     2173    }
     2174    goto SIMPLIFY_GCD;
    21862175  }
    21872176
     
    22222211   mpz_clear(t_null);
    22232212
    2224 
    2225 
    22262213  if(Overflow_Error == FALSE)
    22272214  {
    22282215    Overflow_Error = nError;
    22292216  }
    2230  rComplete(currRing);
    2231   for(kkk=0; kkk<IDELEMS(G);kkk++)
    2232   {
    2233     poly p=G->m[kkk];
     2217  rComplete(currRing);
     2218  for(j=0; j<IDELEMS(G); j++)
     2219  {
     2220    poly p=G->m[j];
    22342221    while(p!=NULL)
    22352222    {
     
    22402227return diff_weight;
    22412228}
     2229*/
     2230/**********************************************************************
     2231 * Compute a next weight vector between curr_weight and target_weight *
     2232 * with respect to an ideal <G>.                                      *
     2233**********************************************************************/
     2234static intvec* MwalkNextWeightCC(intvec* curr_weight, intvec* target_weight,
     2235                                 ideal G)
     2236{
     2237  BOOLEAN nError = Overflow_Error;
     2238  Overflow_Error = FALSE;
     2239
     2240  assume(currRing != NULL && curr_weight != NULL &&
     2241         target_weight != NULL && G != NULL);
     2242
     2243  int nRing = currRing->N;
     2244  int checkRed, j, nG = IDELEMS(G);
     2245  intvec* ivtemp;
     2246
     2247  mpz_t t_zaehler, t_nenner;
     2248  mpz_init(t_zaehler);
     2249  mpz_init(t_nenner);
     2250
     2251  mpz_t s_zaehler, s_nenner, temp, MwWd;
     2252  mpz_init(s_zaehler);
     2253  mpz_init(s_nenner);
     2254  mpz_init(temp);
     2255  mpz_init(MwWd);
     2256
     2257  mpz_t sing_int;
     2258  mpz_init(sing_int);
     2259  mpz_set_si(sing_int,  2147483647);
     2260
     2261  mpz_t sing_int_half;
     2262  mpz_init(sing_int_half);
     2263  mpz_set_si(sing_int_half,  3*(1073741824/2));
     2264
     2265  mpz_t deg_w0_p1, deg_d0_p1;
     2266  mpz_init(deg_w0_p1);
     2267  mpz_init(deg_d0_p1);
     2268
     2269  mpz_t sztn, sntz;
     2270  mpz_init(sztn);
     2271  mpz_init(sntz);
     2272
     2273  mpz_t t_null;
     2274  mpz_init(t_null);
     2275
     2276  mpz_t ggt;
     2277  mpz_init(ggt);
     2278
     2279  mpz_t dcw;
     2280  mpz_init(dcw);
     2281
     2282  int gcd_tmp;
     2283  //intvec* diff_weight = MivSub(target_weight, curr_weight);
     2284
     2285  intvec* diff_weight1 = new intvec(nRing); //MivSub(target_weight, curr_weight);
     2286  poly g;
     2287
     2288  // reduce the size of the entries of the current weight vector
     2289  if(TEST_OPT_REDSB)
     2290  {
     2291    for (j=0; j<nRing; j++)
     2292    {
     2293      (*diff_weight1)[j] = (*curr_weight)[j];
     2294    }
     2295    while(MivAbsMax(diff_weight1)>10000 && test_w_in_ConeCC(G,diff_weight1)==1)
     2296    {
     2297      for(j=0; j<nRing; j++)
     2298      {
     2299        (*curr_weight)[j] = (*diff_weight1)[j]; 
     2300      }
     2301      for(j=0; j<nRing; j++)
     2302      {
     2303        (*diff_weight1)[j] = floor(0.1*(*diff_weight1)[j] + 0.5);
     2304      }
     2305    }
     2306
     2307    if(MivAbsMax(curr_weight)>100000)
     2308    {
     2309      for(j=0; j<nRing; j++)
     2310      {
     2311        (*diff_weight1)[j] = (*curr_weight)[j];
     2312      }
     2313      j = 0;
     2314      while(test_w_in_ConeCC(G,diff_weight1)==1 && MivAbsMax(diff_weight1)>1000)
     2315      {
     2316        (*curr_weight)[j] = (*diff_weight1)[j];
     2317        j = MivAbsMaxArg(diff_weight1);
     2318        (*diff_weight1)[j] = floor(0.1*(*diff_weight1)[j] + 0.5);
     2319      }
     2320    }
     2321
     2322  }
     2323  intvec* diff_weight = MivSub(target_weight, curr_weight);
     2324
     2325  // compute a suitable next weight vector
     2326  for (j=0; j<nG; j++)
     2327  {
     2328    g = G->m[j];
     2329    if (g != NULL)
     2330    {
     2331      ivtemp = MExpPol(g);
     2332      mpz_set_si(deg_w0_p1, MivDotProduct(ivtemp, curr_weight));
     2333      mpz_set_si(deg_d0_p1, MivDotProduct(ivtemp, diff_weight));
     2334      delete ivtemp;
     2335
     2336      pIter(g);
     2337      while (g != NULL)
     2338      {
     2339        ivtemp = MExpPol(g);
     2340        mpz_set_si(MwWd, MivDotProduct(ivtemp, curr_weight));
     2341        mpz_sub(s_zaehler, deg_w0_p1, MwWd);
     2342        if(mpz_cmp(s_zaehler, t_null) != 0)
     2343        {
     2344          mpz_set_si(MwWd, MivDotProduct(ivtemp, diff_weight));
     2345          mpz_sub(s_nenner, MwWd, deg_d0_p1);
     2346          // check for 0 < s <= 1
     2347          if( (mpz_cmp(s_zaehler,t_null) > 0 &&
     2348               mpz_cmp(s_nenner, s_zaehler)>=0) ||
     2349              (mpz_cmp(s_zaehler, t_null) < 0 &&
     2350               mpz_cmp(s_nenner, s_zaehler)<=0))
     2351          {
     2352            // make both positive
     2353            if (mpz_cmp(s_zaehler, t_null) < 0)
     2354            {
     2355              mpz_neg(s_zaehler, s_zaehler);
     2356              mpz_neg(s_nenner, s_nenner);
     2357            }
     2358
     2359            //compute a simple fraction of s
     2360            cancel(s_zaehler, s_nenner);
     2361
     2362            if(mpz_cmp(t_nenner, t_null) != 0)
     2363            {
     2364              mpz_mul(sztn, s_zaehler, t_nenner);
     2365              mpz_mul(sntz, s_nenner, t_zaehler);
     2366
     2367              if(mpz_cmp(sztn,sntz) < 0)
     2368              {
     2369                mpz_add(t_nenner, t_null, s_nenner);
     2370                mpz_add(t_zaehler,t_null, s_zaehler);
     2371              }
     2372            }
     2373            else
     2374            {
     2375              mpz_add(t_nenner, t_null, s_nenner);
     2376              mpz_add(t_zaehler,t_null, s_zaehler);
     2377            }
     2378          }
     2379        }
     2380        pIter(g);
     2381        delete ivtemp;
     2382      }
     2383    }
     2384  }
     2385  //Print("\n// Alloc Size = %d \n", nRing*sizeof(mpz_t));
     2386  mpz_t *vec=(mpz_t*)omAlloc(nRing*sizeof(mpz_t));
     2387
     2388
     2389  // there is no 0<t<1 and define the next weight vector that is equal
     2390  // to the current weight vector
     2391  if(mpz_cmp(t_nenner, t_null) == 0)
     2392  {
     2393#ifndef SING_NDEBUG
     2394    Print("\n//MwalkNextWeightCC: t_nenner=0\n");
     2395#endif
     2396    delete diff_weight;
     2397    diff_weight = ivCopy(curr_weight);//take memory
     2398    goto FINISH;
     2399  }
     2400
     2401  // define the target vector as the next weight vector, if t = 1
     2402  if(mpz_cmp_si(t_nenner, 1)==0 && mpz_cmp_si(t_zaehler,1)==0)
     2403  {
     2404    delete diff_weight;
     2405    diff_weight = ivCopy(target_weight); //this takes memory
     2406    goto FINISH;
     2407  }
     2408
     2409   //checkRed = 0;
     2410
     2411  SIMPLIFY_GCD:
     2412
     2413  // simplify the vectors curr_weight and diff_weight (C-int)
     2414  gcd_tmp = (*curr_weight)[0];
     2415
     2416  for (j=1; j<nRing; j++)
     2417  {
     2418    gcd_tmp = gcd(gcd_tmp, (*curr_weight)[j]);
     2419    if(gcd_tmp == 1)
     2420    {
     2421      break;
     2422    }
     2423  }
     2424  if(gcd_tmp != 1)
     2425  {
     2426    for (j=0; j<nRing; j++)
     2427    {
     2428      gcd_tmp = gcd(gcd_tmp, (*diff_weight)[j]);
     2429      if(gcd_tmp == 1)
     2430      {
     2431        break;
     2432      }
     2433    }
     2434  }
     2435  if(gcd_tmp != 1)
     2436  {
     2437    for (j=0; j<nRing; j++)
     2438    {
     2439      (*curr_weight)[j] =  (*curr_weight)[j]/gcd_tmp;
     2440      (*diff_weight)[j] =  (*diff_weight)[j]/gcd_tmp;
     2441    }
     2442  }
     2443  if(checkRed > 0)
     2444  {
     2445    for (j=0; j<nRing; j++)
     2446    {
     2447      mpz_set_si(vec[j], (*diff_weight)[j]);
     2448    }
     2449    goto TEST_OVERFLOW;
     2450  }
     2451
     2452#ifdef  NEXT_VECTORS_CC
     2453  Print("\n// gcd of the weight vectors (current and target) = %d", gcd_tmp);
     2454  ivString(curr_weight, "new cw");
     2455  ivString(diff_weight, "new dw");
     2456
     2457  PrintS("\n// t_zaehler: ");  mpz_out_str( stdout, 10, t_zaehler);
     2458  PrintS(", t_nenner: ");  mpz_out_str( stdout, 10, t_nenner);
     2459#endif
     2460
     2461// construct a new weight vector and check whether vec[j] is overflow, i.e. vec[j] > 2^31.
     2462// If vec[j] doesn't overflow, define a weight vector. Otherwise, report that overflow
     2463// appears. In the second case, test whether the the correctness of the new vector plays
     2464// an important role
     2465
     2466  for (j=0; j<nRing; j++)
     2467  {
     2468    mpz_set_si(dcw, (*curr_weight)[j]);
     2469    mpz_mul(s_nenner, t_nenner, dcw);
     2470
     2471    if( (*diff_weight)[j]>0)
     2472    {
     2473      mpz_mul_ui(s_zaehler, t_zaehler, (*diff_weight)[j]);
     2474    }
     2475    else
     2476    {
     2477      mpz_mul_ui(s_zaehler, t_zaehler, -(*diff_weight)[j]);
     2478      mpz_neg(s_zaehler, s_zaehler);
     2479    }
     2480    mpz_add(sntz, s_nenner, s_zaehler);
     2481    mpz_init_set(vec[j], sntz);
     2482
     2483#ifdef NEXT_VECTORS_CC
     2484    Print("\n//   j = %d ==> ", j);
     2485    PrintS("(");
     2486    mpz_out_str( stdout, 10, t_nenner);
     2487    Print(" * %d)", (*curr_weight)[j]);
     2488    Print(" + ("); mpz_out_str( stdout, 10, t_zaehler);
     2489    Print(" * %d) =  ",  (*diff_weight)[j]);
     2490    mpz_out_str( stdout, 10, s_nenner);
     2491    PrintS(" + ");
     2492    mpz_out_str( stdout, 10, s_zaehler);
     2493    PrintS(" = "); mpz_out_str( stdout, 10, sntz);
     2494    Print(" ==> vector[%d]: ", j); mpz_out_str(stdout, 10, vec[j]);
     2495#endif
     2496
     2497    if(j==0)
     2498    {
     2499      mpz_set(ggt, sntz);
     2500    }
     2501    else
     2502    {
     2503      if(mpz_cmp_si(ggt,1) != 0)
     2504      {
     2505        mpz_gcd(ggt, ggt, sntz);
     2506      }
     2507    }
     2508  }
     2509  // reduce the vector with the gcd
     2510  if(mpz_cmp_si(ggt,1) != 0)
     2511  {
     2512    for (j=0; j<nRing; j++)
     2513    {
     2514      mpz_divexact(vec[j], vec[j], ggt);
     2515    }
     2516  }
     2517#ifdef  NEXT_VECTORS_CC
     2518  PrintS("\n// gcd of elements of the vector: ");
     2519  mpz_out_str( stdout, 10, ggt);
     2520#endif
     2521
     2522  for (j=0; j<nRing; j++)
     2523  {
     2524    (*diff_weight)[j] = mpz_get_si(vec[j]);
     2525  }
     2526
     2527 TEST_OVERFLOW:
     2528
     2529  for (j=0; j<nRing; j++)
     2530  {
     2531    if(mpz_cmp(vec[j], sing_int)>=0)
     2532    {
     2533      if(Overflow_Error == FALSE)
     2534      {
     2535        Overflow_Error = TRUE;
     2536        PrintS("\n// ** OVERFLOW in \"MwalkNextWeightCC\": ");
     2537        mpz_out_str( stdout, 10, vec[j]);
     2538        PrintS(" is greater than 2147483647 (max. integer representation)\n");
     2539        Print("//  So vector[%d] := %d is wrong!!\n",j+1, vec[j]);// vec[j] is mpz_t
     2540      }
     2541    }
     2542  }
     2543
     2544 FINISH:
     2545   delete diff_weight1;
     2546   mpz_clear(t_zaehler);
     2547   mpz_clear(t_nenner);
     2548   mpz_clear(s_zaehler);
     2549   mpz_clear(s_nenner);
     2550   mpz_clear(sntz);
     2551   mpz_clear(sztn);
     2552   mpz_clear(temp);
     2553   mpz_clear(MwWd);
     2554   mpz_clear(deg_w0_p1);
     2555   mpz_clear(deg_d0_p1);
     2556   mpz_clear(ggt);
     2557   omFree(vec);
     2558   mpz_clear(sing_int_half);
     2559   mpz_clear(sing_int);
     2560   mpz_clear(dcw);
     2561   mpz_clear(t_null);
     2562
     2563  if(Overflow_Error == FALSE)
     2564  {
     2565    Overflow_Error = nError;
     2566  }
     2567  rComplete(currRing);
     2568  for(j=0; j<IDELEMS(G); j++)
     2569  {
     2570    poly p=G->m[j];
     2571    while(p!=NULL)
     2572    {
     2573      p_Setm(p,currRing);
     2574      pIter(p);
     2575    }
     2576  }
     2577return diff_weight;
     2578}
     2579
    22422580
    22432581/**********************************************************************
     
    22712609}
    22722610
    2273 /**************************************************************
     2611/********************************************************************
    22742612 * define and execute a new ring which order is (a(vb),a(va),lp,C)  *
    2275  * ************************************************************/
    2276 #if 0
    2277 // unused
     2613 * ******************************************************************/
    22782614static void VMrHomogeneous(intvec* va, intvec* vb)
    22792615{
     
    23532689  rChangeCurrRing(r);
    23542690}
    2355 #endif
     2691
    23562692
    23572693/**************************************************************
     
    24282764}
    24292765
    2430 static ring VMrDefault1(intvec* va)
    2431 {
    2432 
    2433   if ((currRing->ppNoether)!=NULL)
    2434   {
    2435     pDelete(&(currRing->ppNoether));
    2436   }
    2437   if (((sLastPrinted.rtyp>BEGIN_RING) && (sLastPrinted.rtyp<END_RING)) ||
    2438       ((sLastPrinted.rtyp==LIST_CMD)&&(lRingDependend((lists)sLastPrinted.data))))
    2439   {
    2440     sLastPrinted.CleanUp();
    2441   }
    2442 
    2443   ring r = (ring) omAlloc0Bin(sip_sring_bin);
    2444   int i, nv = currRing->N;
    2445 
    2446   r->cf  = currRing->cf;
    2447   r->N   = currRing->N;
    2448 
    2449   int nb = 4;
    2450 
    2451   //names
    2452   char* Q; // In order to avoid the corrupted memory, do not change.
    2453   r->names = (char **) omAlloc0(nv * sizeof(char_ptr));
    2454   for(i=0; i<nv; i++)
    2455   {
    2456     Q = currRing->names[i];
    2457     r->names[i]  = omStrDup(Q);
    2458   }
    2459 
    2460   /*weights: entries for 3 blocks: NULL Made:???*/
    2461   r->wvhdl = (int **)omAlloc0(nb * sizeof(int_ptr));
    2462   r->wvhdl[0] = (int*) omAlloc(nv*sizeof(int));
    2463   for(i=0; i<nv; i++)
    2464     r->wvhdl[0][i] = (*va)[i];
    2465 
    2466   /* order: a,lp,C,0 */
    2467   r->order = (int *) omAlloc(nb * sizeof(int *));
    2468   r->block0 = (int *)omAlloc0(nb * sizeof(int *));
    2469   r->block1 = (int *)omAlloc0(nb * sizeof(int *));
    2470 
    2471   // ringorder a for the first block: var 1..nv
    2472   r->order[0]  = ringorder_a;
    2473   r->block0[0] = 1;
    2474   r->block1[0] = nv;
    2475 
    2476   // ringorder lp for the second block: var 1..nv
    2477   r->order[1]  = ringorder_lp;
    2478   r->block0[1] = 1;
    2479   r->block1[1] = nv;
    2480 
    2481   // ringorder C for the third block
    2482   // it is very important within "idLift",
    2483   // especially, by ring syz_ring=rCurrRingAssure_SyzComp();
    2484   // therefore, nb  must be (nBlocks(currRing)  + 1)
    2485   r->order[2]  = ringorder_C;
    2486 
    2487   // the last block: everything is 0
    2488   r->order[3]  = 0;
    2489 
    2490   // polynomial ring
    2491   r->OrdSgn    = 1;
    2492 
    2493   // complete ring intializations
    2494 
    2495   rComplete(r);
    2496 
    2497   //rChangeCurrRing(r);
    2498   return r;
    2499 }
    2500 
    25012766/****************************************************************
    25022767 * define and execute a new ring with ordering (a(va),Wp(vb),C) *
    25032768 * **************************************************************/
    2504 
    25052769static ring VMrRefine(intvec* va, intvec* vb)
    25062770{
     
    25762840
    25772841  // complete ring intializations
    2578 
     2842 
    25792843  rComplete(r);
    25802844
     
    28063070}
    28073071
    2808 
    2809 /* define a ring with parameters und change to it */
    2810 /* DefRingPar and DefRingParlp corrupt still memory */
     3072/***************************************************
     3073* define a ring with parameters und change to it   *
     3074* DefRingPar and DefRingParlp corrupt still memory *
     3075****************************************************/
    28113076static void DefRingPar(intvec* va)
    28123077{
     
    29563221}
    29573222
    2958 //unused
    2959 /**************************************************************
    2960  * check wheather one or more components of a vector are zero *
    2961  **************************************************************/
    2962 #if 0
     3223/*************************************************************
     3224 * check whether one or more components of a vector are zero *
     3225 *************************************************************/
    29633226static int isNolVector(intvec* hilb)
    29643227{
     
    29733236  return 0;
    29743237}
    2975 #endif
     3238
     3239/*************************************************************
     3240 * check whether one or more components of a vector are <= 0 *
     3241 *************************************************************/
     3242static int isNegNolVector(intvec* hilb)
     3243{
     3244  int i;
     3245  for(i=hilb->length()-1; i>=0; i--)
     3246  {
     3247    if((* hilb)[i]<=0)
     3248    {
     3249      return 1;
     3250    }
     3251  }
     3252  return 0;
     3253}
     3254
     3255/**************************************************************************
     3256* Gomega is the initial ideal of G w. r. t. the current weight vector     *
     3257* curr_weight. Check whether curr_weight lies on a border of the Groebner *
     3258* cone, i. e. check whether a monomial is divisible by a leading monomial *
     3259***************************************************************************/
     3260static ideal middleOfCone(ideal G, ideal Gomega)
     3261{
     3262  BOOLEAN middle = FALSE;
     3263  int i,j,N = IDELEMS(Gomega);
     3264  poly p,lm,factor1,factor2;
     3265
     3266  ideal Go = idCopy(G);
     3267 
     3268  // check whether leading monomials of G and Gomega coincide
     3269  // and return NULL if not
     3270  for(i=0; i<N; i++)
     3271  {
     3272    if(!pIsConstant(pSub(pCopy(Gomega->m[i]),pCopy(pHead(G->m[i])))))
     3273    {
     3274      idDelete(&Go);
     3275      return NULL;
     3276    }
     3277  }
     3278  for(i=0; i<N; i++)
     3279  {
     3280    for(j=0; j<N; j++)
     3281    {
     3282      if(i!=j)
     3283      {
     3284        p = pCopy(Gomega->m[i]);
     3285        lm = pCopy(Gomega->m[j]);
     3286        pIter(p);
     3287        while(p!=NULL)
     3288        {
     3289          if(pDivisibleBy(lm,p))
     3290          {
     3291            if(middle == FALSE)
     3292            {
     3293              middle = TRUE;
     3294            }
     3295            factor1 = singclap_pdivide(pHead(p),lm,currRing);
     3296            factor2 = pMult(pCopy(factor1),pCopy(Go->m[j]));
     3297            pDelete(&factor1);
     3298            Go->m[i] = pAdd((Go->m[i]),pNeg(pCopy(factor2)));
     3299            pDelete(&factor2);
     3300          }
     3301          pIter(p);
     3302        }
     3303        pDelete(&lm);
     3304        pDelete(&p);
     3305      }
     3306    }
     3307  }
     3308
     3309  if(middle == TRUE)
     3310  {
     3311    return Go;
     3312  }
     3313  idDelete(&Go);
     3314  return NULL;
     3315}
    29763316
    29773317/******************************  Februar 2002  ****************************
     
    31043444    {
    31053445      Print("\n// ring r%d_%d = %s;\n", tp_deg, nwalk, rString(currRing));
     3446/*
    31063447      idElements(Gomega, "Gw");
    31073448      headidString(Gomega, "Gw");
     3449*/
    31083450    }
    31093451#endif
     
    31283470    else
    31293471    {
    3130       rChangeCurrRing(VMrDefault(curr_weight)); //Aenderung
     3472      rChangeCurrRing(VMrDefault(curr_weight));
    31313473    }
    31323474    newRing = currRing;
     
    32553597
    32563598/**********************************************************
    3257  * check whether a polynomial of G has least 3 monomials  *
     3599 * check whether a polynomial of G has least 4 monomials  *
    32583600 **********************************************************/
    32593601static int lengthpoly(ideal G)
     
    32623604  for(i=IDELEMS(G)-1; i>=0; i--)
    32633605  {
    3264 #if 0
    3265     if(pLength(G->m[i])>2)
    3266     {
    3267       return 1;
    3268     }
    3269 #else
    32703606    if((G->m[i]!=NULL) /* len >=0 */
    32713607       && (G->m[i]->next!=NULL) /* len >=1 */
    32723608       && (G->m[i]->next->next!=NULL) /* len >=2 */
    32733609       && (G->m[i]->next->next->next!=NULL) /* len >=3 */
    3274       //&& (G->m[i]->next->next->next->next!=NULL) /* len >=4 */
    3275        )
    3276     {
    3277     return 1;
    3278     }
    3279 #endif
     3610       && (G->m[i]->next->next->next->next!=NULL) /* len >=4*/ )
     3611    {
     3612      return 1;
     3613    }
    32803614  }
    32813615  return 0;
     3616}
     3617
     3618/*****************************************
     3619 * return maximal polynomial length of G *
     3620 *****************************************/
     3621static int maxlengthpoly(ideal G)
     3622{
     3623  int i,k,length=0;
     3624  for(i=IDELEMS(G)-1; i>=0; i--)
     3625  {
     3626    k = pLength(G->m[i]);
     3627    if(k>length)
     3628    {
     3629      length = k;
     3630    }
     3631  }
     3632  return length;
    32823633}
    32833634
     
    33503701  for(i=nG-1; i>=0; i--)
    33513702  {
    3352 #if 0
     3703/*
    33533704    poly t;
    33543705    if((t=pSub(pCopy(H0->m[i]), pCopy(H1->m[i]))) != NULL)
     
    33583709    }
    33593710    pDelete(&t);
    3360 #else
     3711*/
    33613712    if(!pEqualPolys(H0->m[i],H1->m[i]))
    33623713    {
    33633714      return 0;
    33643715    }
    3365 #endif
    33663716  }
    33673717  return 1;
     
    33723722 * find the maximal total degree of polynomials in G *
    33733723 *****************************************************/
    3374 #if 0
     3724/*
    33753725static int Trandegreebound(ideal G)
    33763726{
     
    33933743  return result;
    33943744}
    3395 #endif
     3745*/
    33963746
    33973747//unused
     
    37404090 * basis or n times, where n is the numbers of variables.                    *
    37414091 *****************************************************************************/
    3742 
    3743 //unused
    3744 #if 0
    3745 static int testnegintvec(intvec* v)
    3746 {
    3747   int n = v->length();
    3748   int i;
    3749   for(i=0; i<n; i++)
    3750   {
    3751     if((*v)[i]<0)
    3752     {
    3753       return(1);
    3754     }
    3755   }
    3756   return(0);
    3757 }
    3758 #endif
    37594092
    37604093// npwinc = 0, if curr_weight doesn't stay in the correct Groebner cone
     
    38844217    else
    38854218    {
    3886       rChangeCurrRing(VMrDefault(curr_weight)); //Aenderung
     4219      rChangeCurrRing(VMrDefault(curr_weight));
    38874220    }
    38884221    newRing = currRing;
     
    39684301        //nOverflow_Error = Overflow_Error;
    39694302        tproc=tproc+clock()-tinput;
    3970         /*
    3971           Print("\n// takes %d steps and calls \"Rec_LastGB\" (%d):",
    3972           nwalk, tp_deg+1);
    3973         */
     4303       
     4304        Print("\n// takes %d steps and calls \"Rec_LastGB\" (%d):",
     4305        nwalk, tp_deg+1);
     4306       
    39744307        G = Rec_LastGB(G,curr_weight, orig_target_weight, tp_deg+1,nnwinC);
    39754308        newRing = currRing;
     
    40054338    {
    40064339      // nOverflow_Error = Overflow_Error;
    4007       //Print("\n//  takes %d steps and calls \"Rec_LastGB (%d):", tp_deg+1);
     4340      Print("\n//  takes %d steps and calls \"Rec_LastGB (%d):", tp_deg+1);
    40084341      tproc=tproc+clock()-tinput;
    40094342      F1 = Rec_LastGB(F1,curr_weight, orig_target_weight, tp_deg+1,nnwinC);
     
    40594392    Overflow_Error=nError;
    40604393    }
    4061 // Print("\n// \"Rec_LastGB\" (%d) took %d steps and %.2f sec.Overflow_Error (%d)", tp_deg, nwalk, ((double) tproc)/1000000, nOverflow_Error);
     4394#ifdef TIME_TEST
     4395   Print("\n// \"Rec_LastGB\" (%d) took %d steps and %.2f sec.Overflow_Error (%d)", tp_deg, nwalk, ((double) tproc)/1000000, nOverflow_Error);
     4396#endif
    40624397  return(result);
    40634398}
     
    40814416  //BOOLEAN nOverflow_Error = FALSE;
    40824417  //Print("// pSetm_Error = (%d)", ErrorCheck());
    4083 
     4418#ifdef TIME_TEST
    40844419  xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0; xtextra=0;
    40854420  xftinput = clock();
    40864421  clock_t tostd, tproc;
    4087 
     4422#endif
    40884423  nstep = 0;
    40894424  int i, nV = currRing->N;
     
    40964431  intvec* ivNull = new intvec(nV);
    40974432  intvec* next_weight;
    4098 #if 0
    4099   intvec* extra_curr_weight = new intvec(nV);
    4100 #endif
     4433  //intvec* extra_curr_weight = new intvec(nV);
    41014434  //intvec* hilb_func;
    41024435  intvec* exivlp = Mivlp(nV);
    4103 
    41044436  ring XXRing = currRing;
    41054437
    41064438  //Print("\n// ring r_input = %s;", rString(currRing));
     4439#ifdef TIME_TEST
    41074440  to = clock();
     4441#endif
    41084442  /* compute the reduced Groebner basis of the given ideal w.r.t.
    41094443     a "fast" monomial order, e.g. degree reverse lex. order (dp) */
    41104444  G = MstdCC(Go);
     4445#ifdef TIME_TEST
    41114446  tostd=clock()-to;
    41124447
    4113   /*
    41144448  Print("\n// Computation of the first std took = %.2f sec",
    41154449        ((double) tostd)/1000000);
    4116   */
     4450#endif
    41174451  if(currRing->order[0] == ringorder_a)
    41184452  {
     
    41234457    nwalk ++;
    41244458    nstep ++;
     4459#ifdef TIME_TEST
    41254460    to = clock();
     4461#endif
    41264462    /* compute an initial form ideal of <G> w.r.t. "curr_vector" */
    41274463    Gomega = MwalkInitialForm(G, curr_weight);
     4464#ifdef TIME_TEST
    41284465    xtif=xtif+clock()-to;
    4129 #if 0
     4466#endif
     4467/*
    41304468    if(Overflow_Error == TRUE)
    41314469    {
     
    41354473      goto LAST_GB_ALT2;
    41364474    }
    4137 #endif
     4475*/
    41384476    oldRing = currRing;
    41394477
     
    41454483    else
    41464484    {
    4147       rChangeCurrRing(VMrDefault(curr_weight)); // Aenderung
     4485      rChangeCurrRing(VMrDefault(curr_weight));
    41484486    }
    41494487    newRing = currRing;
    41504488    Gomega1 = idrMoveR(Gomega, oldRing,currRing);
     4489#ifdef TIME_TEST
    41514490    to = clock();
     4491#endif
    41524492    /* compute a reduced Groebner basis of <Gomega> w.r.t. "newRing" */
    41534493    M = MstdhomCC(Gomega1);
     4494#ifdef TIME_TEST
    41544495    xtstd=xtstd+clock()-to;
     4496#endif
    41554497    /* change the ring to oldRing */
    41564498    rChangeCurrRing(oldRing);
    41574499    M1 =  idrMoveR(M, newRing,currRing);
    41584500    Gomega2 =  idrMoveR(Gomega1, newRing,currRing);
    4159 
     4501#ifdef TIME_TEST
    41604502    to = clock();
     4503#endif
    41614504    /* compute the reduced Groebner basis of <G> w.r.t. "newRing"
    41624505       by the liftig process */
    41634506    F = MLifttwoIdeal(Gomega2, M1, G);
     4507#ifdef TIME_TEST
    41644508    xtlift=xtlift+clock()-to;
     4509#endif
    41654510    idDelete(&M1);
    41664511    idDelete(&Gomega2);
     
    41704515    rChangeCurrRing(newRing);
    41714516    F1 = idrMoveR(F, oldRing,currRing);
    4172 
     4517#ifdef TIME_TEST
    41734518    to = clock();
     4519#endif
    41744520    /* reduce the Groebner basis <G> w.r.t. newRing */
    41754521    G = kInterRedCC(F1, NULL);
     4522#ifdef TIME_TEST
    41764523    xtred=xtred+clock()-to;
     4524#endif
    41774525    idDelete(&F1);
    41784526
     
    41814529
    41824530  NEXT_VECTOR:
     4531#ifdef TIME_TEST
    41834532    to = clock();
     4533#endif
    41844534    /* compute a next weight vector */
    41854535    next_weight = MkInterRedNextWeight(curr_weight,target_weight, G);
     4536#ifdef TIME_TEST
    41864537    xtnw=xtnw+clock()-to;
     4538#endif
    41874539#ifdef PRINT_VECTORS
    41884540    MivString(curr_weight, target_weight, next_weight);
     
    42284580     // LAST_GB_ALT2:
    42294581        //nOverflow_Error = Overflow_Error;
     4582#ifdef TIME_TEST
    42304583        tproc = clock()-xftinput;
     4584#endif
    42314585        //Print("\n// takes %d steps and calls the recursion of level 2:",  nwalk);
    42324586        /* call the changed perturbation walk algorithm with degree 2 */
     
    42554609
    42564610#ifdef TIME_TEST
    4257  // Print("\n// \"Main procedure\"  took %d steps dnd %.2f sec. Overflow_Error (%d)", nwalk, ((double) tproc)/1000000, nOverflow_Error);
     4611  Print("\n// \"Main procedure\"  took %d steps dnd %.2f sec. Overflow_Error (%d)",
     4612        nwalk, ((double) tproc)/1000000, nOverflow_Error);
    42584613
    42594614  TimeStringFractal(xftinput, tostd, xtif, xtstd, xtextra,xtlift, xtred,xtnw);
     
    42874642intvec* Xivlp;
    42884643
    4289 #if 0
     4644
    42904645/********************************
    42914646 * compute a next weight vector *
    42924647 ********************************/
    4293 static intvec* MWalkRandomNextWeight(ideal G, intvec* curr_weight, intvec* target_weight, int weight_rad, int pert_deg)
     4648static intvec* MWalkRandomNextWeight(ideal G, intvec* orig_M, intvec* target_weight,
     4649       int weight_rad, int pert_deg)
    42944650{
    4295   int i, weight_norm;
    4296   int nV = currRing->N;
    4297   intvec* next_weight2;
     4651  assume(currRing != NULL && orig_M != NULL &&
     4652         target_weight != NULL && G->m[0] != NULL);
     4653
     4654  //BOOLEAN nError = Overflow_Error;
     4655  Overflow_Error = FALSE;
     4656
     4657  BOOLEAN found_random_weight = FALSE;
     4658  int i,nV = currRing->N;
     4659  intvec* curr_weight = new intvec(nV);
     4660
     4661  for(i=0; i<nV; i++)
     4662  {
     4663    (*curr_weight)[i] = (*orig_M)[i];
     4664  }
     4665
     4666  int k=0,weight_norm;
     4667  intvec* next_weight;
     4668  intvec* next_weight1 = MkInterRedNextWeight(curr_weight,target_weight,G);
     4669  intvec* next_weight2 = new intvec(nV);
    42984670  intvec* next_weight22 = new intvec(nV);
    4299   intvec* next_weight = MwalkNextWeightCC(curr_weight,target_weight, G);
    4300   if(MivComp(next_weight, target_weight) == 1)
    4301   {
    4302     return(next_weight);
    4303   }
    4304   else
    4305   {
    4306     //compute a perturbed next weight vector "next_weight1"
    4307     intvec* next_weight1 = MkInterRedNextWeight(MPertVectors(G, MivMatrixOrder(curr_weight), pert_deg), target_weight, G);
    4308     //Print("\n // size of next_weight1 = %d", sizeof((*next_weight1)));
    4309 
    4310     //compute a random next weight vector "next_weight2"
    4311     while(1)
    4312     {
    4313       weight_norm = 0;
    4314       while(weight_norm == 0)
     4671  intvec* result = new intvec(nV);
     4672  intvec* curr_weight1;
     4673  ideal G_test, G_test1, G_test2;
     4674
     4675  //try to find a random next weight vector "next_weight2"
     4676  if(weight_rad > 0){ while(k<10)
     4677  {
     4678    weight_norm = 0;
     4679    while(weight_norm == 0)
     4680    {
     4681
     4682      for(i=0; i<nV; i++)
     4683      {
     4684        (*next_weight2)[i] = rand() % 60000 - 30000;
     4685        weight_norm = weight_norm + (*next_weight2)[i]*(*next_weight2)[i];
     4686      }
     4687      weight_norm = 1 + floor(sqrt(weight_norm));
     4688    }
     4689
     4690    for(i=0; i<nV; i++)
     4691    {
     4692      if((*next_weight2)[i] < 0)
     4693      {
     4694        (*next_weight2)[i] = 1 + (*curr_weight)[i] + floor(weight_rad*(*next_weight2)[i]/weight_norm);
     4695      }
     4696      else
     4697      {
     4698        (*next_weight2)[i] = (*curr_weight)[i] + floor(weight_rad*(*next_weight2)[i]/weight_norm);
     4699      }
     4700    }
     4701   
     4702    if(test_w_in_ConeCC(G,next_weight2) == 1)
     4703    {
     4704      if(maxlengthpoly(MwalkInitialForm(G,next_weight2))<2)
     4705      {
     4706        next_weight2 = MkInterRedNextWeight(next_weight2,target_weight,G);
     4707      }
     4708/*
     4709      if(MivAbsMax(next_weight2)>1147483647)
    43154710      {
    43164711        for(i=0; i<nV; i++)
    43174712        {
    4318           //Print("\n//  next_weight[%d]  = %d", i, (*next_weight)[i]);
    4319           (*next_weight22)[i] = rand() % 60000 - 30000;
    4320           weight_norm = weight_norm + (*next_weight22)[i]*(*next_weight22)[i];
     4713          (*next_weight22)[i] = (*next_weight2)[i];
    43214714        }
    4322         weight_norm = 1 + floor(sqrt(weight_norm));
    4323       }
    4324 
    4325       for(i=nV-1; i>=0; i--)
    4326       {
    4327         if((*next_weight22)[i] < 0)
     4715        i = 0;
     4716        // reduce the size of the maximal entry of the vector
     4717        while(test_w_in_ConeCC(G,next_weight22) == 1)
    43284718        {
    4329           (*next_weight22)[i] = 1 + (*curr_weight)[i] + floor(weight_rad*(*next_weight22)[i]/weight_norm);
     4719          (*next_weight2)[i] = (*next_weight22)[i];
     4720          i = MivAbsMaxArg(next_weight22);
     4721          (*next_weight22)[i] = floor(0.1*(*next_weight22)[i] + 0.5);
     4722        }
     4723        delete next_weight22;
     4724      }
     4725*/
     4726      G_test2 = MwalkInitialForm(G, next_weight2);
     4727      found_random_weight = TRUE;
     4728      break;
     4729    }
     4730    k++;
     4731  }}
     4732Print("\n MWalkRandomNextWeight: compute perurbation...\n");
     4733  // compute "perturbed" next weight vector
     4734  if(pert_deg > 1)
     4735  {
     4736    curr_weight1 = MPertVectors(G,orig_M,pert_deg);
     4737    next_weight = MkInterRedNextWeight(curr_weight1,target_weight,G);
     4738    delete curr_weight1;
     4739  }
     4740  else
     4741  {
     4742    next_weight = MkInterRedNextWeight(curr_weight,target_weight,G);
     4743  }
     4744  if(MivSame(curr_weight,next_weight)==1 || Overflow_Error == TRUE)
     4745  {
     4746    Overflow_Error = FALSE;
     4747    delete next_weight;
     4748    next_weight = MkInterRedNextWeight(curr_weight,target_weight,G);
     4749  }
     4750  G_test=MwalkInitialForm(G,next_weight);
     4751  G_test1=MwalkInitialForm(G,next_weight1);
     4752Print("\n MWalkRandomNextWeight: finished...\n");
     4753  // compare next weights
     4754  if(Overflow_Error == FALSE)
     4755  {
     4756    if(found_random_weight == TRUE)
     4757    {
     4758    // random next weight vector found
     4759      if(G_test1->m[0] != NULL && maxlengthpoly(G_test1) < maxlengthpoly(G_test))
     4760      {
     4761        if(G_test2->m[0] != NULL && maxlengthpoly(G_test2) < maxlengthpoly(G_test1))
     4762        {
     4763          for(i=0; i<nV; i++)
     4764          {
     4765            (*result)[i] = (*next_weight2)[i];
     4766          }
    43304767        }
    43314768        else
    43324769        {
    4333           (*next_weight22)[i] = (*curr_weight)[i] + floor(weight_rad*(*next_weight22)[i]/weight_norm);
     4770          for(i=0; i<nV; i++)
     4771          {
     4772            (*result)[i] = (*next_weight1)[i];
     4773          }
     4774        }   
     4775      }
     4776      else
     4777      {
     4778        if(G_test2->m[0] != NULL && maxlengthpoly(G_test2) < maxlengthpoly(G_test))
     4779        {
     4780          for(i=0; i<nV; i++)
     4781          {
     4782            (*result)[i] = (*next_weight2)[i];
     4783          }
    43344784        }
    4335       //Print("\n//  next_weight22[%d]  = %d", i, (*next_weight22)[i]);
    4336       }
    4337 
    4338       if(test_w_in_ConeCC(G, next_weight22) == 1)
    4339       {
    4340         //Print("\n//MWalkRandomNextWeight: next_weight2 im Kegel\n");
    4341         next_weight2 = MkInterRedNextWeight(next_weight22, target_weight, G);
    4342         delete next_weight22;
    4343         break;
    4344       }
    4345     }
    4346     intvec* result = new intvec(nV);
    4347     ideal G_test = MwalkInitialForm(G, next_weight);
    4348     ideal G_test1 = MwalkInitialForm(G, next_weight1);
    4349     ideal G_test2 = MwalkInitialForm(G, next_weight2);
    4350 
    4351     // compare next_weights
    4352     if(IDELEMS(G_test1) < IDELEMS(G_test))
    4353     {
    4354       if(IDELEMS(G_test2) <= IDELEMS(G_test1)) // |G_test2| <= |G_test1| < |G_test|
    4355       {
    4356         for(i=0; i<nV; i++)
     4785        else
    43574786        {
    4358           (*result)[i] = (*next_weight2)[i];
     4787          for(i=0; i<nV; i++)
     4788          {
     4789            (*result)[i] = (*next_weight)[i];
     4790          }
    43594791        }
    43604792      }
    4361       else // |G_test1| < |G_test|, |G_test1| < |G_test2|
    4362       {
    4363         for(i=0; i<nV; i++)
     4793    }
     4794    else
     4795    {
     4796      // no random next weight vector found
     4797      if(G_test1->m[0] != NULL && maxlengthpoly(G_test1) < maxlengthpoly(G_test))
     4798      {
     4799       for(i=0; i<nV; i++)
    43644800        {
    43654801          (*result)[i] = (*next_weight1)[i];
    43664802        }
    43674803      }
    4368     }
    4369     else
    4370     {
    4371       if(IDELEMS(G_test2) <= IDELEMS(G_test)) // |G_test2| <= |G_test| <= |G_test1|
    4372       {
    4373         for(i=0; i<nV; i++)
    4374         {
    4375           (*result)[i] = (*next_weight2)[i];
    4376         }
    4377       }
    4378       else // |G_test| <= |G_test1|, |G_test| < |G_test2|
     4804      else
    43794805      {
    43804806        for(i=0; i<nV; i++)
     
    43844810      }
    43854811    }
    4386     delete next_weight;
    4387     delete next_weight1;
    4388     idDelete(&G_test);
    4389     idDelete(&G_test1);
    4390     idDelete(&G_test2);
    4391     if(test_w_in_ConeCC(G, result) == 1)
    4392     {
    4393       delete next_weight2;
    4394       return result;
    4395     }
    4396     else
    4397     {
    4398       delete result;
    4399       return next_weight2;
    4400     }
    4401   }
    4402 }
    4403 #endif
    4404 
    4405 /********************************
    4406  * compute a next weight vector *
    4407  ********************************/
    4408 static intvec* MWalkRandomNextWeight(ideal G, intvec* curr_weight, intvec* target_weight, int weight_rad, int pert_deg)
    4409 {
    4410   int i, weight_norm;
    4411   //int randCount=0;
    4412   int nV = currRing->N;
    4413   intvec* next_weight2;
    4414   intvec* next_weight22 = new intvec(nV);
    4415   intvec* result = new intvec(nV);
    4416 
    4417   //compute a perturbed next weight vector "next_weight1"
    4418   //intvec* next_weight1 = MkInterRedNextWeight(MPertVectors(G,MivMatrixOrderRefine(curr_weight,target_weight),pert_deg),target_weight,G);
    4419   intvec* next_weight1 =MkInterRedNextWeight(curr_weight,target_weight,G);
    4420   //compute a random next weight vector "next_weight2"
    4421   while(1)
    4422   {
    4423     weight_norm = 0;
    4424     while(weight_norm == 0)
    4425     {
    4426       for(i=0; i<nV; i++)
    4427       {
    4428         (*next_weight22)[i] = rand() % 60000 - 30000;
    4429         weight_norm = weight_norm + (*next_weight22)[i]*(*next_weight22)[i];
    4430       }
    4431       weight_norm = 1 + floor(sqrt(weight_norm));
    4432     }
    4433     for(i=0; i<nV; i++)
    4434     {
    4435       if((*next_weight22)[i] < 0)
    4436       {
    4437         (*next_weight22)[i] = 1 + (*curr_weight)[i] + floor(weight_rad*(*next_weight22)[i]/weight_norm);
    4438       }
    4439       else
    4440       {
    4441         (*next_weight22)[i] = (*curr_weight)[i] + floor(weight_rad*(*next_weight22)[i]/weight_norm);
    4442       }
    4443     }
    4444     if(test_w_in_ConeCC(G, next_weight22) == 1)
    4445     {
    4446       next_weight2 = MkInterRedNextWeight(next_weight22,target_weight,G);
    4447       delete next_weight22;
    4448       break;
    4449     }
    4450   }
    4451   // compute "usual" next weight vector
    4452   intvec* next_weight = MwalkNextWeightCC(curr_weight,target_weight, G);
    4453   ideal G_test = MwalkInitialForm(G, next_weight);
    4454   ideal G_test2 = MwalkInitialForm(G, next_weight2);
    4455 
    4456   // compare next weights
    4457   if(Overflow_Error == FALSE)
    4458   {
    4459     ideal G_test1 = MwalkInitialForm(G, next_weight1);
    4460     if(IDELEMS(G_test1) < IDELEMS(G_test))
    4461     {
    4462       if(IDELEMS(G_test2) < IDELEMS(G_test1))
    4463       {
    4464         // |G_test2| < |G_test1| < |G_test|
    4465         for(i=0; i<nV; i++)
     4812  }
     4813  else
     4814  {
     4815    Overflow_Error = FALSE;
     4816    if(found_random_weight == TRUE)
     4817    {
     4818      if(G_test2->m[0] != NULL && maxlengthpoly(G_test2) < maxlengthpoly(G_test))
     4819      {
     4820        for(i=1; i<nV; i++)
    44664821        {
    44674822          (*result)[i] = (*next_weight2)[i];
     
    44704825      else
    44714826      {
    4472         // |G_test1| < |G_test|, |G_test1| <= |G_test2|
    4473         for(i=0; i<nV; i++)
    4474         {
    4475           (*result)[i] = (*next_weight1)[i];
    4476         }
    4477       }
    4478     }
    4479     else
    4480     {
    4481       if(IDELEMS(G_test2) < IDELEMS(G_test)) // |G_test2| < |G_test| <= |G_test1|
    4482       {
    4483         for(i=0; i<nV; i++)
    4484         {
    4485           (*result)[i] = (*next_weight2)[i];
    4486         }
    4487       }
    4488       else
    4489       {
    4490         // |G_test| < |G_test1|, |G_test| <= |G_test2|
    44914827        for(i=0; i<nV; i++)
    44924828        {
     
    44954831      }
    44964832    }
    4497     idDelete(&G_test1);
    4498   }
    4499   else
    4500   {
    4501     Overflow_Error = FALSE;
    4502     if(IDELEMS(G_test2) < IDELEMS(G_test))
    4503     {
    4504       for(i=1; i<nV; i++)
    4505       {
    4506         (*result)[i] = (*next_weight2)[i];
    4507       }
    4508     }
    45094833    else
    45104834    {
     
    45154839    }
    45164840  }
     4841 // delete curr_weight1;
     4842  delete next_weight;
     4843  delete next_weight2;
    45174844  idDelete(&G_test);
    4518   idDelete(&G_test2);
    4519   if(test_w_in_ConeCC(G, result) == 1)
    4520   {
    4521     delete next_weight2;
    4522     delete next_weight;
     4845  idDelete(&G_test1);
     4846  if(found_random_weight == TRUE)
     4847  {
     4848    idDelete(&G_test2);
     4849  }
     4850  if(test_w_in_ConeCC(G, result) == 1 && MivSame(curr_weight,result)==0)
     4851  {
     4852    delete curr_weight;
    45234853    delete next_weight1;
    45244854    return result;
     
    45264856  else
    45274857  {
     4858    delete curr_weight;
    45284859    delete result;
    4529     delete next_weight2;
    4530     delete next_weight1;
    4531     return next_weight;
     4860    return next_weight1;
    45324861  }
    45334862}
     
    45374866 * The procedur REC_GB_Mwalk computes a GB for <G> w.r.t. the weight order *
    45384867 * otw, where G is a reduced GB w.r.t. the weight order cw.                *
    4539  * The new procedur Mwalk calls REC_GB.                                    *
     4868 * The new procedure Mwalk calls REC_GB.                                   *
    45404869 ***************************************************************************/
    45414870static ideal REC_GB_Mwalk(ideal G, intvec* curr_weight, intvec* orig_target_weight,
     
    45754904    else
    45764905    {
    4577       rChangeCurrRing(VMrDefault(orig_target_weight)); // Aenderung
     4906      rChangeCurrRing(VMrDefault(orig_target_weight));
    45784907    }
    45794908    TargetRing = currRing;
     
    46464975    else
    46474976    {
    4648       rChangeCurrRing(VMrDefault(curr_weight)); // Aenderung
     4977      rChangeCurrRing(VMrDefault(curr_weight));
    46494978    }
    46504979    newRing = currRing;
     
    47555084    else
    47565085    {
    4757       rChangeCurrRing(VMrDefault(orig_target_weight)); // Aenderung
     5086      rChangeCurrRing(VMrDefault(orig_target_weight));
    47585087    }
    47595088    F1 = idrMoveR(G, newRing,currRing);
     
    47865115      else
    47875116      {
    4788         rChangeCurrRing(VMrDefault(orig_target_weight)); // Aenderung
     5117        rChangeCurrRing(VMrDefault(orig_target_weight));
    47895118      }
    47905119    KSTD_Finish:
     
    48405169
    48415170  ideal Gomega, M, F, Gomega1, Gomega2, M1, F1, G;
    4842   //ideal G1;
    4843   //ring endRing;
     5171
    48445172  ring newRing, oldRing;
    48455173  intvec* ivNull = new intvec(nV);
     
    48835211         the recursive changed perturbation walk alg. */
    48845212      tim = clock();
    4885       /*
    4886         Print("\n// **** Grï¿œbnerwalk took %d steps and ", nwalk);
     5213#ifdef CHECK_IDEAL_MWALK
     5214        Print("\n// **** Groebnerwalk took %d steps and ", nwalk);
    48875215        PrintS("\n// **** call the rec. Pert. Walk to compute a red GB of:");
    4888         idElements(Gomega, "G_omega");
    4889       */
     5216        idString(Gomega, "Gomega");
     5217#endif
    48905218
    48915219      if(MivSame(exivlp, target_weight)==1)
     
    48935221      else
    48945222        goto NORMAL_GW;
    4895       /*
     5223#ifdef TIME_TEST
    48965224        Print("\n//  time for the last std(Gw)  = %.2f sec",
    48975225        ((double) (clock()-tim)/1000000));
    4898         PrintS("\n// ***************************************************\n");
    4899       */
     5226#endif
     5227/*
    49005228#ifdef CHECK_IDEAL_MWALK
    49015229      idElements(Gomega, "G_omega");
     
    49045232      //headidString(M, "M");
    49055233#endif
     5234*/
    49065235      to = clock();
    49075236      F = MLifttwoIdeal(Gomega, M, G);
     
    49145243      oldRing = currRing;
    49155244
    4916       /* create a new ring newRing */
     5245      // create a new ring newRing
    49175246       if (rParameter(currRing) != NULL)
    49185247       {
     
    49215250       else
    49225251       {
    4923          rChangeCurrRing(VMrDefault(curr_weight)); // Aenderung
     5252         rChangeCurrRing(VMrDefault(curr_weight));
    49245253       }
    49255254      newRing = currRing;
     
    49475276      else
    49485277      {
    4949         rChangeCurrRing(VMrDefault(curr_weight));  //Aenderung
     5278        rChangeCurrRing(VMrDefault(curr_weight));
    49505279      }
    49515280      newRing = currRing;
     
    49595288      M=kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight);
    49605289      delete hilb_func;
    4961 #endif // BUCHBERGER_ALG
     5290#endif
    49625291      tstd = tstd + clock() - to;
    49635292
     
    49685297
    49695298      to = clock();
    4970       // compute a representation of the generators of submod (M) with respect to those of mod (Gomega). Gomega is a reduced Groebner basis w.r.t. the current ring.
     5299      // compute a representation of the generators of submod (M) with respect
     5300      // to those of mod (Gomega).
     5301      // Gomega is a reduced Groebner basis w.r.t. the current ring.
    49715302      F = MLifttwoIdeal(Gomega2, M1, G);
    49725303      tlift = tlift + clock() - to;
     
    50185349      else
    50195350      {
    5020         rChangeCurrRing(VMrDefault(target_weight)); // Aenderung
     5351        rChangeCurrRing(VMrDefault(target_weight));
    50215352      }
    50225353      F1 = idrMoveR(G, newRing,currRing);
     
    50615392}
    50625393
    5063 
    50645394/*******************************
    50655395 * THE GROEBNER WALK ALGORITHM *
    50665396 *******************************/
    5067 ideal Mwalk(ideal Go, intvec* orig_M, intvec* target_M, ring baseRing)
     5397ideal Mwalk(ideal Go, intvec* orig_M, intvec* target_M,
     5398            ring baseRing, int reduction, int printout)
    50685399{
    5069   BITSET save1 = si_opt_1; // save current options
    5070   //si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis
    5071   //si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions
    5072   //si_opt_1|=(Sy_bit(OPT_REDTAIL)|Sy_bit(OPT_REDSB));
     5400  // save current options
     5401  BITSET save1 = si_opt_1;
     5402  if(reduction == 0)
     5403  {
     5404    si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis
     5405    si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions
     5406  }
    50735407  Set_Error(FALSE);
    50745408  Overflow_Error = FALSE;
     5409  //BOOLEAN endwalks = FALSE;
    50755410#ifdef TIME_TEST
    50765411  clock_t tinput, tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0;
     
    50805415#endif
    50815416  nstep=0;
    5082   int i,nwalk,endwalks = 0;
     5417  int i,nwalk;
    50835418  int nV = baseRing->N;
    50845419
    5085   ideal Gomega, M, F, Gomega1, Gomega2, M1; //, F1;
     5420  ideal Gomega, M, F, FF, Gomega1, Gomega2, M1;
    50865421  ring newRing;
    50875422  ring XXRing = baseRing;
     5423  ring targetRing;
    50885424  intvec* ivNull = new intvec(nV);
    50895425  intvec* curr_weight = new intvec(nV);
    50905426  intvec* target_weight = new intvec(nV);
    50915427  intvec* exivlp = Mivlp(nV);
     5428/*
    50925429  intvec* tmp_weight = new intvec(nV);
    50935430  for(i=0; i<nV; i++)
    50945431  {
    5095     (*tmp_weight)[i] = (*target_M)[i];
    5096   }
     5432    (*tmp_weight)[i] = (*orig_M)[i];
     5433  }
     5434*/
    50975435  for(i=0; i<nV; i++)
    50985436  {
     
    51125450  rComplete(currRing);
    51135451#ifdef CHECK_IDEAL_MWALK
    5114     idString(Go,"Go");
    5115 #endif
     5452  if(printout > 2)
     5453  {
     5454    idString(Go,"//** Mwalk: Go");
     5455  }
     5456#endif
     5457
     5458  if(target_M->length() == nV)
     5459  {
     5460   // define the target ring
     5461    targetRing = VMrDefault(target_weight);
     5462  }
     5463  else
     5464  {
     5465    targetRing = VMatrDefault(target_M);
     5466  }
     5467  if(orig_M->length() == nV)
     5468  {
     5469    // define a new ring with ordering "(a(curr_weight),lp)
     5470    newRing = VMrDefault(curr_weight);
     5471  }
     5472  else
     5473  {
     5474    newRing = VMatrDefault(orig_M);
     5475  }
     5476  rChangeCurrRing(newRing);
     5477
    51165478#ifdef TIME_TEST
    51175479  to = clock();
    51185480#endif
    5119      if(orig_M->length() == nV)
    5120       {
    5121         newRing = VMrDefault(curr_weight); // define a new ring with ordering "(a(curr_weight),lp)
    5122       }
    5123       else
    5124       {
    5125         newRing = VMatrDefault(orig_M);
    5126       }
    5127   rChangeCurrRing(newRing);
    51285481  ideal G = MstdCC(idrMoveR(Go,baseRing,currRing));
     5482#ifdef TIME_TEST
     5483  tostd = clock()-to;
     5484#endif
     5485
    51295486  baseRing = currRing;
    5130 #ifdef TIME_TEST
    5131   tostd = clock()-to;
    5132 #endif
    5133 
    51345487  nwalk = 0;
     5488
    51355489  while(1)
    51365490  {
    51375491    nwalk ++;
    51385492    nstep ++;
     5493    //compute an initial form ideal of <G> w.r.t. "curr_vector"
    51395494#ifdef TIME_TEST
    51405495    to = clock();
    51415496#endif
     5497    Gomega = MwalkInitialForm(G, curr_weight);
     5498#ifdef TIME_TEST
     5499    tif = tif + clock()-to;
     5500#endif
     5501
    51425502#ifdef CHECK_IDEAL_MWALK
    5143     idString(G,"G");
    5144 #endif
    5145     Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector"
    5146 #ifdef TIME_TEST
    5147     tif = tif + clock()-to; //time for computing initial form ideal
    5148 #endif
    5149 #ifdef CHECK_IDEAL_MWALK
    5150     idString(Gomega,"Gomega");
    5151 #endif
     5503    if(printout > 1)
     5504    {
     5505      idString(Gomega,"//** Mwalk: Gomega");
     5506    }
     5507#endif
     5508
     5509    if(reduction == 0)
     5510    {
     5511      FF = middleOfCone(G,Gomega);
     5512      if(FF != NULL)
     5513      {
     5514        idDelete(&G);
     5515        G = idCopy(FF);
     5516        idDelete(&FF);
     5517        goto NEXT_VECTOR;
     5518      }
     5519    }
     5520
    51525521#ifndef  BUCHBERGER_ALG
    51535522    if(isNolVector(curr_weight) == 0)
    51545523    {
    51555524      hilb_func = hFirstSeries(Gomega,NULL,NULL,curr_weight,currRing);
    5156     }
     5525    }   
    51575526    else
    51585527    {
     
    51605529    }
    51615530#endif
     5531
    51625532    if(nwalk == 1)
    51635533    {
    51645534      if(orig_M->length() == nV)
    51655535      {
    5166         newRing = VMrDefault(curr_weight); // define a new ring with ordering "(a(curr_weight),lp)
     5536        // define a new ring with ordering "(a(curr_weight),lp)
     5537        newRing = VMrDefault(curr_weight);
    51675538      }
    51685539      else
     
    51755546     if(target_M->length() == nV)
    51765547     {
    5177        newRing = VMrRefine(curr_weight,target_weight); //define a new ring with ordering "(a(curr_weight),Wp(target_weight))"
     5548       //define a new ring with ordering "(a(curr_weight),lp)"
     5549       newRing = VMrDefault(curr_weight);
    51785550     }
    51795551     else
    51805552     {
     5553       //define a new ring with matrix ordering
    51815554       newRing = VMatrRefine(target_M,curr_weight);
    51825555     }
     
    52005573    idSkipZeroes(M);
    52015574#ifdef CHECK_IDEAL_MWALK
    5202     PrintS("\n//** Mwalk: computed M.\n");
    5203     idString(M, "M");
     5575    if(printout > 2)
     5576    {
     5577      idString(M, "//** Mwalk: M");
     5578    }
    52045579#endif
    52055580    //change the ring to baseRing
     
    52125587    to = clock();
    52135588#endif
    5214     // compute a representation of the generators of submod (M) with respect to those of mod (Gomega), where Gomega is a reduced Groebner basis w.r.t. the current ring
     5589    // compute a representation of the generators of submod (M) with respect to those of mod (Gomega),
     5590    // where Gomega is a reduced Groebner basis w.r.t. the current ring
    52155591    F = MLifttwoIdeal(Gomega2, M1, G);
    52165592#ifdef TIME_TEST
     
    52185594#endif
    52195595#ifdef CHECK_IDEAL_MWALK
    5220     idString(F, "F");
     5596    if(printout > 2)
     5597    {
     5598      idString(F, "//** Mwalk: F");
     5599    }
     5600#endif
     5601    idDelete(&Gomega2);
     5602    idDelete(&M1);
     5603
     5604    rChangeCurrRing(newRing); // change the ring to newRing
     5605    G = idrMoveR(F,baseRing,currRing);
     5606    idDelete(&F);
     5607    idSkipZeroes(G);
     5608
     5609#ifdef CHECK_IDEAL_MWALK
     5610    if(printout > 2)
     5611    {
     5612      idString(G, "//** Mwalk: G");
     5613    }
     5614#endif
     5615
     5616    rChangeCurrRing(targetRing);
     5617    G = idrMoveR(G,newRing,currRing);
     5618    // test whether target cone is reached
     5619    if(reduction !=0 && test_w_in_ConeCC(G,curr_weight) == 1)
     5620    {
     5621      baseRing = currRing;
     5622      break;
     5623      //endwalks = TRUE;
     5624    }
     5625
     5626    rChangeCurrRing(newRing);
     5627    G = idrMoveR(G,targetRing,currRing);
     5628    baseRing = currRing;
     5629
     5630    NEXT_VECTOR:
     5631#ifdef TIME_TEST
     5632    to = clock();
     5633#endif
     5634    intvec* next_weight = MwalkNextWeightCC(curr_weight,target_weight,G);
     5635#ifdef TIME_TEST
     5636    tnw = tnw + clock() - to;
     5637#endif
     5638#ifdef PRINT_VECTORS
     5639    if(printout > 0)
     5640    {
     5641      MivString(curr_weight, target_weight, next_weight);
     5642    }
     5643#endif
     5644    if(MivComp(target_weight,curr_weight) == 1)// || endwalks == TRUE)
     5645    {
     5646/*
     5647#ifdef CHECK_IDEAL_MWALK
     5648      if(printout > 0)
     5649      {
     5650        PrintS("\n//** Mwalk: entering last cone.\n");
     5651      }
     5652#endif
     5653
     5654      Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector"
     5655      if(target_M->length() == nV)
     5656      {
     5657        newRing = VMrDefault(target_weight); // define a new ring with ordering "(a(curr_weight),lp)
     5658      }
     5659      else
     5660      {
     5661        newRing = VMatrDefault(target_M);
     5662      }
     5663      rChangeCurrRing(newRing);
     5664      Gomega1 = idrMoveR(Gomega, baseRing,currRing);
     5665      idDelete(&Gomega);
     5666#ifdef CHECK_IDEAL_MWALK
     5667      if(printout > 1)
     5668      {
     5669        idString(Gomega1, "//** Mwalk: Gomega");
     5670      }
     5671      PrintS("\n //** Mwalk: kStd(Gomega)");
     5672#endif
     5673      M = kStd(Gomega1,NULL,testHomog,NULL,NULL,0,0,NULL);
     5674#ifdef CHECK_IDEAL_MWALK
     5675      if(printout > 1)
     5676      {
     5677        idString(M,"//** Mwalk: M");
     5678      }
     5679#endif
     5680      rChangeCurrRing(baseRing);
     5681      M1 =  idrMoveR(M, newRing,currRing);
     5682      idDelete(&M);
     5683      Gomega2 = idrMoveR(Gomega1, newRing,currRing);
     5684      idDelete(&Gomega1);
     5685      //PrintS("\n //** Mwalk: MLifttwoIdeal");
     5686      F = MLifttwoIdeal(Gomega2, M1, G);
     5687#ifdef CHECK_IDEAL_MWALK
     5688      if(printout > 2)
     5689      {
     5690        idString(F,"//** Mwalk: F");
     5691      }
     5692#endif
     5693      idDelete(&Gomega2);
     5694      idDelete(&M1);
     5695      rChangeCurrRing(newRing); // change the ring to newRing
     5696      G = idrMoveR(F,baseRing,currRing);
     5697      idDelete(&F);
     5698      baseRing = currRing;
     5699      idSkipZeroes(G);
     5700#ifdef TIME_TEST
     5701      to = clock();
     5702#endif
     5703      //PrintS("\n //**Mwalk: Interreduce");
     5704      //interreduce the Groebner basis <G> w.r.t. currRing
     5705      //G = kInterRedCC(G,NULL);
     5706#ifdef TIME_TEST
     5707      tred = tred + clock() - to;
     5708#endif
     5709      idSkipZeroes(G);
     5710      delete next_weight;
     5711*/
     5712      break;
     5713    }
     5714
     5715    for(i=nV-1; i>=0; i--)
     5716    {
     5717      //(*tmp_weight)[i] = (*curr_weight)[i];
     5718      (*curr_weight)[i] = (*next_weight)[i];
     5719    }
     5720    delete next_weight;
     5721  }
     5722  rChangeCurrRing(XXRing);
     5723  ideal result = idrMoveR(G,baseRing,currRing);
     5724  idDelete(&Go);
     5725  idDelete(&G);
     5726  //delete tmp_weight;
     5727  delete ivNull;
     5728  delete exivlp;
     5729#ifndef BUCHBERGER_ALG
     5730  delete last_omega;
     5731#endif
     5732#ifdef TIME_TEST
     5733  TimeString(tinput, tostd, tif, tstd, tlift, tred, tnw, nstep);
     5734  //Print("\n// pSetm_Error = (%d)", ErrorCheck());
     5735  //Print("\n// Overflow_Error? (%d)\n", Overflow_Error);
     5736#endif
     5737  Print("\n//** Mwalk: Groebner Walk took %d steps.\n", nstep);
     5738  si_opt_1 = save1; //set original options
     5739  return(result);
     5740}
     5741
     5742// THE RANDOM WALK ALGORITHM
     5743ideal Mrwalk(ideal Go, intvec* orig_M, intvec* target_M, int weight_rad, int pert_deg,
     5744             int reduction, int printout)
     5745{
     5746  BITSET save1 = si_opt_1; // save current options
     5747  if(reduction == 0)
     5748  {
     5749    si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis
     5750    si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions
     5751  }
     5752
     5753  Set_Error(FALSE);
     5754  Overflow_Error = FALSE;
     5755  BOOLEAN endwalks = FALSE;
     5756#ifdef TIME_TEST
     5757  clock_t tinput, tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0;
     5758  xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0;
     5759  tinput = clock();
     5760  clock_t tim;
     5761#endif
     5762  nstep=0;
     5763  int i,nwalk;//polylength;
     5764  int nV = currRing->N;
     5765
     5766  //check that weight radius is valid
     5767  if(weight_rad < 0)
     5768  {
     5769    Werror("Invalid radius.\n");
     5770    return NULL;
     5771  }
     5772
     5773  //check that perturbation degree is valid
     5774  if(pert_deg > nV || pert_deg < 1)
     5775  {
     5776    Werror("Invalid perturbation degree.\n");
     5777    return NULL;
     5778  }
     5779
     5780  ideal Gomega, M, F,FF, Gomega1, Gomega2, M1;
     5781  ring newRing;
     5782  ring targetRing;
     5783  ring baseRing = currRing;
     5784  ring XXRing = currRing;
     5785  intvec* iv_M;
     5786  intvec* ivNull = new intvec(nV);
     5787  intvec* curr_weight = new intvec(nV);
     5788  intvec* target_weight = new intvec(nV);
     5789  intvec* next_weight= new intvec(nV);
     5790
     5791  for(i=0; i<nV; i++)
     5792  {
     5793    (*curr_weight)[i] = (*orig_M)[i];
     5794    (*target_weight)[i] = (*target_M)[i];
     5795  }
     5796
     5797#ifndef BUCHBERGER_ALG
     5798  intvec* hilb_func;
     5799   // to avoid (1,0,...,0) as the target vector
     5800  intvec* last_omega = new intvec(nV);
     5801  for(i=nV-1; i>0; i--)
     5802  {
     5803    (*last_omega)[i] = 1;
     5804  }
     5805  (*last_omega)[0] = 10000;
     5806#endif
     5807  rComplete(currRing);
     5808
     5809  if(target_M->length() == nV)
     5810  {
     5811    targetRing = VMrDefault(target_weight); // define the target ring
     5812  }
     5813  else
     5814  {
     5815    targetRing = VMatrDefault(target_M);
     5816  }
     5817  if(orig_M->length() == nV)
     5818  {
     5819    newRing = VMrDefault(curr_weight); // define a new ring with ordering "(a(curr_weight),lp)
     5820  }
     5821  else
     5822  {
     5823    newRing = VMatrDefault(orig_M);
     5824  }
     5825  rChangeCurrRing(newRing);
     5826#ifdef TIME_TEST
     5827  to = clock();
     5828#endif
     5829  ideal G = MstdCC(idrMoveR(Go,baseRing,currRing));
     5830#ifdef TIME_TEST
     5831  tostd = clock()-to;
     5832#endif
     5833  baseRing = currRing;
     5834  nwalk = 0;
     5835
     5836#ifdef TIME_TEST
     5837  to = clock();
     5838#endif
     5839  Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector"
     5840#ifdef TIME_TEST
     5841  tif = tif + clock()-to; //time for computing initial form ideal
     5842#endif
     5843
     5844  while(1)
     5845  {
     5846    nwalk ++;
     5847    nstep ++;
     5848#ifdef CHECK_IDEAL_MWALK
     5849    if(printout > 1)
     5850    {
     5851      idString(Gomega,"//** Mrwalk: Gomega");
     5852    }
     5853#endif
     5854    if(reduction == 0)
     5855    {
     5856      FF = middleOfCone(G,Gomega);
     5857      if(FF != NULL)
     5858      {
     5859        idDelete(&G);
     5860        G = idCopy(FF);
     5861        idDelete(&FF);
     5862        goto NEXT_VECTOR;
     5863      }
     5864    }
     5865#ifndef  BUCHBERGER_ALG
     5866    if(isNolVector(curr_weight) == 0)
     5867    {
     5868      hilb_func = hFirstSeries(Gomega,NULL,NULL,curr_weight,currRing);
     5869    }   
     5870    else
     5871    {
     5872      hilb_func = hFirstSeries(Gomega,NULL,NULL,last_omega,currRing);
     5873    }
     5874#endif
     5875    if(nwalk == 1)
     5876    {
     5877      if(orig_M->length() == nV)
     5878      {
     5879        newRing = VMrDefault(curr_weight); // define a new ring with ordering "(a(curr_weight),lp)
     5880      }
     5881      else
     5882      {
     5883        newRing = VMatrDefault(orig_M);
     5884      }
     5885    }
     5886    else
     5887    {
     5888     if(target_M->length() == nV)
     5889     {
     5890       newRing = VMrDefault(curr_weight); // define a new ring with ordering "(a(curr_weight),lp)
     5891     }
     5892     else
     5893     {
     5894       newRing = VMatrRefine(target_M,curr_weight);
     5895     }
     5896    }
     5897    rChangeCurrRing(newRing);
     5898    Gomega1 = idrMoveR(Gomega, baseRing,currRing);
     5899    idDelete(&Gomega);
     5900    // compute a reduced Groebner basis of <Gomega> w.r.t. "newRing"
     5901#ifdef TIME_TEST
     5902    to = clock();
     5903#endif
     5904#ifndef BUCHBERGER_ALG
     5905    M=kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight);
     5906    delete hilb_func;
     5907#else
     5908    M = kStd(Gomega1,NULL,testHomog,NULL,NULL,0,0,NULL);
     5909#endif
     5910#ifdef TIME_TEST
     5911    tstd = tstd + clock() - to;
     5912#endif
     5913    idSkipZeroes(M);
     5914#ifdef CHECK_IDEAL_MWALK
     5915    if(printout > 2)
     5916    {
     5917      idString(M, "//** Mrwalk: M");
     5918    }
     5919#endif
     5920    //change the ring to baseRing
     5921    rChangeCurrRing(baseRing);
     5922    M1 =  idrMoveR(M, newRing,currRing);
     5923    idDelete(&M);
     5924    Gomega2 = idrMoveR(Gomega1, newRing,currRing);
     5925    idDelete(&Gomega1);
     5926#ifdef TIME_TEST
     5927    to = clock();
     5928#endif
     5929    // compute a representation of the generators of submod (M) with respect to those of mod (Gomega),
     5930    // where Gomega is a reduced Groebner basis w.r.t. the current ring
     5931    F = MLifttwoIdeal(Gomega2, M1, G);
     5932#ifdef TIME_TEST
     5933    tlift = tlift + clock() - to;
     5934#endif
     5935#ifdef CHECK_IDEAL_MWALK
     5936    if(printout > 2)
     5937    {
     5938      idString(F,"//** Mrwalk: F");
     5939    }
    52215940#endif
    52225941    idDelete(&Gomega2);
     
    52285947#ifdef TIME_TEST
    52295948    to = clock();
    5230 #endif
    5231     //G = kStd(F1,NULL,testHomog,NULL,NULL,0,0,NULL);
    5232 #ifdef TIME_TEST
    52335949    tstd = tstd + clock() - to;
    52345950#endif
    52355951    idSkipZeroes(G);
    52365952#ifdef CHECK_IDEAL_MWALK
    5237     idString(G, "G");
    5238 #endif
     5953    if(printout > 2)
     5954    {
     5955      idString(G,"//** Mrwalk: G");
     5956    }
     5957#endif
     5958
     5959    rChangeCurrRing(targetRing);
     5960    G = idrMoveR(G,newRing,currRing);
     5961
     5962    // test whether target cone is reached
     5963    if(reduction !=0 && test_w_in_ConeCC(G,curr_weight) == 1)
     5964    {
     5965      baseRing = currRing;
     5966      break;
     5967    }
     5968
     5969    rChangeCurrRing(newRing);
     5970    G = idrMoveR(G,targetRing,currRing);
     5971    baseRing = currRing;
     5972
     5973    NEXT_VECTOR:
    52395974#ifdef TIME_TEST
    52405975    to = clock();
    52415976#endif
    5242     intvec* next_weight = MwalkNextWeightCC(curr_weight,target_weight,G);
     5977    next_weight = MwalkNextWeightCC(curr_weight,target_weight,G);
    52435978#ifdef TIME_TEST
    52445979    tnw = tnw + clock() - to;
    52455980#endif
    5246 #ifdef PRINT_VECTORS
    5247     MivString(curr_weight, target_weight, next_weight);
    5248 #endif
    5249     if(MivComp(next_weight, ivNull) == 1 || MivComp(target_weight,curr_weight) == 1)// || test_w_in_ConeCC(G, target_weight) == 1 || MivComp(next_weight,curr_weight) == 1)
    5250     {
    5251 #ifdef CHECK_IDEAL_MWALK
    5252       PrintS("\n//** Mwalk: entering last cone.\n");
    5253 #endif
    5254       Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector"
     5981
     5982#ifdef TIME_TEST
     5983    to = clock();
     5984#endif
     5985    Gomega = MwalkInitialForm(G, next_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector"
     5986#ifdef TIME_TEST
     5987    tif = tif + clock()-to; //time for computing initial form ideal
     5988#endif
     5989
     5990    //lengthpoly(Gomega) = 1 if there is a polynomial in Gomega with at least 3 monomials and 0 otherwise
     5991    //polylength = lengthpoly(Gomega);
     5992    if(lengthpoly(Gomega) > 0)
     5993    {
     5994      //there is a polynomial in Gomega with at least 3 monomials,
     5995      //low-dimensional facet of the cone
     5996      delete next_weight;
    52555997      if(target_M->length() == nV)
    52565998      {
    5257         newRing = VMrDefault(target_weight); // define a new ring with ordering "(a(curr_weight),lp)
     5999        iv_M = MivMatrixOrder(curr_weight);
    52586000      }
    52596001      else
    52606002      {
    5261         newRing = VMatrDefault(target_M);
    5262       }
    5263       rChangeCurrRing(newRing);
    5264       Gomega1 = idrMoveR(Gomega, baseRing,currRing);
     6003        iv_M = MivMatrixOrderRefine(curr_weight,target_M);
     6004      }
     6005#ifdef TIME_TEST
     6006      to = clock();
     6007#endif
     6008      next_weight = MWalkRandomNextWeight(G, iv_M, target_weight, weight_rad, pert_deg);
     6009#ifdef TIME_TEST
     6010      tnw = tnw + clock() - to;
     6011#endif
    52656012      idDelete(&Gomega);
    5266 #ifdef CHECK_IDEAL_MWALK
    5267       idString(Gomega1, "Gomega");
    5268 #endif
    5269       M = kStd(Gomega1,NULL,testHomog,NULL,NULL,0,0,NULL);
    5270 #ifdef CHECK_IDEAL_MWALK
    5271       idString(M,"M");
    5272 #endif
    5273       rChangeCurrRing(baseRing);
    5274       M1 =  idrMoveR(M, newRing,currRing);
    5275       idDelete(&M);
    5276       Gomega2 = idrMoveR(Gomega1, newRing,currRing);
    5277       idDelete(&Gomega1);
    5278       F = MLifttwoIdeal(Gomega2, M1, G);
    5279 #ifdef CHECK_IDEAL_MWALK
    5280       idString(F,"F");
    5281 #endif
    5282       idDelete(&Gomega2);
    5283       idDelete(&M1);
    5284       rChangeCurrRing(newRing); // change the ring to newRing
    5285       G = idrMoveR(F,baseRing,currRing);
    5286       idDelete(&F);
     6013#ifdef TIME_TEST
     6014      to = clock();
     6015#endif
     6016      Gomega = MwalkInitialForm(G, next_weight);
     6017#ifdef TIME_TEST
     6018      tif = tif + clock()-to; //time for computing initial form ideal
     6019#endif
     6020      delete iv_M;
     6021    }
     6022
     6023    // test whether target weight vector is reached
     6024    if(MivComp(next_weight, ivNull) == 1 || MivComp(target_weight,curr_weight) == 1)
     6025    {
    52876026      baseRing = currRing;
    5288       si_opt_1 = save1; //set original options, e. g. option(RedSB)
    5289       idSkipZeroes(G);
    5290 #ifdef TIME_TEST
    5291       to = clock();
    5292 #endif
    5293  //     if(si_opt_1 == (Sy_bit(OPT_REDSB)))
    5294   //    {
    5295         G = kInterRedCC(G,NULL); //reduce the Groebner basis <G> w.r.t. currRing, if option(redSB) is set
    5296   //    }
    5297 #ifdef TIME_TEST
    5298       tred = tred + clock() - to;
    5299 #endif
    5300       idSkipZeroes(G);
    53016027      delete next_weight;
    53026028      break;
    5303 #ifdef CHECK_IDEAL_MWALK
    5304       PrintS("\n//** Mwalk: last cone.\n");
    5305 #endif
    5306     }
    5307 #ifdef CHECK_IDEAL_MWALK
    5308     PrintS("\n//** Mwalk: update weight vectors.\n");
    5309 #endif
     6029    }
     6030
     6031#ifdef PRINT_VECTORS
     6032    if(printout > 0)
     6033    {
     6034      MivString(curr_weight, target_weight, next_weight);
     6035    }
     6036#endif
     6037
    53106038    for(i=nV-1; i>=0; i--)
    53116039    {
    5312       (*tmp_weight)[i] = (*curr_weight)[i];
    53136040      (*curr_weight)[i] = (*next_weight)[i];
    53146041    }
    53156042    delete next_weight;
    53166043  }
     6044  baseRing = currRing;
    53176045  rChangeCurrRing(XXRing);
    53186046  ideal result = idrMoveR(G,baseRing,currRing);
    53196047  idDelete(&G);
    5320 /*#ifdef CHECK_IDEAL_MWALK
    5321   pDelete(&p);
    5322 #endif*/
    5323   delete tmp_weight;
    53246048  delete ivNull;
    5325   delete exivlp;
    53266049#ifndef BUCHBERGER_ALG
    53276050  delete last_omega;
    53286051#endif
    5329 #ifdef TIME_TEST
    5330   Print("\n//** Mwalk: Groebner Walk took %d steps.\n", nstep);
     6052  Print("\n//** Mrwalk: Groebner Walk took %d steps.\n", nstep);
     6053#ifdef TIME_TEST
    53316054  TimeString(tinput, tostd, tif, tstd, tlift, tred, tnw, nstep);
    5332   Print("\n//** Mwalk: Ergebnis.\n");
    53336055  //Print("\n// pSetm_Error = (%d)", ErrorCheck());
    53346056  //Print("\n// Overflow_Error? (%d)\n", Overflow_Error);
    53356057#endif
     6058  si_opt_1 = save1; //set original options
    53366059  return(result);
    53376060}
    5338 
    5339 // 07.11.2012
    5340 // THE RANDOM WALK ALGORITHM  ideal Go, intvec* orig_M, intvec* target_M, ring baseRing
    5341 ideal Mrwalk(ideal Go, intvec* orig_M, intvec* target_M, int weight_rad, int pert_deg, ring baseRing)
    5342 {
    5343   BITSET save1 = si_opt_1; // save current options
    5344   //si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis
    5345   //si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions
    5346   //si_opt_1|=(Sy_bit(OPT_REDTAIL)|Sy_bit(OPT_REDSB));
    5347   Set_Error(FALSE);
    5348   Overflow_Error = FALSE;
    5349 #ifdef TIME_TEST
    5350   clock_t tinput, tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0;
    5351   xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0;
    5352   tinput = clock();
    5353   clock_t tim;
    5354 #endif
    5355   nstep=0;
    5356   int i,nwalk,endwalks = 0;
    5357   int nV = baseRing->N;
    5358 
    5359   ideal Gomega, M, F, Gomega1, Gomega2, M1; //, F1;
    5360   ring newRing;
    5361   ring XXRing = baseRing;
    5362   intvec* ivNull = new intvec(nV);
    5363   intvec* curr_weight = new intvec(nV);
    5364   intvec* target_weight = new intvec(nV);
    5365   intvec* exivlp = Mivlp(nV);
    5366   intvec* tmp_weight = new intvec(nV);
    5367   for(i=0; i<nV; i++)
    5368   {
    5369     (*tmp_weight)[i] = (*target_M)[i];
    5370   }
    5371   for(i=0; i<nV; i++)
    5372   {
    5373     (*curr_weight)[i] = (*orig_M)[i];
    5374     (*target_weight)[i] = (*target_M)[i];
    5375   }
    5376 #ifndef BUCHBERGER_ALG
    5377   intvec* hilb_func;
    5378    // to avoid (1,0,...,0) as the target vector
    5379   intvec* last_omega = new intvec(nV);
    5380   for(i=nV-1; i>0; i--)
    5381   {
    5382     (*last_omega)[i] = 1;
    5383   }
    5384   (*last_omega)[0] = 10000;
    5385 #endif
    5386   rComplete(currRing);
    5387 #ifdef CHECK_IDEAL_MWALK
    5388     idString(Go,"Go");
    5389 #endif
    5390 #ifdef TIME_TEST
    5391   to = clock();
    5392 #endif
    5393      if(orig_M->length() == nV)
    5394       {
    5395         newRing = VMrDefault(curr_weight); // define a new ring with ordering "(a(curr_weight),lp)
    5396       }
    5397       else
    5398       {
    5399         newRing = VMatrDefault(orig_M);
    5400       }
    5401   rChangeCurrRing(newRing);
    5402   ideal G = MstdCC(idrMoveR(Go,baseRing,currRing));
    5403   baseRing = currRing;
    5404 #ifdef TIME_TEST
    5405   tostd = clock()-to;
    5406 #endif
    5407 
    5408   nwalk = 0;
    5409   while(1)
    5410   {
    5411     nwalk ++;
    5412     nstep ++;
    5413 #ifdef TIME_TEST
    5414     to = clock();
    5415 #endif
    5416 #ifdef CHECK_IDEAL_MWALK
    5417     idString(G,"G");
    5418 #endif
    5419     Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector"
    5420 #ifdef TIME_TEST
    5421     tif = tif + clock()-to; //time for computing initial form ideal
    5422 #endif
    5423 #ifdef CHECK_IDEAL_MWALK
    5424     idString(Gomega,"Gomega");
    5425 #endif
    5426 #ifndef  BUCHBERGER_ALG
    5427     if(isNolVector(curr_weight) == 0)
    5428     {
    5429       hilb_func = hFirstSeries(Gomega,NULL,NULL,curr_weight,currRing);
    5430     }
    5431     else
    5432     {
    5433       hilb_func = hFirstSeries(Gomega,NULL,NULL,last_omega,currRing);
    5434     }
    5435 #endif
    5436     if(nwalk == 1)
    5437     {
    5438       if(orig_M->length() == nV)
    5439       {
    5440         newRing = VMrDefault(curr_weight); // define a new ring with ordering "(a(curr_weight),lp)
    5441       }
    5442       else
    5443       {
    5444         newRing = VMatrDefault(orig_M);
    5445       }
    5446     }
    5447     else
    5448     {
    5449      if(target_M->length() == nV)
    5450      {
    5451        newRing = VMrRefine(curr_weight,target_weight); //define a new ring with ordering "(a(curr_weight),Wp(target_weight))"
    5452      }
    5453      else
    5454      {
    5455        newRing = VMatrRefine(target_M,curr_weight);
    5456      }
    5457     }
    5458     rChangeCurrRing(newRing);
    5459     Gomega1 = idrMoveR(Gomega, baseRing,currRing);
    5460     idDelete(&Gomega);
    5461     // compute a reduced Groebner basis of <Gomega> w.r.t. "newRing"
    5462 #ifdef TIME_TEST
    5463     to = clock();
    5464 #endif
    5465 #ifndef  BUCHBERGER_ALG
    5466     M=kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight);
    5467     delete hilb_func;
    5468 #else
    5469     M = kStd(Gomega1,NULL,testHomog,NULL,NULL,0,0,NULL);
    5470 #endif
    5471 #ifdef TIME_TEST
    5472     tstd = tstd + clock() - to;
    5473 #endif
    5474     idSkipZeroes(M);
    5475 #ifdef CHECK_IDEAL_MWALK
    5476     PrintS("\n//** Mwalk: computed M.\n");
    5477     idString(M, "M");
    5478 #endif
    5479     //change the ring to baseRing
    5480     rChangeCurrRing(baseRing);
    5481     M1 =  idrMoveR(M, newRing,currRing);
    5482     idDelete(&M);
    5483     Gomega2 = idrMoveR(Gomega1, newRing,currRing);
    5484     idDelete(&Gomega1);
    5485 #ifdef TIME_TEST
    5486     to = clock();
    5487 #endif
    5488     // compute a representation of the generators of submod (M) with respect to those of mod (Gomega), where Gomega is a reduced Groebner basis w.r.t. the current ring
    5489     F = MLifttwoIdeal(Gomega2, M1, G);
    5490 #ifdef TIME_TEST
    5491     tlift = tlift + clock() - to;
    5492 #endif
    5493 #ifdef CHECK_IDEAL_MWALK
    5494     idString(F, "F");
    5495 #endif
    5496     idDelete(&Gomega2);
    5497     idDelete(&M1);
    5498     rChangeCurrRing(newRing); // change the ring to newRing
    5499     G = idrMoveR(F,baseRing,currRing);
    5500     idDelete(&F);
    5501     baseRing = currRing;
    5502 #ifdef TIME_TEST
    5503     to = clock();
    5504 #endif
    5505     //G = kStd(F1,NULL,testHomog,NULL,NULL,0,0,NULL);
    5506 #ifdef TIME_TEST
    5507     tstd = tstd + clock() - to;
    5508 #endif
    5509     idSkipZeroes(G);
    5510 #ifdef CHECK_IDEAL_MWALK
    5511     idString(G, "G");
    5512 #endif
    5513 #ifdef TIME_TEST
    5514     to = clock();
    5515 #endif
    5516     intvec* next_weight = MWalkRandomNextWeight(G, curr_weight, target_weight, weight_rad, pert_deg);//next_weight = MwalkNextWeightCC(curr_weight,target_weight,G);
    5517 #ifdef TIME_TEST
    5518     tnw = tnw + clock() - to;
    5519 #endif
    5520 #ifdef PRINT_VECTORS
    5521     MivString(curr_weight, target_weight, next_weight);
    5522 #endif
    5523     if(MivComp(next_weight, ivNull) == 1 || MivComp(target_weight,curr_weight) == 1)// || test_w_in_ConeCC(G, target_weight) == 1 || MivComp(next_weight,curr_weight) == 1)
    5524     {
    5525 #ifdef CHECK_IDEAL_MWALK
    5526       PrintS("\n//** Mwalk: entering last cone.\n");
    5527 #endif
    5528       Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector"
    5529       if(target_M->length() == nV)
    5530       {
    5531         newRing = VMrDefault(target_weight); // define a new ring with ordering "(a(curr_weight),lp)
    5532       }
    5533       else
    5534       {
    5535         newRing = VMatrDefault(target_M);
    5536       }
    5537       rChangeCurrRing(newRing);
    5538       Gomega1 = idrMoveR(Gomega, baseRing,currRing);
    5539       idDelete(&Gomega);
    5540 #ifdef CHECK_IDEAL_MWALK
    5541       idString(Gomega1, "Gomega");
    5542 #endif
    5543       M = kStd(Gomega1,NULL,testHomog,NULL,NULL,0,0,NULL);
    5544 #ifdef CHECK_IDEAL_MWALK
    5545       idString(M,"M");
    5546 #endif
    5547       rChangeCurrRing(baseRing);
    5548       M1 =  idrMoveR(M, newRing,currRing);
    5549       idDelete(&M);
    5550       Gomega2 = idrMoveR(Gomega1, newRing,currRing);
    5551       idDelete(&Gomega1);
    5552       F = MLifttwoIdeal(Gomega2, M1, G);
    5553 #ifdef CHECK_IDEAL_MWALK
    5554       idString(F,"F");
    5555 #endif
    5556       idDelete(&Gomega2);
    5557       idDelete(&M1);
    5558       rChangeCurrRing(newRing); // change the ring to newRing
    5559       G = idrMoveR(F,baseRing,currRing);
    5560       idDelete(&F);
    5561       baseRing = currRing;
    5562       si_opt_1 = save1; //set original options, e. g. option(RedSB)
    5563       idSkipZeroes(G);
    5564 #ifdef TIME_TEST
    5565       to = clock();
    5566 #endif
    5567  //     if(si_opt_1 == (Sy_bit(OPT_REDSB)))
    5568   //    {
    5569         //G = kInterRedCC(G,NULL); //reduce the Groebner basis <G> w.r.t. currRing, if option(redSB) is set
    5570   //    }
    5571 #ifdef TIME_TEST
    5572       tred = tred + clock() - to;
    5573 #endif
    5574       idSkipZeroes(G);
    5575       delete next_weight;
    5576       break;
    5577 #ifdef CHECK_IDEAL_MWALK
    5578       PrintS("\n//** Mwalk: last cone.\n");
    5579 #endif
    5580     }
    5581 #ifdef CHECK_IDEAL_MWALK
    5582     PrintS("\n//** Mwalk: update weight vectors.\n");
    5583 #endif
    5584     for(i=nV-1; i>=0; i--)
    5585     {
    5586       (*tmp_weight)[i] = (*curr_weight)[i];
    5587       (*curr_weight)[i] = (*next_weight)[i];
    5588     }
    5589     delete next_weight;
    5590   }
    5591   rChangeCurrRing(XXRing);
    5592   ideal result = idrMoveR(G,baseRing,currRing);
    5593   idDelete(&G);
    5594 /*#ifdef CHECK_IDEAL_MWALK
    5595   pDelete(&p);
    5596 #endif*/
    5597   delete tmp_weight;
    5598   delete ivNull;
    5599   delete exivlp;
    5600 #ifndef BUCHBERGER_ALG
    5601   delete last_omega;
    5602 #endif
    5603 #ifdef TIME_TEST
    5604   Print("\n//** Mwalk: Groebner Walk took %d steps.\n", nstep);
    5605   TimeString(tinput, tostd, tif, tstd, tlift, tred, tnw, nstep);
    5606   Print("\n//** Mwalk: Ergebnis.\n");
    5607   //Print("\n// pSetm_Error = (%d)", ErrorCheck());
    5608   //Print("\n// Overflow_Error? (%d)\n", Overflow_Error);
    5609 #endif
    5610   return(result);
    5611 }
    5612 
    5613 //unused
    5614 #if 0
    5615 ideal Mwalk_tst(ideal Go, intvec* curr_weight, intvec* target_weight)
    5616 {
    5617   //clock_t tinput=clock();
    5618   //idString(Go,"Ginp");
    5619   int i, nV = currRing->N;
    5620   int nwalk=0, endwalks=0;
    5621 
    5622   ideal Gomega, M, F, Gomega1, Gomega2, M1, F1, G;
    5623   // ideal G1; ring endRing;
    5624   ring newRing, oldRing;
    5625   intvec* ivNull = new intvec(nV);
    5626   ring XXRing = currRing;
    5627 
    5628   intvec* tmp_weight = new intvec(nV);
    5629   for(i=nV-1; i>=0; i--)
    5630   {
    5631     (*tmp_weight)[i] = (*curr_weight)[i];
    5632   }
    5633   /* the monomial ordering of this current ring would be "dp" */
    5634   G = MstdCC(Go);
    5635 #ifndef BUCHBERGER_ALG
    5636   intvec* hilb_func;
    5637 #endif
    5638   /* to avoid (1,0,...,0) as the target vector */
    5639   intvec* last_omega = new intvec(nV);
    5640   for(i=nV-1; i>0; i--)
    5641     (*last_omega)[i] = 1;
    5642   (*last_omega)[0] = 10000;
    5643 
    5644   while(1)
    5645   {
    5646     nwalk ++;
    5647     //Print("\n// Entering the %d-th step:", nwalk);
    5648     //Print("\n// ring r[%d] = %s;", nwalk, rString(currRing));
    5649     idString(G,"G");
    5650     /* compute an initial form ideal of <G> w.r.t. "curr_vector" */
    5651     Gomega = MwalkInitialForm(G, curr_weight);
    5652     //ivString(curr_weight, "omega");
    5653     idString(Gomega,"Gw");
    5654 
    5655 #ifndef  BUCHBERGER_ALG
    5656     if(isNolVector(curr_weight) == 0)
    5657       hilb_func = hFirstSeries(Gomega,NULL,NULL,curr_weight,currRing);
    5658     else
    5659       hilb_func = hFirstSeries(Gomega,NULL,NULL,last_omega,currRing);
    5660 #endif // BUCHBERGER_ALG
    5661 
    5662 
    5663     oldRing = currRing;
    5664 
    5665     /* define a new ring that its ordering is "(a(curr_weight),lp) */
    5666     VMrDefault(curr_weight);
    5667     newRing = currRing;
    5668 
    5669     Gomega1 = idrMoveR(Gomega, oldRing,currRing);
    5670 
    5671     /* compute a reduced Groebner basis of <Gomega> w.r.t. "newRing" */
    5672 #ifdef  BUCHBERGER_ALG
    5673     M = MstdhomCC(Gomega1);
    5674 #else
    5675     M=kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight);
    5676     delete hilb_func;
    5677 #endif // BUCHBERGER_ALG
    5678 
    5679     idString(M,"M");
    5680 
    5681       /* change the ring to oldRing */
    5682     rChangeCurrRing(oldRing);
    5683     M1 =  idrMoveR(M, newRing,currRing);
    5684     Gomega2 =  idrMoveR(Gomega1, newRing,currRing);
    5685 
    5686       /* compute a representation of the generators of submod (M)
    5687          with respect to those of mod (Gomega).
    5688          Gomega is a reduced Groebner basis w.r.t. the current ring */
    5689     F = MLifttwoIdeal(Gomega2, M1, G);
    5690     idDelete(&M1);
    5691     idDelete(&Gomega2);
    5692     idDelete(&G);
    5693     idString(F,"F");
    5694 
    5695     /* change the ring to newRing */
    5696     rChangeCurrRing(newRing);
    5697     F1 = idrMoveR(F, oldRing,currRing);
    5698 
    5699     /* reduce the Groebner basis <G> w.r.t. new ring */
    5700     G = kInterRedCC(F1, NULL);
    5701     //idSkipZeroes(G);//done by kInterRed
    5702     idDelete(&F1);
    5703     idString(G,"G");
    5704     if(endwalks == 1)
    5705       break;
    5706 
    5707     /* compute a next weight vector */
    5708     intvec* next_weight = MkInterRedNextWeight(curr_weight,target_weight,G);
    5709 #ifdef PRINT_VECTORS
    5710     MivString(curr_weight, target_weight, next_weight);
    5711 #endif
    5712 
    5713     if(MivComp(next_weight, ivNull) == 1)
    5714     {
    5715       delete next_weight;
    5716       break;
    5717     }
    5718     if(MivComp(next_weight, target_weight) == 1)
    5719       endwalks = 1;
    5720 
    5721     for(i=nV-1; i>=0; i--)
    5722       (*tmp_weight)[i] = (*curr_weight)[i];
    5723 
    5724     /* 06.11.01 to free the memory: NOT Changed!!*/
    5725     for(i=nV-1; i>=0; i--)
    5726       (*curr_weight)[i] = (*next_weight)[i];
    5727     delete next_weight;
    5728   }
    5729   rChangeCurrRing(XXRing);
    5730   G = idrMoveR(G, newRing,currRing);
    5731 
    5732   delete tmp_weight;
    5733   delete ivNull;
    5734   PrintLn();
    5735   return(G);
    5736 }
    5737 #endif
    57386061
    57396062/**************************************************************/
     
    57496072   2) the changed perturbation walk algorithm with a decreased degree.
    57506073*/
    5751 // use kStd, if nP = 0, else call LastGB
     6074// if nP = 0 use kStd, else call LastGB
    57526075ideal Mpwalk(ideal Go, int op_deg, int tp_deg,intvec* curr_weight,
    5753              intvec* target_weight, int nP)
     6076             intvec* target_weight, int nP, int reduction, int printout)
    57546077{
     6078  BITSET save1 = si_opt_1; // save current options
     6079  if(reduction == 0)
     6080  {
     6081    si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis
     6082    si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions
     6083  }
    57556084  Set_Error(FALSE  );
    57566085  Overflow_Error = FALSE;
    57576086  //Print("// pSetm_Error = (%d)", ErrorCheck());
    5758 
     6087#ifdef TIME_TEST
    57596088  clock_t  tinput, tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0;
    57606089  xtextra=0;
     
    57636092
    57646093  clock_t tim;
    5765 
     6094#endif
    57666095  nstep = 0;
    57676096  int i, ntwC=1, ntestw=1,  nV = currRing->N;
    5768   int endwalks=0;
    5769 
    5770   ideal Gomega, M, F, G, Gomega1, Gomega2, M1,F1,Eresult,ssG;
     6097
     6098  //check that perturbation degree is valid
     6099  if(op_deg < 1 || tp_deg < 1 || op_deg > nV || tp_deg > nV)
     6100  {
     6101    Werror("Invalid perturbation degree.\n");
     6102    return NULL;
     6103  }
     6104
     6105  BOOLEAN endwalks = FALSE;
     6106  ideal Gomega, M, F, FF, G, Gomega1, Gomega2, M1,F1,Eresult,ssG;
    57716107  ring newRing, oldRing, TargetRing;
    57726108  intvec* iv_M_dp;
     
    57896125
    57906126  ring XXRing = currRing;
    5791 
    5792 
     6127#ifdef TIME_TEST
    57936128  to = clock();
    5794   /* perturbs the original vector */
     6129#endif
     6130  // perturbs the original vector
    57956131  if(MivComp(curr_weight, iv_dp) == 1) //rOrdStr(currRing) := "dp"
    57966132  {
    57976133    G = MstdCC(Go);
     6134#ifdef TIME_TEST
    57986135    tostd = clock()-to;
     6136#endif
    57996137    if(op_deg != 1){
    58006138      iv_M_dp = MivMatrixOrderdp(nV);
     
    58096147      DefRingPar(curr_weight);
    58106148    else
    5811       rChangeCurrRing(VMrDefault(curr_weight)); //Aenderung 1
     6149      rChangeCurrRing(VMrDefault(curr_weight));
    58126150
    58136151    G = idrMoveR(Go, XXRing,currRing);
    58146152    G = MstdCC(G);
     6153#ifdef TIME_TEST
    58156154    tostd = clock()-to;
     6155#endif
    58166156    if(op_deg != 1){
    58176157      iv_M_dp = MivMatrixOrder(curr_weight);
     
    58246164  ring HelpRing = currRing;
    58256165
    5826   /* perturbs the target weight vector */
     6166  // perturbs the target weight vector
    58276167  if(tp_deg > 1 && tp_deg <= nV)
    58286168  {
     
    58306170      DefRingPar(target_weight);
    58316171    else
    5832       rChangeCurrRing(VMrDefault(target_weight)); // Aenderung 2
     6172      rChangeCurrRing(VMrDefault(target_weight));
    58336173
    58346174    TargetRing = currRing;
     
    58376177    {
    58386178      iv_M_lp = MivMatrixOrderlp(nV);
    5839       //ivString(iv_M_lp, "iv_M_lp");
    5840       //target_weight = MPertVectorslp(ssG, iv_M_lp, tp_deg);
    58416179      target_weight = MPertVectors(ssG, iv_M_lp, tp_deg);
    58426180    }
     
    58446182    {
    58456183      iv_M_lp = MivMatrixOrder(target_weight);
    5846       //target_weight = MPertVectorslp(ssG, iv_M_lp, tp_deg);
    58476184      target_weight = MPertVectors(ssG, iv_M_lp, tp_deg);
    58486185    }
     
    58526189    G = idrMoveR(ssG, TargetRing,currRing);
    58536190  }
    5854   /*
    5855     Print("\n// Perturbationwalkalg. vom Gradpaar (%d,%d):",op_deg,tp_deg);
    5856     ivString(curr_weight, "new sigma");
    5857     ivString(target_weight, "new tau");
    5858   */
     6191  if(printout > 0)
     6192  {
     6193    Print("\n//** Mpwalk: Perturbation Walk of degree (%d,%d):",op_deg,tp_deg);
     6194#ifdef PRINT_VECTORS
     6195    ivString(curr_weight, "//** Mpwalk: new current weight");
     6196    ivString(target_weight, "//** Mpwalk: new target weight");
     6197#endif
     6198  }
    58596199  while(1)
    58606200  {
    58616201    nstep ++;
     6202#ifdef TIME_TEST
    58626203    to = clock();
    5863     /* compute an initial form ideal of <G> w.r.t. the weight vector
    5864        "curr_weight" */
     6204#endif
     6205    // compute an initial form ideal of <G> w.r.t. the weight vector
     6206    // "curr_weight"
    58656207    Gomega = MwalkInitialForm(G, curr_weight);
    5866 
     6208#ifdef TIME_TEST
     6209    tif = tif + clock()-to;
     6210#endif
     6211#ifdef CHECK_IDEAL_MWALK
     6212    if(printout > 1)
     6213    {
     6214      idString(Gomega,"//** Mpwalk: Gomega");
     6215    }
     6216#endif
     6217    if(reduction == 0 && nstep > 1)
     6218    {
     6219/*
     6220      // check whether weight vector is in the interior of the cone
     6221      while(1)
     6222      {
     6223        FF = middleOfCone(G,Gomega);
     6224        if(FF != NULL)
     6225        {
     6226          idDelete(&G);
     6227          G = idCopy(FF);
     6228          idDelete(&FF);
     6229          next_weight = MwalkNextWeightCC(curr_weight,target_weight,G);
     6230#ifdef PRINT_VECTORS
     6231          if(printout > 0)
     6232          {
     6233            MivString(curr_weight, target_weight, next_weight);
     6234          }
     6235#endif
     6236        }
     6237        else
     6238        {
     6239          break;
     6240        }
     6241        for(i=nV-1; i>=0; i--)
     6242        {
     6243          (*curr_weight)[i] = (*next_weight)[i];
     6244        }
     6245        Gomega = MwalkInitialForm(G, curr_weight);
     6246#ifdef CHECK_IDEAL_MWALK
     6247        if(printout > 1)
     6248        {
     6249          idString(Gomega,"//** Mpwalk: Gomega");
     6250        }
     6251#endif
     6252      }
     6253*/
     6254      FF = middleOfCone(G,Gomega);
     6255      if(FF != NULL)
     6256      {
     6257        idDelete(&G);
     6258        G = idCopy(FF);
     6259        idDelete(&FF);
     6260        goto NEXT_VECTOR;
     6261      }
     6262    }
    58676263
    58686264#ifdef ENDWALKS
    5869     if(endwalks == 1){
     6265    if(endwalks == TRUE)
     6266    {
    58706267      Print("\n// ring r%d = %s;\n", nstep, rString(currRing));
     6268/*
    58716269      idElements(G, "G");
    5872       // idElements(Gomega, "Gw");
    58736270      headidString(G, "G");
    5874       //headidString(Gomega, "Gw");
    5875     }
    5876 #endif
    5877 
    5878     tif = tif + clock()-to;
     6271*/
     6272    }
     6273#endif
    58796274
    58806275#ifndef  BUCHBERGER_ALG
     
    58916286      DefRingPar(curr_weight);
    58926287    else
    5893       rChangeCurrRing(VMrDefault(curr_weight)); //Aenderung 3
     6288      rChangeCurrRing(VMrDefault(curr_weight));
    58946289
    58956290    newRing = currRing;
     
    58976292
    58986293#ifdef ENDWALKS
    5899     if(endwalks==1)
     6294    if(endwalks==TRUE)
    59006295    {
    59016296      Print("\n// ring r%d = %s;\n", nstep, rString(currRing));
     6297/*
    59026298      idElements(Gomega1, "Gw");
    59036299      headidString(Gomega1, "headGw");
     6300*/
    59046301      PrintS("\n// compute a rGB of Gw:\n");
    5905 
    59066302#ifndef  BUCHBERGER_ALG
    59076303      ivString(hilb_func, "w");
     
    59096305    }
    59106306#endif
    5911 
     6307#ifdef TIME_TEST
    59126308    tim = clock();
    59136309    to = clock();
    5914     /* compute a reduced Groebner basis of <Gomega> w.r.t. "newRing" */
     6310#endif
     6311    // compute a reduced Groebner basis of <Gomega> w.r.t. "newRing"
    59156312#ifdef  BUCHBERGER_ALG
    59166313    M = MstdhomCC(Gomega1);
     
    59186315    M=kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight);
    59196316    delete hilb_func;
    5920 #endif // BUCHBERGER_ALG
    5921 
    5922     if(endwalks == 1){
     6317#endif
     6318
     6319    if(endwalks == TRUE)
     6320    {
     6321#ifdef TIME_TEST
    59236322      xtstd = xtstd+clock()-to;
     6323#endif
    59246324#ifdef ENDWALKS
    59256325      Print("\n// time for the last std(Gw)  = %.2f sec\n",
     
    59286328    }
    59296329    else
     6330    {
     6331#ifdef TIME_TEST
    59306332      tstd=tstd+clock()-to;
    5931 
    5932     /* change the ring to oldRing */
     6333#endif
     6334    }
     6335#ifdef CHECK_IDEAL_MWALK
     6336    if(printout > 2)
     6337    {
     6338      idString(M,"//** Mpwalk: M");
     6339    }
     6340#endif
     6341    // change the ring to oldRing
    59336342    rChangeCurrRing(oldRing);
    59346343    M1 =  idrMoveR(M, newRing,currRing);
    59356344    Gomega2 =  idrMoveR(Gomega1, newRing,currRing);
    5936 
    5937     //if(endwalks==1)  PrintS("\n// Lifting is working:..");
    5938 
     6345#ifdef TIME_TEST
    59396346    to=clock();
     6347#endif
    59406348    /* compute a representation of the generators of submod (M)
    59416349       with respect to those of mod (Gomega).
    59426350       Gomega is a reduced Groebner basis w.r.t. the current ring */
    59436351    F = MLifttwoIdeal(Gomega2, M1, G);
    5944     if(endwalks != 1)
     6352#ifdef TIME_TEST
     6353    if(endwalks == FALSE)
    59456354      tlift = tlift+clock()-to;
    59466355    else
    59476356      xtlift=clock()-to;
     6357#endif
     6358#ifdef CHECK_IDEAL_MWALK
     6359    if(printout > 2)
     6360    {
     6361      idString(F,"//** Mpwalk: F");
     6362    }
     6363#endif
    59486364
    59496365    idDelete(&M1);
     
    59516367    idDelete(&G);
    59526368
    5953     /* change the ring to newRing */
     6369    // change the ring to newRing
    59546370    rChangeCurrRing(newRing);
    5955     F1 = idrMoveR(F, oldRing,currRing);
    5956 
    5957     //if(endwalks==1)PrintS("\n// InterRed is working now:");
    5958 
     6371    if(reduction == 0)
     6372    {
     6373      G = idrMoveR(F,oldRing,currRing);
     6374    }
     6375    else
     6376    {
     6377      F1 = idrMoveR(F, oldRing,currRing);
     6378      if(printout > 2)
     6379      {
     6380        PrintS("\n //** Mpwalk: reduce the Groebner basis.\n");
     6381      }
     6382#ifdef TIME_TEST
     6383      to=clock();
     6384#endif
     6385      G = kInterRedCC(F1, NULL);
     6386#ifdef TIME_TEST
     6387      if(endwalks == FALSE)
     6388        tred = tred+clock()-to;
     6389      else
     6390        xtred=clock()-to;
     6391#endif
     6392      idDelete(&F1);
     6393    }
     6394    if(endwalks == TRUE)
     6395      break;
     6396
     6397    NEXT_VECTOR:
     6398#ifdef TIME_TEST
    59596399    to=clock();
    5960     /* reduce the Groebner basis <G> w.r.t. new ring */
    5961     G = kInterRedCC(F1, NULL);
    5962     if(endwalks != 1)
    5963       tred = tred+clock()-to;
    5964     else
    5965       xtred=clock()-to;
    5966 
    5967     idDelete(&F1);
    5968 
    5969     if(endwalks == 1)
    5970       break;
    5971 
    5972     to=clock();
    5973     /* compute a next weight vector */
     6400#endif
     6401    // compute a next weight vector
    59746402    next_weight = MkInterRedNextWeight(curr_weight,target_weight, G);
     6403#ifdef TIME_TEST
    59756404    tnw=tnw+clock()-to;
     6405#endif
    59766406#ifdef PRINT_VECTORS
    5977     MivString(curr_weight, target_weight, next_weight);
     6407    if(printout > 0)
     6408    {
     6409      MivString(curr_weight, target_weight, next_weight);
     6410    }
    59786411#endif
    59796412
     
    59946427    }
    59956428    if(MivComp(next_weight, target_weight) == 1)
    5996       endwalks = 1;
     6429      endwalks = TRUE;
    59976430
    59986431    for(i=nV-1; i>=0; i--)
     
    60006433
    60016434    delete next_weight;
    6002   }//while
     6435  }//end of while-loop
    60036436
    60046437  if(tp_deg != 1)
     
    60146447        DefRingPar(orig_target);
    60156448      else
    6016         rChangeCurrRing(VMrDefault(orig_target)); //Aenderung
     6449        rChangeCurrRing(VMrDefault(orig_target));
    60176450
    60186451    TargetRing=currRing;
    60196452    F1 = idrMoveR(G, newRing,currRing);
    6020 #ifdef CHECK_IDEAL
     6453/*
     6454#ifdef CHECK_IDEAL_MWALK
    60216455      headidString(G, "G");
    60226456#endif
    6023 
     6457*/
    60246458
    60256459    // check whether the pertubed target vector stays in the correct cone
     
    60306464    if( ntestw != 1 || ntwC == 0)
    60316465    {
    6032       /*
    6033       if(ntestw != 1){
     6466      if(ntestw != 1 && printout >2)
     6467      {
    60346468        ivString(pert_target_vector, "tau");
    60356469        PrintS("\n// ** perturbed target vector doesn't stay in cone!!");
    60366470        Print("\n// ring r%d = %s;\n", nstep, rString(currRing));
    6037         idElements(F1, "G");
    6038       }
    6039       */
     6471        //idElements(F1, "G");
     6472      }
    60406473      // LastGB is "better" than the kStd subroutine
    60416474      to=clock();
     
    60686501    Eresult = idrMoveR(G, newRing,currRing);
    60696502  }
     6503  si_opt_1 = save1; //set original options, e. g. option(RedSB)
    60706504  delete ivNull;
    60716505  if(tp_deg != 1)
     
    60826516             tnw+xtnw);
    60836517
    6084   Print("\n// pSetm_Error = (%d)", ErrorCheck());
    6085   Print("\n// It took %d steps and Overflow_Error? (%d)\n", nstep,  Overflow_Error);
    6086 #endif
     6518  //Print("\n// pSetm_Error = (%d)", ErrorCheck());
     6519  //Print("\n// It took %d steps and Overflow_Error? (%d)\n", nstep,  Overflow_Error);
     6520#endif
     6521  Print("\n//** Mpwalk: Perturbation Walk took %d steps.\n", nstep);
     6522  return(Eresult);
     6523}
     6524
     6525/*******************************************************
     6526 * THE PERTURBATION WALK ALGORITHM WITH RANDOM ELEMENT *
     6527 *******************************************************/
     6528ideal Mprwalk(ideal Go, intvec* orig_M, intvec* target_M, int weight_rad,
     6529              int op_deg, int tp_deg, int nP, int reduction, int printout)
     6530{
     6531  BITSET save1 = si_opt_1; // save current options
     6532  if(reduction == 0)
     6533  {
     6534    si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis
     6535    si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions
     6536  }
     6537  Set_Error(FALSE);
     6538  Overflow_Error = FALSE;
     6539  //Print("// pSetm_Error = (%d)", ErrorCheck());
     6540#ifdef TIME_TEST
     6541  clock_t  tinput, tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0;
     6542  xtextra=0;
     6543  xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0;
     6544  tinput = clock();
     6545
     6546  clock_t tim;
     6547#endif
     6548  nstep = 0;
     6549  int i, ntwC=1, ntestw=1, nV = currRing->N; //polylength
     6550
     6551  //check that weight radius is valid
     6552  if(weight_rad < 0)
     6553  {
     6554    Werror("Invalid radius.\n");
     6555    return NULL;
     6556  }
     6557
     6558  //check that perturbation degree is valid
     6559  if(op_deg < 1 || tp_deg < 1 || op_deg > nV || tp_deg > nV)
     6560  {
     6561    Werror("Invalid perturbation degree.\n");
     6562    return NULL;
     6563  }
     6564
     6565  BOOLEAN endwalks = FALSE;
     6566
     6567  ideal Gomega, M, F, FF, G, Gomega1, Gomega2, M1,F1,Eresult,ssG;
     6568  ring newRing, oldRing, TargetRing;
     6569  intvec* iv_M;
     6570  intvec* iv_M_dp;
     6571  intvec* iv_M_lp;
     6572  intvec* exivlp = Mivlp(nV);
     6573  intvec* curr_weight = new intvec(nV);
     6574  intvec* target_weight = new intvec(nV);
     6575  for(i=0; i<nV; i++)
     6576  {
     6577    (*curr_weight)[i] = (*orig_M)[i];
     6578    (*target_weight)[i] = (*target_M)[i];
     6579  }
     6580  intvec* orig_target = target_weight;
     6581  intvec* pert_target_vector = target_weight;
     6582  intvec* ivNull = new intvec(nV);
     6583  intvec* iv_dp = MivUnit(nV);// define (1,1,...,1)
     6584#ifndef BUCHBERGER_ALG
     6585  intvec* hilb_func;
     6586#endif
     6587  intvec* next_weight;
     6588
     6589  // to avoid (1,0,...,0) as the target vector
     6590  intvec* last_omega = new intvec(nV);
     6591  for(i=nV-1; i>0; i--)
     6592    (*last_omega)[i] = 1;
     6593  (*last_omega)[0] = 10000;
     6594
     6595  ring XXRing = currRing;
     6596
     6597  // perturbs the original vector
     6598  if(orig_M->length() == nV)
     6599  {
     6600    if(MivComp(curr_weight, iv_dp) == 1) //rOrdStr(currRing) := "dp"
     6601    {
     6602#ifdef TIME_TEST
     6603  to = clock();
     6604#endif
     6605      G = MstdCC(Go);
     6606#ifdef TIME_TEST
     6607      tostd = clock()-to;
     6608#endif
     6609      if(op_deg != 1)
     6610      {
     6611        iv_M_dp = MivMatrixOrderdp(nV);
     6612        curr_weight = MPertVectors(G, iv_M_dp, op_deg);
     6613      }
     6614    }
     6615    else
     6616    {
     6617      //define ring order := (a(curr_weight),lp);
     6618      if (rParameter(currRing) != NULL)
     6619        DefRingPar(curr_weight);
     6620      else
     6621        rChangeCurrRing(VMrDefault(curr_weight));
     6622
     6623      G = idrMoveR(Go, XXRing,currRing);
     6624#ifdef TIME_TEST
     6625  to = clock();
     6626#endif
     6627      G = MstdCC(G);
     6628#ifdef TIME_TEST
     6629      tostd = clock()-to;
     6630#endif
     6631      if(op_deg != 1)
     6632      {
     6633        iv_M_dp = MivMatrixOrder(curr_weight);
     6634        curr_weight = MPertVectors(G, iv_M_dp, op_deg);
     6635      }
     6636    }
     6637  }
     6638  else
     6639  {
     6640    rChangeCurrRing(VMatrDefault(orig_M));
     6641    G = idrMoveR(Go, XXRing,currRing);
     6642#ifdef TIME_TEST
     6643    to = clock();
     6644#endif
     6645    G = MstdCC(G);
     6646#ifdef TIME_TEST
     6647    tostd = clock()-to;
     6648#endif
     6649    if(op_deg != 1)
     6650    {
     6651      curr_weight = MPertVectors(G, orig_M, op_deg);
     6652    }
     6653  }
     6654
     6655  delete iv_dp;
     6656  if(op_deg != 1) delete iv_M_dp;
     6657
     6658  ring HelpRing = currRing;
     6659
     6660  // perturbs the target weight vector
     6661  if(target_M->length() == nV)
     6662  {
     6663    if(tp_deg > 1 && tp_deg <= nV)
     6664    {
     6665      if (rParameter(currRing) != NULL)
     6666        DefRingPar(target_weight);
     6667      else
     6668        rChangeCurrRing(VMrDefault(target_weight));
     6669
     6670      TargetRing = currRing;
     6671      ssG = idrMoveR(G,HelpRing,currRing);
     6672      if(MivSame(target_weight, exivlp) == 1)
     6673      {
     6674        iv_M_lp = MivMatrixOrderlp(nV);
     6675        target_weight = MPertVectors(ssG, iv_M_lp, tp_deg);
     6676      }
     6677      else
     6678      {
     6679        iv_M_lp = MivMatrixOrder(target_weight);
     6680        target_weight = MPertVectors(ssG, iv_M_lp, tp_deg);
     6681      }
     6682      delete iv_M_lp;
     6683      pert_target_vector = target_weight;
     6684      rChangeCurrRing(HelpRing);
     6685      G = idrMoveR(ssG, TargetRing,currRing);
     6686    }
     6687  }
     6688  else
     6689  {
     6690    if(tp_deg > 1 && tp_deg <= nV)
     6691    {
     6692      rChangeCurrRing(VMatrDefault(target_M));
     6693      TargetRing = currRing;
     6694      ssG = idrMoveR(G,HelpRing,currRing);
     6695      target_weight = MPertVectors(ssG, target_M, tp_deg);
     6696    }
     6697  }
     6698  if(printout > 0)
     6699  {
     6700    Print("\n//** Mprwalk: Random Perturbation Walk of degree (%d,%d):",op_deg,tp_deg);
     6701    ivString(curr_weight, "//** Mprwalk: new current weight");
     6702    ivString(target_weight, "//** Mprwalk: new target weight");
     6703  }
     6704
     6705#ifdef TIME_TEST
     6706  to = clock();
     6707#endif
     6708  Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector"
     6709#ifdef TIME_TEST
     6710  tif = tif + clock()-to; //time for computing initial form ideal
     6711#endif
     6712
     6713  while(1)
     6714  {
     6715    nstep ++;
     6716#ifdef CHECK_IDEAL_MWALK
     6717    if(printout > 1)
     6718    {
     6719      idString(Gomega,"//** Mprwalk: Gomega");
     6720    }
     6721#endif
     6722
     6723    if(reduction == 0 && nstep > 1)
     6724    {
     6725/*
     6726      // check whether weight vector is in the interior of the cone
     6727      while(1)
     6728      {
     6729        FF = middleOfCone(G,Gomega);
     6730        if(FF != NULL)
     6731        {
     6732          idDelete(&G);
     6733          G = idCopy(FF);
     6734          idDelete(&FF);
     6735          next_weight = MwalkNextWeightCC(curr_weight,target_weight,G);
     6736#ifdef PRINT_VECTORS
     6737          if(printout > 0)
     6738          {
     6739            MivString(curr_weight, target_weight, next_weight);
     6740          }
     6741#endif
     6742        }
     6743        else
     6744        {
     6745          break;
     6746        }
     6747        for(i=nV-1; i>=0; i--)
     6748        {
     6749          (*curr_weight)[i] = (*next_weight)[i];
     6750        }
     6751        Gomega = MwalkInitialForm(G, curr_weight);
     6752#ifdef CHECK_IDEAL_MWALK
     6753        if(printout > 1)
     6754        {
     6755          idString(Gomega,"//** Mprwalk: Gomega");
     6756        }
     6757#endif
     6758      }
     6759*/
     6760      FF = middleOfCone(G,Gomega);
     6761      if(FF != NULL)
     6762      {
     6763        idDelete(&G);
     6764        G = idCopy(FF);
     6765        idDelete(&FF);
     6766        goto NEXT_VECTOR;
     6767      }
     6768    }
     6769
     6770#ifdef ENDWALKS
     6771    if(endwalks == TRUE)
     6772    {
     6773      Print("\n// ring r%d = %s;\n", nstep, rString(currRing));
     6774/*
     6775      idElements(G, "G");
     6776      headidString(G, "G");
     6777*/
     6778    }
     6779#endif
     6780
     6781#ifndef  BUCHBERGER_ALG
     6782    if(isNolVector(curr_weight) == 0)
     6783      hilb_func = hFirstSeries(Gomega,NULL,NULL,curr_weight,currRing);
     6784    else
     6785      hilb_func = hFirstSeries(Gomega,NULL,NULL,last_omega,currRing);
     6786#endif // BUCHBERGER_ALG
     6787
     6788    oldRing = currRing;
     6789
     6790    if(target_M->length() == nV)
     6791    {
     6792      // define a new ring with ordering "(a(curr_weight),lp)
     6793      if (rParameter(currRing) != NULL)
     6794        DefRingPar(curr_weight);
     6795      else
     6796        rChangeCurrRing(VMrDefault(curr_weight));
     6797    }
     6798    else
     6799    {
     6800      rChangeCurrRing(VMatrRefine(target_M,curr_weight));
     6801    }
     6802    newRing = currRing;
     6803    Gomega1 = idrMoveR(Gomega, oldRing,currRing);
     6804#ifdef ENDWALKS
     6805    if(endwalks == TRUE)
     6806    {
     6807      Print("\n// ring r%d = %s;\n", nstep, rString(currRing));
     6808/*
     6809      idElements(Gomega1, "Gw");
     6810      headidString(Gomega1, "headGw");
     6811*/
     6812      PrintS("\n// compute a rGB of Gw:\n");
     6813
     6814#ifndef  BUCHBERGER_ALG
     6815      ivString(hilb_func, "w");
     6816#endif
     6817    }
     6818#endif
     6819#ifdef TIME_TEST
     6820    tim = clock();
     6821    to = clock();
     6822#endif
     6823    // compute a reduced Groebner basis of <Gomega> w.r.t. "newRing"
     6824#ifdef  BUCHBERGER_ALG
     6825    M = MstdhomCC(Gomega1);
     6826#else
     6827    M=kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight);
     6828    delete hilb_func;
     6829#endif
     6830#ifdef CHECK_IDEAL_MWALK
     6831    if(printout > 2)
     6832    {
     6833      idString(M,"//** Mprwalk: M");
     6834    }
     6835#endif
     6836#ifdef TIME_TEST
     6837    if(endwalks == TRUE)
     6838    {
     6839      xtstd = xtstd+clock()-to;
     6840#ifdef ENDWALKS
     6841      Print("\n// time for the last std(Gw)  = %.2f sec\n",
     6842            ((double) clock())/1000000 -((double)tim) /1000000);
     6843#endif
     6844    }
     6845    else
     6846      tstd=tstd+clock()-to;
     6847#endif
     6848    /* change the ring to oldRing */
     6849    rChangeCurrRing(oldRing);
     6850    M1 =  idrMoveR(M, newRing,currRing);
     6851    Gomega2 =  idrMoveR(Gomega1, newRing,currRing);
     6852#ifdef TIME_TEST
     6853    to=clock();
     6854#endif
     6855    /* compute a representation of the generators of submod (M)
     6856       with respect to those of mod (Gomega).
     6857       Gomega is a reduced Groebner basis w.r.t. the current ring */
     6858    F = MLifttwoIdeal(Gomega2, M1, G);
     6859#ifdef TIME_TEST
     6860    if(endwalks == FALSE)
     6861      tlift = tlift+clock()-to;
     6862    else
     6863      xtlift=clock()-to;
     6864#endif
     6865#ifdef CHECK_IDEAL_MWALK
     6866    if(printout > 2)
     6867    {
     6868      idString(F,"//** Mprwalk: F");
     6869    }
     6870#endif
     6871
     6872    idDelete(&M1);
     6873    idDelete(&Gomega2);
     6874    idDelete(&G);
     6875
     6876    // change the ring to newRing
     6877    rChangeCurrRing(newRing);
     6878    if(reduction == 0)
     6879    {
     6880      G = idrMoveR(F,oldRing,currRing);
     6881    }
     6882    else
     6883    {
     6884      F1 = idrMoveR(F, oldRing,currRing);
     6885      if(printout > 2)
     6886      {
     6887        PrintS("\n //** Mprwalk: reduce the Groebner basis.\n");
     6888      }
     6889#ifdef TIME_TEST
     6890      to=clock();
     6891#endif
     6892      G = kInterRedCC(F1, NULL);
     6893#ifdef TIME_TEST
     6894      if(endwalks == FALSE)
     6895        tred = tred+clock()-to;
     6896      else
     6897        xtred=clock()-to;
     6898#endif
     6899      idDelete(&F1);
     6900    }
     6901
     6902    if(endwalks == TRUE)
     6903      break;
     6904
     6905    NEXT_VECTOR:
     6906#ifdef TIME_TEST
     6907    to = clock();
     6908#endif
     6909    next_weight = next_weight = MkInterRedNextWeight(curr_weight,target_weight, G);
     6910#ifdef TIME_TEST
     6911    tnw = tnw + clock() - to;
     6912#endif
     6913
     6914#ifdef TIME_TEST
     6915    to = clock();
     6916#endif
     6917    // compute an initial form ideal of <G> w.r.t. "next_vector"
     6918    Gomega = MwalkInitialForm(G, next_weight);
     6919#ifdef TIME_TEST
     6920    tif = tif + clock()-to; //time for computing initial form ideal
     6921#endif
     6922
     6923    //lengthpoly(Gomega) = 1 if there is a polynomial in Gomega with at least 3 monomials and 0 otherwise
     6924    if(lengthpoly(Gomega) > 0)
     6925    {
     6926      Print("\n there is a polynomial in Gomega with at least 3 monomials,\n");
     6927      // low-dimensional facet of the cone
     6928      delete next_weight;
     6929      if(target_M->length() == nV)
     6930      {
     6931        iv_M = MivMatrixOrder(curr_weight);
     6932      }
     6933      else
     6934      {
     6935        iv_M = MivMatrixOrderRefine(curr_weight,target_M);
     6936      }
     6937#ifdef TIME_TEST
     6938      to = clock();
     6939#endif
     6940      next_weight = MWalkRandomNextWeight(G, iv_M, target_weight, weight_rad, op_deg);
     6941#ifdef TIME_TEST
     6942      tnw = tnw + clock() - to;
     6943#endif
     6944      idDelete(&Gomega);
     6945#ifdef TIME_TEST
     6946      to = clock();
     6947#endif
     6948      Gomega = MwalkInitialForm(G, next_weight);
     6949#ifdef TIME_TEST
     6950      tif = tif + clock()-to; //time for computing initial form ideal
     6951#endif
     6952  Print("delete\n");
     6953      delete iv_M;
     6954    }
     6955
     6956/*
     6957    to=clock();
     6958    next_weight = MkInterRedNextWeight(curr_weight,target_weight, G);
     6959    if(polylength > 0)
     6960    {
     6961      if(printout > 2)
     6962      {
     6963        Print("\n //**Mprwalk: there is a polynomial in Gomega with at least 3 monomials, low-dimensional facet of the cone.\n");
     6964      }
     6965      delete next_weight;
     6966      next_weight = MWalkRandomNextWeight(G, curr_weight, target_weight, weight_rad, op_deg);
     6967    }
     6968    tnw=tnw+clock()-to;
     6969*/
     6970#ifdef PRINT_VECTORS
     6971    if(printout > 0)
     6972    {
     6973      MivString(curr_weight, target_weight, next_weight);
     6974    }
     6975#endif
     6976
     6977    if(Overflow_Error == TRUE)
     6978    {
     6979      ntwC = 0;
     6980      //Print("\n// ring r%d = %s;\n", nstep, rString(currRing));
     6981      //idElements(G, "G");
     6982      delete next_weight;
     6983      goto FINISH_160302;
     6984    }
     6985    if(MivComp(next_weight, ivNull) == 1){
     6986      newRing = currRing;
     6987      delete next_weight;
     6988      //Print("\n// ring r%d = %s;\n", nstep, rString(currRing));
     6989      break;
     6990    }
     6991    if(MivComp(next_weight, target_weight) == 1)
     6992      endwalks = TRUE;
     6993
     6994    for(i=nV-1; i>=0; i--)
     6995      (*curr_weight)[i] = (*next_weight)[i];
     6996
     6997    delete next_weight;
     6998  }// end of while-loop
     6999
     7000  if(tp_deg != 1)
     7001  {
     7002    FINISH_160302:
     7003    if(target_M->length() == nV)
     7004    {
     7005      if(MivSame(orig_target, exivlp) == 1)
     7006        if (rParameter(currRing) != NULL)
     7007          DefRingParlp();
     7008        else
     7009          VMrDefaultlp();
     7010      else
     7011        if (rParameter(currRing) != NULL)
     7012          DefRingPar(orig_target);
     7013        else
     7014          rChangeCurrRing(VMrDefault(orig_target));
     7015    }
     7016    else
     7017    {
     7018      rChangeCurrRing(VMatrDefault(target_M));
     7019    }
     7020    TargetRing=currRing;
     7021    F1 = idrMoveR(G, newRing,currRing);
     7022
     7023    // check whether the pertubed target vector stays in the correct cone
     7024    if(ntwC != 0)
     7025    {
     7026      ntestw = test_w_in_ConeCC(F1, pert_target_vector);
     7027    }
     7028    if(ntestw != 1 || ntwC == 0)
     7029    {
     7030      if(ntestw != 1 && printout > 2)
     7031      {
     7032#ifdef PRINT_VECTORS
     7033        ivString(pert_target_vector, "tau");
     7034#endif
     7035        PrintS("\n// **Mprwalk: perturbed target vector doesn't stay in cone.");
     7036        Print("\n// ring r%d = %s;\n", nstep, rString(currRing));
     7037        //idElements(F1, "G");
     7038      }
     7039      // LastGB is "better" than the kStd subroutine
     7040#ifdef TIME_TEST
     7041      to=clock();
     7042#endif
     7043      ideal eF1;
     7044      if(nP == 0 || tp_deg == 1 || MivSame(orig_target, exivlp) != 1 || target_M->length() != nV)
     7045      {
     7046        if(printout > 2)
     7047        {
     7048          PrintS("\n// ** Mprwalk: Call \"std\" to compute a Groebner basis.\n");
     7049        }
     7050        eF1 = MstdCC(F1);
     7051        idDelete(&F1);
     7052      }
     7053      else
     7054      {
     7055        if(printout > 2)
     7056        {
     7057          PrintS("\n// **Mprwalk: Call \"LastGB\" to compute a Groebner basis.\n");
     7058        }
     7059        rChangeCurrRing(newRing);
     7060        ideal F2 = idrMoveR(F1, TargetRing,currRing);
     7061        eF1 = LastGB(F2, curr_weight, tp_deg-1);
     7062        F2=NULL;
     7063      }
     7064#ifdef TIME_TEST
     7065      xtextra=clock()-to;
     7066#endif
     7067      ring exTargetRing = currRing;
     7068
     7069      rChangeCurrRing(XXRing);
     7070      Eresult = idrMoveR(eF1, exTargetRing,currRing);
     7071    }
     7072    else
     7073    {
     7074      rChangeCurrRing(XXRing);
     7075      Eresult = idrMoveR(F1, TargetRing,currRing);
     7076    }
     7077  }
     7078  else
     7079  {
     7080    rChangeCurrRing(XXRing);
     7081    Eresult = idrMoveR(G, newRing,currRing);
     7082  }
     7083  si_opt_1 = save1; //set original options, e. g. option(RedSB)
     7084  delete ivNull;
     7085  if(tp_deg != 1)
     7086    delete target_weight;
     7087
     7088  if(op_deg != 1 )
     7089    delete curr_weight;
     7090
     7091  delete exivlp;
     7092  delete last_omega;
     7093
     7094#ifdef TIME_TEST
     7095  TimeStringFractal(tinput, tostd, tif+xtif, tstd+xtstd,0, tlift+xtlift, tred+xtred,
     7096             tnw+xtnw);
     7097
     7098  //Print("\n// pSetm_Error = (%d)", ErrorCheck());
     7099  //Print("\n// It took %d steps and Overflow_Error? (%d)\n", nstep,  Overflow_Error);
     7100#endif
     7101  Print("\n//** Mprwalk: Perturbation Walk took %d steps.\n", nstep);
    60877102  return(Eresult);
    60887103}
     
    61107125 * Perturb the start weight vector at the top level, i.e. nlev = 1     *
    61117126 ***********************************************************************/
    6112 static ideal rec_fractal_call(ideal G, int nlev, intvec* omtmp)
     7127static ideal rec_fractal_call(ideal G, int nlev, intvec* ivtarget,
     7128             int reduction, int printout)
    61137129{
    61147130  Overflow_Error =  FALSE;
    6115   //Print("\n\n// Entering the %d-th recursion:", nlev);
    6116 
     7131  if(printout >0)
     7132  {
     7133    Print("\n\n// Entering the %d-th recursion:", nlev);
     7134  }
    61177135  int i, nV = currRing->N;
    61187136  ring new_ring, testring;
    61197137  //ring extoRing;
    6120   ideal Gomega, Gomega1, Gomega2, F, F1, Gresult, Gresult1, G1, Gt;
     7138  ideal Gomega, Gomega1, Gomega2, FF, F, F1, Gresult, Gresult1, G1, Gt;
    61217139  int nwalks = 0;
    61227140  intvec* Mwlp;
     
    61247142  intvec* hilb_func;
    61257143#endif
    6126 //  intvec* extXtau;
     7144  //intvec* extXtau;
    61277145  intvec* next_vect;
    61287146  intvec* omega2 = new intvec(nV);
    6129   intvec* altomega = new intvec(nV);
    6130 
     7147  intvec* omtmp = new intvec(nV);
     7148  //intvec* altomega = new intvec(nV);
     7149
     7150  for(i = nV -1; i>0; i--)
     7151  {
     7152    (*omtmp)[i] = (*ivtarget)[i];
     7153  }
    61317154  //BOOLEAN isnewtarget = FALSE;
    61327155
     
    61687191    nwalks ++;
    61697192    NEXT_VECTOR_FRACTAL:
     7193#ifdef TIME_TEST
    61707194    to=clock();
    6171     /* determine the next border */
     7195#endif
     7196    // determine the next border
    61727197    next_vect = MkInterRedNextWeight(omega,omega2,G);
     7198#ifdef TIME_TEST
    61737199    xtnw=xtnw+clock()-to;
    6174 #ifdef PRINT_VECTORS
    6175     MivString(omega, omega2, next_vect);
    61767200#endif
    61777201    oRing = currRing;
    61787202
    6179     /* We only perturb the current target vector at the recursion  level 1 */
     7203    // We only perturb the current target vector at the recursion level 1
    61807204    if(Xngleich == 0 && nlev == 1) //(ngleich == 0) important, e.g. ex2, ex3
    6181       if (MivComp(next_vect, omega2) != 1)
    6182       {
    6183         /* to dispense with taking initial (and lifting/interreducing
    6184            after the call of recursion */
    6185         //Print("\n\n// ** Perturb the both vectors with degree %d with",nlev);
    6186         //idElements(G, "G");
     7205      if (MivComp(next_vect, omega2) == 1)
     7206      {
     7207        // to dispense with taking initial (and lifting/interreducing
     7208        // after the call of recursion
     7209        if(printout > 0)
     7210        {
     7211          Print("\n//** rec_fractal_call: Perturb the both vectors with degree %d.",nlev);
     7212          //idElements(G, "G");
     7213        }
    61877214
    61887215        Xngleich = 1;
    61897216        nlev +=1;
    61907217
    6191         if (rParameter(currRing) != NULL)
    6192           DefRingPar(omtmp);
     7218        if(ivtarget->length() == nV)
     7219        {
     7220          if (rParameter(currRing) != NULL)
     7221            DefRingPar(omtmp);
     7222          else
     7223            rChangeCurrRing(VMrDefault(omtmp));
     7224        }
    61937225        else
    6194           rChangeCurrRing(VMrDefault1(omtmp)); //Aenderung3
    6195 
     7226        {
     7227          rChangeCurrRing(VMatrDefault(ivtarget));
     7228        }
    61967229        testring = currRing;
    61977230        Gt = idrMoveR(G, oRing,currRing);
    61987231
    6199         /* perturb the original target vector w.r.t. the current GB */
    6200         delete Xtau;
    6201         Xtau = NewVectorlp(Gt);
     7232        // perturb the original target vector w.r.t. the current GB
     7233        if(ivtarget->length() == nV)
     7234        {
     7235          delete Xtau;
     7236          Xtau = NewVectorlp(Gt);
     7237        }
     7238        else
     7239        {
     7240          delete Xtau;
     7241          Xtau = Mfpertvector(Gt,ivtarget);
     7242        }
    62027243
    62037244        rChangeCurrRing(oRing);
    62047245        G = idrMoveR(Gt, testring,currRing);
    62057246
    6206         /* perturb the current vector w.r.t. the current GB */
     7247        // perturb the current vector w.r.t. the current GB
    62077248        Mwlp = MivWeightOrderlp(omega);
    62087249        Xsigma = Mfpertvector(G, Mwlp);
     
    62157256
    62167257        delete next_vect;
     7258#ifdef TIME_TEST
    62177259        to=clock();
    6218 
    6219         /* to avoid the value of Overflow_Error that occur in Mfpertvector*/
     7260#endif
     7261        // to avoid the value of Overflow_Error that occur in Mfpertvector
    62207262        Overflow_Error = FALSE;
    6221 
    62227263        next_vect = MkInterRedNextWeight(omega,omega2,G);
     7264#ifdef TIME_TEST
    62237265        xtnw=xtnw+clock()-to;
     7266#endif
     7267      }// end of (if MivComp(next_vect, omega2) == 1)
    62247268
    62257269#ifdef PRINT_VECTORS
     7270      if(printout > 0)
     7271      {
    62267272        MivString(omega, omega2, next_vect);
    6227 #endif
    6228       }
    6229 
    6230 
    6231     /* check whether the the computed vector is in the correct cone */
    6232     /* If no, the reduced GB of an omega-homogeneous ideal will be
    6233        computed by Buchberger algorithm and stop this recursion step*/
    6234     //if(test_w_in_ConeCC(G, next_vect) != 1) //e.g. Example s7, cyc6
    6235     if(Overflow_Error == TRUE)
     7273      }
     7274#endif
     7275
     7276    // check whether the the computed vector is in the correct cone.
     7277    // If no, compute the reduced Groebner basis of an omega-homogeneous
     7278    // ideal with Buchberger's algorithm and stop this recursion step
     7279    if(Overflow_Error == TRUE || test_w_in_ConeCC(G, next_vect) != 1)  //e.g. Example s7, cyc6
    62367280    {
    62377281      delete next_vect;
    6238       if (rParameter(currRing) != NULL)
    6239       {
    6240         DefRingPar(omtmp);
     7282      if(ivtarget->length() == nV)
     7283      {
     7284        if (rParameter(currRing) != NULL)
     7285          DefRingPar(omtmp);
     7286        else
     7287          rChangeCurrRing(VMrDefault(omtmp));
    62417288      }
    62427289      else
    62437290      {
    6244         rChangeCurrRing(VMrDefault1(omtmp)); // Aenderung4
     7291        rChangeCurrRing(VMatrDefault(ivtarget));
    62457292      }
    62467293#ifdef TEST_OVERFLOW
     
    62487295      Gt = NULL; return(Gt);
    62497296#endif
    6250 
    6251       //Print("\n\n// apply BB's alg. in ring r = %s;", rString(currRing));
     7297      if(printout > 0)
     7298      {
     7299        Print("\n//** rec_fractal_call: Applying Buchberger's algorithm in ring r = %s;",
     7300              rString(currRing));
     7301      }
     7302#ifdef TIME_TEST
    62527303      to=clock();
     7304#endif
    62537305      Gt = idrMoveR(G, oRing,currRing);
    62547306      G1 = MstdCC(Gt);
     7307#ifdef TIME_TEST
    62557308      xtextra=xtextra+clock()-to;
     7309#endif
    62567310      Gt = NULL;
    62577311
    62587312      delete omega2;
    6259       delete altomega;
    6260 
    6261       //Print("\n// Leaving the %d-th recursion with %d steps", nlev, nwalks);
    6262       //Print("  ** Overflow_Error? (%d)", Overflow_Error);
     7313      //delete altomega;
     7314      if(printout > 0)
     7315      {
     7316        Print("\n//** rec_fractal_call: Overflow. Leaving the %d-th recursion with %d steps.\n",
     7317              nlev, nwalks);
     7318        //Print(" ** Overflow_Error? (%d)", Overflow_Error);
     7319      }
     7320
    62637321      nnflow ++;
    6264 
    62657322      Overflow_Error = FALSE;
    62667323      return (G1);
    62677324    }
    6268 
    62697325
    62707326    /* If the perturbed target vector stays in the correct cone,
     
    62777333    if (MivComp(next_vect, XivNull) == 1)
    62787334    {
    6279       if (rParameter(currRing) != NULL)
    6280         DefRingPar(omtmp);
     7335      if(ivtarget->length() == nV)
     7336      {
     7337        if (rParameter(currRing) != NULL)
     7338          DefRingPar(omtmp);
     7339        else
     7340          rChangeCurrRing(VMrDefault(omtmp));
     7341      }
    62817342      else
    6282         rChangeCurrRing(VMrDefault1(omtmp)); //Aenderung5
     7343      {
     7344        rChangeCurrRing(VMatrDefault(ivtarget));
     7345      }
    62837346
    62847347      testring = currRing;
    62857348      Gt = idrMoveR(G, oRing,currRing);
    62867349
    6287       if(test_w_in_ConeCC(Gt, omega2) == 1) {
     7350      if(test_w_in_ConeCC(Gt, omega2) == 1)
     7351      {
     7352        delete omega2;
     7353        delete next_vect;
     7354        //delete altomega;
     7355        if(printout > 0)
     7356        {
     7357          Print("\n//** rec_fractal_call: Correct cone. Leaving the %d-th recursion with %d steps.\n",
     7358              nlev, nwalks);
     7359        }
     7360        return (Gt);
     7361      }
     7362      else
     7363      {
     7364        if(printout > 0)
     7365        {
     7366          Print("\n//** rec_fractal_call: Wrong cone. Tau doesn't stay in the correct cone.\n");
     7367        }
     7368
     7369#ifndef  MSTDCC_FRACTAL
     7370        intvec* Xtautmp;
     7371        if(ivtarget->length() == nV)
     7372        {
     7373          Xtautmp = Mfpertvector(Gt, MivMatrixOrder(omtmp));
     7374        }
     7375        else
     7376        {
     7377          Xtautmp = Mfpertvector(Gt, ivtarget);
     7378        }
     7379#ifdef TEST_OVERFLOW
     7380      if(Overflow_Error == TRUE)
     7381      Gt = NULL; return(Gt);
     7382#endif
     7383
     7384        if(MivSame(Xtau, Xtautmp) == 1)
     7385        {
     7386          if(printout > 0)
     7387          {
     7388            Print("\n//** rec_fractal_call: Updated vectors are equal to the old vectors.\n");
     7389          }
     7390          delete Xtautmp;
     7391          goto FRACTAL_MSTDCC;
     7392        }
     7393
     7394        Xtau = Xtautmp;
     7395        Xtautmp = NULL;
     7396
     7397        for(i=nV-1; i>=0; i--)
     7398          (*omega2)[i] = (*Xtau)[(nlev-1)*nV+i];
     7399
     7400        rChangeCurrRing(oRing);
     7401        G = idrMoveR(Gt, testring,currRing);
     7402
     7403        goto NEXT_VECTOR_FRACTAL;
     7404#endif
     7405
     7406      FRACTAL_MSTDCC:
     7407        if(printout > 0)
     7408        {
     7409          Print("\n//** rec_fractal_call: Wrong cone. Applying Buchberger's algorithm in ring = %s.\n",
     7410                rString(currRing));
     7411        }
     7412#ifdef TIME_TEST
     7413        to=clock();
     7414#endif
     7415        G = MstdCC(Gt);
     7416#ifdef TIME_TEST
     7417        xtextra=xtextra+clock()-to;
     7418#endif
     7419        oRing = currRing;
     7420
     7421        // update the original target vector w.r.t. the current GB
     7422        if(ivtarget->length() == nV)
     7423        {
     7424          if(MivSame(Xivinput, Xivlp) == 1)
     7425            if (rParameter(currRing) != NULL)
     7426              DefRingParlp();
     7427            else
     7428              VMrDefaultlp();
     7429          else
     7430            if (rParameter(currRing) != NULL)
     7431              DefRingPar(Xivinput);
     7432            else
     7433              rChangeCurrRing(VMrDefault(Xivinput));
     7434        }
     7435        else
     7436        {
     7437          rChangeCurrRing(VMatrRefine(ivtarget,Xivinput));
     7438        }
     7439        testring = currRing;
     7440        Gt = idrMoveR(G, oRing,currRing);
     7441
     7442        // perturb the original target vector w.r.t. the current GB
     7443        if(ivtarget->length() == nV)
     7444        {
     7445          delete Xtau;
     7446          Xtau = NewVectorlp(Gt);
     7447        }
     7448        else
     7449        {
     7450          delete Xtau;
     7451          Xtau = Mfpertvector(Gt,ivtarget);
     7452        }
     7453
     7454        rChangeCurrRing(oRing);
     7455        G = idrMoveR(Gt, testring,currRing);
     7456
     7457        delete omega2;
     7458        delete next_vect;
     7459        //delete altomega;
     7460        if(printout > 0)
     7461        {
     7462          Print("\n//** rec_fractal_call: Vectors updated. Leaving the %d-th recursion with %d steps.\n",
     7463              nlev, nwalks);
     7464          //Print(" ** Overflow_Error? (%d)", Overflow_Error);
     7465        }
     7466        if(Overflow_Error == TRUE)
     7467          nnflow ++;
     7468
     7469        Overflow_Error = FALSE;
     7470        return(G);
     7471      }
     7472    }// end of (if next_vect==nullvector)
     7473
     7474    for(i=nV-1; i>=0; i--) {
     7475      //(*altomega)[i] = (*omega)[i];
     7476      (*omega)[i] = (*next_vect)[i];
     7477    }
     7478    delete next_vect;
     7479#ifdef TIME_TEST
     7480    to=clock();
     7481#endif
     7482    // Take the initial form of <G> w.r.t. omega
     7483    Gomega = MwalkInitialForm(G, omega);
     7484#ifdef TIME_TEST
     7485    xtif=xtif+clock()-to;
     7486#endif
     7487#ifdef CHECK_IDEAL_MWALK
     7488    if(printout > 1)
     7489    {
     7490      idString(Gomega,"//** rec_fractal_call: Gomega");
     7491    }
     7492#endif
     7493    if(reduction == 0)
     7494    {
     7495      // Check whether the intermediate weight vector lies in the interior of the cone.
     7496      // If so, only perform reductions. Otherwise apply Buchberger's algorithm.
     7497      FF = middleOfCone(G,Gomega);
     7498      if( FF != NULL)
     7499      {
     7500        idDelete(&G);
     7501        G = idCopy(FF);
     7502        idDelete(&FF);
     7503        // Compue next vector.
     7504        goto NEXT_VECTOR_FRACTAL;
     7505      }
     7506    }
     7507
     7508#ifndef  BUCHBERGER_ALG
     7509    if(isNolVector(omega) == 0)
     7510      hilb_func = hFirstSeries(Gomega,NULL,NULL,omega,currRing);
     7511    else
     7512      hilb_func = hFirstSeries(Gomega,NULL,NULL,last_omega,currRing);
     7513#endif
     7514
     7515    if(ivtarget->length() == nV)
     7516    {
     7517      if (rParameter(currRing) != NULL)
     7518        DefRingPar(omega);
     7519      else
     7520        rChangeCurrRing(VMrDefault(omega));
     7521    }
     7522    else
     7523    {
     7524      rChangeCurrRing(VMatrRefine(ivtarget,omega));
     7525    }
     7526    Gomega1 = idrMoveR(Gomega, oRing,currRing);
     7527
     7528    // Maximal recursion depth, to compute a red. GB
     7529    // Fractal walk with the alternative recursion
     7530    // alternative recursion
     7531    if(nlev == Xnlev || lengthpoly(Gomega1) == 0)
     7532    {
     7533      if(printout > 1)
     7534      {
     7535        Print("\n//** rec_fractal_call: Maximal recursion depth.\n");
     7536      }
     7537#ifdef TIME_TEST
     7538      to=clock();
     7539#endif
     7540#ifdef  BUCHBERGER_ALG
     7541      Gresult = MstdhomCC(Gomega1);
     7542#else
     7543      Gresult =kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,omega);
     7544      delete hilb_func;
     7545#endif
     7546#ifdef TIME_TEST
     7547      xtstd=xtstd+clock()-to;
     7548#endif
     7549    }
     7550    else
     7551    {
     7552      rChangeCurrRing(oRing);
     7553      Gomega1 = idrMoveR(Gomega1, oRing,currRing);
     7554      Gresult = rec_fractal_call(idCopy(Gomega1),nlev+1,omega,reduction,printout);
     7555    }
     7556#ifdef CHECK_IDEAL_MWALK
     7557    if(printout > 2)
     7558    {
     7559      idString(Gresult,"//** rec_fractal_call: M");
     7560    }
     7561#endif
     7562    //convert a Groebner basis from a ring to another ring
     7563    new_ring = currRing;
     7564
     7565    rChangeCurrRing(oRing);
     7566    Gresult1 = idrMoveR(Gresult, new_ring,currRing);
     7567    Gomega2 = idrMoveR(Gomega1, new_ring,currRing);
     7568#ifdef TIME_TEST
     7569    to=clock();
     7570#endif
     7571    // Lifting process
     7572    F = MLifttwoIdeal(Gomega2, Gresult1, G);
     7573#ifdef TIME_TEST
     7574    xtlift=xtlift+clock()-to;
     7575#endif
     7576#ifdef CHECK_IDEAL_MWALK
     7577    if(printout > 2)
     7578    {
     7579      idString(F,"//** rec_fractal_call: F");
     7580    }
     7581#endif
     7582    idDelete(&Gresult1);
     7583    idDelete(&Gomega2);
     7584    idDelete(&G);
     7585
     7586    rChangeCurrRing(new_ring);
     7587    G = idrMoveR(F,oRing,currRing);
     7588/*
     7589    F1 = idrMoveR(F, oRing,currRing);
     7590#ifdef TIME_TEST
     7591    to=clock();
     7592#endif
     7593    // Interreduce G
     7594    G = kInterRedCC(F1, NULL);
     7595#ifdef TIME_TEST
     7596    xtred=xtred+clock()-to;
     7597#endif
     7598    idDelete(&F1);
     7599*/
     7600  }
     7601}
     7602
     7603/************************************************************************
     7604 * Perturb the start weight vector at the top level with random element *
     7605 ************************************************************************/
     7606static ideal rec_r_fractal_call(ideal G, int nlev, intvec* ivtarget,
     7607                int weight_rad, int reduction, int printout)
     7608{
     7609  Overflow_Error =  FALSE;
     7610  //Print("\n\n// Entering the %d-th recursion:", nlev);
     7611
     7612  int nwalks = 0,i,nV=currRing->N;//polylength
     7613  ring new_ring, testring;
     7614  //ring extoRing;
     7615  ideal Gomega, Gomega1, Gomega2, F, FF, F1, Gresult, Gresult1, G1, Gt;
     7616  intvec* Mwlp;
     7617#ifndef BUCHBERGER_ALG
     7618  intvec* hilb_func;
     7619#endif
     7620//  intvec* extXtau;
     7621  intvec* next_vect;
     7622  intvec* iv_M;
     7623  intvec* omega2 = new intvec(nV);
     7624  intvec* omtmp = new intvec(nV);
     7625  intvec* altomega = new intvec(nV);
     7626
     7627  //BOOLEAN isnewtarget = FALSE;
     7628
     7629  for(i = nV -1; i>0; i--)
     7630  {
     7631    (*omtmp)[i] = (*ivtarget)[i];
     7632  }
     7633  // to avoid (1,0,...,0) as the target vector (Hans)
     7634  intvec* last_omega = new intvec(nV);
     7635  for(i=nV-1; i>0; i--)
     7636    (*last_omega)[i] = 1;
     7637  (*last_omega)[0] = 10000;
     7638
     7639  intvec* omega = new intvec(nV);
     7640  for(i=0; i<nV; i++) {
     7641    if(Xsigma->length() == nV)
     7642      (*omega)[i] =  (*Xsigma)[i];
     7643    else
     7644      (*omega)[i] = (*Xsigma)[(nV*(nlev-1))+i];
     7645
     7646    (*omega2)[i] = (*Xtau)[(nlev-1)*nV+i];
     7647  }
     7648
     7649   if(nlev == 1)  Xcall = 1;
     7650   else Xcall = 0;
     7651
     7652  ring oRing = currRing;
     7653
     7654  while(1)
     7655  {
     7656#ifdef FIRST_STEP_FRACTAL
     7657    /*
     7658    perturb the current weight vector only on the top level or
     7659    after perturbation of the both vectors, nlev = 2 as the top level
     7660    */
     7661    if((nlev == 1 && Xcall == 0) || (nlev == 2 && Xngleich == 1))
     7662      if(islengthpoly2(G) == 1)
     7663      {
     7664        Mwlp = MivWeightOrderlp(omega);
     7665        Xsigma = Mfpertvector(G, Mwlp);
     7666        delete Mwlp;
     7667        Overflow_Error = FALSE;
     7668      }
     7669#endif
     7670    nwalks ++;
     7671    NEXT_VECTOR_FRACTAL:
     7672#ifdef TIME_TEST
     7673    to=clock();
     7674#endif
     7675    /* determine the next border */
     7676    next_vect = MkInterRedNextWeight(omega,omega2,G);
     7677#ifdef TIME_TEST
     7678    xtnw=xtnw+clock()-to;
     7679#endif
     7680    if(lengthpoly(MwalkInitialForm(G, next_vect)) > 0 && G->m[0] != NULL)
     7681    {
     7682      if(printout > 0)
     7683      {
     7684        PrintS("\n**// rec_r_fractal_call: there is a polynomial in Gomega with at least 3 monomials.\n");
     7685      }
     7686      delete next_vect;
     7687      iv_M = MivMatrixOrder(omega);
     7688#ifdef TIME_TEST
     7689      to=clock();
     7690#endif
     7691      next_vect = MWalkRandomNextWeight(G,iv_M,omega2,weight_rad,nlev);
     7692#ifdef TIME_TEST
     7693      xtnw=xtnw+clock()-to;
     7694#endif
     7695      if(isNegNolVector(next_vect) == 1)
     7696      {
     7697        delete next_vect;
     7698#ifdef TIME_TEST
     7699        to=clock();
     7700#endif
     7701        next_vect = MkInterRedNextWeight(omega,omega2,G);
     7702#ifdef TIME_TEST
     7703        xtnw=xtnw+clock()-to;
     7704#endif
     7705      }
     7706    }
     7707    oRing = currRing;
     7708
     7709    // We only perturb the current target vector at the recursion  level 1
     7710    if(Xngleich == 0 && nlev == 1) //(ngleich == 0) important, e.g. ex2, ex3
     7711      if (MivComp(next_vect, omega2) == 1)
     7712      {
     7713        // to dispense with taking initials and lifting/interreducing
     7714        // after the call of recursion.
     7715        if(printout > 0)
     7716        {
     7717          Print("\n//** rec_r_fractal_call: Perturb both vectors with degree %d.",nlev);
     7718          //idElements(G, "G");
     7719        }
     7720        Xngleich = 1;
     7721        nlev +=1;
     7722        if(ivtarget->length() == nV)
     7723        {
     7724          if (rParameter(currRing) != NULL)
     7725            DefRingPar(omtmp);
     7726          else
     7727            rChangeCurrRing(VMrDefault(omtmp));
     7728        }
     7729        else
     7730        {
     7731          rChangeCurrRing(VMatrDefault(ivtarget));
     7732        }
     7733        testring = currRing;
     7734        Gt = idrMoveR(G, oRing,currRing);
     7735
     7736        // perturb the original target vector w.r.t. the current GB
     7737        if(ivtarget->length() == nV)
     7738        {
     7739          delete Xtau;
     7740          Xtau = NewVectorlp(Gt);
     7741        }
     7742        else
     7743        {
     7744          delete Xtau;
     7745          Xtau = Mfpertvector(Gt,ivtarget);
     7746        }
     7747
     7748        rChangeCurrRing(oRing);
     7749        G = idrMoveR(Gt,testring,currRing);
     7750
     7751        // perturb the current vector w.r.t. the current GB
     7752        Mwlp = MivWeightOrderlp(omega);
     7753        if(ivtarget->length() > nV)
     7754        {
     7755          delete Mwlp;
     7756          Mwlp = MivMatrixOrderRefine(omega,ivtarget);
     7757        }
     7758        Xsigma = Mfpertvector(G, Mwlp);
     7759        delete Mwlp;
     7760
     7761        for(i=nV-1; i>=0; i--)
     7762        {
     7763          (*omega2)[i] = (*Xtau)[nV+i];
     7764          (*omega)[i] = (*Xsigma)[nV+i];
     7765        }
     7766
     7767        delete next_vect;
     7768
     7769   //to avoid the value of Overflow_Error that occur in Mfpertvector
     7770        Overflow_Error = FALSE;
     7771#ifdef TIME_TEST
     7772        to=clock();
     7773#endif
     7774        next_vect = MkInterRedNextWeight(omega,omega2,G);
     7775#ifdef TIME_TEST
     7776        xtnw=xtnw+clock()-to;
     7777#endif
     7778        if(lengthpoly(MwalkInitialForm(G, next_vect)) > 0 && G->m[0] != NULL)
     7779        {
     7780          // there is a polynomial in Gomega with at least 3 monomials
     7781          iv_M = MivMatrixOrder(omega);
     7782          delete next_vect;
     7783#ifdef TIME_TEST
     7784          to=clock();
     7785#endif
     7786          next_vect = MWalkRandomNextWeight(G,iv_M,omega2,weight_rad,nlev);
     7787#ifdef TIME_TEST
     7788          xtnw=xtnw+clock()-to;
     7789#endif
     7790          delete iv_M;
     7791          if(isNegNolVector(next_vect) == 1)
     7792          {
     7793            delete next_vect;
     7794#ifdef TIME_TEST
     7795            to=clock();
     7796#endif
     7797            next_vect = MkInterRedNextWeight(omega,omega2,G);
     7798#ifdef TIME_TEST
     7799        xtnw=xtnw+clock()-to;
     7800#endif
     7801          }
     7802        }
     7803      }
     7804#ifdef PRINT_VECTORS
     7805      if(printout > 0)
     7806      {
     7807        MivString(omega, omega2, next_vect);
     7808      }
     7809#endif
     7810
     7811/*     check whether the the computed vector is in the correct cone
     7812       If no, the reduced GB of an omega-homogeneous ideal will be
     7813       computed by Buchberger algorithm and stop this recursion step
     7814*/
     7815    if(Overflow_Error == TRUE || test_w_in_ConeCC(G,next_vect) != 1)//e.g. Example s7, cyc6
     7816    {
     7817      delete next_vect;
     7818      if(ivtarget->length() == nV)
     7819      {
     7820        if (rParameter(currRing) != NULL)
     7821        {
     7822          DefRingPar(omtmp);
     7823        }
     7824        else
     7825        {
     7826          rChangeCurrRing(VMrDefault(omtmp));
     7827        }
     7828      }
     7829      else
     7830      {
     7831        rChangeCurrRing(VMatrDefault(ivtarget));
     7832      }
     7833#ifdef TEST_OVERFLOW
     7834      Gt = idrMoveR(G, oRing,currRing);
     7835      Gt = NULL;
     7836      return(Gt);
     7837#endif
     7838      if(printout > 0)
     7839      {
     7840        Print("\n//** rec_r_fractal_call: applying Buchberger's algorithm in ring r = %s;",
     7841              rString(currRing));
     7842      }
     7843      Gt = idrMoveR(G, oRing,currRing);
     7844#ifdef TIME_TEST
     7845      to=clock();
     7846#endif
     7847      G1 = MstdCC(Gt);
     7848#ifdef TIME_TEST
     7849      xtextra=xtextra+clock()-to;
     7850#endif
     7851      Gt = NULL;
     7852
     7853      delete omega2;
     7854      delete altomega;
     7855      if(printout > 0)
     7856      {
     7857        Print("\n//** rec_r_fractal_call: Leaving the %d-th recursion with %d steps.\n",
     7858              nlev, nwalks);
     7859        //Print(" ** Overflow_Error? (%d)", Overflow_Error);
     7860      }
     7861      nnflow ++;
     7862      Overflow_Error = FALSE;
     7863      return (G1);
     7864    }
     7865    /*
     7866       If the perturbed target vector stays in the correct cone,
     7867       return the current Groebner basis.
     7868       Otherwise, return the Groebner basis computed with Buchberger's
     7869       algorithm.
     7870       Then we update the perturbed target vectors w.r.t. this GB.
     7871    */
     7872    if (MivComp(next_vect, XivNull) == 1)
     7873    {
     7874      // The computed vector is equal to the origin vector,
     7875      // because t is not defined
     7876      if(ivtarget->length() == nV)
     7877      {
     7878        if (rParameter(currRing) != NULL)
     7879          DefRingPar(omtmp);
     7880        else
     7881          rChangeCurrRing(VMrDefault(omtmp));
     7882      }
     7883      else
     7884      {
     7885        rChangeCurrRing(VMatrDefault(ivtarget));
     7886      }
     7887      testring = currRing;
     7888      Gt = idrMoveR(G, oRing,currRing);
     7889
     7890      if(test_w_in_ConeCC(Gt, omega2) == 1)
     7891      {
    62887892        delete omega2;
    62897893        delete next_vect;
    62907894        delete altomega;
    6291         //Print("\n// Leaving the %d-th recursion with %d steps ",nlev, nwalks);
    6292         //Print(" ** Overflow_Error? (%d)", Overflow_Error);
    6293 
     7895        if(printout > 0)
     7896        {
     7897          Print("\n//** rec_r_fractal_call: Leaving the %d-th recursion with %d steps.\n",
     7898                nlev, nwalks);
     7899          //Print(" ** Overflow_Error? (%d)", Overflow_Error);
     7900        }
    62947901        return (Gt);
    62957902      }
    62967903      else
    6297       {
    6298         //ivString(omega2, "tau'");
    6299         //Print("\n//  tau' doesn't stay in the correct cone!!");
     7904      {
     7905        if(printout > 0)
     7906        {
     7907          Print("\n//** rec_r_fractal_call: target weight doesn't stay in the correct cone.\n");
     7908        }
    63007909
    63017910#ifndef  MSTDCC_FRACTAL
    6302         //07.08.03
    6303         //ivString(Xtau, "old Xtau");
    6304         intvec* Xtautmp = Mfpertvector(Gt, MivMatrixOrder(omtmp));
     7911#ifdef PRINT_VECTORS
     7912        if(printout > 0)
     7913        {
     7914          ivString(Xtau, "old Xtau");
     7915        }
     7916#endif
     7917        intvec* Xtautmp;
     7918        if(ivtarget->length() == nV)
     7919        {
     7920          Xtautmp = Mfpertvector(Gt, MivMatrixOrder(omtmp));
     7921        }
     7922        else
     7923        {
     7924          Xtautmp = Mfpertvector(Gt, ivtarget);
     7925        }
    63057926#ifdef TEST_OVERFLOW
    63067927      if(Overflow_Error == TRUE)
     
    63177938        Xtau = Xtautmp;
    63187939        Xtautmp = NULL;
    6319         //ivString(Xtau, "new  Xtau");
     7940#ifdef PRINT_VECTORS
     7941        if(printout > 0)
     7942        {
     7943          ivString(Xtau, "new  Xtau");
     7944        }
     7945#endif
    63207946
    63217947        for(i=nV-1; i>=0; i--)
     
    63307956
    63317957      FRACTAL_MSTDCC:
    6332         //Print("\n//  apply BB-Alg in ring = %s;", rString(currRing));
     7958        if(printout > 0)
     7959        {
     7960          Print("\n//** rec_r_fractal_call: apply Buchberger's algorithm in ring = %s.\n",
     7961                rString(currRing));
     7962        }
     7963#ifdef TIME_TEST
    63337964        to=clock();
     7965#endif
    63347966        G = MstdCC(Gt);
     7967#ifdef TIME_TEST
    63357968        xtextra=xtextra+clock()-to;
    6336 
     7969#endif
    63377970        oRing = currRing;
    63387971
    63397972        // update the original target vector w.r.t. the current GB
    6340         if(MivSame(Xivinput, Xivlp) == 1)
    6341           if (rParameter(currRing) != NULL)
    6342             DefRingParlp();
     7973        if(ivtarget->length() == nV)
     7974        {
     7975          if(MivSame(Xivinput, Xivlp) == 1)
     7976            if (rParameter(currRing) != NULL)
     7977              DefRingParlp();
     7978            else
     7979              VMrDefaultlp();
    63437980          else
    6344             VMrDefaultlp();
     7981            if (rParameter(currRing) != NULL)
     7982              DefRingPar(Xivinput);
     7983            else
     7984              rChangeCurrRing(VMrDefault(Xivinput));
     7985        }
    63457986        else
    6346           if (rParameter(currRing) != NULL)
    6347             DefRingPar(Xivinput);
    6348           else
    6349             rChangeCurrRing(VMrDefault1(Xivinput)); //Aenderung6
    6350 
     7987        {
     7988          rChangeCurrRing(VMatrRefine(ivtarget,Xivinput));
     7989        }
    63517990        testring = currRing;
    63527991        Gt = idrMoveR(G, oRing,currRing);
    63537992
    6354         delete Xtau;
    6355         Xtau = NewVectorlp(Gt);
     7993        // perturb the original target vector w.r.t. the current GB
     7994        if(ivtarget->length() == nV)
     7995        {
     7996          delete Xtau;
     7997          Xtau = NewVectorlp(Gt);
     7998        }
     7999        else
     8000        {
     8001          delete Xtau;
     8002          Xtau = Mfpertvector(Gt,ivtarget);
     8003        }
    63568004
    63578005        rChangeCurrRing(oRing);
     
    63618009        delete next_vect;
    63628010        delete altomega;
    6363         /*
    6364           Print("\n// Leaving the %d-th recursion with %d steps,", nlev,nwalks);
    6365           Print(" ** Overflow_Error? (%d)", Overflow_Error);
    6366         */
     8011        if(printout > 0)
     8012        {
     8013          Print("\n//** rec_r_fractal_call: Leaving the %d-th recursion with %d steps.\n",
     8014                nlev,nwalks);
     8015          //Print(" ** Overflow_Error? (%d)", Overflow_Error);
     8016        }
    63678017        if(Overflow_Error == TRUE)
    63688018          nnflow ++;
     
    63718021        return(G);
    63728022      }
    6373     }
    6374 
    6375     for(i=nV-1; i>=0; i--) {
     8023    } //end of if(MivComp(next_vect, XivNull) == 1)
     8024
     8025    for(i=nV-1; i>=0; i--)
     8026    {
    63768027      (*altomega)[i] = (*omega)[i];
    63778028      (*omega)[i] = (*next_vect)[i];
    63788029    }
    63798030    delete next_vect;
    6380 
     8031#ifdef TIME_TEST
    63818032    to=clock();
    6382     /* Take the initial form of <G> w.r.t. omega */
     8033#endif
     8034    // Take the initial form of <G> w.r.t. omega
    63838035    Gomega = MwalkInitialForm(G, omega);
     8036#ifdef TIME_TEST
    63848037    xtif=xtif+clock()-to;
     8038#endif
     8039    //polylength = 1 if there is a polynomial in Gomega with at least 3 monomials and 0 otherwise
     8040    //polylength = lengthpoly(Gomega);
     8041#ifdef CHECK_IDEAL_MWALK
     8042    if(printout > 1)
     8043    {
     8044      idString(Gomega,"//** rec_r_fractal_call: Gomega");
     8045    }
     8046#endif
     8047    if(reduction == 0)
     8048    {
     8049      /* Check whether the intermediate weight vector lies in the interior of the cone.
     8050       * If so, only perform reductions. Otherwise apply Buchberger's algorithm. */
     8051      FF = middleOfCone(G,Gomega);
     8052      if( FF != NULL)
     8053      {
     8054        idDelete(&G);
     8055        G = idCopy(FF);
     8056        idDelete(&FF);
     8057        /* Compue next vector. */
     8058        goto NEXT_VECTOR_FRACTAL;
     8059      }
     8060    }
    63858061
    63868062#ifndef  BUCHBERGER_ALG
     
    63898065    else
    63908066      hilb_func = hFirstSeries(Gomega,NULL,NULL,last_omega,currRing);
    6391 #endif // BUCHBERGER_ALG
    6392 
    6393     if (rParameter(currRing) != NULL)
    6394       DefRingPar(omega);
     8067#endif
     8068    if(ivtarget->length() == nV)
     8069    {
     8070      if (rParameter(currRing) != NULL)
     8071        DefRingPar(omega);
     8072      else
     8073        rChangeCurrRing(VMrDefault(omega));
     8074    }
    63958075    else
    6396       rChangeCurrRing(VMrDefault1(omega)); //Aenderung7
    6397 
     8076    {
     8077      rChangeCurrRing(VMatrRefine(ivtarget,omega));
     8078    }
    63988079    Gomega1 = idrMoveR(Gomega, oRing,currRing);
    63998080
    6400     /* Maximal recursion depth, to compute a red. GB */
    6401     /* Fractal walk with the alternative recursion */
    6402     /* alternative recursion */
    6403     // if(nlev == nV || lengthpoly(Gomega1) == 0)
     8081    // Maximal recursion depth, to compute a red. GB
     8082    // Fractal walk with the alternative recursion
     8083    // alternative recursion
    64048084    if(nlev == Xnlev || lengthpoly(Gomega1) == 0)
    6405       //if(nlev == nV) // blind recursion
    6406     {
    6407       /*
    6408       if(Xnlev != nV)
    6409       {
    6410         Print("\n// ** Xnlev = %d", Xnlev);
    6411         ivString(Xtau, "Xtau");
    6412       }
    6413       */
     8085    {
     8086#ifdef TIME_TEST
    64148087      to=clock();
     8088#endif
    64158089#ifdef  BUCHBERGER_ALG
    64168090      Gresult = MstdhomCC(Gomega1);
     
    64188092      Gresult =kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,omega);
    64198093      delete hilb_func;
    6420 #endif // BUCHBERGER_ALG
     8094#endif
     8095#ifdef TIME_TEST
    64218096      xtstd=xtstd+clock()-to;
    6422     }
    6423     else {
     8097#endif
     8098    }
     8099    else
     8100    {
    64248101      rChangeCurrRing(oRing);
    64258102      Gomega1 = idrMoveR(Gomega1, oRing,currRing);
    6426       Gresult = rec_fractal_call(idCopy(Gomega1),nlev+1,omega);
    6427     }
    6428 
    6429     //convert a Groebner basis from a ring to another ring,
     8103      Gresult = rec_r_fractal_call(idCopy(Gomega1),nlev+1,omega,weight_rad,reduction,printout);
     8104    }
     8105#ifdef CHECK_IDEAL_MWALK
     8106    if(printout > 2)
     8107    {
     8108      idString(Gresult,"//** rec_r_fractal_call: M");
     8109    }
     8110#endif
     8111    //convert a Groebner basis from a ring to another ring
    64308112    new_ring = currRing;
    64318113
     
    64338115    Gresult1 = idrMoveR(Gresult, new_ring,currRing);
    64348116    Gomega2 = idrMoveR(Gomega1, new_ring,currRing);
    6435 
     8117#ifdef TIME_TEST
    64368118    to=clock();
    6437     /* Lifting process */
     8119#endif
     8120    // Lifting process
    64388121    F = MLifttwoIdeal(Gomega2, Gresult1, G);
     8122#ifdef TIME_TEST
    64398123    xtlift=xtlift+clock()-to;
     8124#endif
     8125#ifdef CHECK_IDEAL_MWALK
     8126    if(printout > 2)
     8127    {
     8128      idString(F,"//** rec_r_fractal_call: F");
     8129    }
     8130#endif
    64408131    idDelete(&Gresult1);
    64418132    idDelete(&Gomega2);
     
    64438134
    64448135    rChangeCurrRing(new_ring);
    6445     F1 = idrMoveR(F, oRing,currRing);
    6446 
     8136    //F1 = idrMoveR(F, oRing,currRing);
     8137    G = idrMoveR(F,oRing,currRing);
     8138/*
     8139#ifdef TIME_TEST
    64478140    to=clock();
    6448     /* Interreduce G */
     8141#endif
     8142    // Interreduce G
    64498143    G = kInterRedCC(F1, NULL);
     8144#ifdef TIME_TEST
    64508145    xtred=xtred+clock()-to;
     8146#endif
    64518147    idDelete(&F1);
     8148*/
    64528149  }
    64538150}
    6454 
    6455 /************************************************************************
    6456  * Perturb the start weight vector at the top level with random element *
    6457  ************************************************************************/
    6458 static ideal rec_r_fractal_call(ideal G, int nlev, intvec* omtmp, int weight_rad)
    6459 {
    6460   Overflow_Error =  FALSE;
    6461   //Print("\n\n// Entering the %d-th recursion:", nlev);
    6462 
    6463   int i, nV = currRing->N;
    6464   ring new_ring, testring;
    6465   //ring extoRing;
    6466   ideal Gomega, Gomega1, Gomega2, F, F1, Gresult, Gresult1, G1, Gt;
    6467   int nwalks = 0;
    6468   intvec* Mwlp;
    6469 #ifndef BUCHBERGER_ALG
    6470   intvec* hilb_func;
    6471 #endif
    6472 //  intvec* extXtau;
    6473   intvec* next_vect;
    6474   intvec* omega2 = new intvec(nV);
    6475   intvec* altomega = new intvec(nV);
    6476 
    6477   //BOOLEAN isnewtarget = FALSE;
    6478 
    6479   // to avoid (1,0,...,0) as the target vector (Hans)
    6480   intvec* last_omega = new intvec(nV);
    6481   for(i=nV-1; i>0; i--)
    6482     (*last_omega)[i] = 1;
    6483   (*last_omega)[0] = 10000;
    6484 
    6485   intvec* omega = new intvec(nV);
    6486   for(i=0; i<nV; i++) {
    6487     if(Xsigma->length() == nV)
    6488       (*omega)[i] =  (*Xsigma)[i];
    6489     else
    6490       (*omega)[i] = (*Xsigma)[(nV*(nlev-1))+i];
    6491 
    6492     (*omega2)[i] = (*Xtau)[(nlev-1)*nV+i];
    6493   }
    6494 
    6495    if(nlev == 1)  Xcall = 1;
    6496    else Xcall = 0;
    6497 
    6498   ring oRing = currRing;
    6499 
    6500   while(1)
    6501   {
    6502 #ifdef FIRST_STEP_FRACTAL
    6503     // perturb the current weight vector only on the top level or
    6504     // after perturbation of the both vectors, nlev = 2 as the top level
    6505     if((nlev == 1 && Xcall == 0) || (nlev == 2 && Xngleich == 1))
    6506       if(islengthpoly2(G) == 1)
    6507       {
    6508         Mwlp = MivWeightOrderlp(omega);
    6509         Xsigma = Mfpertvector(G, Mwlp);
    6510         delete Mwlp;
    6511         Overflow_Error = FALSE;
    6512       }
    6513 #endif
    6514     nwalks ++;
    6515     NEXT_VECTOR_FRACTAL:
    6516     to=clock();
    6517     /* determine the next border */
    6518     next_vect = MWalkRandomNextWeight(G, omega,omega2, weight_rad, 1+nlev);
    6519     //next_vect = MkInterRedNextWeight(omega,omega2,G);
    6520     xtnw=xtnw+clock()-to;
    6521 #ifdef PRINT_VECTORS
    6522     MivString(omega, omega2, next_vect);
    6523 #endif
    6524     oRing = currRing;
    6525 
    6526     /* We only perturb the current target vector at the recursion  level 1 */
    6527     if(Xngleich == 0 && nlev == 1) //(ngleich == 0) important, e.g. ex2, ex3
    6528       if (MivComp(next_vect, omega2) == 1)
    6529       {
    6530         /* to dispense with taking initial (and lifting/interreducing
    6531            after the call of recursion */
    6532         //Print("\n\n// ** Perturb the both vectors with degree %d with",nlev);
    6533         //idElements(G, "G");
    6534 
    6535         Xngleich = 1;
    6536         nlev +=1;
    6537 
    6538         if (rParameter(currRing) != NULL)
    6539           DefRingPar(omtmp);
    6540         else
    6541           rChangeCurrRing(VMrDefault1(omtmp)); //Aenderung3
    6542 
    6543         testring = currRing;
    6544         Gt = idrMoveR(G, oRing,currRing);
    6545 
    6546         /* perturb the original target vector w.r.t. the current GB */
    6547         delete Xtau;
    6548         Xtau = NewVectorlp(Gt);
    6549 
    6550         rChangeCurrRing(oRing);
    6551         G = idrMoveR(Gt, testring,currRing);
    6552 
    6553         /* perturb the current vector w.r.t. the current GB */
    6554         Mwlp = MivWeightOrderlp(omega);
    6555         Xsigma = Mfpertvector(G, Mwlp);
    6556         delete Mwlp;
    6557 
    6558         for(i=nV-1; i>=0; i--) {
    6559           (*omega2)[i] = (*Xtau)[nV+i];
    6560           (*omega)[i] = (*Xsigma)[nV+i];
    6561         }
    6562 
    6563         delete next_vect;
    6564         to=clock();
    6565 
    6566         /* to avoid the value of Overflow_Error that occur in Mfpertvector*/
    6567         Overflow_Error = FALSE;
    6568 
    6569         next_vect = MkInterRedNextWeight(omega,omega2,G);
    6570         xtnw=xtnw+clock()-to;
    6571 
    6572 #ifdef PRINT_VECTORS
    6573         MivString(omega, omega2, next_vect);
    6574 #endif
    6575       }
    6576 
    6577 
    6578     /* check whether the the computed vector is in the correct cone */
    6579     /* If no, the reduced GB of an omega-homogeneous ideal will be
    6580        computed by Buchberger algorithm and stop this recursion step*/
    6581     //if(test_w_in_ConeCC(G, next_vect) != 1) //e.g. Example s7, cyc6
    6582     if(Overflow_Error == TRUE)
    6583     {
    6584       delete next_vect;
    6585       if (rParameter(currRing) != NULL)
    6586       {
    6587         DefRingPar(omtmp);
    6588       }
    6589       else
    6590       {
    6591         rChangeCurrRing(VMrDefault1(omtmp)); // Aenderung4
    6592       }
    6593 #ifdef TEST_OVERFLOW
    6594       Gt = idrMoveR(G, oRing,currRing);
    6595       Gt = NULL; return(Gt);
    6596 #endif
    6597 
    6598       //Print("\n\n// apply BB's alg. in ring r = %s;", rString(currRing));
    6599       to=clock();
    6600       Gt = idrMoveR(G, oRing,currRing);
    6601       G1 = MstdCC(Gt);
    6602       xtextra=xtextra+clock()-to;
    6603       Gt = NULL;
    6604 
    6605       delete omega2;
    6606       delete altomega;
    6607 
    6608       //Print("\n// Leaving the %d-th recursion with %d steps", nlev, nwalks);
    6609       //Print("  ** Overflow_Error? (%d)", Overflow_Error);
    6610       nnflow ++;
    6611 
    6612       Overflow_Error = FALSE;
    6613       return (G1);
    6614     }
    6615 
    6616 
    6617     /* If the perturbed target vector stays in the correct cone,
    6618        return the current GB,
    6619        otherwise, return the computed  GB by the Buchberger-algorithm.
    6620        Then we update the perturbed target vectors w.r.t. this GB. */
    6621 
    6622     /* the computed vector is equal to the origin vector, since
    6623        t is not defined */
    6624     if (MivComp(next_vect, XivNull) == 1)
    6625     {
    6626       if (rParameter(currRing) != NULL)
    6627         DefRingPar(omtmp);
    6628       else
    6629         rChangeCurrRing(VMrDefault1(omtmp)); //Aenderung5
    6630 
    6631       testring = currRing;
    6632       Gt = idrMoveR(G, oRing,currRing);
    6633 
    6634       if(test_w_in_ConeCC(Gt, omega2) == 1) {
    6635         delete omega2;
    6636         delete next_vect;
    6637         delete altomega;
    6638         //Print("\n// Leaving the %d-th recursion with %d steps ",nlev, nwalks);
    6639         //Print(" ** Overflow_Error? (%d)", Overflow_Error);
    6640 
    6641         return (Gt);
    6642       }
    6643       else
    6644       {
    6645         //ivString(omega2, "tau'");
    6646         //Print("\n//  tau' doesn't stay in the correct cone!!");
    6647 
    6648 #ifndef  MSTDCC_FRACTAL
    6649         //07.08.03
    6650         //ivString(Xtau, "old Xtau");
    6651         intvec* Xtautmp = Mfpertvector(Gt, MivMatrixOrder(omtmp));
    6652 #ifdef TEST_OVERFLOW
    6653       if(Overflow_Error == TRUE)
    6654       Gt = NULL; return(Gt);
    6655 #endif
    6656 
    6657         if(MivSame(Xtau, Xtautmp) == 1)
    6658         {
    6659           //PrintS("\n// Update vectors are equal to the old vectors!!");
    6660           delete Xtautmp;
    6661           goto FRACTAL_MSTDCC;
    6662         }
    6663 
    6664         Xtau = Xtautmp;
    6665         Xtautmp = NULL;
    6666         //ivString(Xtau, "new  Xtau");
    6667 
    6668         for(i=nV-1; i>=0; i--)
    6669           (*omega2)[i] = (*Xtau)[(nlev-1)*nV+i];
    6670 
    6671         //Print("\n//  ring tau = %s;", rString(currRing));
    6672         rChangeCurrRing(oRing);
    6673         G = idrMoveR(Gt, testring,currRing);
    6674 
    6675         goto NEXT_VECTOR_FRACTAL;
    6676 #endif
    6677 
    6678       FRACTAL_MSTDCC:
    6679         //Print("\n//  apply BB-Alg in ring = %s;", rString(currRing));
    6680         to=clock();
    6681         G = MstdCC(Gt);
    6682         xtextra=xtextra+clock()-to;
    6683 
    6684         oRing = currRing;
    6685 
    6686         // update the original target vector w.r.t. the current GB
    6687         if(MivSame(Xivinput, Xivlp) == 1)
    6688           if (rParameter(currRing) != NULL)
    6689             DefRingParlp();
    6690           else
    6691             VMrDefaultlp();
    6692         else
    6693           if (rParameter(currRing) != NULL)
    6694             DefRingPar(Xivinput);
    6695           else
    6696             rChangeCurrRing(VMrDefault1(Xivinput)); //Aenderung6
    6697 
    6698         testring = currRing;
    6699         Gt = idrMoveR(G, oRing,currRing);
    6700 
    6701         delete Xtau;
    6702         Xtau = NewVectorlp(Gt);
    6703 
    6704         rChangeCurrRing(oRing);
    6705         G = idrMoveR(Gt, testring,currRing);
    6706 
    6707         delete omega2;
    6708         delete next_vect;
    6709         delete altomega;
    6710         /*
    6711           Print("\n// Leaving the %d-th recursion with %d steps,", nlev,nwalks);
    6712           Print(" ** Overflow_Error? (%d)", Overflow_Error);
    6713         */
    6714         if(Overflow_Error == TRUE)
    6715           nnflow ++;
    6716 
    6717         Overflow_Error = FALSE;
    6718         return(G);
    6719       }
    6720     }
    6721 
    6722     for(i=nV-1; i>=0; i--) {
    6723       (*altomega)[i] = (*omega)[i];
    6724       (*omega)[i] = (*next_vect)[i];
    6725     }
    6726     delete next_vect;
    6727 
    6728     to=clock();
    6729     /* Take the initial form of <G> w.r.t. omega */
    6730     Gomega = MwalkInitialForm(G, omega);
    6731     xtif=xtif+clock()-to;
    6732 
    6733 #ifndef  BUCHBERGER_ALG
    6734     if(isNolVector(omega) == 0)
    6735       hilb_func = hFirstSeries(Gomega,NULL,NULL,omega,currRing);
    6736     else
    6737       hilb_func = hFirstSeries(Gomega,NULL,NULL,last_omega,currRing);
    6738 #endif // BUCHBERGER_ALG
    6739 
    6740     if (rParameter(currRing) != NULL)
    6741       DefRingPar(omega);
    6742     else
    6743       rChangeCurrRing(VMrDefault1(omega)); //Aenderung7
    6744 
    6745     Gomega1 = idrMoveR(Gomega, oRing,currRing);
    6746 
    6747     /* Maximal recursion depth, to compute a red. GB */
    6748     /* Fractal walk with the alternative recursion */
    6749     /* alternative recursion */
    6750     // if(nlev == nV || lengthpoly(Gomega1) == 0)
    6751     if(nlev == Xnlev || lengthpoly(Gomega1) == 0)
    6752       //if(nlev == nV) // blind recursion
    6753     {
    6754       /*
    6755       if(Xnlev != nV)
    6756       {
    6757         Print("\n// ** Xnlev = %d", Xnlev);
    6758         ivString(Xtau, "Xtau");
    6759       }
    6760       */
    6761       to=clock();
    6762 #ifdef  BUCHBERGER_ALG
    6763       Gresult = MstdhomCC(Gomega1);
    6764 #else
    6765       Gresult =kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,omega);
    6766       delete hilb_func;
    6767 #endif // BUCHBERGER_ALG
    6768       xtstd=xtstd+clock()-to;
    6769     }
    6770     else {
    6771       rChangeCurrRing(oRing);
    6772       Gomega1 = idrMoveR(Gomega1, oRing,currRing);
    6773       Gresult = rec_fractal_call(idCopy(Gomega1),nlev+1,omega);
    6774     }
    6775 
    6776     //convert a Groebner basis from a ring to another ring,
    6777     new_ring = currRing;
    6778 
    6779     rChangeCurrRing(oRing);
    6780     Gresult1 = idrMoveR(Gresult, new_ring,currRing);
    6781     Gomega2 = idrMoveR(Gomega1, new_ring,currRing);
    6782 
    6783     to=clock();
    6784     /* Lifting process */
    6785     F = MLifttwoIdeal(Gomega2, Gresult1, G);
    6786     xtlift=xtlift+clock()-to;
    6787     idDelete(&Gresult1);
    6788     idDelete(&Gomega2);
    6789     idDelete(&G);
    6790 
    6791     rChangeCurrRing(new_ring);
    6792     F1 = idrMoveR(F, oRing,currRing);
    6793 
    6794     to=clock();
    6795     /* Interreduce G */
    6796     G = kInterRedCC(F1, NULL);
    6797     xtred=xtred+clock()-to;
    6798     idDelete(&F1);
    6799   }
    6800 }
    6801 
    6802 
    68038151
    68048152
     
    68078155 *                                                                             *
    68088156 * The main procedur Mfwalk calls the recursive Subroutine                     *
    6809  * rec_fractal_call to compute the wanted Grï¿œbner basis.                       *
    6810  * At the main procedur we compute the reduced Grï¿œbner basis w.r.t. a "fast"   *
     8157 * rec_fractal_call to compute the wanted Groebner basis.                      *
     8158 * At the main procedur we compute the reduced Groebner basis w.r.t. a "fast"  *
    68118159 * order, e.g. "dp" and a sequence of weight vectors which are row vectors     *
    68128160 * of a matrix. This matrix defines the given monomial order, e.g. "lp"        *
    68138161 *******************************************************************************/
    6814 ideal Mfwalk(ideal G, intvec* ivstart, intvec* ivtarget)
     8162ideal Mfwalk(ideal G, intvec* ivstart, intvec* ivtarget,
     8163             int reduction, int printout)
    68158164{
     8165  BITSET save1 = si_opt_1; // save current options
     8166  if(reduction == 0)
     8167  {
     8168    si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis
     8169    //si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions
     8170  }
    68168171  Set_Error(FALSE);
    68178172  Overflow_Error = FALSE;
     
    68228177  Xngleich = 0;
    68238178  Xcall = 0;
     8179#ifdef TIME_TEST
    68248180  xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0; xtextra=0;
    68258181  xftinput = clock();
    6826 
     8182#endif
    68278183  ring  oldRing = currRing;
    68288184  int i, nV = currRing->N;
     
    68308186  Xivinput = ivtarget;
    68318187  ngleich = 0;
     8188#ifdef TIME_TEST
    68328189  to=clock();
     8190#endif
    68338191  ideal I = MstdCC(G);
    68348192  G = NULL;
     8193#ifdef TIME_TEST
    68358194  xftostd=clock()-to;
     8195#endif
    68368196  Xsigma = ivstart;
    68378197
     
    68488208      intvec* iv_dp = MivUnit(nV); // define (1,1,...,1)
    68498209      intvec* Mdp;
    6850 
    6851       if(MivSame(ivstart, iv_dp) != 1)
    6852         Mdp = MivWeightOrderdp(ivstart);
     8210      if(ivstart->length() == nV)
     8211      {
     8212        if(MivSame(ivstart, iv_dp) != 1)
     8213          Mdp = MivWeightOrderdp(ivstart);
     8214        else
     8215          Mdp = MivMatrixOrderdp(nV);
     8216      }
    68538217      else
    6854         Mdp = MivMatrixOrderdp(nV);
     8218      {
     8219        Mdp = ivstart;
     8220      }
    68558221
    68568222      Xsigma = Mfpertvector(I, Mdp);
     
    68698235  Xivlp = Mivlp(nV);
    68708236
    6871   if(MivComp(ivtarget, Xivlp)  != 1)
    6872   {
    6873     if (rParameter(currRing) != NULL)
    6874       DefRingPar(ivtarget);
     8237  if(ivtarget->length() == nV)
     8238  {
     8239    if(MivComp(ivtarget, Xivlp)  != 1)
     8240    {
     8241      if (rParameter(currRing) != NULL)
     8242        DefRingPar(ivtarget);
     8243      else
     8244        rChangeCurrRing(VMrDefault(ivtarget));
     8245
     8246      I1 = idrMoveR(I, oldRing,currRing);
     8247      Mlp = MivWeightOrderlp(ivtarget);
     8248      Xtau = Mfpertvector(I1, Mlp);
     8249    }
    68758250    else
    6876       rChangeCurrRing(VMrDefault1(ivtarget)); //Aenderung1
    6877 
    6878     I1 = idrMoveR(I, oldRing,currRing);
    6879     Mlp = MivWeightOrderlp(ivtarget);
    6880     Xtau = Mfpertvector(I1, Mlp);
     8251    {
     8252      if (rParameter(currRing) != NULL)
     8253        DefRingParlp();
     8254      else
     8255        VMrDefaultlp();
     8256
     8257      I1 = idrMoveR(I, oldRing,currRing);
     8258      Mlp =  MivMatrixOrderlp(nV);
     8259      Xtau = Mfpertvector(I1, Mlp);
     8260    }
    68818261  }
    68828262  else
    68838263  {
    6884     if (rParameter(currRing) != NULL)
    6885       DefRingParlp();
    6886     else
    6887       VMrDefaultlp();
    6888 
    6889     I1 = idrMoveR(I, oldRing,currRing);
    6890     Mlp =  MivMatrixOrderlp(nV);
     8264    rChangeCurrRing(VMatrDefault(ivtarget));
     8265    I1 = idrMoveR(I,oldRing,currRing);
     8266    Mlp =  ivtarget;
    68918267    Xtau = Mfpertvector(I1, Mlp);
    68928268  }
     
    68998275  id_Delete(&I, oldRing);
    69008276  ring tRing = currRing;
    6901 
    6902   if (rParameter(currRing) != NULL)
    6903     DefRingPar(ivstart);
     8277  if(ivtarget->length() == nV)
     8278  {
     8279    if (rParameter(currRing) != NULL)
     8280      DefRingPar(ivstart);
     8281    else
     8282      rChangeCurrRing(VMrDefault(ivstart));
     8283  }
    69048284  else
    6905     rChangeCurrRing(VMrDefault1(ivstart)); //Aenderung2
     8285  {
     8286    rChangeCurrRing(VMatrDefault(ivstart));
     8287  }
    69068288
    69078289  I = idrMoveR(I1,tRing,currRing);
     8290#ifdef TIME_TEST
    69088291  to=clock();
     8292#endif
    69098293  ideal J = MstdCC(I);
    69108294  idDelete(&I);
     8295#ifdef TIME_TEST
    69118296  xftostd=xftostd+clock()-to;
    6912 
     8297#endif
    69138298  ideal resF;
    69148299  ring helpRing = currRing;
    69158300
    6916   J = rec_fractal_call(J, 1, ivtarget);
     8301  J = rec_fractal_call(J,1,ivtarget,reduction,printout);
    69178302
    69188303  rChangeCurrRing(oldRing);
     
    69208305  idSkipZeroes(resF);
    69218306
     8307  si_opt_1 = save1; //set original options, e. g. option(RedSB)
    69228308  delete Xivlp;
    69238309  delete Xsigma;
     
    69388324}
    69398325
    6940 ideal Mfrwalk(ideal G, intvec* ivstart, intvec* ivtarget,int weight_rad)
     8326/*******************************************************************************
     8327 * The implementation of the fractal walk algorithm with random element        *
     8328 *                                                                             *
     8329 * The main procedur Mfwalk calls the recursive Subroutine                     *
     8330 * rec_r_fractal_call to compute the wanted Groebner basis.                    *
     8331 * At the main procedure we compute the reduced Groebner basis w.r.t. a "fast" *
     8332 * order, e.g. "dp" and a sequence of weight vectors which are row vectors     *
     8333 * of a matrix. This matrix defines the given monomial order, e.g. "lp"        *
     8334 *******************************************************************************/
     8335ideal Mfrwalk(ideal G, intvec* ivstart, intvec* ivtarget,
     8336              int weight_rad, int reduction, int printout)
    69418337{
     8338  BITSET save1 = si_opt_1; // save current options
     8339  //check that weight radius is valid
     8340  if(weight_rad < 0)
     8341  {
     8342    Werror("Invalid radius.\n");
     8343    return NULL;
     8344  }
     8345  if(reduction == 0)
     8346  {
     8347    si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis
     8348    si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions
     8349  }
    69428350  Set_Error(FALSE);
    69438351  Overflow_Error = FALSE;
     
    69488356  Xngleich = 0;
    69498357  Xcall = 0;
     8358#ifdef TIME_TEST
    69508359  xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0; xtextra=0;
    69518360  xftinput = clock();
    6952 
     8361#endif
    69538362  ring  oldRing = currRing;
    69548363  int i, nV = currRing->N;
     
    69568365  Xivinput = ivtarget;
    69578366  ngleich = 0;
     8367#ifdef TIME_TEST
    69588368  to=clock();
     8369#endif
    69598370  ideal I = MstdCC(G);
    69608371  G = NULL;
     8372#ifdef TIME_TEST
    69618373  xftostd=clock()-to;
     8374#endif
    69628375  Xsigma = ivstart;
    69638376
     
    69748387      intvec* iv_dp = MivUnit(nV); // define (1,1,...,1)
    69758388      intvec* Mdp;
    6976 
    6977       if(MivSame(ivstart, iv_dp) != 1)
    6978         Mdp = MivWeightOrderdp(ivstart);
     8389      if(ivstart->length() == nV)
     8390      {
     8391        if(MivSame(ivstart, iv_dp) != 1)
     8392          Mdp = MivWeightOrderdp(ivstart);
     8393        else
     8394          Mdp = MivMatrixOrderdp(nV);
     8395      }
    69798396      else
    6980         Mdp = MivMatrixOrderdp(nV);
     8397      {
     8398        Mdp = ivstart;
     8399      }
    69818400
    69828401      Xsigma = Mfpertvector(I, Mdp);
     
    69958414  Xivlp = Mivlp(nV);
    69968415
    6997   if(MivComp(ivtarget, Xivlp)  != 1)
    6998   {
    6999     if (rParameter(currRing) != NULL)
    7000       DefRingPar(ivtarget);
     8416  if(ivtarget->length() == nV)
     8417  {
     8418    if(MivComp(ivtarget, Xivlp)  != 1)
     8419    {
     8420      if (rParameter(currRing) != NULL)
     8421        DefRingPar(ivtarget);
     8422      else
     8423        rChangeCurrRing(VMrDefault(ivtarget));
     8424
     8425      I1 = idrMoveR(I, oldRing,currRing);
     8426      Mlp = MivWeightOrderlp(ivtarget);
     8427      Xtau = Mfpertvector(I1, Mlp);
     8428    }
    70018429    else
    7002       rChangeCurrRing(VMrDefault1(ivtarget)); //Aenderung1
    7003 
    7004     I1 = idrMoveR(I, oldRing,currRing);
    7005     Mlp = MivWeightOrderlp(ivtarget);
    7006     Xtau = Mfpertvector(I1, Mlp);
     8430    {
     8431      if (rParameter(currRing) != NULL)
     8432        DefRingParlp();
     8433      else
     8434        VMrDefaultlp();
     8435
     8436      I1 = idrMoveR(I, oldRing,currRing);
     8437      Mlp =  MivMatrixOrderlp(nV);
     8438      Xtau = Mfpertvector(I1, Mlp);
     8439    }
    70078440  }
    70088441  else
    70098442  {
    7010     if (rParameter(currRing) != NULL)
    7011       DefRingParlp();
    7012     else
    7013       VMrDefaultlp();
    7014 
    7015     I1 = idrMoveR(I, oldRing,currRing);
    7016     Mlp =  MivMatrixOrderlp(nV);
     8443    rChangeCurrRing(VMatrDefault(ivtarget));
     8444    I1 = idrMoveR(I,oldRing,currRing);
     8445    Mlp =  ivtarget;
    70178446    Xtau = Mfpertvector(I1, Mlp);
    70188447  }
     
    70258454  id_Delete(&I, oldRing);
    70268455  ring tRing = currRing;
    7027 
    7028   if (rParameter(currRing) != NULL)
    7029     DefRingPar(ivstart);
     8456  if(ivtarget->length() == nV)
     8457  {
     8458    if (rParameter(currRing) != NULL)
     8459      DefRingPar(ivstart);
     8460    else
     8461      rChangeCurrRing(VMrDefault(ivstart));
     8462  }
    70308463  else
    7031     rChangeCurrRing(VMrDefault1(ivstart)); //Aenderung2
     8464  {
     8465    rChangeCurrRing(VMatrDefault(ivstart));
     8466  }
    70328467
    70338468  I = idrMoveR(I1,tRing,currRing);
     8469#ifdef TIME_TEST
    70348470  to=clock();
     8471#endif
    70358472  ideal J = MstdCC(I);
    70368473  idDelete(&I);
     8474#ifdef TIME_TEST
    70378475  xftostd=xftostd+clock()-to;
    7038 
     8476#endif
    70398477  ideal resF;
    70408478  ring helpRing = currRing;
    7041 //ideal G, int nlev, intvec* omtmp, int weight_rad)
    7042   J = rec_r_fractal_call(J, 1, ivtarget,weight_rad);
     8479
     8480  J = rec_r_fractal_call(J,1,ivtarget,weight_rad,reduction,printout);
    70438481
    70448482  rChangeCurrRing(oldRing);
     
    70468484  idSkipZeroes(resF);
    70478485
     8486  si_opt_1 = save1; //set original options, e. g. option(RedSB)
    70488487  delete Xivlp;
    70498488  delete Xsigma;
     
    71018540  intvec* hilb_func;
    71028541#endif
    7103   /* to avoid (1,0,...,0) as the target vector */
     8542  // to avoid (1,0,...,0) as the target vector
    71048543  intvec* last_omega = new intvec(nV);
    71058544  for(i=nV-1; i>0; i--)
     
    71168555
    71178556  to=clock();
    7118   /* compute a red. GB w.r.t. the help ring */
     8557  // compute a red. GB w.r.t. the help ring
    71198558  if(MivComp(curr_weight, iv_dp) == 1) //rOrdStr(currRing) = "dp"
    71208559    G = MstdCC(G);
     
    71258564      DefRingPar(curr_weight);
    71268565    else
    7127       rChangeCurrRing(VMrDefault(curr_weight)); // Aenderung 4
     8566      rChangeCurrRing(VMrDefault(curr_weight));
    71288567    G = idrMoveR(G, XXRing,currRing);
    71298568    G = MstdCC(G);
     
    71518590      DefRingPar(curr_weight);
    71528591    else
    7153       rChangeCurrRing(VMrDefault(curr_weight)); //Aenderung 5
     8592      rChangeCurrRing(VMrDefault(curr_weight));
    71548593    to=clock();
    71558594    Gw = idrMoveR(G, exring,currRing);
     
    71868625      DefRingPar(curr_weight);
    71878626    else
    7188       rChangeCurrRing(VMrDefault(curr_weight)); //Aenderung 6
     8627      rChangeCurrRing(VMrDefault(curr_weight));
    71898628
    71908629    newRing = currRing;
     
    72568695      goto  BE_FINISH;
    72578696#endif
    7258 
     8697/*
    72598698#ifdef CHECK_IDEAL_MWALK
    72608699      idElements(G, "G");
    72618700      //headidString(G, "G");
    72628701#endif
    7263 
     8702*/
    72648703      if(MivSame(target_tmp, iv_lp) == 1)
    72658704        if (rParameter(currRing) != NULL)
     
    72718710          DefRingPar(target_tmp);
    72728711        else
    7273           rChangeCurrRing(VMrDefault(target_tmp)); // Aenderung 8
     8712          rChangeCurrRing(VMrDefault(target_tmp));
    72748713
    72758714      lpRing = currRing;
     
    73318770          DefRingPar(target_tmp);
    73328771        else
    7333           rChangeCurrRing(VMrDefault(target_tmp)); //Aenderung 9
     8772          rChangeCurrRing(VMrDefault(target_tmp));
    73348773
    73358774      lpRing = currRing;
     
    75348973    else
    75358974    {
    7536       rChangeCurrRing(VMrDefault(curr_weight)); // Aenderung 10
     8975      rChangeCurrRing(VMrDefault(curr_weight));
    75378976    }
    75388977    G = idrMoveR(G, XXRing,currRing);
     
    75679006    else
    75689007    {
    7569       rChangeCurrRing(VMrDefault(curr_weight)); //Aenderung 11
     9008      rChangeCurrRing(VMrDefault(curr_weight));
    75709009    }
    75719010    to=clock();
     
    76109049    else
    76119050    {
    7612       rChangeCurrRing(VMrDefault(curr_weight)); // Aenderung 12
     9051      rChangeCurrRing(VMrDefault(curr_weight));
    76139052    }
    76149053    newRing = currRing;
     
    77799218        else
    77809219        {
    7781           rChangeCurrRing(VMrDefault(target_tmp)); // Aenderung 13
     9220          rChangeCurrRing(VMrDefault(target_tmp));
    77829221        }
    77839222      }
     
    78529291        else
    78539292        {
    7854           rChangeCurrRing(VMrDefault(target_tmp)); // Aenderung 14
     9293          rChangeCurrRing(VMrDefault(target_tmp));
    78559294        }
    78569295      }
     
    79959434  clock_t tinput=clock();
    79969435  int i, nV = currRing->N;
     9436
     9437  //check that perturbation degree is valid
     9438  if(tp_deg < 1 || tp_deg > nV)
     9439  {
     9440    Werror("Invalid perturbation degree.\n");
     9441    return NULL;
     9442  }
     9443
    79979444  int nwalk=0, endwalks=0, ntestwinC=1;
    79989445  int tp_deg_tmp = tp_deg;
     
    80959542    else
    80969543    {
    8097       rChangeCurrRing(VMrDefault(curr_weight)); // Aenderung 15
     9544      rChangeCurrRing(VMrDefault(curr_weight));
    80989545    }
    80999546    newRing = currRing;
     
    81049551    {
    81059552      Print("\n//  it is  %d-th step!!", nwalk);
    8106       idElements(Gomega1, "Gw");
     9553      idString(Gomega1, "Gw");
    81079554      PrintS("\n//  compute a rGB of Gw:");
    81089555    }
     
    82379684
    82389685  //Print("\n// \"Mpwalk\" (1,%d) took %d steps and %.2f sec. Overflow_Error (%d)", tp_deg, nwalk, ((double) clock()-tinput)/1000000, nOverflow_Error);
    8239 
     9686  Print("\n// Mprwalk took %d steps. Ring= %s;\n", nwalk, rString(currRing));
    82409687  return(result);
    8241 }
    8242 
    8243 /*******************************************************
    8244  * THE PERTURBATION WALK ALGORITHM WITH RANDOM ELEMENT *
    8245  *******************************************************/
    8246 ideal Mprwalk(ideal Go, intvec* curr_weight, intvec* target_weight, int weight_rad, int op_deg, int tp_deg, ring baseRing)
    8247 {
    8248   BITSET save1 = si_opt_1; // save current options
    8249   si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis
    8250   Set_Error(FALSE);
    8251   Overflow_Error = FALSE;
    8252 #ifdef TIME_TEST
    8253   clock_t tinput=0, tostd=0, tif=0, tstd=0, tlift=0, tred=0, tnw=0;
    8254   xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0;
    8255   tinput = clock();
    8256   clock_t tim;
    8257 #endif
    8258   int i,nwalk,nV = baseRing->N;
    8259 
    8260   ideal G, Gomega, M, F, Gomega1, Gomega2, M1;
    8261   ring newRing;
    8262   ring XXRing = baseRing;
    8263   intvec* exivlp = Mivlp(nV);
    8264   intvec* orig_target = target_weight;
    8265   intvec* pert_target_vector = target_weight;
    8266   intvec* ivNull = new intvec(nV);
    8267   intvec* tmp_weight = new intvec(nV);
    8268 #ifdef CHECK_IDEAL_MWALK
    8269   poly p;
    8270 #endif
    8271   for(i=0; i<nV; i++)
    8272   {
    8273     (*tmp_weight)[i] = (*curr_weight)[i];
    8274   }
    8275 #ifndef BUCHBERGER_ALG
    8276   intvec* hilb_func;
    8277    // to avoid (1,0,...,0) as the target vector
    8278   intvec* last_omega = new intvec(nV);
    8279   for(i=0 i<nV; i++)
    8280   {
    8281     (*last_omega)[i] = 1;
    8282   }
    8283   (*last_omega)[0] = 10000;
    8284 #endif
    8285   baseRing = currRing;
    8286   newRing = VMrDefault(curr_weight);
    8287   rChangeCurrRing(newRing);
    8288   G = idrMoveR(Go,baseRing,currRing);
    8289 #ifdef TIME_TEST
    8290   to = clock();
    8291 #endif
    8292   G = kStd(G,NULL,testHomog,NULL,NULL,0,0,NULL);
    8293   idSkipZeroes(G);
    8294 #ifdef TIME_TEST
    8295   tostd = tostd + to - clock();
    8296 #endif
    8297 #ifdef CHECK_IDEAL_MWALK
    8298   idString(G,"G");
    8299 #endif
    8300   if(op_deg >1)
    8301   {
    8302     if(MivComp(curr_weight,MivUnit(nV)) == 1) //ring order is "dp"
    8303     {
    8304       curr_weight = MPertVectors(G, MivMatrixOrderdp(nV), op_deg);
    8305     }
    8306     else //ring order is not "dp"
    8307     {
    8308       curr_weight = MPertVectors(G, MivMatrixOrder(curr_weight), op_deg);
    8309     }
    8310   }
    8311   baseRing = currRing;
    8312   if(tp_deg > 1 && tp_deg <= nV)
    8313   {
    8314     pert_target_vector = target_weight;
    8315   }
    8316 #ifdef CHECK_IDEAL_MWALK
    8317   ivString(curr_weight, "new curr_weight");
    8318   ivString(target_weight, "new target_weight");
    8319 #endif
    8320   nwalk = 0;
    8321   while(1)
    8322   {
    8323     nwalk ++;
    8324 #ifdef TIME_TEST
    8325     to = clock();
    8326 #endif
    8327     Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector"
    8328 #ifdef TIME_TEST
    8329     tif = tif + clock()-to; //time for computing initial form ideal
    8330 #endif
    8331 #ifdef CHECK_IDEAL_MWALK
    8332     idString(Gomega,"Gomega");
    8333 #endif
    8334 #ifndef  BUCHBERGER_ALG
    8335     if(isNolVector(curr_weight) == 0)
    8336     {
    8337       hilb_func = hFirstSeries(Gomega,NULL,NULL,curr_weight,currRing);
    8338     }
    8339     else
    8340     {
    8341       hilb_func = hFirstSeries(Gomega,NULL,NULL,last_omega,currRing);
    8342     }
    8343 #endif
    8344     if(nwalk == 1)
    8345     {
    8346       newRing = VMrDefault(curr_weight); // define a new ring with ordering "(a(curr_weight),lp)
    8347     }
    8348     else
    8349     {
    8350       newRing = VMrRefine(curr_weight,target_weight); //define a new ring with ordering "(a(curr_weight),Wp(target_weight))"
    8351     }
    8352     rChangeCurrRing(newRing);
    8353     Gomega1 = idrMoveR(Gomega, baseRing,currRing);
    8354     idDelete(&Gomega);
    8355     // compute a Groebner basis of <Gomega> w.r.t. "newRing"
    8356 #ifdef TIME_TEST
    8357     to = clock();
    8358 #endif
    8359 #ifndef  BUCHBERGER_ALG
    8360     M=kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight);
    8361     delete hilb_func;
    8362 #else
    8363     M = kStd(Gomega1,NULL,testHomog,NULL,NULL,0,0,NULL);
    8364 #endif
    8365     idSkipZeroes(M);
    8366 #ifdef TIME_TEST
    8367     tstd = tstd + clock() - to;
    8368 #endif
    8369 #ifdef CHECK_IDEAL_MWALK
    8370     idString(M, "M");
    8371 #endif
    8372     //change the ring to baseRing
    8373     rChangeCurrRing(baseRing);
    8374     M1 =  idrMoveR(M, newRing,currRing);
    8375     idDelete(&M);
    8376     Gomega2 = idrMoveR(Gomega1, newRing,currRing);
    8377     idDelete(&Gomega1);
    8378     to = clock();
    8379     // compute a representation of the generators of submod (M) with respect to those of mod (Gomega), where Gomega is a reduced Groebner basis w.r.t. the current ring
    8380     F = MLifttwoIdeal(Gomega2, M1, G);
    8381     idSkipZeroes(F);
    8382 #ifdef TIME_TEST
    8383     tlift = tlift + clock() - to;
    8384 #endif
    8385 #ifdef CHECK_IDEAL_MWALK
    8386     idString(F,"F");
    8387 #endif
    8388     rChangeCurrRing(newRing); // change the ring to newRing
    8389     G = idrMoveR(F,baseRing,currRing);
    8390     idDelete(&F);
    8391     baseRing = currRing; // set baseRing equal to newRing
    8392 #ifdef CHECK_IDEAL_MWALK
    8393     idString(G,"G");
    8394 #endif
    8395 #ifdef TIME_TEST
    8396     to = clock();
    8397 #endif
    8398     intvec* next_weight = MWalkRandomNextWeight(G, curr_weight, target_weight, weight_rad, op_deg);
    8399 #ifdef TIME_TEST
    8400     tnw = tnw + clock() - to;
    8401 #endif
    8402 #ifdef PRINT_VECTORS
    8403     MivString(curr_weight, target_weight, next_weight);
    8404 #endif
    8405     if(Overflow_Error == TRUE)
    8406     {
    8407       PrintS("\n//**Mprwalk: OVERFLOW: The computed vector does not stay in cone, the result may be wrong.\n");
    8408       delete next_weight;
    8409       break;
    8410     }
    8411 
    8412     if(test_w_in_ConeCC(G,target_weight) == 1 || MivComp(next_weight, ivNull) == 1)
    8413     {
    8414       delete next_weight;
    8415       break;
    8416     }
    8417     //update tmp_weight and curr_weight
    8418     for(i=nV-1; i>=0; i--)
    8419     {
    8420       (*tmp_weight)[i] = (*curr_weight)[i];
    8421       (*curr_weight)[i] = (*next_weight)[i];
    8422     }
    8423     delete next_weight;
    8424   } //end of while-loop
    8425   Print("\n// Mprwalk took %d steps. Ring= %s;\n", nwalk, rString(currRing));
    8426   idSkipZeroes(G);
    8427   si_opt_1 = save1; //set original options, e. g. option(RedSB)
    8428   baseRing = currRing;
    8429   rChangeCurrRing(XXRing);
    8430   ideal Res = idrMoveR(G,baseRing,currRing);
    8431   delete tmp_weight;
    8432   delete ivNull;
    8433   delete exivlp;
    8434 #ifndef BUCHBERGER_ALG
    8435   delete last_omega;
    8436 #endif
    8437 #ifdef TIME_TEST
    8438   TimeString(tinput, tostd, tif, tstd, tlift, tred, tnw, nstep);
    8439 #endif
    8440   return(Res);
    84419688}
    84429689
     
    85179764        else
    85189765        {
    8519           rChangeCurrRing(VMrDefault(cw_tmp)); // Aenderung 16
     9766          rChangeCurrRing(VMrDefault(cw_tmp));
    85209767        }
    85219768        G = idrMoveR(Go, XXRing,currRing);
     
    85919838    else
    85929839    {
    8593       rChangeCurrRing(VMrDefault(curr_weight)); // Aenderung 17
     9840      rChangeCurrRing(VMrDefault(curr_weight));
    85949841    }
    85959842    newRing = currRing;
     
    86539900      else
    86549901      {
    8655         rChangeCurrRing(VMrDefault(target_weight)); // Aenderung 18
     9902        rChangeCurrRing(VMrDefault(target_weight));
    86569903      }
    86579904      F1 = idrMoveR(G, newRing,currRing);
  • Singular/walk.h

    • Property mode changed from 100644 to 100755
    re3e129 r74fe358  
    5252
    5353/* Okt -- Nov'01 */
    54 // compute a Groebner basis of an ideal G w.r.t. lexicographic order
     54// compute a Groebner basis of an ideal G w.r.t. lexicographic order 
    5555//ideal Mwalk(ideal Go, intvec* orig_M, intvec* target_M);
    56 ideal Mwalk(ideal Go, intvec* orig_M, intvec* target_M, ring baseRing);
     56ideal Mwalk(ideal Go, intvec* orig_M, intvec* target_M, ring baseRing, int reduction, int printout);
    5757
    5858// random walk algorithm to compute a Groebner basis
    59 ideal Mrwalk(ideal Go, intvec* curr_weight, intvec* target_weight, int weight_rad, int pert_deg, ring baseRing);
     59
     60ideal Mrwalk(ideal Go, intvec* orig_M, intvec* target_M, int weight_rad, int pert_deg, int reduction, int printout);
    6061
    6162/* the perturbation walk algorithm */
    6263
    63 ideal Mpwalk(ideal Go, int op_deg, int tp_deg,intvec* curr_weight,intvec* target_weight, int nP);
     64ideal Mpwalk(ideal Go, int op_deg, int tp_deg,intvec* curr_weight,intvec* target_weight, int nP, int reduction, int printout);
    6465
    6566/* the perturbation walk algorithm with random element */
    66 
    67 ideal Mprwalk(ideal Go, intvec* curr_weight, intvec* target_weight, int weight_rad, int op_deg, int tp_deg, ring baseRing);
     67ideal Mprwalk(ideal Go, intvec* orig_M, intvec* target_M, int weight_rad, int op_deg, int tp_deg, int nP, int reduction, int printout);
    6868
    6969/* The fractal walk algorithm */
    70 ideal Mfwalk(ideal G, intvec* ivstart, intvec* ivtarget);
     70ideal Mfwalk(ideal G, intvec* ivstart, intvec* ivtarget, int reduction, int printout);
    7171
    7272/* The fractal walk algorithm with random element */
    73 ideal Mfrwalk(ideal G, intvec* ivstart, intvec* ivtarget,int weight_rad);
     73ideal Mfrwalk(ideal G, intvec* ivstart, intvec* ivtarget, int weight_rad, int reduction, int printout);
    7474
    7575/* Implement Tran's idea */
  • Tst/Plural/derham.res.gz.uu

    r654a23 r74fe358  
    11begin 640 derham.res.gz
    2 M'XL("(/O0%4``V1E<FAA;2YR97,`I=?=;MHP%`#@^SR%A781(-#XWRD":>MZ
    3 M48E5TSI5D]#4IDIHHU%2)51+>/HE#;%-FJ:IQPWFV([QIW.PN?KY]>(2```7
    4 M8'GQ!0QVZ6ZZB>X&,U"T;J)MM+.'A_;]-DY">W!R`D8CL(G](`S`H+7S!D0I
    5 MV,8@W?G;P$\"<.>G45J,M<H'@L4"!&'RX#].M^'?:3%H9Q7SU&-.P=$:[9WM
    6 M:UA7A_V@PWZ"\$>YT,N6K&IF$@;ANO@BVWMPF_KK\-I/+OW'\+;HD]/Q`L@V
    7 MF19+3GJ^Y"Q:SCK_]?G;]^4Y@#+,C![&IR`IOV\R=QT[<_*A$SS-9*]8@*=X
    8 MDX/U/$>3#$]0-L:JUUN`393NP')>69S%#_%CO(GO<WL]E,.@6X#-K!7\?6J5
    9 MZ6"MD&SAJH7DV")9_D2;#4B<<DX=1<H,8I-M0J*;J>6HT<-8EQGD#;-,=8E^
    10 M8%Y_,.2V@2&HP!`RV2/".AB68:.,1;0+#+&#RMF\?+,S-('%J#$<CG(G']DY
    11 M&J/RDP)"_&W',VV8>,/1E8Y%BU0M8JUH':OG>VVVV%6V&)IP8*3;$ADVRFQ,
    12 M&K;._D@7TX;NR,XF<%B.&]G[LK6O(LH-LUZ\F'^`U]5X5ZQJ86O%&^18M))[
    13 MBIRX)DH$ZN14AHUJ@^!N<D*:Y&4>[Y4<H1W`SN`Z2,*7(ZT>SM[]/5#04$++
    14 MDX'P-E0B-%3/Q(&Z.BJ38:.BH.@5JO-\Q$IQ@_4P1@T@O?*6TO_,6U?+VY5H
    15 M8%/6ADVYPJ;"R,?3L7D=9D;EP&!W!C,DS[`,CW,\WJM3G^%>AQ@C/0ZQ6ED>
    16 M9XRVZ3&F]!@WVK#0]80,&^4]=[OU.%1Z:%P<7WND^E"'WNO2Y_@#I2]_13EI
    17 M4^14*7*CRR+GNJ(GPT8)S;WW"EZXS8M!A:G7O("]:EZ@#]0\;*WY^DFXS580
    18 M92N*VXYL&SF+(V>HUC:"%J^ACYB]!G-Y1<A?K@CHZ%K@]:/VWJ+N/JWD)KU6
    19 <8$\#]@K@\E];^??N.;7A</;)^@?Q'F.9;0X`````
     2M'XL("`)WP%4``V1E<FAA;2YR97,`I==;;]HP%`#@]_P*"^TA0*#QW6X%TM;U
     3MH1*;IG6:)J&IH@IMHZ6D2JB6\.L7%V*;-$U3CY<>CB^I/XZQN?KQ^?(K``#.
     4MP>+R$QAL\^TTB6\&9Z"*KN--O/6'A_ANDV9K?W!R`D8CD*2K:!V!06OC-8AS
     5ML$E!OEUMHE46@9M5'N=57T]-".9S$*VS^]7#=+/^.ZTZ;;UJG)GF%!P]H[VQ
     6M_1G>U6$]Z+">:/U=/>AY2;H1SX&.R;2:<-+SI4=1->KBU\<OWQ87`.HT<YJ,
     7M3T$6;^Y`-@L#OPC*81`]FG]6S,%CFI3@=E:B28$GJ!ACTRKG((GS+5C,]BL]
     8M3^_3AS1)[TK_=JB[P;#B./.6\/>IISYL;XETA/<1TGVK4O@3)PG(`C6FSB)C
     9M!K'+,B&QS<SCJ--DK,L,\H9989I$/S#9'PR%;6`(&C"$7-:(L`V&==JI8A'M
     10M`D/LH'(^4W_\`DU@U6L,AZ,R*$=^B<9(O3-`B+_N>&YU$Z\XAMJQBL@^(MZ2
     11MUKEZO&RSQ:&QQ="%`R/;ENBT4V5CTK`-=D>ZF#9T1WXQ@4/5;^3O5+3;9XP;
     12M9KUX,7\';VCQ+MD^PMZ2-\BQ:"67AIR$+DH$VN14IYWV!L'=Y(0TR54=[XP<
     13MH1W`P>!GE*V?#ZRZ.WOS^\!`0PVM3P;"VU")L%"EBP,-;52FTTZ;@J(7J,'3
     14M$2O%#=9#'].!]*I;2O^S;D.K;I>B@4U9&S;E!IL*)Q]I8_,ZS9RV`X/=%<R0
     15M/L,*/"[Q>&=.?89['6*,]#C$:F5]G#':IL>8T6/<:<'"UA,Z[53W/.S6X]#H
     16MH7%U?.V0:4,=>B^W/L?OV/KZ6Y23-D5.C2)WNBQR;BM*G78J:"[?VO`B;%X,
     17M]ICVGA>PUYX7Z!U['K;N^7HFW&8KB+$5U6U'QT[.XL@9FF<[08N7T$?,LL&L
     18MK@CE\Q4!'5T+9#]J^1IU]VFE%RE;@:4%+"M@]9M,_7A[RGTX//O@_0-O58,G
     19$2PX`````
    2020`
    2121end
  • Tst/Short/alias.res.gz.uu

    r654a23 r74fe358  
    11begin 640 alias.res.gz
    2 M'XL(""2@A4\``V%L:6%S+G)E<P#M4\MNPC`0O.<K5E4/21N9V.%5(G)`O2!5
    3 MO=`;JE`H`1E9`=EN2XOX]ZX=<'P(53^@.22V=W9V=C.>O3Q.GP&`YO`TG<"-
    4 M5IH(OKS)@MDYPG+`PP6ON`ZC+#!?R',H!"\4J<I/HG2A'3K-P:V[!/9R]V9>
    5 MRS*T"2"XTE#(C8H<K$?@Z#9]8J--^2$!_;4O=^O09KD`30CP2@.',2C^7=KP
    6 MG+YZ"$;@Y#:>,(K")*\V(#$WB>$0PVK?I/5RX*NR$);ZT)SW\UJ]P&.S"'D,
    7 MS"LW\"H,R;EK@0!4-0JPE04NQH=@SNHM"PR+2WEHTEGB3X[YH^,1'(%G<')U
    8 M&?42L64+JU`C;2#8_)FJ\O10%^]Z%#V_=GJN;2==ES;\'X5$+_@B^A[#H/XS
    9 MVS%KXL/\0KA%!2SH='"\+0]J@]I;!K)MA20(,04L2W458H3&UALC;!6A\BKT
    10 MSMC!0.PC_D3)'+Z]$:O2^BB<3:(8*&S*JI2%WLD0W8_)YEJ9R_.N%FLN2B]/
    11 M:>O/]CO&/*>D";G,E=X;,Z:_3]:,+?V?[)7)IMY52O$J-30AC;+;X`<31!RO
    12 $+04`````
     2M'XL("`?2S54``V%L:6%S+G)E<P#M4SUOPC`0W?,K3JA#TD8F=O@J$1E0%Z2J
     3M"]U0A4()R%&4(,=M:1'_O6<G.!Y0H4.W9@#;=^_=NZ_Y\\/L"0!H#(^S*71D
     4M)4G.5YW(F3<6%@,^+GG!I>M%COJ'.(8DYTE%BO2#5#*1QCN,P9Q[!':B?%4_
     5MJ]35`,AY)2$1V\HS;GT"!W,9$&UMPX\(R,]=6FY<C3(&&A#@A00.$ZCX5ZK-
     6M"_IB>3`"1W.QA%$4)GBQ!8'8P(>]#^M="^O'P-=IDFOJ??L^B&OU.3ZK@\M]
     7M8%:XH15A1)JL<W1`56,'4UGB8;)W%JR^,D>Q&,A]"V>!73EFEXY[<``>P='$
     8M9=0"8LK:K4"-M'7!Y!NJPM)#C;UG4?3MV&$36U>Z#JWXWQ.!LV"+&%@,P[HS
     9MV82U]E%\(LQ0`7.Z72SOCQ^JA'K*8%,*R!0DNP`)$*)":_[B"F>5C*_G9XSE
     10M0)"X`G2KAD<YZR__91AFD)<*H+/1D^C.IYX/%+9ID8I$EL+%_4$:M9AJ_=ZJ
     11MY8;GZ5F&2NI9/[^OS)JZ,""G'M$[-=CAM5U2)0__^_,'_0FMY0YQN5M"EWK1
     12+C?,-2!0&\[\%````
    1313`
    1414end
  • Tst/Short/ok_s.lst

    r654a23 r74fe358  
    4646bug_tr723
    4747bug_tr724
     48bug_732
     49bug_tr735
    4850bug_genus_etc
    4951conv_bi
  • doc/Singular.man

    r654a23 r74fe358  
    4848.TP
    4949\fB\-\-allow\-net\fR
    50 Allow to fetch (html) help pages from the net
     50Allow one to fetch (html) help pages from the net
    5151.TP
    5252\fB\-\-browser\fR=\fIBROWSER\fR
  • kernel/ideals.cc

    r654a23 r74fe358  
    928928    }
    929929  }
     930  s_temp->rank += k;
    930931}
    931932
     
    10241025      }
    10251026    }
     1027    s_temp->rank += k;
    10261028  }
    10271029  ideal s_result = kNF(s_h3,currRing->qideal,s_temp,k);
  • libpolys/polys/monomials/p_polys.cc

    r654a23 r74fe358  
    116116    {
    117117      hh=xx[j];
    118       if ((hh!=NULL) && (p_LmCmp(r,hh,R)==0))
     118      if ((hh!=NULL) && (p_LmCmp(h,hh,R)==0))
    119119      {
    120120        x[j]=pGetCoeff(hh);
  • libpolys/polys/simpleideals.cc

    r654a23 r74fe358  
    17211721ideal id_ChineseRemainder(ideal *xx, number *q, int rl, const ring r)
    17221722{
    1723   int cnt=IDELEMS(xx[0])*xx[0]->nrows;
     1723  int cnt=0;int rw=0; int cl=0;
     1724  int i,j;
     1725  // find max. size of xx[.]:
     1726  for(j=rl-1;j>=0;j--)
     1727  {
     1728    i=IDELEMS(xx[j])*xx[j]->nrows;
     1729    if (i>cnt) cnt=i;
     1730    if (xx[j]->nrows >rw) rw=xx[j]->nrows; // for lifting matrices
     1731    if (xx[j]->ncols >cl) cl=xx[j]->ncols; // for lifting matrices
     1732  }
     1733  if (rw*cl !=cnt)
     1734  {
     1735    WerrorS("format mismatch in CRT");
     1736    return NULL;
     1737  }
    17241738  ideal result=idInit(cnt,xx[0]->rank);
    1725   result->nrows=xx[0]->nrows; // for lifting matrices
    1726   result->ncols=xx[0]->ncols; // for lifting matrices
    1727   int i,j;
     1739  result->nrows=rw; // for lifting matrices
     1740  result->ncols=cl; // for lifting matrices
    17281741  number *x=(number *)omAlloc(rl*sizeof(number));
    17291742  poly *p=(poly *)omAlloc(rl*sizeof(poly));
    1730   CFArray inv_cache(rl);;
     1743  CFArray inv_cache(rl);
    17311744  for(i=cnt-1;i>=0;i--)
    17321745  {
    17331746    for(j=rl-1;j>=0;j--)
    17341747    {
    1735       p[j]=xx[j]->m[i];
     1748      if(i>=IDELEMS(xx[j])*xx[j]->nrows) // out of range of this ideal
     1749        p[j]=NULL;
     1750      else
     1751        p[j]=xx[j]->m[i];
    17361752    }
    17371753    result->m[i]=p_ChineseRemainder(p,x,q,rl,inv_cache,r);
    17381754    for(j=rl-1;j>=0;j--)
    17391755    {
    1740       xx[j]->m[i]=p[j];
     1756      if(i<IDELEMS(xx[j])*xx[j]->nrows) xx[j]->m[i]=p[j];
    17411757    }
    17421758  }
  • omalloc/omAllocFunc.h

    r654a23 r74fe358  
    1212void omFreeFunc(void* addr);
    1313void* omVallocFunc(size_t size);
    14 #if defined(sgi)
    1514void* omMemalignFunc(size_t size_1, size_t size_2);
    16 #else
    17 #if (defined(__sun) && (defined(__sparc) || defined(__i386) || defined(__x86_64)) || defined(__CYGWIN__))
    18 extern void* omMemalignFunc(size_t, size_t);
    19 #else
    20 void* omMemalignFunc(void* alignment, size_t size);
    21 #endif
    22 #endif
    2315void* omReallocFunc(void* old_addr, size_t new_size);
    2416char* omStrdupFunc(const char* addr);
  • omalloc/omalloc.c

    r654a23 r74fe358  
    4747}
    4848
    49 #if defined(sgi)
    5049void* memalign(size_t size_1, size_t size_2)
    51 #elif (defined(__sun) && (defined(__sparc) || defined(__i386) || defined(__x86_64)) || defined(__CYGWIN__))
    52 void* memalign(size_t size_1, size_t size_2)
    53 #else
    54 void* memalign(void* alignment, size_t size)
    55 #endif
    5650{
    5751  fprintf(stderr, "omalloc Warning: memalign not yet implemented\n");
Note: See TracChangeset for help on using the changeset viewer.