Changeset 578051 in git for Singular/LIB/freegb.lib


Ignore:
Timestamp:
Dec 18, 2017, 4:15:00 PM (6 years ago)
Author:
Karim Abou Zeid <karim23697@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
909b29541ce0c334010bba6696154e22461eb5ce
Parents:
9b58b3fcc6a12daf4ea426458fac85c628277f67179aaba41255e379952db14e553b6a3df355202c
Message:
Merge branch 'spielwiese' into develop
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/LIB/freegb.lib

    r179aaba r578051  
    33category="Noncommutative";
    44info="
    5 LIBRARY: freegb.lib   Compute two-sided Groebner bases in free algebras via
    6 @*                    letterplace
     5LIBRARY: freegb.lib   Compute two-sided Groebner bases in free algebras via letterplace approach
    76AUTHORS: Viktor Levandovskyy,     viktor.levandovskyy@math.rwth-aachen.de
    8 @*       Grischa Studzinski,      grischa.studzinski@math.rwth-aachen.de
    9 
    10 OVERVIEW: For the theory, see chapter 'Letterplace' in the Singular Manual
     7       Grischa Studzinski,      grischa.studzinski@math.rwth-aachen.de
     8
     9OVERVIEW: For the theory, see chapter 'Letterplace' in the @sc{Singular} Manual
    1110
    1211PROCEDURES:
    13 makeLetterplaceRing(d);    creates a ring with d blocks of shifted original
    14 @*                         variables
    15 letplaceGBasis(I); computes two-sided Groebner basis of a letterplace ideal I
    16 @*                 up to a degree bound
    17 lpNF(f,I);      normal form of f with respect to ideal I
    18 freeGBasis(L, n);  computes two-sided Groebner basis of an ideal, encoded via
    19 @*                 list L, up to degree n
     12makeLetterplaceRing(d); creates a ring with d blocks of shifted original variables
     13letplaceGBasis(I); computes two-sided Groebner basis of a letterplace ideal I up to a degree bound
     14lpNF(f,I); two-sided normal form of f with respect to ideal I
    2015setLetterplaceAttributes(R,d,b); supplies ring R with the letterplace structure
    21 
     16freeGBasis(L, n);  computes two-sided Groebner basis of an ideal, encoded via list L, up to degree n
    2217
    2318lpMult(f,g);    letterplace multiplication of letterplace polynomials
    2419shiftPoly(p,i); compute the i-th shift of letterplace polynomial p
    2520lpPower(f,n);   natural power of a letterplace polynomial
    26 lp2lstr(K, s);      convert letter-place ideal to a list of modules
    27 lst2str(L[, n]);   convert a list (of modules) into polynomials in free algebra
    28 mod2str(M[, n]); convert a module into a polynomial in free algebra
     21lieBracket(a,b[, N]);  compute Lie bracket ab-ba of two letterplace polynomials
     22
     23lp2lstr(K, s);  convert a letterplace ideal into a list of modules
     24lst2str(L[, n]); convert a list (of modules) into polynomials in free algebra via strings
     25mod2str(M[, n]); convert a module into a polynomial in free algebra via strings
    2926vct2str(M[, n]);   convert a vector into a word in free algebra
    30 lieBracket(a,b[, N]);  compute Lie bracket ab-ba of two letterplace polynomials
    31 serreRelations(A,z);   compute the homogeneous part of Serre's relations
    32 @*                     associated to a generalized Cartan matrix A
    33 fullSerreRelations(A,N,C,P,d); compute the ideal of all Serre's relations
    34 @*                             associated to a generalized Cartan matrix A
    35 isVar(p);                   check whether p is a power of a single variable
     27
     28serreRelations(A,z); compute the homogeneous part of Serre's relations associated to a generalized Cartan matrix A
     29fullSerreRelations(A,N,C,P,d); compute the ideal of all Serre's relations associated to a generalized Cartan matrix A
     30isVar(p);              check whether p is a power of a single variable
    3631ademRelations(i,j);    compute the ideal of Adem relations for i<2j in char 0
    3732
     
    973968"
    974969{
    975   int use_old_mlr = 0;
     970  int alternativeVersion = 0;
    976971  if ( size(#)>0 )
    977972  {
    978     if (( typeof(#[1]) == "int" ) || ( typeof(#[1]) == "poly" ) )
    979     {
    980       poly x = poly(#[1]);
    981       if (x!=0)
    982       {
    983         use_old_mlr = 1;
    984       }
    985     }
    986   }
    987   if (use_old_mlr)
     973    if (typeof(#[1]) == "int")
     974    {
     975      alternativeVersion = #[1];
     976    }
     977  }
     978  if (alternativeVersion == 1)
    988979  {
    989980    def @A = makeLetterplaceRing1(d);
    990981  }
    991   else
    992   {
    993     def @A = makeLetterplaceRing2(d);
     982  else {
     983    if (alternativeVersion == 2)
     984    {
     985      def @A = makeLetterplaceRing2(d);
     986    }
     987    else {
     988      def @A = makeLetterplaceRing4(d);
     989    }
    994990  }
    995991  return(@A);
     
    12051201}
    12061202
     1203static proc makeLetterplaceRing4(int d)
     1204"USAGE:  makeLetterplaceRing2(d); d an integer
     1205RETURN:  ring
     1206PURPOSE: creates a Letterplace ring with a Dp ordering, suitable for
     1207@* the use of non-homogeneous letterplace
     1208NOTE: the matrix for the ordering looks as follows: first row is 1,1,...,1
     1209EXAMPLE: example makeLetterplaceRing2; shows examples
     1210"
     1211{
     1212
     1213  // ToDo future: inherit positive weights in the orig ring
     1214  // complain on nonpositive ones
     1215
     1216  // d = up to degree, will be shifted to d+1
     1217  if (d<1) {"bad d"; return(0);}
     1218
     1219  int uptodeg = d; int lV = nvars(basering);
     1220
     1221  int ppl = printlevel-voice+2;
     1222  string err = "";
     1223
     1224  int i,j,s;
     1225  def save = basering;
     1226  int D = d-1;
     1227  list LR  = ringlist(save);
     1228  list L, tmp, tmp2, tmp3;
     1229  L[1] = LR[1]; // ground field
     1230  L[4] = LR[4]; // quotient ideal
     1231  tmp  = LR[2]; // varnames
     1232  s = size(LR[2]);
     1233  for (i=1; i<=D; i++)
     1234  {
     1235    for (j=1; j<=s; j++)
     1236    {
     1237      tmp[i*s+j] = string(tmp[j])+"("+string(i+1)+")";
     1238    }
     1239  }
     1240  for (i=1; i<=s; i++)
     1241  {
     1242    tmp[i] = string(tmp[i])+"("+string(1)+")";
     1243  }
     1244  L[2] = tmp;
     1245  list OrigNames = LR[2];
     1246
     1247  s = size(LR[3]);
     1248  list ordering;
     1249  ordering[1] = list("Dp",intvec(1: int(d*lV)));
     1250  ordering[2] = LR[3][s]; // module ord to place at the very end
     1251  LR[3] = ordering;
     1252
     1253  L[3] = LR[3];
     1254  attrib(L,"maxExp",1);
     1255  def @R = ring(L);
     1256  def @@R = setLetterplaceAttributes(@R,uptodeg,lV);
     1257  return (@@R);
     1258}
     1259example
     1260{
     1261  "EXAMPLE:"; echo = 2;
     1262  ring r = 0,(x,y,z),(dp(1),dp(2));
     1263  def A = makeLetterplaceRing2(2);
     1264  setring A;
     1265  A;
     1266  attrib(A,"isLetterplaceRing");
     1267  attrib(A,"uptodeg");  // degree bound
     1268  attrib(A,"lV"); // number of variables in the main block
     1269}
     1270
    12071271// P[s;sigma] approach
    12081272static proc makeLetterplaceRing3(int d)
     
    13141378  attrib(A,"lV"); // number of variables in the main block
    13151379}
    1316 
    1317 
    13181380
    13191381/* EXAMPLES:
     
    26002662  if (i>N)
    26012663  {
    2602     ERROR("The total number of elements in input ideals must not exceed the dimension of the ground ring");
     2664    string s1="The total number of elements in input ideals";
     2665    string s2="must not exceed the dimension of the ground ring";
     2666    ERROR(s1+s2);
    26032667  }
    26042668  if (i < N)
     
    30293093*/
    30303094
    3031 //static
    3032 proc lpMultX(poly f, poly g)
     3095static proc lpMultX(poly f, poly g)
    30333096{
    30343097  /* multiplies two polys in a very general setting correctly */
     
    30833146}
    30843147
    3085 // TODO:
    30863148// multiply two letterplace polynomials, lpMult: done
    30873149// reduction/ Normalform? needs kernel stuff
     
    31723234//@* else there wouldn't be an dvec representation
    31733235
    3174 //Mainprocedure for the user
     3236//Main procedure for the user
    31753237
    31763238proc lpNF(poly p, ideal G)
     
    31813243being a Letterplace Groebner basis (no check for this will be done)
    31823244NOTE: Strategy: take the smallest monomial wrt ordering for reduction
    3183 @*     For homogenous ideals the shift does not matter
    3184 @*     For non-homogenous ideals the first shift will be the smallest monomial
     3245-     For homogenous ideals the shift does not matter
     3246-     For non-homogenous ideals the first shift will be the smallest monomial
    31853247EXAMPLE: example lpNF; shows examples
    31863248"
     
    31893251 G = sort(G)[1];
    31903252 list L = makeDVecI(G);
    3191  return(normalize(lpNormalForm1(p,G,L)));
     3253 return(normalize(lpNormalForm2(p,G,L)));
    31923254}
    31933255example
     
    32143276RETURN: list of intvecs
    32153277PURPOSE: convert G into a list of intvecs, corresponding to the exponent vector
    3216 @* of the leading monomials of G
     3278 of the leading monomials of G
    32173279"
    32183280{int i; list L;
     
    32203282 return(L);
    32213283}
    3222 
    32233284
    32243285static proc delSupZero(intvec I)
     
    32473308}
    32483309
    3249 
    32503310static proc delSupZeroList(list L)
    32513311"USUAGE:delSupZeroList(L); L a list, containing intvecs
     
    33263386}
    33273387
    3328 
    3329 
    3330 //the actual normalform procedure, if a user want not to presort the ideal, just make it not static
    3331 
     3388//the first normal form procedure, if a user want not to presort the ideal, just make it not static
    33323389
    33333390static proc lpNormalForm1(poly p, ideal G, list L)
     
    33583415
    33593416
     3417// new VL; called from lpNF
     3418static proc lpNormalForm2(poly pp, ideal G, list L)
     3419"USUAGE:lpNormalForm2(p,G);
     3420RETURN:poly
     3421PURPOSE:computation of the normal form of p w.r.t. G
     3422ASSUME: p is a Letterplace polynomial, G is a set of Letterplace polynomials
     3423NOTE: Taking the first possible reduction
     3424"
     3425{
     3426 poly one = 1;
     3427 if ( (pp == 0) || (leadmonom(pp) == one) ) { return(pp); }
     3428 poly p = pp; poly q;
     3429 int i; int s; intvec V;
     3430 while ( (p != 0) && (leadmonom(p) != one) )
     3431 {
     3432   //"entered while with p="; p;
     3433   V = makeDVec(delSupZero(leadexp(p)));
     3434   i = 0;
     3435   s = -1;
     3436   //"look for divisor";
     3437   while ( (s == -1) && (i<size(L)) )
     3438   {
     3439     i = i+1;
     3440     s = dShiftDiv(V, L[i])[1];
     3441   }
     3442 // now, out of here: either i=size(L) and s==-1 => no reduction
     3443 // otherwise: i<=size(L) and s!= -1 => reduction
     3444    //"out of divisor search: s="; s; "i="; i;
     3445    if (s != -1)
     3446    {
     3447    //"start reducing with G[i]:";
     3448      p = lpReduce(p,G[i],s); // lm-reduction
     3449      //"reduced to p="; p;
     3450    }
     3451    else
     3452    {
     3453      // ie no lm-reduction possible; proceed with the tail reduction
     3454      q = p-lead(p);
     3455      p = lead(p);
     3456      if (q!=0)
     3457      {
     3458        p = p + lpNormalForm2(q,G,L);
     3459      }
     3460      return(p);
     3461    }
     3462 }
     3463 // out of while when p==0 or p == const
     3464 return(p);
     3465}
     3466
     3467
    33603468
    33613469
     
    35213629// // interface
    35223630
    3523 // proc whichshift(poly p, int numvars)
     3631// static proc whichshift(poly p, int numvars)
    35243632// {
    35253633// // numvars = number of vars of the orig free algebra
     
    35383646
    35393647// LIB "qhmoduli.lib";
    3540 // proc polyshift(poly p,  int numvars)
     3648// static proc polyshift(poly p,  int numvars)
    35413649// {
    35423650//   poly q = p; int i = 0;
     
    36153723  lpMultX(a,b); // seems to work properly
    36163724}
     3725
     3726/* THE FOLLOWING IS UNDER DEVELOPMENT
     3727// copied following from freegb_wrkcp.lib by Karim Abou Zeid on 07.04.2017:
     3728// makeLetterplaceRingElim(int d)
     3729// makeLetterplaceRingNDO(int d)
     3730// setLetterplaceAttributesElim(def R, int uptodeg, int lV)
     3731// lpElimIdeal(ideal I)
     3732// makeLetterplaceRingWt(int d, intvec W)
     3733
     3734static proc makeLetterplaceRingElim(int d)
     3735"USAGE:  makeLetterplaceRingElim(d); d integers
     3736RETURN:  ring
     3737PURPOSE: creates a ring with an elimination ordering
     3738NOTE: the matrix for the ordering looks as follows: first row is 1,..,0,1,0,..
     3739@* then 0,1,0,...,0,0,1,0... and so on, lastly its lp
     3740@* this ordering is only correct if only polys with same shift are compared
     3741EXAMPLE: example makeLetterplaceRingElim; shows examples
     3742"
     3743{
     3744
     3745  // ToDo future: inherit positive weights in the orig ring
     3746  // complain on nonpositive ones
     3747
     3748  // d = up to degree, will be shifted to d+1
     3749  if (d<1) {"bad d"; return(0);}
     3750
     3751  int uptodeg = d; int lV = nvars(basering);
     3752
     3753  int ppl = printlevel-voice+2;
     3754  string err = "";
     3755
     3756  int i,j,s; intvec iV,iVl;
     3757  def save = basering;
     3758  int D = d-1;
     3759  list LR  = ringlist(save);
     3760  list L, tmp, tmp2, tmp3;
     3761  L[1] = LR[1]; // ground field
     3762  L[4] = LR[4]; // quotient ideal
     3763  tmp  = LR[2]; // varnames
     3764  s = size(LR[2]);
     3765  for (i=1; i<=D; i++)
     3766  {
     3767    for (j=1; j<=s; j++)
     3768    {
     3769      tmp[i*s+j] = string(tmp[j])+"("+string(i+1)+")";
     3770    }
     3771  }
     3772  for (i=1; i<=s; i++)
     3773  {
     3774    tmp[i] = string(tmp[i])+"("+string(1)+")";
     3775  }
     3776  L[2] = tmp;
     3777  L[3] = list();
     3778  list OrigNames = LR[2];
     3779  s = size(LR[3]);
     3780  //creation of first block
     3781
     3782  if (s==2)
     3783  {
     3784    // not a blockord, 1 block + module ord
     3785    tmp = LR[3][s]; // module ord
     3786    for (i = 1; i <= lV;  i++)
     3787    {
     3788      iV = (0: lV);
     3789      iV[i] = 1;
     3790      iVl = iV;
     3791      for (j = 1; j <= D; j++)
     3792       { iVl = iVl,iV; }
     3793      L[3][i] = list("a",iVl);
     3794    }
     3795//    for (i=1; i<=d; i++)
     3796//    {
     3797//      LR[3][s-1+i] = LR[3][1];
     3798//    }
     3799    //    LR[3][s+D] = tmp;
     3800    //iV = (1:(d*lV));
     3801    L[3][lV+1] = list("lp",(1:(d*lV)));
     3802    L[3][lV+2] = tmp;
     3803  }
     3804  else {ERROR("Please set the ordering of basering to dp");}
     3805//  if (s>2)
     3806//  {
     3807//    // there are s-1 blocks
     3808//    int nb = s-1;
     3809//    tmp = LR[3][s]; // module ord to place at the very end
     3810//   tmp2 = LR[3]; tmp2 = tmp2[1..nb];
     3811//    LR[3][1] = list("a",LTO);
     3812//    //tmp3[1] = list("a",intvec(1: int(d*lV))); // deg-ord, insert as the 1st
     3813//    for (i=1; i<=d; i++)
     3814//    {
     3815//      tmp3 = tmp3 + tmp2;
     3816//    }
     3817//    tmp3 = tmp3 + list(tmp);
     3818//    LR[3] = tmp3;
     3819//     for (i=1; i<=d; i++)
     3820//     {
     3821//       for (j=1; j<=nb; j++)
     3822//       {
     3823//         //        LR[3][i*nb+j+1]= LR[3][j];
     3824//         LR[3][i*nb+j+1]= tmp2[j];
     3825//       }
     3826//     }
     3827//     //    size(LR[3]);
     3828//     LR[3][(s-1)*d+2] = tmp;
     3829//     LR[3] = list("a",intvec(1: int(d*lV))) + LR[3]; // deg-ord, insert as the 1st
     3830    // remove everything behind nb*(D+1)+1 ?
     3831    //    tmp = LR[3];
     3832    //    LR[3] = tmp[1..size(tmp)-1];
     3833 // }
     3834 // L[3] = LR[3];
     3835  def @R = ring(L);
     3836  //  setring @R;
     3837  //  int uptodeg = d; int lV = nvars(basering); // were defined before
     3838  def @@R = setLetterplaceAttributesElim(@R,uptodeg,lV);
     3839  return (@@R);
     3840}
     3841example
     3842{
     3843  "EXAMPLE:"; echo = 2;
     3844  ring r = 0,(x,y,z),lp;
     3845  def A = makeLetterplaceRingElim(2);
     3846  setring A;
     3847  A;
     3848  attrib(A,"isLetterplaceRing");
     3849  attrib(A,"uptodeg");  // degree bound
     3850  attrib(A,"lV"); // number of variables in the main block
     3851}
     3852
     3853
     3854
     3855static proc makeLetterplaceRingNDO(int d)
     3856"USAGE:  makeLetterplaceRingNDO(d); d an integer
     3857RETURN:  ring
     3858PURPOSE: creates a ring with a non-degree first ordering, suitable for
     3859@* the use of non-homogeneous letterplace
     3860NOTE: the matrix for the ordering looks as follows:
     3861@*    'd' blocks of shifted original variables
     3862EXAMPLE: example makeLetterplaceRingNDO; shows examples
     3863"
     3864{
     3865
     3866  // ToDo future: inherit positive weights in the orig ring
     3867  // complain on nonpositive ones
     3868
     3869  // d = up to degree, will be shifted to d+1
     3870  if (d<1) {"bad d"; return(0);}
     3871
     3872  int uptodeg = d; int lV = nvars(basering);
     3873
     3874  int ppl = printlevel-voice+2;
     3875  string err = "";
     3876
     3877  int i,j,s;
     3878  def save = basering;
     3879  int D = d-1;
     3880  list LR  = ringlist(save);
     3881  list L, tmp, tmp2, tmp3;
     3882  L[1] = LR[1]; // ground field
     3883  L[4] = LR[4]; // quotient ideal
     3884  tmp  = LR[2]; // varnames
     3885  s = size(LR[2]);
     3886  for (i=1; i<=D; i++)
     3887  {
     3888    for (j=1; j<=s; j++)
     3889    {
     3890      tmp[i*s+j] = string(tmp[j])+"("+string(i+1)+")";
     3891    }
     3892  }
     3893  for (i=1; i<=s; i++)
     3894  {
     3895    tmp[i] = string(tmp[i])+"("+string(1)+")";
     3896  }
     3897  L[2] = tmp;
     3898  list OrigNames = LR[2];
     3899  // ordering: one 1..1 a above
     3900  // ordering: d blocks of the ord on r
     3901  // try to get whether the ord on r is blockord itself
     3902  // TODO: make L(2) ordering! exponent is maximally 2
     3903  s = size(LR[3]);
     3904  if (s==2)
     3905  {
     3906    // not a blockord, 1 block + module ord
     3907    tmp = LR[3][s]; // module ord
     3908    for (i=1; i<=d; i++)
     3909    {
     3910      LR[3][i] = LR[3][1];
     3911    }
     3912    //    LR[3][s+D] = tmp;
     3913    LR[3][d+1] = tmp;
     3914    //LR[3][1] = list("a",intvec(1: int(d*lV))); // deg-ord not wanted here
     3915  }
     3916  if (s>2)
     3917  {
     3918    // there are s-1 blocks
     3919    int nb = s-1;
     3920    tmp = LR[3][s]; // module ord to place at the very end
     3921    tmp2 = LR[3]; tmp2 = tmp2[1..nb];
     3922    //tmp3[1] = list("a",intvec(1: int(d*lV))); // deg-ord not wanted here
     3923    for (i=1; i<=d; i++)
     3924    {
     3925      tmp3 = tmp3 + tmp2;
     3926    }
     3927    tmp3 = tmp3 + list(tmp);
     3928    LR[3] = tmp3;
     3929//     for (i=1; i<=d; i++)
     3930//     {
     3931//       for (j=1; j<=nb; j++)
     3932//       {
     3933//         //        LR[3][i*nb+j+1]= LR[3][j];
     3934//         LR[3][i*nb+j+1]= tmp2[j];
     3935//       }
     3936//     }
     3937//     //    size(LR[3]);
     3938//     LR[3][(s-1)*d+2] = tmp;
     3939//     LR[3] = list("a",intvec(1: int(d*lV))) + LR[3]; // deg-ord, insert as the 1st
     3940    // remove everything behind nb*(D+1)+1 ?
     3941    //    tmp = LR[3];
     3942    //    LR[3] = tmp[1..size(tmp)-1];
     3943  }
     3944  L[3] = LR[3];
     3945  def @R = ring(L);
     3946  //  setring @R;
     3947  //  int uptodeg = d; int lV = nvars(basering); // were defined before
     3948  def @@R = setLetterplaceAttributes(@R,uptodeg,lV);
     3949  return (@@R);
     3950}
     3951example
     3952{
     3953  "EXAMPLE:"; echo = 2;
     3954  ring r = 0,(x,y,z),lp;
     3955  def A = makeLetterplaceRingNDO(2);
     3956  setring A;
     3957  A;
     3958  attrib(A,"isLetterplaceRing");
     3959  attrib(A,"uptodeg");  // degree bound
     3960  attrib(A,"lV"); // number of variables in the main block
     3961}
     3962
     3963static proc setLetterplaceAttributesElim(def R, int uptodeg, int lV)
     3964"USAGE: setLetterplaceAttributesElim(R, d, b, eV); R a ring, b,d, eV integers
     3965RETURN: ring with special attributes set
     3966PURPOSE: sets attributes for a letterplace ring:
     3967@*      'isLetterplaceRing' = true, 'uptodeg' = d, 'lV' = b, 'eV' = eV, where
     3968@*      'uptodeg' stands for the degree bound,
     3969@*      'lV' for the number of variables in the block 0
     3970@*      'eV' for the number of elimination variables
     3971NOTE: Activate the resulting ring by using @code{setring}
     3972"
     3973{
     3974  if (uptodeg*lV != nvars(R))
     3975  {
     3976    ERROR("uptodeg and lV do not agree on the basering!");
     3977  }
     3978
     3979
     3980    // Set letterplace-specific attributes for the output ring!
     3981  attrib(R, "uptodeg", uptodeg);
     3982  attrib(R, "lV", lV);
     3983  attrib(R, "isLetterplaceRing", 1);
     3984  attrib(R, "HasElimOrd", 1);
     3985  return (R);
     3986}
     3987example
     3988{
     3989  "EXAMPLE:"; echo = 2;
     3990  ring r = 0,(x(1),y(1),x(2),y(2),x(3),y(3),x(4),y(4)),dp;
     3991  def R = setLetterplaceAttributesElim(r, 4, 2, 1); setring R;
     3992  attrib(R,"isLetterplaceRing");
     3993  lieBracket(x(1),y(1),2);
     3994}
     3995
     3996
     3997static proc lpElimIdeal(ideal I)
     3998"
     3999does not work for degree reasons (deg function does not work for lp rings -> newone!)
     4000"
     4001{
     4002  def lpring = attrib(basering,"isLetterplaceRing");
     4003  def lpEO =  attrib(basering,"HasElimOrd");
     4004  if ( typeof(lpring)!="int" && typeof(lpEO)!="int")
     4005  {
     4006    ERROR("Ring is not a lp-ring with an elimination ordering");
     4007  }
     4008
     4009  //int nE = attrib(basering, "eV");
     4010
     4011  return(letplaceGBasis(I));
     4012}
     4013
     4014
     4015static proc makeLetterplaceRingWt(int d, intvec W)
     4016"USAGE:  makeLetterplaceRingWt(d,W); d an integer, W a vector of positive integers
     4017RETURN:  ring
     4018PURPOSE: creates a ring with a special ordering, suitable for
     4019@* the use of non-homogeneous letterplace
     4020NOTE: the matrix for the ordering looks as follows: first row is W,W,W,...
     4021@* then there come 'd' blocks of shifted original variables
     4022EXAMPLE: example makeLetterplaceRing2; shows examples
     4023"
     4024{
     4025
     4026  // ToDo future: inherit positive weights in the orig ring
     4027  // complain on nonpositive ones
     4028
     4029  // d = up to degree, will be shifted to d+1
     4030  if (d<1) {"bad d"; return(0);}
     4031
     4032  int uptodeg = d; int lV = nvars(basering);
     4033
     4034  //check weightvector
     4035  if (size(W) <> lV) {"bad weights"; return(0);}
     4036
     4037  int i;
     4038  for (i = 1; i <= size(W); i++) {if (W[i] < 0) {"bad weights"; return(0);}}
     4039  intvec Wt = W;
     4040  for (i = 2; i <= d; i++) {Wt = Wt, W;}
     4041  kill i;
     4042
     4043  int ppl = printlevel-voice+2;
     4044  string err = "";
     4045
     4046  int i,j,s;
     4047  def save = basering;
     4048  int D = d-1;
     4049  list LR  = ringlist(save);
     4050  list L, tmp, tmp2, tmp3;
     4051  L[1] = LR[1]; // ground field
     4052  L[4] = LR[4]; // quotient ideal
     4053  tmp  = LR[2]; // varnames
     4054  s = size(LR[2]);
     4055  for (i=1; i<=D; i++)
     4056  {
     4057    for (j=1; j<=s; j++)
     4058    {
     4059      tmp[i*s+j] = string(tmp[j])+"("+string(i+1)+")";
     4060    }
     4061  }
     4062  for (i=1; i<=s; i++)
     4063  {
     4064    tmp[i] = string(tmp[i])+"("+string(1)+")";
     4065  }
     4066  L[2] = tmp;
     4067  list OrigNames = LR[2];
     4068  // ordering: one 1..1 a above
     4069  // ordering: d blocks of the ord on r
     4070  // try to get whether the ord on r is blockord itself
     4071  // TODO: make L(2) ordering! exponent is maximally 2
     4072  s = size(LR[3]);
     4073  if (s==2)
     4074  {
     4075    // not a blockord, 1 block + module ord
     4076    tmp = LR[3][s]; // module ord
     4077    for (i=1; i<=d; i++)
     4078    {
     4079      LR[3][s-1+i] = LR[3][1];
     4080    }
     4081    //    LR[3][s+D] = tmp;
     4082    LR[3][s+1+D] = tmp;
     4083    LR[3][1] = list("a",Wt); // deg-ord
     4084  }
     4085  if (s>2)
     4086  {
     4087    // there are s-1 blocks
     4088    int nb = s-1;
     4089    tmp = LR[3][s]; // module ord to place at the very end
     4090    tmp2 = LR[3]; tmp2 = tmp2[1..nb];
     4091    tmp3[1] = list("a",Wt); // deg-ord, insert as the 1st
     4092    for (i=1; i<=d; i++)
     4093    {
     4094      tmp3 = tmp3 + tmp2;
     4095    }
     4096    tmp3 = tmp3 + list(tmp);
     4097    LR[3] = tmp3;
     4098
     4099  }
     4100  L[3] = LR[3];
     4101  def @R = ring(L);
     4102  //  setring @R;
     4103  //  int uptodeg = d; int lV = nvars(basering); // were defined before
     4104  def @@R = setLetterplaceAttributes(@R,uptodeg,lV);
     4105  return (@@R);
     4106}
     4107example
     4108{
     4109  "EXAMPLE:"; echo = 2;
     4110  ring r = 0,(x,y,z),(dp(1),dp(2));
     4111  def A = makeLetterplaceRingWt(2,intvec(1,2,3));
     4112  setring A;
     4113  A;
     4114  attrib(A,"isLetterplaceRing");
     4115  attrib(A,"uptodeg");  // degree bound
     4116  attrib(A,"lV"); // number of variables in the main block
     4117}
     4118*/
Note: See TracChangeset for help on using the changeset viewer.