Changeset 565e866 in git for Singular/LIB/bfct.lib


Ignore:
Timestamp:
Dec 23, 2008, 10:39:31 PM (15 years ago)
Author:
Viktor Levandovskyy <levandov@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
199ae72040d35b09813089e33464df761b5aad78
Parents:
6045c31371ebacbf1acfc2f082225f05016f06b2
Message:
*levandov: numerous changes, docu fixes, exchange of procs between libs etc


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

Legend:

Unmodified
Added
Removed
  • Singular/LIB/bfct.lib

    r6045c3 r565e866  
    11//////////////////////////////////////////////////////////////////////////////
    2 version="$Id: bfct.lib,v 1.7 2008-12-09 16:50:21 levandov Exp $";
     2version="$Id: bfct.lib,v 1.8 2008-12-23 21:39:31 levandov Exp $";
    33category="Noncommutative";
    44info="
    5 LIBRARY: bfct.lib     M. Noro's Algorithm for Bernstein-Sato polynomial
     5LIBRARY: bfct.lib     Algorithms for b-functions and Bernstein-Sato polynomial
    66AUTHORS: Daniel Andres, daniel.andres@math.rwth-aachen.de
    77@* Viktor Levandovskyy,      levandov@math.rwth-aachen.de
    88
    99THEORY: Given a polynomial ring R = K[x_1,...,x_n] and a polynomial F in R,
    10 @*      one is interested in the global Bernstein-Sato polynomial b(s) in K[s],
    11 @*      defined to be the monic polynomial, satisfying a functional identity
    12 @*             L * f^{s+1} = b(s) f^s,   for some operator L in D[s].
    13 @* Here, D stands for an n-th Weyl algebra K<x_1,...,x_n,d_1,...,d_n | d_j x_j = x_j d_j +1>
    14 @* One is interested in the following data:
    15 @*   global Bernstein-Sato polynomial in K[s] and
    16 @*   the list of all roots of b(s), which are known to be rational, with their multiplicities.
     10@*      one is interested in the global b-Function (also known as Bernstein-Sato
     11@*      polynomial) b(s) in K[s], defined to be the monic polynomial, satisfying a functional
     12@*      identity L * F^{s+1} = b(s) F^s,   for some operator L in D[s]. Here, D stands for an
     13@*      n-th Weyl algebra K<x_1,...,x_n,d_1,...,d_n | d_j x_j = x_j d_j +1>.
     14@*      One is interested in the following data:
     15@*      - Bernstein-Sato polynomial b(s) in K[s],
     16@*      - the list of its roots, which are known to be rational
     17@*      - the multiplicities of the roots.
     18@*      References: Saito, Strurmfels, Takayama: Groebner Deformations of Hypergeometric
     19@*      Differential Equations (2000), Noro: An Efficient Modular Algorithm for Computing
     20@*      the Global b-function, (2002).
     21
    1722
    1823MAIN PROCEDURES:
    1924
    20 bfct(f[,s,t,v]);            compute the global Bernstein-Sato polynomial of a given poly
    21 bfctsyz(f[,r,s,t,u,v]);     compute the global Bernstein-Sato polynomial of a given poly
    22 bfctann(f[,s]);             compute the global Bernstein-Sato polynomial of a given poly
    23 bfctonestep(f[,s,t]);       compute the global Bernstein-Sato polynomial of a given poly
    24 bfctideal(I,w[,s,t]);       compute the global b-function of a given ideal w.r.t. a given weight
    25 pintersect(f,I);            compute the intersection of the ideal generated by a given poly with a given ideal
    26 pintersectsyz(f,I[,p,s,t]); compute the intersection of the ideal generated by a given poly with a given ideal
    27 linreduce(f,I[,s]);         reduce a poly by linear reductions only
    28 ncsolve(I[,s]);             find and compute a linear dependency of the elements of an ideal
     25bfct(f[,s,t,v]);            computes the Bernstein-Sato polynomial of poly f
     26bfctSyz(f[,r,s,t,u,v]);     computes the Bernstein-Sato polynomial of poly f
     27bfctAnn(f[,s]);             computes the Bernstein-Sato polynomial of poly f
     28bfctOneGB(f[,s,t]);         computes the Bernstein-Sato polynomial of poly f
     29bfctIdeal(I,w[,s,t]);       computes the global b-function of ideal I w.r.t. the weight w
     30pIntersect(f,I);            intersection of the ideal I with the subalgebra K[f] for a poly f
     31pIntersectSyz(f,I[,p,s,t]);  intersection of the ideal I with the subalgebra K[f] for a poly f
     32linReduce(f,I[,s]);         reduces a poly by linear reductions only
     33linSyzSolve(I[,s]);         computes a linear dependency of the elements of ideal I
    2934
    3035AUXILIARY PROCEDURES:
    3136
    32 ispositive(v);   check whether all entries of an intvec are positive
    33 isin(l,i);       check whether an element is a member of a list
    34 scalarprod(v,w); compute the standard scalar product of two intvecs
    35 vec2poly(v[,i]); convert a coefficient vector to a poly
     37allPositive(v);  checks whether all entries of an intvec are positive
     38scalarProd(v,w); computes the standard scalar product of two intvecs
     39vec2poly(v[,i]); constructs an univariate poly with given coefficients
    3640
    3741SEE ALSO: dmod_lib, dmodapp_lib, gmssing_lib
     
    4044
    4145LIB "qhmoduli.lib"; // for Max
    42 LIB "dmod.lib"; // for SannfsBFCT etc
    43 LIB "dmodapp.lib";  // for initialideal etc
    44 
    45 
     46LIB "dmod.lib";     // for SannfsBFCT etc
     47LIB "dmodapp.lib";  // for initialIdeal etc
     48
     49
     50///////////////////////////////////////////////////////////////////////////////
     51// testing for consistency of the library:
    4652proc testbfctlib ()
    4753{
    4854  // tests all procs for consistency
    4955  "AUXILIARY PROCEDURES:";
    50   example ispositive;
    51   example isin;
    52   example scalarprod;
     56  example allPositive;
     57  example scalarProd;
    5358  example vec2poly;
    5459  "MAIN PROCEDURES:";
    5560  example bfct;
    56   example bfctsyz;
    57   example bfctann;
    58   example bfctonestep;
    59   example bfctideal;
    60   example pintersect;
    61   example pintersectsyz;
    62   example linreduce;
    63   example ncsolve;
    64 }
    65 
     61  example bfctSyz;
     62  example bfctAnn;
     63  example bfctOneGB;
     64  example bfctIdeal;
     65  example pIntersect;
     66  example pIntersectSyz;
     67  example linReduce;
     68  example linReduceIdeal;
     69  example linSyzSolve;
     70}
    6671
    6772//--------------- auxiliary procedures ---------------------------------------------------------
     
    7176RETURN:  a ring, the associated graded ring of the basering w.r.t. u and v
    7277PURPOSE: compute the associated graded ring of the basering w.r.t. u and v
     78ASSUME: basering is a Weyl algebra
    7379EXAMPLE: example gradedWeyl; shows examples
    7480NOTE:    u[i] is the weight of x(i), v[i] the weight of D(i).
     
    122128{
    123129  "EXAMPLE:"; echo = 2;
    124   LIB "bfct.lib";
    125130  ring @D = 0,(x,y,z,Dx,Dy,Dz),dp;
    126131  def D = Weyl();
     
    132137
    133138
    134 proc ispositive (intvec v)
    135 "USAGE:  ispositive(v);  v an intvec
    136 RETURN:  1 if all components of v are positive, or 0 otherwise
     139proc allPositive (intvec v)
     140"USAGE:  allPositive(v);  v an intvec
     141RETURN:  int, 1 if all components of v are positive, or 0 otherwise
    137142PURPOSE: check whether all components of an intvec are positive
    138 EXAMPLE: example ispositive; shows an example
     143EXAMPLE: example allPositive; shows an example
    139144"
    140145{
     
    154159  "EXAMPLE:"; echo = 2;
    155160  intvec v = 1,2,3;
    156   ispositive(v);
     161  allPositive(v);
    157162  intvec w = 1,-2,3;
    158   ispositive(w);
    159 }
    160 
    161 proc isin (list l, i)
    162 "USAGE:  isin(l,i);  l a list, i an argument of any type
    163 RETURN:  an int, the position of the first appearance of i in l, or 0 if i is not a member of l
     163  allPositive(w);
     164}
     165
     166static proc findFirst (list l, i)
     167"USAGE:  findFirst(l,i);  l a list, i an argument of any type
     168RETURN:  int, the position of the first appearance of i in l, or 0 if i is not a member of l
    164169PURPOSE: check whether the second argument is a member of a list
    165 EXAMPLE: example isin; shows an example
     170EXAMPLE: example findFirst; shows an example
    166171"
    167172{
     
    177182  return(0);
    178183}
     184//   isin(list(1, 2, list(1)),2);       // seems to be a bit buggy,
     185//   isin(list(1, 2, list(1)),3);       // but works for the purposes
     186//   isin(list(1, 2, list(1)),list(1)); // of this library
     187//   isin(l,list(2));
    179188example
    180189{
     
    182191  ring r = 0,x,dp;
    183192  list l = 1,2,3;
    184   isin(l,4);
    185   isin(l,2);
    186 }
    187 
    188 proc scalarprod (intvec v, intvec w)
    189 "USAGE:  scalarprod(v,w);  v,w intvecs
    190 RETURN:  an int, the standard scalar product of v and w
    191 PURPOSE: compute the scalar product of two intvecs
    192 NOTE:    the arguments must have the same size
    193 EXAMPLE: example scalarprod; shows examples
     193  findFirst(l,4);
     194  findFirst(l,2);
     195}
     196
     197proc scalarProd (intvec v, intvec w)
     198"USAGE:  scalarProd(v,w);  v,w intvecs
     199RETURN:  int, the standard scalar product of v and w
     200PURPOSE: computes the scalar product of two intvecs
     201ASSUME:  the arguments are of the same size
     202EXAMPLE: example scalarProd; shows examples
    194203"
    195204{
     
    213222  intvec v = 1,2,3;
    214223  intvec w = 4,5,6;
    215   scalarprod(v,w);
    216 }
    217 
     224  scalarProd(v,w);
     225}
    218226
    219227//-------------- main procedures -------------------------------------------------------
    220228
    221 
    222 proc linreduce(poly f, ideal I, list #)
    223 "USAGE:  linreduce(f, I [,s,t]);  f a poly, I an ideal, s,t optional ints
    224 RETURN:  a poly obtained by linear reductions of the given poly with the given ideal
    225 PURPOSE: reduce a poly only by linear reductions
    226 NOTE:    If s<>0, a list consisting of the reduced poly and the coefficient vector of the used
    227 @*       reductions is returned.
    228 @*       If t<>0, only leading monomials are reduced, otherwise, and by default, all monomials
    229 @*       are reduced, if possible.
    230 EXAMPLE: example linreduce; shows examples
     229proc linReduceIdeal(ideal I, list #)
     230"USAGE:  linReduceIdeal(I [,s,t]); I an ideal, s,t optional ints
     231RETURN:  ideal/list, linear reductum (over field) of f by elements from I
     232PURPOSE: reduce a poly only by linear reductions (no monomial multiplications)
     233NOTE:    If s<>0, a list consisting of the reduced ideal and the coefficient
     234@*       vectors of the used reductions given as module is returned.
     235@*       Otherwise (and by default), only the reduced ideal is returned.
     236@*       If t=0 (and by default) all monomials are reduced (if possible),
     237@*       otherwise, only leading monomials are reduced.
     238DISPLAY: If @code{printlevel}>=1, all debug messages will be printed.
     239EXAMPLE: example linReduceIdeal; shows examples
    231240"
    232241{
     242  // #[1] = remembercoeffs
     243  // #[2] = redtail
    233244  int ppl = printlevel - voice + 2;
    234245  int remembercoeffs = 0; // default
    235   int redlm          = 0; // default
     246  int redtail        = 0; // default
    236247  if (size(#)>0)
    237248  {
     
    244255      if (typeof(#[2])=="int" || typeof(#[2])=="number")
    245256      {
    246         redlm = #[2];
     257        redtail = #[2];
     258      }
     259    }
     260  }
     261  int sI = ncols(I);
     262  int sZeros = sI - size(I);
     263  dbprint(ppl,"ideal contains "+string(sZeros)+" zero(s)");
     264  int i,j;
     265  ideal J,lmJ,ordJ;
     266  list lJ = sort(I);
     267  module M; // for the coefficients
     268  if (sZeros > 0) // I contains zeros
     269  {
     270    if (remembercoeffs <> 0)
     271    {
     272      j = 0;
     273      for (i=1; i<=sI; i++)
     274      {
     275        if (I[i] == 0)
     276        {
     277          j++;
     278          J[j] = 0;
     279          ordJ[j] = -1;
     280          M[j] = gen(i);
     281        }
     282        else
     283        {
     284          M[i+sZeros-j] = gen(lJ[2][i-j]+j);
     285        }
     286      }
     287    }
     288    else
     289    {
     290      for (i=1; i<=sZeros; i++)
     291      {
     292        J[i] = 0;
     293        ordJ[i] = -1;
     294      }
     295    }
     296    I = J,lJ[1];
     297  }
     298  else
     299  {
     300    I = lJ[1];
     301    if (remembercoeffs <> 0)
     302    {
     303      for (i=1; i<=size(lJ[1]); i++) { M[i+sZeros] = gen(lJ[2][i]); }
     304    }
     305  }
     306  dbprint(ppl,"initially sorted ideal:", I);
     307  if (remembercoeffs <> 0) { dbprint(ppl," used permutations:", M); }
     308  poly lm,c,redpoly,maxlmJ;
     309  J[sZeros+1] = I[sZeros+1];
     310  lm = I[sZeros+1];
     311  maxlmJ = leadmonom(lm);
     312  lmJ[sZeros+1] = maxlmJ;
     313  int ordlm,reduction,maxordJ;
     314  maxordJ = ord(lm);
     315  ordJ[sZeros+1] = maxordJ;
     316  vector v;
     317  for (i=sZeros+2; i<=sI; i++)
     318  {
     319    redpoly = I[i];
     320    lm = leadmonom(redpoly);
     321    ordlm = ord(lm);
     322    reduction = 1;
     323    if (remembercoeffs <> 0) { v = M[i]; }
     324    while (reduction == 1) // while there was a reduction
     325    {
     326      reduction = 0;
     327      for (j=sZeros+1; j<i; j++)
     328      {
     329        if (lm == 0) { break; }
     330        if (ordlm > maxordJ) { break; }
     331        if (ordlm == ordJ[j])
     332        {           
     333          if (lm > maxlmJ) { break; }
     334          if (lm == lmJ[j])
     335          {
     336            dbprint(ppl,"reducing " + string(redpoly));
     337            dbprint(ppl," with " + string(J[j]));
     338            c = leadcoef(redpoly)/leadcoef(J[j]);
     339            redpoly = redpoly - c*J[j];
     340            dbprint(ppl," to " + string(redpoly));
     341            lm = leadmonom(redpoly);
     342            ordlm = ord(lm);
     343            if (remembercoeffs <> 0) { M[i] = M[i] - c * M[j]; }
     344            reduction = 1;
     345          }
     346        }
     347      }
     348    }
     349    for (j=sZeros+1; j<i; j++)
     350    {
     351      if (redpoly < J[j]) { break; }
     352    }
     353    J = insertGenerator(J,redpoly,j);
     354    lmJ = insertGenerator(lmJ,lm,j);
     355    ordJ = insertGenerator(ordJ,poly(ordlm),j);
     356    if (remembercoeffs <> 0)
     357    {
     358      v = M[i];
     359      M = deleteGenerator(M,i);
     360      M = insertGenerator(M,v,j);
     361    }
     362    maxordJ = ord(J[i]);
     363    maxlmJ = lmJ[i];
     364  }
     365  if (redtail <> 0)
     366  {
     367    dbprint(ppl,"finished reducing leading monomials:",J);
     368    if (remembercoeffs <> 0) { dbprint(ppl,"used reductions:",M); }
     369    int k;
     370    for (i=sZeros+1; i<=sI; i++)
     371    {
     372      lm = lmJ[i];
     373      for (j=i+1; j<=sI; j++)
     374      {
     375        for (k=2; k<=size(J[j]); k++) // run over all terms in J[j]
     376        {
     377          if (ordJ[i] == ord(J[j][k]))
     378          {   
     379            if (lm == normalize(J[j][k]))
     380            {
     381              c = leadcoef(J[j][k])/leadcoef(J[i]);
     382              dbprint(ppl,"reducing " + string(J[j]));
     383              dbprint(ppl," with " + string(J[i]));
     384              J[j] = J[j] - c*J[i];
     385              dbprint(ppl," to " + string(J[j]));
     386              if (remembercoeffs <> 0) { M[j] = M[j] - c * M[i]; }
     387            }
     388          }
     389        }
     390      }
     391    }
     392  }
     393  if (remembercoeffs <> 0) { return(list(J,M)); }
     394  else { return(J); }
     395}
     396example
     397{
     398  "EXAMPLE:"; echo = 2;
     399  ring r = 0,(x,y),dp;
     400  ideal I = 3,x+9,y4,y4+7x+2;
     401  linReduceIdeal(I);
     402  linReduceIdeal(I,0,1);
     403  list l = linReduceIdeal(I,1,1); l;
     404  module M = I;
     405  l[1] - ideal(M*l[2]);
     406}
     407
     408proc linReduce(poly f, ideal I, list #)
     409"USAGE:  linReduce(f, I [,s,t]); f a poly, I an ideal, s,t optional ints
     410RETURN:  poly/list, linear reductum (over field) of f by elements from I
     411PURPOSE: reduce a poly only by linear reductions (no monomial multiplications)
     412NOTE:    If s<>0, a list consisting of the reduced poly and the coefficient
     413@*       vector of the used reductions is returned, otherwise (and by default)
     414@*       only reduced poly is returned.
     415@*       If t=0 (and by default) all monomials are reduced (if possible),
     416@*       otherwise, only leading monomials are reduced.
     417DISPLAY: If @code{printlevel}>=1, all debug messages will be printed.
     418EXAMPLE: example linReduce; shows examples
     419"
     420{
     421  int ppl = printlevel - voice + 2;
     422  int remembercoeffs = 0; // default
     423  int redtail        = 0; // default
     424  int prepareideal   = 1; // default
     425  if (size(#)>0)
     426  {
     427    if (typeof(#[1])=="int" || typeof(#[1])=="number")
     428    {
     429      remembercoeffs = #[1];
     430    }
     431    if (size(#)>1)
     432    {
     433      if (typeof(#[2])=="int" || typeof(#[2])=="number")
     434      {
     435        redtail = #[2];
     436      }
     437      if (size(#)>2)
     438      {
     439        if (typeof(#[3])=="int" || typeof(#[3])=="number")
     440        {
     441          prepareideal = #[3];
     442        }
    247443      }
    248444    }
     
    250446  int i,j,k;
    251447  int sI = ncols(I);
    252   ideal lmI,lcI;
     448  // pre-reduce I:
     449  module M;
     450  if (prepareideal <> 0)
     451  {
     452    if (remembercoeffs <> 0)
     453    {
     454      list sortedI = linReduceIdeal(I,1,redtail);
     455      I = sortedI[1];
     456      M = sortedI[2];
     457      dbprint(ppl,"prepared ideal:",I);
     458      dbprint(ppl," with operations:",M);
     459    }
     460    else
     461    {
     462      I = linReduceIdeal(I,0,redtail);
     463    }
     464  }
     465  else
     466  {
     467    if (remembercoeffs <> 0)
     468    {
     469      for (i=1; i<=sI; i++)
     470      {
     471        M[i] = gen(i);
     472      }
     473    }
     474  }
     475  ideal lmI,lcI,ordI;
    253476  for (i=1; i<=sI; i++)
    254477  {
    255478    lmI[i] = leadmonom(I[i]);
    256479    lcI[i] = leadcoef(I[i]);
     480    ordI[i] = ord(lmI[i]);
    257481  }
    258482  vector v;
    259483  poly c;
    260   int reduction = 1;
    261   if (redlm == 0)
    262   {
    263     ideal monomf;
    264     for (k=1; k<=size(f); k++)
    265     {
    266       monomf[k] = normalize(f[k]);
    267     }
    268     while (reduction == 1) // while there was a reduction
    269     {
    270       reduction = 0;
    271       for (i=sI; i>=1; i--)
    272       {
    273         dbprint(ppl,"testing ideal entry:",i);
    274         for (j=1; j<=size(f); j++)
     484  // === reduce leading monomials ===
     485  poly lm = leadmonom(f);
     486  int ordf = ord(lm);
     487  for (i=sI; i>=1; i--)  // I is sorted: smallest lm's on top
     488  {
     489    if (lm == 0)
     490    {
     491      break;
     492    }
     493    else
     494    {
     495      if (ordf == ordI[i])
     496      {
     497        if (lm == lmI[i])
    275498        {
    276           if (monomf[j] == lmI[i])
     499          c = leadcoef(f)/lcI[i];
     500          f = f - c*I[i];
     501          lm = leadmonom(f);
     502          ordf = ord(lm);
     503          if (remembercoeffs <> 0)
     504          {
     505            v = v - c * M[i];
     506          }
     507        }
     508      }
     509    }
     510  }
     511  // === reduce tails as well ===
     512  if (redtail <> 0)
     513  {
     514    dbprint(ppl,"poly after reduction of leading monomials:",f);
     515    for (i=1; i<=sI; i++)
     516    {
     517      dbprint(ppl,"testing ideal entry:",i);
     518      for (j=1; j<=size(f); j++)
     519      {
     520        if (ord(f[j]) == ordI[i])
     521        {
     522          if (normalize(f[j]) == lmI[i])
    277523          {
    278524            c = leadcoef(f[j])/lcI[i];
    279525            f = f - c*I[i];
    280526            dbprint(ppl,"reducing poly to ",f);
    281             monomf = 0;
    282             for (k=1; k<=size(f); k++)
    283             {
    284               monomf[k] = normalize(f[k]);
    285             }
    286             reduction = 1;
    287527            if (remembercoeffs <> 0)
    288528            {
    289               v = v - c * gen(i);
     529              v = v - c * M[i];
    290530            }
    291             break;
    292           }
    293         }
    294         if (reduction == 1)
    295         {
    296           break;
    297         }
    298       }
    299     }
    300   }
    301   else // reduce only leading monomials
    302   {
    303     poly lm = leadmonom(f);
    304     while (reduction == 1) // while there was a reduction
    305     {
    306       reduction = 0;
    307       for (i=sI;i>=1;i--)
    308       {
    309         if (lm <> 0 && lm == lmI[i])
    310         {
    311           c = leadcoef(f)/lcI[i];
    312           f = f - c*I[i];
    313           lm = leadmonom(f);
    314           reduction = 1;
    315           if (remembercoeffs <> 0)
    316           {
    317             v = v - c * gen(i);
    318531          }
    319532        }
     
    338551  poly f = 5xy+7y+3;
    339552  poly g = 7x+5y+3;
    340   linreduce(g,I);
    341   linreduce(g,I,0,1);
    342   linreduce(f,I,1);
    343 }
    344 
    345 proc ncsolve (ideal I, list #)
    346 "USAGE:  ncsolve(I[,s]);  I an ideal, s an optional int
    347 RETURN:  coefficient vector of a linear combination of 0 in the elements of I
    348 PURPOSE: compute a linear dependency between the elements of an ideal if such one exists
     553  linReduce(g,I);
     554  linReduce(g,I,0,1);
     555  linReduce(f,I,1);
     556  f = x3 + y2 + x2 + y + x;
     557  I = x3 - y3, y3 - x2, x3 - y2, x2 - y, y2-x;
     558  list l = linReduce(f, I, 1);
     559  l;
     560  module M = I;
     561  f - (l[1] - (M*l[2])[1,1]);
     562}
     563
     564proc linSyzSolve (ideal I, list #)
     565"USAGE:  linSyzSolve(I[,s]);  I an ideal, s an optional int
     566RETURN:  vector, coefficient vector of a linear combination of 0 in the elements of I
     567PURPOSE: compute a linear dependency between the elements of an ideal
     568@*       if such one exists
    349569NOTE:    If s<>0, @code{std} is used for Groebner basis computations,
    350570@*       otherwise, @code{slimgb} is used.
    351571@*       By default, @code{slimgb} is used in char 0 and @code{std} in char >0.
    352 @*      If printlevel=1, progress debug messages will be printed,
     572DISPLAY: If printlevel=1, progress debug messages will be printed,
    353573@*       if printlevel>=2, all the debug messages will be printed.
    354 EXAMPLE: example ncsolve; shows examples
     574EXAMPLE: example linSyzSolve; shows examples
    355575"
    356576{
     
    374594  else
    375595  {
    376     // 1. introduce undefined coeffs
     596    // ------- 1. introduce undefined coeffs ------------------
    377597    def save = basering;
    378598    int p = char(save);
     
    386606    ring @A = p,(@a(1..sI)),lp;
    387607    ring @aA = (p,@a(1..sI)), (@z),dp;
     608    // TODO: BUG! WHAT IF THE ORIGINAL RING ALREADY HAS SUCH VARIABLES/PARAMETERS!!!?
     609    // TODO: YOU CAN OVERCOME THIS BY MEANS SIMILAR TO "chooseSafeVarName" FROM NEW "matrix.lib"
    388610    def @B = save + @aA;
    389611    setring @B;
    390612    ideal I = imap(save,I);
    391     // 2. form the linear system for the undef coeffs
     613    // ------- 2. form the linear system for the undef coeffs ---
    392614    int i;   poly W;  ideal QQ;
    393615    for (i=1; i<=sI; i++)
     
    403625    setring @A;
    404626    ideal QQ = imap(@B,QQ);
    405     // 3. this QQ is a polynomial ideal, so "solve" the system
    406     dbprint(ppl, "ncsolve: starting Groebner basis computation with engine:", whichengine);
     627    // ------- 3. this QQ is a polynomial ideal, so "solve" the system -----
     628    dbprint(ppl, "linSyzSolve: starting Groebner basis computation with engine:", whichengine);
    407629    QQ = engine(QQ,whichengine);
    408630    dbprint(ppl, "QQ after engine:", QQ);
    409631    if (dim(QQ) == -1)
    410632    {
    411       dbprint(ppl+1, "no solutions by ncsolve");
     633      dbprint(ppl+1, "no solutions by linSyzSolve");
    412634      // output zeroes
    413635      setring save;
     
    415637      return(v);
    416638    }
    417     // 4. in order to get the numeric values
     639    // ------- 4. in order to get the numeric values -------
    418640    matrix AA = matrix(maxideal(1));
    419641    module MQQ = std(module(QQ));
     
    439661  ring r = 0,x,dp;
    440662  ideal I = x,2x;
    441   ncsolve(I);
     663  linSyzSolve(I);
    442664  ideal J = x,x2;
    443   ncsolve(J);
    444 }
    445 
    446 proc pintersect (poly s, ideal I)
    447 "USAGE:  pintersect(f, I);  f a poly, I an ideal
    448 RETURN:  coefficient vector of the monic generator of the intersection of the ideal generated by f with I
    449 PURPOSE: compute the intersection of an ideal with a principal ideal defined by f
     665  linSyzSolve(J);
     666}
     667
     668proc pIntersect (poly s, ideal I)
     669"USAGE:  pIntersect(f, I);  f a poly, I an ideal
     670RETURN:  vector, coefficient vector of the monic polynomial
     671PURPOSE: compute the intersection of ideal I with the subalgebra K[f]
     672ASSUME:  I is given as Groebner basis.
    450673NOTE:    If the intersection is zero, this proc might not terminate.
    451 @*       I should be given as standard basis.
    452 @*       If printlevel=1, progress debug messages will be printed,
     674DISPLAY: If printlevel=1, progress debug messages will be printed,
    453675@*       if printlevel>=2, all the debug messages will be printed.
    454 EXAMPLE: example pintersect; shows examples
     676EXAMPLE: example pIntersect; shows examples
    455677"
    456678{
    457679  // assume I is given in Groebner basis
    458   attrib(I,"isSB",1); // set attribute for suppressing NF messages
     680  if (attrib(I,"isSB") <> 1)
     681  {
     682    print("WARNING: The input has no SB attribute!");
     683    print(" Treating it as if it were a Groebner basis and proceeding...");
     684    attrib(I,"isSB",1); // set attribute for suppressing NF messages
     685  }
    459686  int ppl = printlevel-voice+2;
    460687  // ---case 1: I = basering---
    461688  if (size(I) == 1)
    462689  {
    463     if (simplify(I,1) == ideal(1))
     690    if (simplify(I,2)[1] == 1)
    464691    {
    465692      return(gen(2)); // = s
     
    512739  poly toNF,tobracket,newNF,rednewNF,oldNF,secNF;
    513740  i = 1;
    514   dbprint(ppl+1,"pintersect starts...");
     741  dbprint(ppl+1,"pIntersect starts...");
    515742  while (1)
    516743  {
     
    535762      secNF = newNF;
    536763    }
    537     ll = linreduce(newNF,redNI,1);
     764    ll = linReduce(newNF,redNI,1);
    538765    rednewNF = ll[1];
    539766    l[i+1] = ll[2];
     
    578805  v = imap(@R,v);
    579806  kill @R;
    580   dbprint(ppl+1,"pintersect finished");
     807  dbprint(ppl+1,"pIntersect finished");
    581808  return(v);
    582809}
     
    586813  ring r = 0,(x,y),dp;
    587814  poly f = x^2+y^3+x*y^2;
    588   def D = initialmalgrange(f);
     815  def D = initialMalgrange(f);
    589816  setring D;
    590817  inF;
    591   pintersect(t*Dt,inF);
    592 }
    593 
    594 proc pintersectsyz (poly s, ideal II, list #)
    595 "USAGE:  pintersectsyz(f, I [,p,s,t]);  f a poly, I an ideal, p, t optial ints, p a prime number
    596 RETURN:  coefficient vector of the monic generator of the intersection of the ideal generated by f with I
    597 PURPOSE: compute the intersection of an ideal with a principal ideal defined by f
    598 NOTE:    If the intersection is zero, this proc might not terminate.
    599 @*       I should be given as standard basis.
    600 @*       If p>0 is given, this proc computes the generator of the intersection in char p first and
    601 @*       then only searches for a generator of the obtained degree in the basering.
    602 @*       Otherwise, it searched for all degrees.
    603 @*       This is done by computing syzygies.
     818  pIntersect(t*Dt,inF);
     819}
     820
     821proc pIntersectSyz (poly s, ideal II, list #)
     822"USAGE:  pIntersectSyz(f, I [,p,s,t]);  f a poly, I an ideal, p, t optial ints, p a prime number
     823RETURN:  vector, coefficient vector of the monic polynomial
     824PURPOSE: compute the intersection of an ideal I with the subalgebra K[f]
     825ASSUME:  I is given as Groebner basis.
     826NOTE:    If the intersection is zero, this procedure might not terminate.
     827@*       If p>0 is given, this proc computes the generator of the intersection in char p first
     828@*       and then only searches for a generator of the obtained degree in the basering.
     829@*       Otherwise, it searched for all degrees by computing syzygies.
    604830@*       If s<>0, @code{std} is used for Groebner basis computations in char 0,
    605831@*       otherwise, and by default, @code{slimgb} is used.
    606832@*       If t<>0 and by default, @code{std} is used for Groebner basis computations in char >0,
    607833@*       otherwise, @code{slimgb} is used.
    608 @*      If printlevel=1, progress debug messages will be printed,
     834DISPLAY: If printlevel=1, progress debug messages will be printed,
    609835@*       if printlevel>=2, all the debug messages will be printed.
    610 EXAMPLE: example pintersectsyz; shows examples
     836EXAMPLE: example pIntersectSyz; shows examples
    611837"
    612838{
    613839  // assume I is given in Groebner basis
    614840  ideal I = II;
    615   attrib(I,"isSB",1); // set attribute for suppressing NF messages
     841  if (attrib(I,"isSB") <> 1)
     842  {
     843    print("WARNING: The input has no SB attribute!");
     844    print(" Treating it as if it were a Groebner basis and proceeding...");
     845    attrib(I,"isSB",1); // set attribute for suppressing NF messages
     846  }
    616847  int ppl = printlevel-voice+2;
    617848  int whichengine  = 0; // default
     
    668899  }
    669900  i = 1;
    670   dbprint(ppl+1,"pintersectsyz starts...");
     901  dbprint(ppl+1,"pIntersectSyz starts...");
    671902  dbprint(ppl+1,"with ideal I=", I);
    672903  while (1)
     
    688919    }
    689920    // look for a solution
    690     dbprint(ppl,"ncsolve starts with: "+string(matrix(NI)));
     921    dbprint(ppl,"linSyzSolve starts with: "+string(matrix(NI)));
    691922    if (solveincharp<>0) // modular method
    692923    {
    693924      setring Rp;
    694925      NI[i+1] = phi(newNF);
    695       v = ncsolve(NI,modengine);
     926      v = linSyzSolve(NI,modengine);
    696927      if (v!=0) // there is a modular solution
    697928      {
    698929        dbprint(ppl,"got solution in char ",solveincharp," of degree " ,i);
    699930        setring save;
    700         v = ncsolve(NI,whichengine);
     931        v = linSyzSolve(NI,whichengine);
    701932        if (v==0)
    702933        {
     
    712943    else // non-modular method
    713944    {
    714       v = ncsolve(NI,whichengine);
     945      v = linSyzSolve(NI,whichengine);
    715946    }
    716947    matrix MM[1][nrows(v)] = matrix(v);
    717     dbprint(ppl,"ncsolve ready  with: "+string(MM));
     948    dbprint(ppl,"linSyzSolve ready  with: "+string(MM));
    718949    kill MM;
    719     //  "ncsolve ready with"; print(v);
     950    //  "linSyzSolve ready with"; print(v);
    720951    if (v!=0)
    721952    {
     
    729960      if (p!=0)
    730961      {
    731         dbprint(ppl,"ncsolve: bad solution!");
     962        dbprint(ppl,"linSyzSolve: bad solution!");
    732963      }
    733964      else
    734965      {
    735         dbprint(ppl,"ncsolve: got solution!");
     966        dbprint(ppl,"linSyzSolve: got solution!");
    736967        // "got solution!";
    737968        break;
     
    741972    i++;
    742973  }
    743   dbprint(ppl+1,"pintersectsyz finished");
     974  dbprint(ppl+1,"pIntersectSyz finished");
    744975  return(v);
    745976}
     
    749980  ring r = 0,(x,y),dp;
    750981  poly f = x^2+y^3+x*y^2;
    751   def D = initialmalgrange(f);
     982  def D = initialMalgrange(f);
    752983  setring D;
    753984  inF;
    754985  poly s = t*Dt;
    755   pintersectsyz(s,inF);
     986  pIntersectSyz(s,inF);
    756987  int p = prime(20000);
    757   pintersectsyz(s,inF,p,0,0);
     988  pIntersectSyz(s,inF,p,0,0);
    758989}
    759990
    760991proc vec2poly (list #)
    761992"USAGE:  vec2poly(v [,i]);  v a vector or an intvec, i an optional int
    762 RETURN:  a poly with coefficient vector v
    763 PURPOSE: convert a coefficient vector to a poly
    764 NOTE:    If i>0 is given, the returned poly is an element of K[var(i)],
    765 @*       otherwise, and by default, @code{i=1} is used.
    766 @*       The first entry of v is the coefficient of 1.
     993RETURN:  poly, an univariate poly in i-th variable with coefficients given by v
     994PURPOSE: constructs an univariate poly in K[var(i)] with given coefficients,
     995@*       such that the coefficient at var(i)^{j-1} is v[j].
     996NOTE:    The optional argument i must be positive, by default i is 1.
    767997EXAMPLE: example vec2poly; shows examples
    768998"
     
    8581088}
    8591089
    860 static proc bfctengine (poly f, int inorann, int whichengine, int methodord, int methodpintersect, int pintersectchar, int modengine, intvec u0)
     1090static proc bfctengine (poly f, int inorann, int whichengine, int methodord, int methodpIntersect, int pIntersectchar, int modengine, intvec u0)
    8611091{
    8621092  int ppl = printlevel - voice +2;
     
    8661096  if (inorann == 0) // bfct using initial ideal
    8671097  {
    868     def D = initialmalgrange(f,whichengine,methodord,1,u0);
     1098    def D = initialMalgrange(f,whichengine,methodord,1,u0);
    8691099    setring D;
    8701100    ideal J = inF;
     
    8811111  vector b;
    8821112  // try it modular
    883   if (methodpintersect <> 0) // pintersectsyz
    884   {
    885     if (pintersectchar == 0) // pintersectsyz::modular
     1113  if (methodpIntersect <> 0) // pIntersectSyz
     1114  {
     1115    if (pIntersectchar == 0) // pIntersectSyz::modular
    8861116    {
    8871117      int lb = 30000;
     
    8931123        dbprint(ppl,"number of run in the loop: "+string(i));
    8941124        int q = prime(random(lb,ub));
    895         if (isin(usedprimes,q)==0) // if q was not already used
     1125        if (findFirst(usedprimes,q)==0) // if q was not already used
    8961126        {
    8971127          usedprimes = usedprimes,q;
    8981128          dbprint(ppl,"used prime is: "+string(q));
    899           b = pintersectsyz(s,J,q,whichengine,modengine);
     1129          b = pIntersectSyz(s,J,q,whichengine,modengine);
    9001130        }
    9011131        i++;
    9021132      }
    9031133    }
    904     else // pintersectsyz::non-modular
    905     {
    906       b = pintersectsyz(s,J,0,whichengine);
    907     }
    908   }
    909   else // pintersect: linreduce
    910   {
    911     b = pintersect(s,J);
     1134    else // pIntersectSyz::non-modular
     1135    {
     1136      b = pIntersectSyz(s,J,0,whichengine);
     1137    }
     1138  }
     1139  else // pIntersect: linReduce
     1140  {
     1141    b = pIntersect(s,J);
    9121142  }
    9131143  setring save;
     
    9261156proc bfct (poly f, list #)
    9271157"USAGE:  bfct(f [,s,t,v]);  f a poly, s,t optional ints, v an optional intvec
    928 RETURN:  list of roots of the Bernstein-Sato polynomial bs(f) and their multiplicies
    929 PURPOSE: compute the global Bernstein-Sato polynomial for a hypersurface, defined by f, according to the algorithm by Masayuki Noro
    930 NOTE:    In this proc, the initial Malgrange ideal is computed.
    931 @*       Further, a system of linear equations is solved by linear reductions.
    932 @*       If s<>0, @code{std} is used for Groebner basis computations,
     1158RETURN:  list of ideal and intvec
     1159PURPOSE: computes the roots of the Bernstein-Sato polynomial b(s)
     1160@*       for the hypersurface defined by f.
     1161ASSUME:  The basering is a commutative polynomial ring in char 0.
     1162BACKGROUND: In this proc, the initial Malgrange ideal is computed according to the algorithm
     1163@*       by Masayuki Noro and then a system of linear equations is solved by linear reductions.
     1164NOTE:    In the output list, the ideal contains all the roots
     1165@*       and the intvec their multiplicities.
     1166@*       If s<>0, @code{std} is used for GB computations,
    9331167@*       otherwise, and by default, @code{slimgb} is used.
    9341168@*       If t<>0, a matrix ordering is used for Groebner basis computations,
    9351169@*       otherwise, and by default, a block ordering is used.
    936 @*       If v is a positive weight vector, v is used for homogenization computations,
     1170@*       If v is a positive weight vector, v is used for homogenization computations, 
    9371171@*       otherwise and by default, no weights are used.
    938 @*      If printlevel=1, progress debug messages will be printed,
     1172DISPLAY: If printlevel=1, progress debug messages will be printed,
    9391173@*       if printlevel>=2, all the debug messages will be printed.
    9401174EXAMPLE: example bfct; shows examples
     
    9651199      if (size(#)>2)
    9661200      {
    967         if (typeof(#[3])=="intvec" && size(#[3])==n && ispositive(#[3])==1)
     1201        if (typeof(#[3])=="intvec" && size(#[3])==n && allPositive(#[3])==1)
    9681202        {
    9691203          u0 = #[3];
     
    9851219}
    9861220
    987 proc bfctsyz (poly f, list #)
    988 "USAGE:  bfctsyz(f [,r,s,t,u,v]);  f a poly, r,s,t,u optional ints, v an optional intvec
    989 RETURN:  list of roots of the Bernstein-Sato polynomial bs(f) and its multiplicies
    990 PURPOSE: compute the global Bernstein-Sato polynomial for a hypersurface, defined by f, according to the algorithm by Masayuki Noro
    991 NOTE:    In this proc, the initial Malgrange ideal is computed.
    992 @*       Further, a system of linear equations is solved by computing syzygies.
    993 @*       If r<>0, @code{std} is used for Groebner basis computations in characteristic 0,
     1221proc bfctSyz (poly f, list #)
     1222"USAGE:  bfctSyz(f [,r,s,t,u,v]);  f a poly, r,s,t,u optional ints, v an optional intvec
     1223RETURN:  list of ideal and intvec
     1224PURPOSE: computes the roots of the Bernstein-Sato polynomial b(s)
     1225@*       for the hypersurface defined by f
     1226ASSUME:  The basering is a commutative polynomial ring in char 0.
     1227BACKGROUND: In this proc, the initial Malgrange ideal is computed according to the algorithm
     1228@*       by Masayuki Noro and then a system of linear equations is solved by computing syzygies.
     1229NOTE:    In the output list, the ideal contains all the roots
     1230@*       and the intvec their multiplicities.
     1231@*       If r<>0, @code{std} is used for GB computations in characteristic 0,
    9941232@*       otherwise, and by default, @code{slimgb} is used.
    995 @*       If s<>0, a matrix ordering is used for Groebner basis computations,
    996 @*       otherwise, and by default, a block ordering is used.
    997 @*       If t<>0, the computation of the intersection is solely performed over charasteristic 0,
    998 @*       otherwise and by default, a modular method is used.
    999 @*       If u<>0 and by default, @code{std} is used for Groebner basis computations in characteristic >0,
    1000 @*       otherwise, @code{slimgb} is used.
    1001 @*       If v is a positive weight vector, v is used for homogenization computations,
    1002 @*       otherwise and by default, no weights are used.
    1003 @*      If printlevel=1, progress debug messages will be printed,
     1233@*       If s<>0, a matrix ordering is used for GB computations, otherwise,
     1234@*       and by default, a block ordering is used.
     1235@*       If t<>0, the computation of the intersection is solely performed over
     1236@*       charasteristic 0, otherwise and by default, a modular method is used.
     1237@*       If u<>0 and by default, @code{std} is used for GB computations in
     1238@*       characteristic >0, otherwise, @code{slimgb} is used.
     1239@*       If v is a positive weight vector, v is used for homogenization
     1240@*       computations, otherwise and by default, no weights are used.
     1241DISPLAY: If printlevel=1, progress debug messages will be printed,
    10041242@*       if printlevel>=2, all the debug messages will be printed.
    10051243EXAMPLE: example bfct; shows examples
     
    10181256  int whichengine = 0; // default
    10191257  int methodord   = 0; // default
    1020   int pintersectchar  = 0; // default
     1258  int pIntersectchar  = 0; // default
    10211259  int modengine   = 1; // default
    10221260  intvec u0       = 0; // default
     
    10371275        if (typeof(#[3])=="int" || typeof(#[3])=="number")
    10381276        {
    1039           pintersectchar = int(#[3]);
     1277          pIntersectchar = int(#[3]);
    10401278        }
    10411279        if (size(#)>3)
     
    10471285          if (size(#)>4)
    10481286          {
    1049             if (typeof(#[5])=="intvec" && size(#[5])==n && ispositive(#[5])==1)
     1287            if (typeof(#[5])=="intvec" && size(#[5])==n && allPositive(#[5])==1)
    10501288            {
    10511289              u0 = #[5];
     
    10561294    }
    10571295  }
    1058   list b = bfctengine(f,0,whichengine,methodord,1,pintersectchar,modengine,u0);
     1296  list b = bfctengine(f,0,whichengine,methodord,1,pIntersectchar,modengine,u0);
    10591297  return(b);
    10601298}
     
    10641302  ring r = 0,(x,y),dp;
    10651303  poly f = x^2+y^3+x*y^2;
    1066   bfctsyz(f);
     1304  bfctSyz(f);
    10671305  intvec v = 3,2;
    1068   bfctsyz(f,0,1,1,0,v);
    1069 }
    1070 
    1071 proc bfctideal (ideal I, intvec w, list #)
    1072 "USAGE:  bfctideal(I,w[,s,t]);  I an ideal, w an intvec, s,t optional ints
    1073 RETURN:  list of roots and their multiplicies of the global b-function of I w.r.t. the weight vector (-w,w)
    1074 PURPOSE: compute the global b-function of an ideal according to the algorithm by M. Noro
    1075 NOTE:    Assume, I is an ideal in the n-th Weyl algebra where the sequence of the
    1076 @*       variables is x(1),...,x(n),D(1),...,D(n).
    1077 @*       If s<>0, @code{std} is used for Groebner basis computations in characteristic 0,
     1306  bfctSyz(f,0,1,1,0,v);
     1307}
     1308
     1309proc bfctIdeal (ideal I, intvec w, list #)
     1310"USAGE:  bfctIdeal(I,w[,s,t]);  I an ideal, w an intvec, s,t optional ints
     1311RETURN:  list of ideal and intvec
     1312PURPOSE: computes the roots of the global b-function of I wrt the weight vector (-w,w).
     1313ASSUME:  The basering is the n-th Weyl algebra in char 0, where the sequence of
     1314@*       the variables is x(1),...,x(n),D(1),...,D(n).
     1315BACKGROUND:  In this proc, the initial ideal of I is computed according to the algorithm by
     1316@*       Masayuki Noro and then a system of linear equations is solved by linear reductions.
     1317NOTE:    In the output list, the ideal contains all the roots
     1318@*       and the intvec their multiplicities.
     1319@*       If s<>0, @code{std} is used for GB computations in characteristic 0,
    10781320@*       otherwise, and by default, @code{slimgb} is used.
    1079 @*       If t<>0, a matrix ordering is used for Groebner basis computations,
    1080 @*       otherwise, and by default, a block ordering is used.
    1081 @*      If printlevel=1, progress debug messages will be printed,
     1321@*       If t<>0, a matrix ordering is used for GB computations, otherwise,
     1322@*       and by default, a block ordering is used.
     1323DISPLAY: If printlevel=1, progress debug messages will be printed,
    10821324@*       if printlevel>=2, all the debug messages will be printed.
    10831325EXAMPLE: example bfctideal; shows examples
     
    11041346    }
    11051347  }
    1106   ideal J = initialideal(I,-w,w,whichengine,methodord);
     1348  ideal J = initialIdeal(I,-w,w,whichengine,methodord);
    11071349  poly s;
    11081350  for (i=1; i<=n; i++)
     
    11101352    s = s + w[i]*var(i)*var(n+i);
    11111353  }
    1112   vector b = pintersect(s,J);
     1354  vector b = pIntersect(s,J);
    11131355  list l = listofroots(b,0);
    11141356  return(l);
     
    11201362  def D = Weyl();
    11211363  setring D;
    1122   ideal I = 3*x^2*Dy+2*y*Dx,2*x*Dx+3*y*Dy+6;
     1364  ideal I = std(3*x^2*Dy+2*y*Dx,2*x*Dx+3*y*Dy+6); I;
    11231365  intvec w1 = 1,1;
    11241366  intvec w2 = 1,2;
    11251367  intvec w3 = 2,3;
    1126   bfctideal(I,w1);
    1127   bfctideal(I,w2,1);
    1128   bfctideal(I,w3,0,1);
    1129 }
    1130 
    1131 
    1132 proc bfctonestep (poly f,list #)
    1133 "USAGE:  bfctonestep(f [,s,t]);  f a poly, s,t optional ints
    1134 RETURN:  list of roots of the Bernstein-Sato polynomial bs(f) and its multiplicies
    1135 PURPOSE: compute the global Bernstein-Sato polynomial for a hypersurface, defined by f, using only one Groebner basis computation
    1136 NOTE:    If s<>0, @code{std} is used for the Groebner basis computation, otherwise,
     1368  bfctIdeal(I,w1);
     1369  bfctIdeal(I,w2,1);
     1370  bfctIdeal(I,w3,0,1);
     1371}
     1372
     1373proc bfctOneGB (poly f,list #)
     1374"USAGE:  bfctOneGB(f [,s,t]);  f a poly, s,t optional ints
     1375RETURN:  list of ideal and intvec
     1376PURPOSE: computes the roots of the Bernstein-Sato polynomial b(s) for the
     1377@*       hypersurface defined by f, using only one GB computation
     1378ASSUME:  The basering is a commutative polynomial ring in char 0.
     1379BACKGROUND: In this proc, the initial Malgrange ideal is computed based on the
     1380@*       algorithm by Masayuki Noro and combined with an elimination ordering.
     1381NOTE:    In the output list, the ideal contains all the roots
     1382@*       and the intvec their multiplicities.
     1383@*       If s<>0, @code{std} is used for the GB computation, otherwise,
    11371384@*       and by default, @code{slimgb} is used.
    1138 @*       If t<>0, a matrix ordering is used for Groebner basis computations,
     1385@*       If t<>0, a matrix ordering is used for GB computations,
    11391386@*       otherwise, and by default, a block ordering is used.
    1140 @*      If printlevel=1, progress debug messages will be printed,
     1387DISPLAY: If printlevel=1, progress debug messages will be printed,
    11411388@*       if printlevel>=2, all the debug messages will be printed.
    1142 EXAMPLE: example bfctonestep; shows examples
     1389EXAMPLE: example bfctOneGB; shows examples
    11431390"
    11441391{
     
    11461393  def save = basering;
    11471394  int n = nvars(save);
     1395  int noofvars = 2*n+4;
    11481396  int i;
    11491397  int whichengine = 0; // default
     
    11631411    }
    11641412  }
    1165   def DDh = initialidealengine("bfctonestep", whichengine, methodord, f);
     1413  intvec uv;
     1414  uv[n+3] = 1;
     1415  ring r = 0,(x(1..n)),dp;
     1416  poly f = fetch(save,f);
     1417  uv[1] = -1; uv[noofvars] = 0;
     1418  //  for the ordering
     1419  intvec @a; @a = 1:noofvars; @a[2] = 2;
     1420  intvec @a2 = @a; @a2[2] = 0; @a2[2*n+4] = 0;
     1421  if (methodord == 0) // default: block ordering
     1422  {
     1423    ring Dh = 0,(t,s,x(n..1),Dt,D(n..1),h),(a(@a),a(@a2),a(uv),dp(noofvars-1),lp(1));
     1424  }
     1425  else // M() ordering
     1426  {
     1427    intmat @Ord[noofvars][noofvars];
     1428    @Ord[1,1..noofvars] = uv;
     1429    @Ord[2,1..noofvars] = 1:(noofvars-1);
     1430    for (i=1; i<=noofvars-2; i++)
     1431    {
     1432      @Ord[2+i,noofvars - i] = -1;
     1433    }
     1434    dbprint(ppl,"weights for ordering:",transpose(@a));
     1435    dbprint(ppl,"the ordering matrix:",@Ord);
     1436    ring Dh = 0,(t,s,x(n..1),Dt,D(n..1),h),(a(@a),a(@a2),M(@Ord));
     1437  }
     1438  dbprint(ppl,"the ring Dh:",Dh);
     1439  // non-commutative relations
     1440  matrix @relD[noofvars][noofvars];
     1441  @relD[1,2] = t*h^2;// s*t = t*s+t*h^2
     1442  @relD[2,n+3] = Dt*h^2;// Dt*s = s*Dt+h^2
     1443  @relD[1,n+3] = h^2;
     1444  for (i=1; i<=n; i++)
     1445  {
     1446    @relD[i+2,n+3+i] = h^2;
     1447  }
     1448  dbprint(ppl,"nc relations:",@relD);
     1449  def DDh = nc_algebra(1,@relD);
    11661450  setring DDh;
    1167   dbprint(ppl, "the initial ideal:", string(matrix(inF)));
     1451  dbprint(ppl,"computing in ring",DDh);
     1452  ideal I;
     1453  poly f = imap(r,f);
     1454  kill r;
     1455  f = homog(f,h);
     1456  I = t - f, t*Dt - s;  // defining the Malgrange ideal
     1457  for (i=1; i<=n; i++)
     1458  {
     1459    I = I, D(i)+diff(f,x(i))*Dt;
     1460  }
     1461  dbprint(ppl, "starting Groebner basis computation with engine:", whichengine);
     1462  I = engine(I, whichengine);
     1463  dbprint(ppl, "finished Groebner basis computation");
     1464  dbprint(ppl, "I before dehomogenization is" ,I);
     1465  I = subst(I,h,1); // dehomogenization
     1466  dbprint(ppl, "I after dehomogenization is" ,I);
     1467  I = inForm(I,uv); // we are only interested in the initial form w.r.t. uv
     1468  dbprint(ppl, "the initial ideal:", string(matrix(I)));
    11681469  intvec tonselect = 1;
    1169   for (i=3; i<=2*n+4; i++)
    1170   {
    1171     tonselect = tonselect,i;
    1172   }
    1173   inF = nselect(inF,tonselect);
    1174   dbprint(ppl, "generators containing only s:", string(matrix(inF)));
    1175   inF = engine(inF, whichengine); // is now a principal ideal;
     1470  for (i=3; i<=2*n+4; i++) { tonselect = tonselect,i; }
     1471  I = nselect(I,tonselect);
     1472  dbprint(ppl, "generators containing only s:", string(matrix(I)));
     1473  I = engine(I, whichengine); // is now a principal ideal;
    11761474  setring save;
    11771475  ideal J; J[2] = var(1);
    11781476  map @m = DDh,J;
    1179   ideal inF = @m(inF);
    1180   poly p = inF[1];
     1477  ideal I = @m(I);
     1478  poly p = I[1];
    11811479  list l = listofroots(p,1);
    11821480  return(l);
     
    11871485  ring r = 0,(x,y),dp;
    11881486  poly f = x^2+y^3+x*y^2;
    1189   bfctonestep(f);
    1190   bfctonestep(f,1,1);
    1191 }
    1192 
    1193 proc bfctann (poly f, list #)
    1194 "USAGE:  bfctann(f [,r]);  f a poly, r an optional int
    1195 RETURN:  list of roots of the Bernstein-Sato polynomial bs(f) and their multiplicies
    1196 PURPOSE: compute the global Bernstein-Sato polynomial for a hypersurface, defined by f
    1197 NOTE:    In this proc, ann(f^s) is computed.
    1198 @*       If r<>0, @code{std} is used for Groebner basis computations,
     1487  bfctOneGB(f);
     1488  bfctOneGB(f,1,1);
     1489}
     1490
     1491proc bfctAnn (poly f, list #)
     1492"USAGE:  bfctAnn(f [,r]);  f a poly, r an optional int
     1493RETURN:  list of ideal and intvec
     1494PURPOSE: computes the roots of the Bernstein-Sato polynomial b(s)
     1495@*       for the hypersurface defined by f
     1496ASSUME:  The basering is a commutative polynomial ring in char 0.
     1497BACKGROUND: In this proc, ann(f^s) is computed and then a system of linear
     1498@*       equations is solved by linear reductions.
     1499NOTE:    In the output list, the ideal contains all the roots
     1500@*       and the intvec their multiplicities.
     1501@*       If r<>0, @code{std} is used for GB computations,
    11991502@*       otherwise, and by default, @code{slimgb} is used.
    1200 @*      If printlevel=1, progress debug messages will be printed,
     1503DISPLAY: If printlevel=1, progress debug messages will be printed,
    12011504@*       if printlevel>=2, all the debug messages will be printed.
    12021505EXAMPLE: example bfctann; shows examples
     
    12211524  ring r = 0,(x,y),dp;
    12221525  poly f = x^2+y^3+x*y^2;
    1223   bfctann(f);
    1224 }
    1225 
    1226 static proc hardexamples ()
     1526  bfctAnn(f);
     1527}
     1528
     1529/*
     1530//static proc hardexamples ()
    12271531{
    12281532  //  some hard examples
     
    12461550  bfct(xyzreiffen45);
    12471551}
    1248 
     1552*/
Note: See TracChangeset for help on using the changeset viewer.