Changeset dfb2c6 in git for Singular/LIB/bfun.lib


Ignore:
Timestamp:
Mar 6, 2009, 9:32:29 PM (15 years ago)
Author:
Viktor Levandovskyy <levandov@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
fda698647a5a06bd263906206d3ce89a87b42c0d
Parents:
2a5ce368e94b24f2bbac34de08062477cb206040
Message:
*levandov: bfun and dmodapp seriously reworked


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

Legend:

Unmodified
Added
Removed
  • Singular/LIB/bfun.lib

    r2a5ce36 rdfb2c6  
    11//////////////////////////////////////////////////////////////////////////////
    2 version="$Id: bfun.lib,v 1.2 2009-02-23 15:10:18 Singular Exp $";
     2version="$Id: bfun.lib,v 1.3 2009-03-06 20:32:28 levandov Exp $";
    33category="Noncommutative";
    44info="
     
    99THEORY: Given a polynomial ring R = K[x_1,...,x_n] and a polynomial F in R,
    1010@*      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>.
     11@*      polynomial) b(s) in K[s], defined to be the monic polynomial, satisfying
     12@*      a functional identity    L * F^{s+1} = b(s) F^s,   
     13@*      for some operator L in D[s]. Here, D stands for an n-th Weyl algebra
     14@*      K<x_1,...,x_n,d_1,...,d_n | d_j x_j = x_j d_j +1>.
    1415@*      One is interested in the following data:
    1516@*      - Bernstein-Sato polynomial b(s) in K[s],
    1617@*      - the list of its roots, which are known to be rational
    1718@*      - the multiplicities of the roots.
    18 @*      References: Saito, Sturmfels, Takayama: Groebner Deformations of Hypergeometric
    19 @*      Differential Equations (2000), Noro: An Efficient Modular Algorithm for Computing
    20 @*      the Global b-function, (2002).
     19@*
     20@*    There is a general definition of a b-function of a holonomic ideal [SST]
     21@*    (that is, an ideal I in a Weyl algebra D, such that D/I is holonomic module)
     22@*    with respect to the given weight vector. B-function b_w(s) is in K[s].
     23@*    Unlike Bernstein-Sato polynomial, general B-function with respect to
     24@*    arbitrary weights need not have rational roots at all.
     25@*
     26@*      References: [SST] Saito, Sturmfels, Takayama: Groebner Deformations of
     27@*      Hypergeometric Differential Equations (2000),
     28@*      Noro: An Efficient Modular Algorithm for Computing the Global b-function,
     29@*      (2002).
    2130
    2231
     
    2736bfctAnn(f[,s]);             computes the Bernstein-Sato polynomial of poly f
    2837bfctOneGB(f[,s,t]);         computes the Bernstein-Sato polynomial of poly f
    29 bfctIdeal(I,w[,s,t]);       computes the global b-function of ideal I w.r.t. the weight w
    30 pIntersect(f,I);            intersection of the ideal I with the subalgebra K[f] for a poly f
    31 pIntersectSyz(f,I[,p,s,t]); intersection of the ideal I with the subalgebra K[f] for a poly f
     38bfctIdeal(I,w[,s,t]);       computes the global b-function of ideal wrt weight
     39pIntersect(f,I[,s]);        intersection of ideal with subalgebra K[f] for poly f
     40pIntersectSyz(f,I[,p,s,t]); intersection of ideal with subalgebra K[f] for poly f
    3241linReduce(f,I[,s]);         reduces a poly by linear reductions only
    3342linReduceIdeal(I,[s,t]);    reduces generators of ideal by linear reductions only
    34 linSyzSolve(I[,s]);         computes a linear dependency of the elements of ideal I
     43linSyzSolve(I[,s]);         computes a linear dependency of elements of ideal I
    3544
    3645AUXILIARY PROCEDURES:
     
    4756LIB "dmod.lib";     // for SannfsBFCT etc
    4857LIB "dmodapp.lib";  // for initialIdealW etc
    49 
     58LIB "nctools.lib"; // for isWeyl etc
    5059
    5160///////////////////////////////////////////////////////////////////////////////
     
    8392"
    8493{
     94  // todo check assumption
    8595  int i;
    8696  def save = basering;
     
    137147}
    138148
     149static proc safeVarName (string s)
     150{
     151  string cv = "," + charstr(basering) + "," + varstr(basering) + ",";
     152  s = "," + s + ",";
     153  while (find(cv,s) <> 0)
     154  {
     155    s[1] = "@";
     156    s = "," + s;
     157  }
     158  s = s[2..size(s)-1];
     159  return(s)
     160}
    139161
    140162proc allPositive (intvec v)
     
    167189static proc findFirst (list l, i)
    168190"USAGE:  findFirst(l,i);  l a list, i an argument of any type
    169 RETURN:  int, the position of the first appearance of i in l, or 0 if i is not a member of l
     191RETURN:  int, the position of the first appearance of i in l,
     192@*       or 0 if i is not a member of l
    170193PURPOSE: check whether the second argument is a member of a list
    171194EXAMPLE: example findFirst; shows an example
     
    230253"USAGE:  linReduceIdeal(I [,s,t,u]); I an ideal, s,t,u optional ints
    231254RETURN:  ideal or list, linear reductum (over field) of I by its elements
    232 PURPOSE: reduce a list of polys only by linear reductions (no monomial multiplications)
    233 NOTE:    If s<>0, a list consisting of the reduced ideal and the coefficient
     255PURPOSE: reduces a list of polys only by linear reductions (no monomial
     256@*        multiplications)
     257NOTE:    If s<>0, a list consisting of the reduced ideal and the coefficient
    234258@*       vectors of the used reductions given as module is returned.
    235259@*       Otherwise (and by default), only the reduced ideal is returned.
     
    237261@*       otherwise, only leading monomials are reduced.
    238262@*       If u<>0 (and by default), the ideal is first sorted in increasing order.
    239 @*       If u is set to 0 and the given ideal is not sorted in the way described, 
     263@*       If u is set to 0 and the given ideal is not sorted in the way described,
    240264@*       the result might not be as expected.
    241265DISPLAY: If @code{printlevel}=1, progress debug messages will be printed,
     
    327351    }
    328352  } 
    329   dbprint(ppl-1,"initially sorted ideal:", I);
    330   if (remembercoeffs <> 0) { dbprint(ppl-1," used permutations:", M); }
     353  dbprint(ppl-1,"// initially sorted ideal:", I);
     354  if (remembercoeffs <> 0) { dbprint(ppl-1,"// used permutations:", M); }
    331355  // step 2: reduce leading monomials by linear reductions
    332356  poly lm,c,redpoly,maxlmJ;
     
    358382          if (lm == lmJ[j])
    359383          {
    360             dbprint(ppl-1,"reducing " + string(redpoly));
    361             dbprint(ppl-1," with " + string(J[j]));
     384            dbprint(ppl-1,"// reducing " + string(redpoly));
     385            dbprint(ppl-1,"// with " + string(J[j]));
    362386            c = leadcoef(redpoly)/leadcoef(J[j]);
    363387            redpoly = redpoly - c*J[j];
    364             dbprint(ppl-1," to " + string(redpoly));
     388            dbprint(ppl-1,"// to " + string(redpoly));
    365389            lm = leadmonom(redpoly);
    366390            ordlm = ord(lm);
     
    390414  if (redtail <> 0)
    391415  {
    392     dbprint(ppl,"finished reducing leading monomials");
     416    dbprint(ppl,"// finished reducing leading monomials");
    393417    dbprint(ppl-1,string(J));
    394     if (remembercoeffs <> 0) { dbprint(ppl-1,"used reductions:" + string(M)); }
     418    if (remembercoeffs <> 0) { dbprint(ppl-1,"// used reductions:" + string(M)); }
    395419    int k;
    396420    for (i=sZeros+1; i<=sI; i++)
     
    406430            {
    407431              c = leadcoef(J[j][k])/leadcoef(J[i]);
    408               dbprint(ppl-1,"reducing " + string(J[j]));
    409               dbprint(ppl-1," with " + string(J[i]));
     432              dbprint(ppl-1,"// reducing " + string(J[j]));
     433              dbprint(ppl-1,"// with " + string(J[i]));
    410434              J[j] = J[j] - c*J[i];
    411               dbprint(ppl-1," to " + string(J[j]));
     435              dbprint(ppl-1,"// to " + string(J[j]));
    412436              if (remembercoeffs <> 0) { M[j] = M[j] - c * M[i]; }
    413437            }
     
    442466@*       If t<>0 (and by default) all monomials are reduced (if possible),
    443467@*       otherwise, only leading monomials are reduced.
    444 @*       If u<>0 (and by default), the ideal is linearly pre-reduced, i.e. instead
    445 @*       of the given ideal, the output of @code{linReduceIdeal} is used. If u is
    446 @*       set to 0 and the given ideal does not equal the output of
    447 @*       @code{linReduceIdeal}, the result might not be as expected. 
     468@*       If u<>0 (and by default), the ideal is linearly pre-reduced, i.e.
     469@*       instead of the given ideal, the output of @code{linReduceIdeal} is used.
     470@*       If u is set to 0 and the given ideal does not equal the output of
     471@*       @code{linReduceIdeal}, the result might not be as expected.
    448472DISPLAY: If @code{printlevel}=1, progress debug messages will be printed,
    449473@*       if printlevel>=2, all the debug messages will be printed.
     
    487511      I = sortedI[1];
    488512      M = sortedI[2];
    489       dbprint(ppl-1,"prepared ideal:",I);
    490       dbprint(ppl-1," with operations:",M);
     513      dbprint(ppl-1,"// prepared ideal:" +string(I));
     514      dbprint(ppl-1,"//  with operations:" +string(M));
    491515    }
    492516    else { I = linReduceIdeal(I,0,redtail); }
     
    532556  if (redtail <> 0)
    533557  {
    534     dbprint(ppl,"finished reducing leading monomials");
     558    dbprint(ppl,"// finished reducing leading monomials");
    535559    dbprint(ppl-1,string(f));
    536     if (remembercoeffs <> 0) { dbprint(ppl-1,"used reductions:" + string(v)); }
     560    if (remembercoeffs <> 0) { dbprint(ppl-1,"// used reductions:" + string(v)); }
    537561    for (i=1; i<=sI; i++)
    538562    {
    539       dbprint(ppl,"testing ideal entry:",i);
     563      dbprint(ppl,"// testing ideal entry "+string(i));
    540564      for (j=1; j<=size(f); j++)
    541565      {
     
    546570            c = leadcoef(f[j])/lcI[i];
    547571            f = f - c*I[i];
    548             dbprint(ppl-1,"reducing with " + string(I[i]));
    549             dbprint(ppl-1," to " + string(f));
     572            dbprint(ppl-1,"// reducing with " + string(I[i]));
     573            dbprint(ppl-1,"// to " + string(f));
    550574            if (remembercoeffs <> 0) { v = v - c * M[i]; }
    551575          }
     
    581605proc linSyzSolve (ideal I, list #)
    582606"USAGE:  linSyzSolve(I[,s]);  I an ideal, s an optional int
    583 RETURN:  vector, coefficient vector of a linear combination of 0 in the elements of I
     607RETURN:  vector, coefficient vector of linear combination of 0 in elements of I
    584608PURPOSE: compute a linear dependency between the elements of an ideal
    585609@*       if such one exists
     
    613637    // ------- 1. introduce undefined coeffs ------------------
    614638    def save = basering;
     639    list RL = ringlist(save);
     640    int nv = nvars(save);
     641    int np = npars(save);
    615642    int p = char(save);
     643    string cs = "(" + charstr(save) + ")";
    616644    if (enginespecified == 0)
    617645    {
     
    621649      }
    622650    }
    623     ring @A = p,(@a(1..sI)),lp;
    624     ring @aA = (p,@a(1..sI)), (@z),dp;
    625     // TODO: BUG! WHAT IF THE ORIGINAL RING ALREADY HAS SUCH VARIABLES/PARAMETERS!!!?
    626     // TODO: YOU CAN OVERCOME THIS BY MEANS SIMILAR TO "chooseSafeVarName" FROM NEW "matrix.lib"
     651    int i;
     652    list Lvar;
     653    for (i=1; i<=sI; i++)
     654    {
     655      Lvar[i] = safeVarName("@a(" + string(i) + ")");
     656    }
     657    list L@A = RL[1..4];
     658    L@A[2] = Lvar;
     659    L@A[3] = list(list("lp",intvec(1:sI)),list("C",intvec(0)));
     660    def @A = ring(L@A);
     661    L@A[2] = list(safeVarName("@z"));
     662    L@A[3][1] = list("dp",intvec(1));
     663    if (size(L@A[1])>1)
     664    {
     665      L@A[1][2] = L@A[1][2] + Lvar;
     666      L@A[1][3][size(L@A[1][3])+1] = list("lp",intvec(1:sI));
     667    }
     668    else
     669    {
     670      L@A[1] = list(p,Lvar,list(list("lp",intvec(1:sI))),ideal(0));
     671    }
     672    def @aA = ring(L@A);
    627673    def @B = save + @aA;
    628674    setring @B;
    629675    ideal I = imap(save,I);
    630676    // ------- 2. form the linear system for the undef coeffs ---
    631     int i;  poly W;  ideal QQ;
     677    poly W;  ideal QQ;
    632678    for (i=1; i<=sI; i++)
    633679    {
    634       W = W + @a(i)*I[i];
     680      W = W + par(np+i)*I[i];
    635681    }
    636682    while (W!=0)
     
    643689    ideal QQ = imap(@B,QQ);
    644690    // ------- 3. this QQ is a polynomial ideal, so "solve" the system -----
    645     dbprint(ppl, "linSyzSolve: starting Groebner basis computation with engine:", whichengine);
     691    dbprint(ppl, "// linSyzSolve: starting Groebner basis computation with engine:", whichengine);
    646692    QQ = engine(QQ,whichengine);
    647     dbprint(ppl, "QQ after engine:", QQ);
     693    dbprint(ppl, "// QQ after engine:", QQ);
    648694    if (dim(QQ) == -1)
    649695    {
    650       dbprint(ppl+1, "no solutions by linSyzSolve");
     696      dbprint(ppl+1, "// no solutions by linSyzSolve");
    651697      // output zeroes
    652698      setring save;
     
    658704    module MQQ = std(module(QQ));
    659705    AA = NF(AA,MQQ); // todo: we still receive NF warnings
    660     dbprint(ppl, "AA after NF:",AA);
     706    dbprint(ppl, "// AA after NF:",AA);
    661707    //    "AA after NF:"; print(AA);
    662708    for(i=1; i<=sI; i++)
     
    664710      AA = subst(AA,var(i),1);
    665711    }
    666     dbprint(ppl, "AA after subst:",AA);
     712    dbprint(ppl, "// AA after subst:",AA);
    667713    //    "AA after subst: "; print(AA);
    668714    vector v = (module(transpose(AA)))[1];
     
    687733RETURN:  vector, coefficient vector of the monic polynomial
    688734PURPOSE: compute the intersection of ideal I with the subalgebra K[f]
    689 ASSUME:  I is given as Groebner basis.
     735ASSUME:  I is given as Groebner basis, basering is not a qring.
    690736NOTE:    If the intersection is zero, this proc might not terminate.
    691737@*       If s>0 is given, it is searched for the generator of the intersection
     
    696742"
    697743{
     744  def save = basering;
     745  int n = nvars(save);
     746  list RL = ringlist(save);
     747  int i,j,k;
     748  if (RL[4]<>0)
     749  {
     750    ERROR ("basering must not be a qring");
     751  }
    698752  // assume I is given in Groebner basis
    699753  if (attrib(I,"isSB") <> 1)
    700754  {
    701     print("WARNING: The input has no SB attribute!");
    702     print(" Treating it as if it were a Groebner basis and proceeding...");
     755    print("// WARNING: The input has no SB attribute!");
     756    print("// Treating it as if it were a Groebner basis and proceeding...");
    703757    attrib(I,"isSB",1); // set attribute for suppressing NF messages
    704758  }
     
    711765    }
    712766  }
    713   int ppl = printlevel-voice+1;
     767  int ppl = printlevel-voice+2;
    714768  // ---case 1: I = basering---
    715769  if (size(I) == 1)
     
    717771    if (simplify(I,2)[1] == 1)
    718772    {
    719       return(gen(2)); // = s
    720     }
    721   }
    722   def save = basering;
    723   int n = nvars(save);
    724   int i,j,k;
     773      return(gen(1)); // = 1
     774    }
     775  }
    725776  // ---case 2: intersection is zero---
    726777  intvec degs = leadexp(s);
     
    752803    return(vector(0));
    753804  } 
    754   dbprint(ppl,"a lower bound for the degree of the insection is:");
    755   dbprint(ppl,degbound);
     805  dbprint(ppl,"// lower bound for the degree of the insection is " +string(degbound));
    756806  if (degbound == 0) // lm(s) does not appear in lm(I)
    757807  {
     
    766816  poly toNF,tobracket,newNF,rednewNF,oldNF,secNF;
    767817  i = 1;
    768   dbprint(ppl+1,"pIntersect starts...");
    769818  while (1)
    770819  {
    771820    if (bound>0 && i>bound) { return(vector(0)); }
    772     dbprint(ppl,"testing degree: "+string(i));
     821    dbprint(ppl,"// Testing degree "+string(i));
    773822    if (i>1)
    774823    {
     
    793842    rednewNF = ll[1];
    794843    l[i+1] = ll[2];
    795     dbprint(ppl,"newNF is:", newNF);
    796     dbprint(ppl,"rednewNF is:", rednewNF);
     844    dbprint(ppl-1,"// newNF is: "+string(newNF));
     845    dbprint(ppl-1,"// rednewNF is: "+string(rednewNF));
    797846    if (rednewNF != 0) // no linear dependency
    798847    {
     
    802851    else // there is a linear dependency, hence we are done
    803852    {
    804       dbprint(ppl+1,"the degree of the generator of the intersection is:", i);
     853      dbprint(ppl,"// degree of the generator of the intersection is: "+string(i));
    805854      break;
    806855    }
    807856  }
    808   dbprint(ppl,"used linear reductions:", l);
    809   // we obtain the coefficients of the generator of the intersection by the used reductions:
    810   ring @R = 0,(a(1..i+1)),dp;
    811   setring @R;
     857  dbprint(ppl-1,"// used linear reductions:", l);
     858  // we obtain the coefficients of the generator by the used reductions:
     859  list Lvar;
     860  for (j=1; j<=i+1; j++)
     861  {
     862    Lvar[j] = safeVarName("a("+string(j)+")");
     863  }
     864  list Lord = list("dp",intvec(1:(i+1))),list("C",intvec(0));
     865  list L@R = RL[1..4];
     866  L@R[2] = Lvar; L@R[3] = Lord;
     867  def @R = ring(L@R); setring @R;
    812868  list l = imap(save,l);
    813869  ideal C;
     
    817873    for (k=1;k<=j;k++)
    818874    {
    819       C[j] = C[j]+l[j][k]*a(k);
     875      C[j] = C[j]+l[j][k]*var(k);
    820876    }
    821877  }
    822878  for (j=i;j>=1;j--)
    823879  {
    824     C[i+1]= subst(C[i+1],a(j),a(j)+C[j]);
     880    C[i+1]= subst(C[i+1],var(j),var(j)+C[j]);
    825881  }
    826882  matrix m = coeffs(C[i+1],maxideal(1));
     
    833889  v = imap(@R,v);
    834890  kill @R;
    835   dbprint(ppl+1,"pIntersect finished");
    836891  return(v);
    837892}
     
    849904
    850905proc pIntersectSyz (poly s, ideal II, list #)
    851 "USAGE:  pIntersectSyz(f, I [,p,s,t]);  f a poly, I an ideal, p, t optial ints, p a prime number
     906"USAGE:  pIntersectSyz(f, I [,p,s,t]);  f poly, I ideal, p,t optial ints, p prime
    852907RETURN:  vector, coefficient vector of the monic polynomial
    853908PURPOSE: compute the intersection of an ideal I with the subalgebra K[f]
    854 ASSUME:  I is given as Groebner basis.
     909ASSUME:  I is given as Groebner basis, basering is free of parameters.
    855910NOTE:    If the intersection is zero, this procedure might not terminate.
    856 @*       If p>0 is given, this proc computes the generator of the intersection in char p first
    857 @*       and then only searches for a generator of the obtained degree in the basering.
    858 @*       Otherwise, it searched for all degrees by computing syzygies.
     911@*       If p>0 is given, this proc computes the generator of the intersection in
     912@*       char p first and then only searches for a generator of the obtained
     913@*       degree in the basering. Otherwise, it searched for all degrees by
     914@*       computing syzygies.
    859915@*       If s<>0, @code{std} is used for Groebner basis computations in char 0,
    860916@*       otherwise, and by default, @code{slimgb} is used.
    861 @*       If t<>0 and by default, @code{std} is used for Groebner basis computations in char >0,
    862 @*       otherwise, @code{slimgb} is used.
     917@*       If t<>0 and by default, @code{std} is used for Groebner basis
     918@*       computations in char >0, otherwise, @code{slimgb} is used.
    863919DISPLAY: If printlevel=1, progress debug messages will be printed,
    864920@*       if printlevel>=2, all the debug messages will be printed.
     
    870926  if (attrib(I,"isSB") <> 1)
    871927  {
    872     print("WARNING: The input has no SB attribute!");
    873     print(" Treating it as if it were a Groebner basis and proceeding...");
     928    print("// WARNING: The input has no SB attribute!");
     929    print("// Treating it as if it were a Groebner basis and proceeding...");
    874930    attrib(I,"isSB",1); // set attribute for suppressing NF messages
    875931  }
     
    920976    setring Rp;
    921977    kill @Rp;
    922     dbprint(ppl+1,"solving in ring ", Rp);
     978    dbprint(ppl+1,"// solving in ring ", Rp);
    923979    vector v;
    924980    map phi = save,maxideal(1);
     
    928984  }
    929985  i = 1;
    930   dbprint(ppl+1,"pIntersectSyz starts...");
    931   dbprint(ppl+1,"with ideal I=", I);
     986  dbprint(ppl+1,"// pIntersectSyz starts...");
     987  dbprint(ppl+1,"// with ideal I=", I);
    932988  while (1)
    933989  {
    934     dbprint(ppl,"i:"+string(i));
     990    dbprint(ppl,"// i:"+string(i));
    935991    if (i>1)
    936992    {
     
    9481004    }
    9491005    // look for a solution
    950     dbprint(ppl,"linSyzSolve starts with: "+string(matrix(NI)));
     1006    dbprint(ppl,"// linSyzSolve starts with: "+string(matrix(NI)));
    9511007    if (solveincharp<>0) // modular method
    9521008    {
     
    9561012      if (v!=0) // there is a modular solution
    9571013      {
    958         dbprint(ppl,"got solution in char ",solveincharp," of degree " ,i);
     1014        dbprint(ppl,"// got solution in char "+string(solveincharp)+" of degree "+string(i));
    9591015        setring save;
    9601016        v = linSyzSolve(NI,whichengine);
     
    9751031    }
    9761032    matrix MM[1][nrows(v)] = matrix(v);
    977     dbprint(ppl,"linSyzSolve ready  with: "+string(MM));
     1033    dbprint(ppl,"// linSyzSolve ready  with: "+string(MM));
    9781034    kill MM;
    9791035    //  "linSyzSolve ready with"; print(v);
     
    9891045      if (p!=0)
    9901046      {
    991         dbprint(ppl,"linSyzSolve: bad solution!");
     1047        dbprint(ppl,"// linSyzSolve: bad solution!");
    9921048      }
    9931049      else
    9941050      {
    995         dbprint(ppl,"linSyzSolve: got solution!");
     1051        dbprint(ppl,"// linSyzSolve: got solution!");
    9961052        // "got solution!";
    9971053        break;
     
    10011057    i++;
    10021058  }
    1003   dbprint(ppl+1,"pIntersectSyz finished");
     1059  dbprint(ppl+1,"// pIntersectSyz finished");
    10041060  return(v);
    10051061}
     
    10881144  }
    10891145  int substitution = int(#[2]);
    1090   ring S = 0,s,dp;
     1146  string s = safeVarName("s");
     1147  list RL = ringlist(save); RL = RL[1..4];
     1148  RL[2] = list(s); RL[3] = list(list("dp",intvec(1)),list("C",0));
     1149  def S = ring(RL); setring S;
    10911150  ideal J;
    10921151  for (i=1; i<=n; i++)
    10931152  {
    1094     J[i] = s;
     1153    J[i] = var(1);
    10951154  }
    10961155  map @m = save,J;
     
    10981157  if (substitution == 1)
    10991158  {
    1100     p = subst(p,s,-s-1);
     1159    p = subst(p,var(1),-var(1)-1);
    11011160  }
    11021161  // the rest of this proc is nicked from bernsteinBM from dmod.lib
    11031162  list P = factorize(p);//with constants and multiplicities
    1104   ideal bs; intvec m;   //the Bernstein polynomial is monic, so we are not interested in constants
     1163  ideal bs; intvec m;   //the BS poly is monic, so we are not interested in constants
    11051164  for (i=2; i<= size(P[1]); i++)  //we delete P[1][1] and P[2][1]
    11061165  {
     
    11091168  }
    11101169  bs =  normalize(bs);
    1111   bs = -subst(bs,s,0);
     1170  bs = -subst(bs,var(1),0);
    11121171  setring save;
    11131172  ideal bs = imap(S,bs);
     
    11231182  def save = basering;
    11241183  int n = nvars(save);
     1184  if (isCommutative() == 0) { ERROR("basering must be commutative"); }
     1185  if (char(save) <> 0) { ERROR("characteristic of basering has to be 0"); }
     1186  list L = ringlist(save);
     1187  int qr;
     1188  if (L[4] <> 0) // qring
     1189  {
     1190    print("// basering is qring:");
     1191    print("// discarding the quotient and proceeding...");
     1192    L[4] = 0;
     1193    qr = 1;
     1194    def save2 = ring(L);
     1195    setring save2;
     1196    poly f = imap(save,f);
     1197  }
    11251198  if (size(variables(f)) == 0) // f is constant
    11261199  {
     
    11291202  if (inorann == 0) // bfct using initial ideal
    11301203  {
    1131     def D = initialMalgrange(f,whichengine,methodord,1,u0);
     1204    def D = initialMalgrange(f,whichengine,methodord,u0);
    11321205    setring D;
    11331206    ideal J = inF;
     
    11541227      while (b == 0)
    11551228      {
    1156         dbprint(ppl,"number of run in the loop: "+string(i));
     1229        dbprint(ppl,"// number of run in the loop: "+string(i));
    11571230        int q = prime(random(lb,ub));
    11581231        if (findFirst(usedprimes,q)==0) // if q was not already used
    11591232        {
    11601233          usedprimes = usedprimes,q;
    1161           dbprint(ppl,"used prime is: "+string(q));
     1234          dbprint(ppl,"// used prime is: "+string(q));
    11621235          b = pIntersectSyz(s,J,q,whichengine,modengine);
    11631236        }
     
    11741247    b = pIntersect(s,J);
    11751248  }
    1176   setring save;
     1249  if (qr == 1) { setring save2; }
     1250  else { setring save; }
    11771251  vector b = imap(D,b);
    1178   if (inorann == 0)
    1179   {
    1180     list l = listofroots(b,1);
    1181   }
    1182   else
    1183   {
    1184     list l = listofroots(b,0);
     1252  if (inorann == 0) { list l = listofroots(b,1); }
     1253  else              { list l = listofroots(b,0); }
     1254  if (qr == 1)
     1255  {
     1256    setring save;
     1257    list l = imap(save2,l);
    11851258  }
    11861259  return(l);
     
    11921265PURPOSE: computes the roots of the Bernstein-Sato polynomial b(s)
    11931266@*       for the hypersurface defined by f.
    1194 ASSUME:  The basering is a commutative polynomial ring in char 0.
    1195 BACKGROUND: In this proc, the initial Malgrange ideal is computed according to the algorithm
    1196 @*       by Masayuki Noro and then a system of linear equations is solved by linear reductions.
     1267ASSUME:  The basering is commutative and of characteristic 0.
     1268BACKGROUND: In this proc, the initial Malgrange ideal is computed according to
     1269@*       the algorithm by Masayuki Noro and then a system of linear equations is
     1270@*       solved by linear reductions.
    11971271NOTE:    In the output list, the ideal contains all the roots
    11981272@*       and the intvec their multiplicities.
     
    12011275@*       If t<>0, a matrix ordering is used for Groebner basis computations,
    12021276@*       otherwise, and by default, a block ordering is used.
    1203 @*       If v is a positive weight vector, v is used for homogenization computations,
    1204 @*       otherwise and by default, no weights are used.
     1277@*       If v is a positive weight vector, v is used for homogenization
     1278@*       computations, otherwise and by default, no weights are used.
    12051279DISPLAY: If printlevel=1, progress debug messages will be printed,
    12061280@*       if printlevel>=2, all the debug messages will be printed.
     
    12531327
    12541328proc bfctSyz (poly f, list #)
    1255 "USAGE:  bfctSyz(f [,r,s,t,u,v]);  f a poly, r,s,t,u optional ints, v an optional intvec
     1329"USAGE:  bfctSyz(f [,r,s,t,u,v]);  f poly, r,s,t,u optional ints, v opt. intvec
    12561330RETURN:  list of ideal and intvec
    1257 PURPOSE: computes the roots of the Bernstein-Sato polynomial b(s) 
     1331PURPOSE: computes the roots of the Bernstein-Sato polynomial b(s)
    12581332@*       for the hypersurface defined by f
    1259 ASSUME:  The basering is a commutative polynomial ring in char 0.
    1260 BACKGROUND: In this proc, the initial Malgrange ideal is computed according to the algorithm
    1261 @*       by Masayuki Noro and then a system of linear equations is solved by computing syzygies.
    1262 NOTE:    In the output list, the ideal contains all the roots
    1263 @*       and the intvec their multiplicities.
    1264 @*       If r<>0, @code{std} is used for GB computations in characteristic 0,
    1265 @*       otherwise, and by default, @code{slimgb} is used.
    1266 @*       If s<>0, a matrix ordering is used for GB computations, otherwise,
     1333ASSUME:  The basering is commutative and of characteristic 0.
     1334BACKGROUND: In this proc, the initial Malgrange ideal is computed according to
     1335@*       the algorithm by Masayuki Noro and then a system of linear equations is
     1336@*       solved by computing syzygies.
     1337NOTE:    In the output list, the ideal contains all the roots and the intvec
     1338@*       their multiplicities.
     1339@*       If r<>0, @code{std} is used for GB computations in characteristic 0,
     1340@*       otherwise, and by default, @code{slimgb} is used.
     1341@*       If s<>0, a matrix ordering is used for GB computations, otherwise,
    12671342@*       and by default, a block ordering is used.
    1268 @*       If t<>0, the computation of the intersection is solely performed over 
     1343@*       If t<>0, the computation of the intersection is solely performed over
    12691344@*       charasteristic 0, otherwise and by default, a modular method is used.
    1270 @*       If u<>0 and by default, @code{std} is used for GB computations in 
    1271 @*       characteristic >0, otherwise, @code{slimgb} is used. 
    1272 @*       If v is a positive weight vector, v is used for homogenization 
     1345@*       If u<>0 and by default, @code{std} is used for GB computations in
     1346@*       characteristic >0, otherwise, @code{slimgb} is used.
     1347@*       If v is a positive weight vector, v is used for homogenization
    12731348@*       computations, otherwise and by default, no weights are used.
    12741349DISPLAY: If printlevel=1, progress debug messages will be printed,
     
    12851360  // and one for the engine used for Groebner basis computations in char >0
    12861361  // in # can also be the optional weight vector
    1287   def save = basering;
    1288   int n = nvars(save);
     1362  int n = nvars(basering);
    12891363  int whichengine = 0; // default
    12901364  int methodord   = 0; // default
     
    13431417"USAGE:  bfctIdeal(I,w[,s,t]);  I an ideal, w an intvec, s,t optional ints
    13441418RETURN:  list of ideal and intvec
    1345 PURPOSE: computes the roots of the global b-function of I wrt the weight vector (-w,w).
    1346 ASSUME:  The basering is the n-th Weyl algebra in char 0, where the sequence of
    1347 @*       the variables is x(1),...,x(n),D(1),...,D(n).
    1348 BACKGROUND:  In this proc, the initial ideal of I is computed according to the algorithm by
    1349 @*       Masayuki Noro and then a system of linear equations is solved by linear reductions.
    1350 NOTE:    In the output list, the ideal contains all the roots
    1351 @*       and the intvec their multiplicities.
     1419PURPOSE: computes the roots of the global b-function of I wrt the weight (-w,w).
     1420ASSUME:  The basering is the n-th Weyl algebra in characteristic 0 and  for all
     1421@*       1<=i<=n the identity var(i+n)*var(i)=var(i)*var(i+1)+1 holds, i.e. the
     1422@*       sequence of variables is given by x(1),...,x(n),D(1),...,D(n),
     1423@*       where D(i) is the differential operator belonging to x(i).
     1424@*       Further assume that I is holonomic.
     1425BACKGROUND:  In this proc, the initial ideal of I is computed according to the
     1426@*       algorithm by Masayuki Noro and then a system of linear equations is
     1427@*       solved by linear reductions.
     1428NOTE:    In the output list, the ideal contains all the roots and the intvec
     1429@*       their multiplicities.
    13521430@*       If s<>0, @code{std} is used for GB computations in characteristic 0,
    13531431@*       otherwise, and by default, @code{slimgb} is used.
     
    13791457    }
    13801458  }
     1459  if (isWeyl()==0) { ERROR("basering is not a Weyl algebra"); }
     1460  for (i=1; i<=n; i++)
     1461  {
     1462    if (bracket(var(i+n),var(i))<>1)
     1463    {
     1464      ERROR(string(var(i+n))+" is not a differential operator for " +string(var(i)));
     1465    }
     1466  }
     1467  int isH = isHolonomic(I);
     1468  if (isH<>1)
     1469  {
     1470    print("// given ideal is not holonomic");
     1471    print("// setting bound for degree of b-fubction to 10 and proceeding");
     1472    isH = 10;
     1473  }
     1474  else { isH = 0; } // no degree bound for pIntersect
    13811475  ideal J = initialIdealW(I,-w,w,whichengine,methodord);
    13821476  poly s;
     
    13851479    s = s + w[i]*var(i)*var(n+i);
    13861480  }
    1387   vector b = pIntersect(s,J);
    1388   list l = listofroots(b,0);
     1481  vector b = pIntersect(s,J,isH);
     1482  list RL = ringlist(save); RL = RL[1..4];
     1483  RL[2] = list(safeVarName("s"));
     1484  RL[3] = list(list("dp",intvec(1)),list("C",intvec(0)));
     1485  def @S = ring(RL); setring @S;
     1486  vector b = imap(save,b);
     1487  poly bs = vec2poly(b);
     1488  list l = bFactor(bs);
     1489  setring save;
     1490  list l = imap(@S,l);
    13891491  return(l);
    13901492}
     
    14071509"USAGE:  bfctOneGB(f [,s,t]);  f a poly, s,t optional ints
    14081510RETURN:  list of ideal and intvec
    1409 PURPOSE: computes the roots of the Bernstein-Sato polynomial b(s) for the 
     1511PURPOSE: computes the roots of the Bernstein-Sato polynomial b(s) for the
    14101512@*       hypersurface defined by f, using only one GB computation
    1411 ASSUME:  The basering is a commutative polynomial ring in char 0.
    1412 BACKGROUND: In this proc, the initial Malgrange ideal is computed based on the 
     1513ASSUME:  The basering is commutative and of characteristic 0.
     1514BACKGROUND: In this proc, the initial Malgrange ideal is computed based on the
    14131515@*       algorithm by Masayuki Noro and combined with an elimination ordering.
    1414 NOTE:    In the output list, the ideal contains all the roots
    1415 @*       and the intvec their multiplicities.
     1516NOTE:    In the output list, the ideal contains all the roots and the intvec
     1517@*       their multiplicities.
    14161518@*       If s<>0, @code{std} is used for the GB computation, otherwise,
    14171519@*       and by default, @code{slimgb} is used.
     
    14241526{
    14251527  int ppl = printlevel - voice +2;
     1528  if (isCommutative() == 0) { ERROR("basering must be commutative"); }
    14261529  def save = basering;
    14271530  int n = nvars(save);
     1531  if (char(save) <> 0)
     1532  {
     1533    ERROR("characteristic of basering has to be 0");
     1534  }
     1535  list L = ringlist(save);
     1536  int qr;
     1537  if (L[4] <> 0) // qring?
     1538  {
     1539    print("// basering is qring:");
     1540    print("// discarding the quotient and proceeding...");
     1541    L[4] = 0;
     1542    qr = 1;
     1543    def save2 = ring(L);
     1544    setring save2;
     1545    poly f = imap(save,f);
     1546  }
    14281547  int noofvars = 2*n+4;
    14291548  int i;
     
    14541573  if (methodord == 0) // default: block ordering
    14551574  {
    1456     ring Dh = 0,(t,s,x(n..1),Dt,D(n..1),h),(a(@a),a(@a2),a(uv),dp(noofvars-1),lp(1));
     1575    ring @Dh = 0,(t,s,x(n..1),Dt,D(n..1),h),(a(@a),a(@a2),a(uv),dp(noofvars-1),lp(1));
    14571576  }
    14581577  else // M() ordering
     
    14651584      @Ord[2+i,noofvars - i] = -1;
    14661585    }
    1467     dbprint(ppl,"weights for ordering:",transpose(@a));
    1468     dbprint(ppl,"the ordering matrix:",@Ord);
    1469     ring Dh = 0,(t,s,x(n..1),Dt,D(n..1),h),(a(@a),a(@a2),M(@Ord));
    1470   }
    1471   dbprint(ppl,"the ring Dh:",Dh);
     1586    dbprint(ppl,"// weights for ordering: "+string(transpose(@a)));
     1587    dbprint(ppl,"// the ordering matrix:",@Ord);
     1588    ring @Dh = 0,(t,s,x(n..1),Dt,D(n..1),h),(a(@a),a(@a2),M(@Ord));
     1589  }
     1590  dbprint(ppl,"// the ring Dh:",Dh);
    14721591  // non-commutative relations
    14731592  matrix @relD[noofvars][noofvars];
     
    14791598    @relD[i+2,n+3+i] = h^2;
    14801599  }
    1481   dbprint(ppl,"nc relations:",@relD);
    1482   def DDh = nc_algebra(1,@relD);
    1483   setring DDh;
    1484   dbprint(ppl,"computing in ring",DDh);
     1600  dbprint(ppl,"// nc relations:",@relD);
     1601  def Dh = nc_algebra(1,@relD);
     1602  setring Dh;
     1603  dbprint(ppl,"// computing in ring",DDh);
    14851604  ideal I;
    14861605  poly f = imap(r,f);
     
    14921611    I = I, D(i)+diff(f,x(i))*Dt;
    14931612  }
    1494   dbprint(ppl, "starting Groebner basis computation with engine:", whichengine);
     1613  dbprint(ppl, "// starting Groebner basis computation with engine: "+string(whichengine));
    14951614  I = engine(I, whichengine);
    1496   dbprint(ppl, "finished Groebner basis computation");
    1497   dbprint(ppl, "I before dehomogenization is" ,I);
     1615  dbprint(ppl, "// finished Groebner basis computation");
     1616  dbprint(ppl, "// I before dehomogenization: "+string(I));
    14981617  I = subst(I,h,1); // dehomogenization
    1499   dbprint(ppl, "I after dehomogenization is" ,I);
     1618  dbprint(ppl, "// I after dehomogenization: " +string(I));
    15001619  I = inForm(I,uv); // we are only interested in the initial form w.r.t. uv
    1501   dbprint(ppl, "the initial ideal:", string(matrix(I)));
     1620  dbprint(ppl, "// the initial ideal:", string(matrix(I)));
    15021621  intvec tonselect = 1;
    15031622  for (i=3; i<=2*n+4; i++) { tonselect = tonselect,i; }
    15041623  I = nselect(I,tonselect);
    1505   dbprint(ppl, "generators containing only s:", string(matrix(I)));
     1624  dbprint(ppl, "// generators containing only s:", string(matrix(I)));
    15061625  I = engine(I, whichengine); // is now a principal ideal;
    1507   setring save;
     1626  if (qr == 1) { setring save2; }
     1627  else { setring save; }
    15081628  ideal J; J[2] = var(1);
    1509   map @m = DDh,J;
     1629  map @m = Dh,J;
    15101630  ideal I = @m(I);
    15111631  poly p = I[1];
    15121632  list l = listofroots(p,1);
     1633  if (qr == 1)
     1634  {
     1635    setring save;
     1636    list l = imap(save2,l);
     1637  }
    15131638  return(l);
    15141639}
     
    15251650"USAGE:  bfctAnn(f [,r]);  f a poly, r an optional int
    15261651RETURN:  list of ideal and intvec
    1527 PURPOSE: computes the roots of the Bernstein-Sato polynomial b(s)
    1528 @*       for the hypersurface defined by f
    1529 ASSUME:  The basering is a commutative polynomial ring in char 0.
     1652PURPOSE: computes the roots of the Bernstein-Sato polynomial b(s) for the
     1653@*       hypersurface defined by f.
     1654ASSUME:  The basering is commutative and of characteristic 0.
    15301655BACKGROUND: In this proc, ann(f^s) is computed and then a system of linear
    15311656@*       equations is solved by linear reductions.
    1532 NOTE:    In the output list, the ideal contains all the roots
    1533 @*       and the intvec their multiplicities.
     1657NOTE:    In the output list, the ideal contains all the roots and the intvec
     1658@*       their multiplicities.
    15341659@*       If r<>0, @code{std} is used for GB computations,
    15351660@*       otherwise, and by default, @code{slimgb} is used.
     
    15491674    }
    15501675  }
    1551   list b = bfctengine(f,1,whichengine,0,1,0,0,0);
     1676  list b = bfctengine(f,1,whichengine,0,0,0,0,0);
    15521677  return(b);
    15531678}
Note: See TracChangeset for help on using the changeset viewer.