Changeset fbd9e6f in git


Ignore:
Timestamp:
Jan 8, 2018, 2:31:08 PM (5 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a657104b677b4c461d018cbf3204d72d34ad66a9')
Children:
88dc1d4c1c83ba8ca3e1cbb7e574d2427539b133
Parents:
6b02216593677b82e2b32595292b3622d7c6816ea135fdaed631e5e179009a4772aa1ab7f20f7dc2
Message:
Merge branch 'stable' of https://github.com/kabouzeid/Singular into test
Files:
1 added
18 edited

Legend:

Unmodified
Added
Removed
  • Singular/LIB/dmodloc.lib

    ra135fd rfbd9e6f  
    312312  int i;
    313313  int n = nvars(basering);
    314   for (i=1; i<=nrows(v); i++)
     314  for (i=1; i<=size(v); i++)
    315315  {
    316316    if ( (v[i]<0) || (v[i]>n) )
  • Singular/LIB/fpadim.lib

    r6b02216 rfbd9e6f  
    44info="
    55LIBRARY: fpadim.lib     Algorithms for quotient algebras in the letterplace case
    6 AUTHORS: Grischa Studzinski,       grischa.studzinski@rwth-aachen.de
     6AUTHORS: Grischa Studzinski,       grischa.studzinski at rwth-aachen.de
     7@*       Viktor Levandovskyy,      viktor.levandovskyy at math.rwth-aachen.de
     8@*       Karim Abou Zeid,          karim.abou.zeid at rwth-aachen.de
    79
    810Support: Joint projects LE 2697/2-1 and KR 1907/3-1 of the Priority Programme SPP 1489:
    9 @* 'Algorithmische und Experimentelle Methoden in Algebra, Geometrie und Zahlentheorie'
    10 @* of the German DFG
    11 
    12 OVERVIEW: Given the free algebra A = K<x_1,...,x_n> and a (finite) Groebner basis
     11'Algorithmische und Experimentelle Methoden in Algebra, Geometrie und Zahlentheorie'
     12of the German DFG
     13and Project II.6 of the transregional collaborative research centre
     14SFB-TRR 195 'Symbolic Tools in Mathematics and their Application' of the German DFG
     15
     16OVERVIEW: Given the free associative algebra A = K<x_1,...,x_n> and a (finite) Groebner basis
    1317      GB = {g_1,..,g_w}, one is interested in the K-dimension and in the
    1418      explicit K-basis of A/<GB>.
    1519      Therefore one is interested in the following data:
    16 @*      - the Ufnarovskij graph induced by GB
    17 @*      - the mistletoes of A/<GB>
    18 @*      - the K-dimension of A/<GB>
    19 @*      - the Hilbert series of A/<GB>
    20 
    21       The Ufnarovskij graph is used to determine whether A/<GB> has finite
    22       K-dimension. One has to check if the graph contains cycles.
    23       For the whole theory we refer to [ufna]. Given a
    24       reduced set of monomials GB one can define the basis tree, whose vertex
    25       set V consists of all normal monomials w.r.t. GB. For every two
    26       monomials m_1, m_2 in V there is a direct edge from m_1 to m_2, if and
    27       only if there exists x_k in {x_1,..,x_n}, such that m_1*x_k = m_2. The
    28       set M = {m in V | there is no edge from m to another monomial in V} is
    29       called the set of mistletoes. As one can easily see it consists of
    30       the endpoints of the graph. Since there is a unique path to every
    31       monomial in V the whole graph can be described only from the knowledge
    32       of the mistletoes. Note that V corresponds to a basis of A/<GB>, so
    33       knowing the mistletoes we know a K-basis. The name mistletoes was given
    34       to those points because of these miraculous value and the algorithm is
    35       named sickle, because a sickle is the tool to harvest mistletoes.
    36       For more details see [studzins]. This package uses the Letterplace
    37       format introduced by [lls]. The algebra can either be represented as a
    38       Letterplace ring or via integer vectors: Every variable will only be
    39       represented by its number, so variable one is represented as 1,
    40       variable two as 2 and so on. The monomial x_1*x_3*x_2 for example will
    41       be stored as (1,3,2). Multiplication is concatenation. Note that there
    42       is no algorithm for computing the normal form needed for our case.
    43       Note that the name fpadim.lib is short for dimensions of finite
    44       presented algebras.
     20      - the Ufnarovskij graph induced by GB
     21      - the mistletoes of A/<GB> (special monomials in a basis)
     22      - the K-dimension of A/<GB>
     23      - the Hilbert series of A/<GB>
     24
     25@*      The Ufnarovskij graph is used to determine whether A/<GB> has finite
     26@*      K-dimension. One has to check if the graph contains cycles.
     27@*      For the whole theory we refer to [ufna]. Given a
     28@*      reduced set of monomials GB one can define the basis tree, whose vertex
     29@*      set V consists of all normal monomials w.r.t. GB. For every two
     30@*      monomials m_1, m_2 in V there is a direct edge from m_1 to m_2, if and
     31@*      only if there exists x_k in {x_1,..,x_n}, such that m_1*x_k = m_2. The
     32@*      set M = {m in V | there is no edge from m to another monomial in V} is
     33@*      called the set of mistletoes. As one can easily see it consists of
     34@*      the endpoints of the graph. Since there is a unique path to every
     35@*      monomial in V the whole graph can be described only from the knowledge
     36@*      of the mistletoes. Note that V corresponds to a basis of A/<GB>, so
     37@*      knowing the mistletoes we know a K-basis. The name mistletoes was given
     38@*      to those points because of these miraculous value and the algorithm is
     39@*      named sickle, because a sickle is the tool to harvest mistletoes.
     40@*      For more details see [studzins]. This package uses the Letterplace
     41@*      format introduced by [lls]. The algebra can either be represented as a
     42@*      Letterplace ring or via integer vectors: Every variable will only be
     43@*      represented by its number, so variable one is represented as 1,
     44@*      variable two as 2 and so on. The monomial x_1*x_3*x_2 for example will
     45@*      be stored as (1,3,2). Multiplication is concatenation. Note that the
     46@*      approach in this library does not need an algorithm for computing the normal
     47@*      form yet. Note that the name fpadim.lib is short for dimensions of
     48@*      finite presented algebras.
     49@*
    4550
    4651REFERENCES:
     
    4853@*   [ufna] Ufnarovskij: Combinatorical and asymptotic methods in algebra, 1990
    4954@*   [lls] Levandovskyy, La Scala: Letterplace ideals and non-commutative
    50           Groebner bases, 2009
     55Groebner bases, 2009
    5156@*   [studzins] Studzinski: Dimension computations in non-commutative,
    52                      associative algebras, Diploma thesis, RWTH Aachen, 2010
    53 
    54 Assumptions:
    55 @* - basering is always a Letterplace ring
    56 @* - all intvecs correspond to Letterplace monomials
    57 @* - if you specify a different degree bound d,
    58      d <= attrib(basering,uptodeg) should hold.
    59 @* In the procedures below, 'iv' stands for intvec representation
    60   and 'lp' for the letterplace representation of monomials
     57associative algebras, Diploma thesis, RWTH Aachen, 2010
     58
     59NOTE:
     60- basering is always a Letterplace ring
     61- all intvecs correspond to Letterplace monomials
     62- if you specify a different degree bound d, d <= attrib(basering,uptodeg) holds
     63
     64In the procedures below, 'iv' stands for intvec representation
     65and 'lp' for the letterplace representation of monomials
    6166
    6267PROCEDURES:
     68
     69lpMis2Dim(M);              computes the K-dimension of the monomial factor algebra
     70lpKDim(G[,d,n]);           computes the K-dimension of A/<G>
     71lpDimCheck(G);             checks if the K-dimension of A/<G> is infinite
     72lpMis2Base(M);             computes a K-basis of the factor algebra
     73lpHilbert(G[,d,n]);        computes the Hilbert series of A/<G> in lp format
     74lpDHilbert(G[,d,n]);       computes the K-dimension and Hilbert series of A/<G>
     75lpDHilbertSickle(G[,d,n]); computes mistletoes, K-dimension and Hilbert series
    6376
    6477ivDHilbert(L,n[,d]);       computes the K-dimension and the Hilbert series
     
    7386ivSickleHil(L,n[,d]);      computes the mistletoes and Hilbert series of A/<L>
    7487ivSickleDim(L,n[,d]);      computes the mistletoes and the K-dimension of A/<L>
    75 lpDHilbert(G[,d,n]);       computes the K-dimension and Hilbert series of A/<G>
    76 lpDHilbertSickle(G[,d,n]); computes mistletoes, K-dimension and Hilbert series
    77 lpHilbert(G[,d,n]);        computes the Hilbert series of A/<G> in lp format
    78 lpDimCheck(G);             checks if the K-dimension of A/<G> is infinite
    79 lpKDim(G[,d,n]);           computes the K-dimension of A/<G> in lp format
    80 lpMis2Base(M);             computes a K-basis of the factor algebra
    81 lpMis2Dim(M);              computes the K-dimension of the factor algebra
    8288lpOrdMisLex(M);            orders an ideal of lp-monomials lexicographically
    8389lpSickle(G[,d,n]);         computes the mistletoes of A/<G> in lp format
     
    8591lpSickleDim(G[,d,n]);      computes the mistletoes and the K-dimension of A/<G>
    8692sickle(G[,m,d,h]);         can be used to access all lp main procedures
    87 
    8893
    8994ivL2lpI(L);           transforms a list of intvecs into an ideal of lp monomials
     
    145150    {for (i3 = 1; i3 <= n; i3++)
    146151      {for (i4 = 1; i4 <= (n^(i1-1)); i4++)
    147       {
    148         M[i2,i1] = i3;
     152        {M[i2,i1] = i3;
    149153          i2 = i2 + 1;
    150        }
     154        }
    151155      }
    152156    }
     
    170174"PURPOSE:checks, if all entries in M are variable-related
    171175"
    172 {if ((nrows(M) == 1) && (ncols(M) == 1)) {if (M[1,1] == 0){return(0);}}
    173  int i,j;
     176{int i,j;
    174177  for (i = 1; i <= nrows(M); i++)
    175178  {for (j = 1; j <= ncols(M); j++)
     
    328331}
    329332
     333
     334static proc findCycleDFS(int i, intmat T, intvec V)
     335"
     336PURPOSE:
     337this is a classical deep-first search for cycles contained in a graph given by an intmat
     338"
     339{
     340  intvec rV;
     341  int k,k1,t;
     342  int j = V[size(V)];
     343  if (T[j,i] > 0) {return(V);}
     344  else
     345  {
     346    for (k = 1; k <= ncols(T); k++)
     347    {
     348      t = 0;
     349      if (T[j,k] > 0)
     350      {
     351        for (k1 = 1; k1 <= size(V); k1++) {if (V[k1] == k) {t = 1; break;}}
     352        if (t == 0)
     353        {
     354          rV = V;
     355          rV[size(rV)+1] = k;
     356          rV = findCycleDFS(i,T,rV);
     357          if (rV[1] > -1) {return(rV);}
     358        }
     359      }
     360    }
     361  }
     362  return(intvec(-1));
     363}
     364
     365
     366
    330367static proc findHCoeff(intvec V,int n,list L,intvec P,intvec H,list #)
    331368"USAGE: findHCoeff(V,n,L,P,H,degbound); L a list of intmats, degbound an integer
     
    565602      }
    566603      return(R);
    567 
    568604    }
    569605  }
     
    647683}
    648684
     685static proc growthAlg(intmat T, list #)
     686"
     687real algorithm for checking the growth of an algebra
     688"
     689{
     690  int s = 1;
     691  if (size(#) > 0) { s = #[1];}
     692  int j;
     693  int n = ncols(T);
     694  intvec NV,C; NV[n] = 0; int m,i;
     695  intmat T2[n][n] = T[1..n,1..n]; intmat N[n][n];
     696  if (T2 == N)
     697  {
     698    for (i = 1; i <= n; i++)
     699    {
     700      if (m <  T[n+1,i]) { m = T[n+1,i];}
     701    }
     702    return(m);
     703  }
     704
     705  //first part: the diagonals
     706  for (i = s; i <= n; i++)
     707  {
     708    if (T[i,i] > 0)
     709    {
     710      if ((T[i,i] >= 1) && (T[n+1,i] > 0)) {return(-1);}
     711      if ((T[i,i] == 1) && (T[n+1,i] == 0))
     712      {
     713        T[i,i] = 0;
     714        T[n+1,i] = 1;
     715        return(growthAlg(T));
     716      }
     717    }
     718  }
     719
     720  //second part: searching for the last but one vertices
     721  T2 = T2*T2;
     722  for (i = s; i <= n; i++)
     723  {
     724    if ((intvec(T[i,1..n]) <> intvec(0)) && (intvec(T2[i,1..n]) == intvec(0)))
     725    {
     726      for (j = 1; j <= n; j++)
     727      {
     728        if ((T[i,j] > 0) && (m < T[n+1,j])) {m = T[n+1,j];}
     729      }
     730      T[n+1,i] = T[n+1,i] + m;
     731      T[i,1..n] = NV;
     732      return(growthAlg(T));
     733    }
     734  }
     735  m = 0;
     736
     737  //third part: searching for circles
     738  for (i = s; i <= n; i++)
     739  {
     740    T2 = T[1..n,1..n];
     741    C = findCycleDFS(i,T2, intvec(i));
     742    if (C[1] > 0)
     743    {
     744      for (j = 2; j <= size(C); j++)
     745      {
     746        T[i,1..n] = T[i,1..n] + T[C[j],1..n];
     747        T[C[j],1..n] = NV;
     748      }
     749      for (j = 2; j <= size(C); j++)
     750      {
     751        T[1..n,i] = T[1..n,i] + T[1..n,C[j]];
     752        T[1..n,C[j]] = NV;
     753      }
     754      T[i,i] = T[i,i] - size(C) + 1;
     755      m = 0;
     756      for (j = 1; j <= size(C); j++)
     757      {
     758        m = m + T[n+1,C[j]];
     759      }
     760      for (j = 1; j <= size(C); j++)
     761      {
     762        T[n+1,C[j]] = m;
     763      }
     764      return(growthAlg(T,i));
     765    }
     766    else {ERROR("No Cycle found, something seems wrong! Please contact the authors.");}
     767  }
     768
     769  m = 0;
     770  for (i = 1; i <= n; i++)
     771  {
     772    if (m < T[n+1,i])
     773    {
     774      m = T[n+1,i];
     775    }
     776  }
     777  return(m);
     778}
     779
     780static proc GlDimSuffix(intvec v, intvec g)
     781{
     782  //Computes the shortest r such that g is a suffix for vr
     783  //only valid for lex orderings?
     784  intvec r,gt,vt,lt,g2;
     785  int lg,lv,l,i,c,f;
     786  lg = size(g); lv = size(v);
     787  if (lg <= lv)
     788  {
     789    l = lv-lg;
     790  }
     791  else
     792  {
     793    l = 0; g2 = g[(lv+1)..lg];
     794    g = g[1..lv]; lg = size(g);
     795    c = 1;
     796  }
     797  while (l < lv)
     798  {
     799    vt = v[(l+1)..lv];
     800    gt = g[1..(lv-l)];
     801    lt = size(gt);
     802    for (i = 1; i <= lt; i++)
     803    {
     804      if (vt[i]<>gt[i]) {l++; break;}
     805    }
     806    if (lt <=i ) { f = 1; break;}
     807  }
     808  if (f == 0) {return(g);}
     809  r = g[(lv-l+1)..lg];
     810  if (c == 1) {r = r,g2;}
     811  return(r);
     812}
     813
     814static proc isNormal(intvec V, list G)
     815{
     816  int i,j,k,l;
     817  k = 0;
     818  for (i = 1; i <= size(G); i++)
     819  {
     820    if ( size(G[i]) <= size(V) )
     821    {
     822      while ( size(G[i])+k <= size(V) )
     823      {
     824        if ( G[i] == V[(1+k)..size(V)] ) {return(1);}
     825      }
     826    }
     827  }
     828  return(0);
     829}
     830
     831static proc findDChain(list L)
     832{
     833  list Li; int i,j;
     834  for (i = 1; i <= size(L); i++) {Li[i] = size(L[i]);}
     835  Li = sort(Li); Li = Li[1];
     836  return(Li[size(Li)]);
     837}
     838
    649839static proc isInList(intvec V, list L)
    650840"USAGE: isInList(V,L); V an intvec, L a list of intvecs
     
    684874}
    685875
     876
     877static proc isPF(intvec P, intvec I)
     878"
     879PURPOSE:
     880checks, if a word P is a praefix of another word I
     881"
     882{
     883  int n = size(P);
     884  if (n <= 0 || P == 0) {return(1);}
     885  if (size(I) < n) {return(0);}
     886  intvec IP = I[1..n];
     887  if (IP == P) {return(1);}
     888  else {return(0);}
     889}
     890
    686891proc ivL2lpI(list L)
    687892"USAGE: ivL2lpI(L); L a list of intvecs
    688893RETURN: ideal
    689 PURPOSE:Transforming a list of intvecs into an ideal of Letterplace monomials.
    690 @*      For the encoding of the variables see the overview.
     894PURPOSE:Transforming a list of intvecs into an ideal of Letterplace monomials
    691895ASSUME: - Intvec corresponds to a Letterplace monomial
    692896@*      - basering has to be a Letterplace ring
     897NOTE:   - Assumptions will not be checked!
    693898EXAMPLE: example ivL2lpI; shows examples
    694899"
    695 {checkAssumptions(0,L);
     900{
    696901  int i; ideal G;
    697902  poly p;
     
    718923RETURN: poly
    719924PURPOSE:Transforming an intvec into the corresponding Letterplace polynomial
    720 @*      For the encoding of the variables see the overview.
    721925ASSUME: - Intvec corresponds to a Letterplace monomial
    722926@*      - basering has to be a Letterplace ring
     
    748952RETURN: ideal
    749953PURPOSE:Converting a list of intmats into an ideal of corresponding monomials
    750 @*      The rows of the intmat corresponds to an intvec, which stores the
    751 @*      monomial.
    752 @*      For the encoding of the variables see the overview.
    753954ASSUME: - The rows of each intmat in L must correspond to a Letterplace monomial
    754955@*      - basering has to be a Letterplace ring
     
    779980"USAGE: iv2lpMat(M); M an intmat
    780981RETURN: ideal
    781 PURPOSE:Converting an intmat into an ideal of the corresponding monomials.
    782 @*      The rows of the intmat corresponds to an intvec, which stores the
    783 @*      monomial.
    784 @*      For the encoding of the variables see the overview.
     982PURPOSE:Converting an intmat into an ideal of the corresponding monomials
    785983ASSUME: - The rows of M must correspond to Letterplace monomials
    786984@*      - basering has to be a Letterplace ring
     
    8161014"USAGE: lpId2ivLi(G); G an ideal
    8171015RETURN: list
    818 PURPOSE:Transforming an ideal into the corresponding list of intvecs.
    819 @*      For the encoding of the variables see the overview.
     1016PURPOSE:Transforming an ideal into the corresponding list of intvecs
    8201017ASSUME: - basering has to be a Letterplace ring
    8211018EXAMPLE: example lpId2ivLi; shows examples
    8221019"
    823 {int i,j,k;
     1020{
     1021  int i,j,k;
    8241022  list M;
    8251023  checkAssumptions(0,M);
     
    8401038"USAGE: lp2iv(p); p a poly
    8411039RETURN: intvec
    842 PURPOSE:Transforming a monomial into the corresponding intvec.
    843 @*      For the encoding of the variables see the overview.
     1040PURPOSE:Transforming a monomial into the corresponding intvec
    8441041ASSUME: - basering has to be a Letterplace ring
    8451042NOTE:   - Assumptions will not be checked!
     
    8831080RETURN: list
    8841081PURPOSE:Converting an ideal into an list of intmats,
    885 @*      the corresponding intvecs forming the rows.
    886 @*      For the encoding of the variables see the overview.
     1082@*      the corresponding intvecs forming the rows
    8871083ASSUME: - basering has to be a Letterplace ring
    8881084EXAMPLE: example lp2ivId; shows examples
     
    9251121// -----------------main procedures----------------------
    9261122
     1123static proc lpGraphOfNormalWords(ideal G)
     1124"USAGE: lpGraphOfNormalWords(G); G a set of monomials in a letterplace ring
     1125RETURN: intmat
     1126PURPOSE: Constructs the graph of normal words induced by G
     1127@*:      the adjacency matrix of the graph of normal words induced by G
     1128ASSUME: - basering is a Letterplace ring
     1129- G are the leading monomials of a Groebner basis
     1130"
     1131{
     1132  // construct the Graph of normal words [Studzinski page 78]
     1133  // construct set of vertices
     1134  int v = attrib(basering,"lV"); int d = attrib(basering,"uptodeg");
     1135  ideal V; poly p,q,w;
     1136  ideal LG = lead(G);
     1137  int i,j,k,b; intvec E,Et;
     1138  for (i = 1; i <= v; i++){V = V, var(i);}
     1139  for (i = 1; i <= size(LG); i++)
     1140  {
     1141    E = leadexp(LG[i]);
     1142    if (E == intvec(0)) {V = V,monomial(intvec(0));}
     1143    else
     1144    {
     1145      for (j = 1; j < d; j++)
     1146      {
     1147        Et = E[(j*v+1)..(d*v)];
     1148        if (Et == intvec(0)) {break;}
     1149        else {V = V, monomial(Et);}
     1150      }
     1151    }
     1152  }
     1153  V = simplify(V,2+4);
     1154  printf("V = %p", V);
     1155
     1156
     1157  // construct incidence matrix
     1158
     1159  list LV = lpId2ivLi(V);
     1160  intvec Ip,Iw;
     1161  int n = size(V);
     1162  intmat T[n+1][n];
     1163  for (i = 1; i <= n; i++)
     1164  {
     1165    // printf("for1 (i=%p, n=%p)", i, n);
     1166    p = V[i]; Ip = lp2iv(p);
     1167    for (j = 1; j <= n; j++)
     1168    {
     1169      // printf("for2 (j=%p, n=%p)", j, n);
     1170      k = 1; b = 1;
     1171      q = V[j];
     1172      w = lpNF(lpMult(p,q),LG);
     1173      if (w <> 0)
     1174      {
     1175        Iw = lp2iv(w);
     1176        while (k <= n)
     1177        {
     1178          // printf("while (k=%p, n=%p)", k, n);
     1179          if (isPF(LV[k],Iw) > 0)
     1180          {if (isPF(LV[k],Ip) == 0) {b = 0; k = n+1;} else {k++;}
     1181          }
     1182          else {k++;}
     1183        }
     1184        T[i,j] = b;
     1185        //  print("Incidence Matrix:");
     1186        // print(T);
     1187      }
     1188    }
     1189  }
     1190  return(T);
     1191}
     1192
     1193// This proc is deprecated, see lpGkDim() in fpaprops.lib
     1194/* proc lpGkDim(ideal G) */
     1195/* "USAGE: lpGkDim(G); G an ideal in a letterplace ring */
     1196/* RETURN: int */
     1197/* PURPOSE: Determines the Gelfand Kirillov dimension of A/<G> */
     1198/* @*:     -1 means it is infinite */
     1199/* ASSUME: - basering is a Letterplace ring */
     1200/* - G is a Groebner basis */
     1201/* NOTE: see fpaprops.lib for a faster and more up to date version of this method */
     1202/* " */
     1203/* { */
     1204/*   return(growthAlg(lpGraphOfNormalWords(G))); */
     1205/* } */
     1206
    9271207proc ivDHilbert(list L, int n, list #)
    9281208"USAGE: ivDHilbert(L,n[,degbound]); L a list of intmats, n an integer,
     
    9321212ASSUME: - basering is a Letterplace ring
    9331213@*      - all rows of each intmat correspond to a Letterplace monomial
    934 @*        for the encoding of the variables see the overview
    9351214@*      - if you specify a different degree bound degbound,
    936 @*        degbound <= attrib(basering,uptodeg) should hold.
     1215@*        degbound <= attrib(basering,uptodeg) holds
    9371216NOTE: - If L is the list returned, then L[1] is an integer corresponding to the
    9381217@*      dimension, L[2] is an intvec which contains the coefficients of the
     
    9841263ASSUME: - basering is a Letterplace ring.
    9851264@*      - All rows of each intmat correspond to a Letterplace monomial.
    986 @*        for the encoding of the variables see the overview
    9871265@*      - If you specify a different degree bound degbound,
    988 @*        degbound <= attrib(basering,uptodeg) should hold.
     1266@*        degbound <= attrib(basering,uptodeg) holds.
    9891267NOTE: - If L is the list returned, then L[1] is an integer, L[2] is an intvec
    9901268@*      which contains the coefficients of the Hilbert series and L[3]
     
    10311309RETURN: int, 0 if the dimension is finite, or 1 otherwise
    10321310PURPOSE:Decides, whether the K-dimension is finite or not
    1033 ASSUME: - basering is a Letterplace ring
    1034 @*      - All rows of each intmat correspond to a Letterplace monomial
    1035 @*        For the encoding of the variables see the overview.
    1036 NOTE:   - n is the number of variables
     1311ASSUME: - basering is a Letterplace ring.
     1312@*      - All rows of each intmat correspond to a Letterplace monomial.
     1313NOTE:   - n is the number of variables.
    10371314EXAMPLE: example ivDimCheck; shows examples
    10381315"
     
    10901367ASSUME: - basering is a Letterplace ring.
    10911368@*      - all rows of each intmat correspond to a Letterplace monomial
    1092 @*        for the encoding of the variables see the overview
    10931369@*      - if you specify a different degree bound degbound,
    1094 @*       degbound <= attrib(basering,uptodeg) should hold.
     1370@*       degbound <= attrib(basering,uptodeg) holds.
    10951371NOTE: - If degbound is set, a degree bound  will be added. By default there
    10961372@*      is no degree bound.
     
    11761452ASSUME: - basering is a Letterplace ring.
    11771453@*      - all rows of each intmat correspond to a Letterplace monomial
    1178 @*        for the encoding of the variables see the overview
    11791454@*      - if you specify a different degree bound degbound,
    1180 @*        degbound <= attrib(basering,uptodeg) should hold.
     1455@*        degbound <= attrib(basering,uptodeg) holds.
    11811456NOTE: - If degbound is set, a degree bound will be added. By default there
    11821457@*      is no degree bound.
     
    12631538"
    12641539{
    1265 //checkAssumptions(0,M);
     1540  //checkAssumptions(0,M);
    12661541  intvec L,A;
    12671542  if (size(M) == 0){ERROR("There are no mistletoes, so it appears your dimension is infinite!");}
     
    12741549  for (i = 2; i <= size(M); i++)
    12751550  {A = M[i]; L = M[i-1];
    1276    s = size(A);
    1277    if (s > size(L))
    1278    {d = size(L);
    1279     for (j = s; j > d; j--) {Rt = insert(Rt,intvec(A[1..j]));}
    1280     A = A[1..d];
    1281    }
    1282    if (size(L) > s){L = L[1..s];}
    1283    while (A <> L)
    1284    {Rt = insert(Rt, intvec(A));
    1285     if (size(A) > 1)
    1286     {A = A[1..(size(A)-1)];
    1287      L = L[1..(size(L)-1)];
    1288     }
    1289     else {break;}
    1290    }
     1551    s = size(A);
     1552    if (s > size(L))
     1553    {d = size(L);
     1554      for (j = s; j > d; j--) {Rt = insert(Rt,intvec(A[1..j]));}
     1555      A = A[1..d];
     1556    }
     1557    if (size(L) > s){L = L[1..s];}
     1558    while (A <> L)
     1559    {Rt = insert(Rt, intvec(A));
     1560      if (size(A) > 1)
     1561      {A = A[1..(size(A)-1)];
     1562        L = L[1..(size(L)-1)];
     1563      }
     1564      else {break;}
     1565    }
    12911566  }
    12921567  return(Rt);
     
    13131588@*        Otherwise the returned value may differ from the K-dimension.
    13141589@*      - basering is a Letterplace ring.
    1315 @*      - mistletoes are stored as intvecs, as described in the overview
    13161590EXAMPLE: example ivMis2Dim; shows examples
    13171591"
     
    13211595  if (isInList(L,M) > 0) {print("1 is a mistletoe, therefore dim = 1"); return(1);}
    13221596  int i,j,d,s;
     1597  j = 1;
    13231598  d = 1 + size(M[1]);
    13241599  for (i = 1; i < size(M); i++)
    1325   {j = 1;
    1326    s = size(M[i]); if (s > size(M[i+1])){s = size(M[i+1]);}
    1327    while ((M[i][j] == M[i+1][j]) && (j <= s)){j = j + 1;}
    1328    d = d + size(M[i+1])- j + 1;
     1600  {s = size(M[i]); if (s > size(M[i+1])){s = size(M[i+1]);}
     1601    while ((M[i][j] == M[i+1][j]) && (j <= s)){j = j + 1;}
     1602    d = d + size(M[i+1])- j + 1;
    13291603  }
    13301604  return(d);
     
    13481622PURPOSE:Orders a given set of mistletoes lexicographically
    13491623ASSUME: - basering is a Letterplace ring.
    1350 @*      - intvecs correspond to monomials, as explained in the overview
     1624- intvecs correspond to monomials
    13511625NOTE:   - This is preprocessing, it's not needed if the mistletoes are returned
    13521626@*        from the sickle algorithm.
     
    13741648@*      optional integer
    13751649RETURN: list, containing intvecs, the mistletoes of A/<L>
    1376 PURPOSE:Computing the mistletoes for a given Groebner basis L, given by intmats
     1650PURPOSE:Computing the mistletoes for a given Groebner basis L
    13771651ASSUME: - basering is a Letterplace ring.
    13781652@*      - all rows of each intmat correspond to a Letterplace monomial
    1379 @*        as explained in the overview
    13801653@*      - if you specify a different degree bound degbound,
    1381 @*        degbound <= attrib(basering,uptodeg) should hold.
     1654@*        degbound <= attrib(basering,uptodeg) holds.
    13821655NOTE: - If degbound is set, a degree bound will be added. By default there
    13831656@*      is no degree bound.
     
    14571730ASSUME: - basering is a Letterplace ring.
    14581731@*      - all rows of each intmat correspond to a Letterplace monomial
    1459 @*        as explained in the overview
    14601732@*      - if you specify a different degree bound degbound,
    1461 @*        degbound <= attrib(basering,uptodeg) should hold.
     1733@*        degbound <= attrib(basering,uptodeg) holds.
    14621734NOTE: - If L is the list returned, then L[1] is an integer, L[2] is a list,
    14631735@*      containing the mistletoes as intvecs.
     
    15451817ASSUME: - basering is a Letterplace ring.
    15461818@*      - all rows of each intmat correspond to a Letterplace monomial
    1547 @*        as explained in the overview
    15481819@*      - if you specify a different degree bound degbound,
    1549 @*        degbound <= attrib(basering,uptodeg) should hold.
     1820@*        degbound <= attrib(basering,uptodeg) holds.
    15501821NOTE: - If L is the list returned, then L[1] is an intvec, L[2] is a list,
    15511822@*      containing the mistletoes as intvecs.
     
    16301901RETURN: list
    16311902PURPOSE:Computing K-dimension and Hilbert series, starting with a lp-ideal
    1632 ASSUME: - basering is a Letterplace ring. G is a Letterplace ideal.
     1903ASSUME: - basering is a Letterplace ring.
    16331904@*      - if you specify a different degree bound degbound,
    1634 @*        degbound <= attrib(basering,uptodeg) should hold.
     1905@*        degbound <= attrib(basering,uptodeg) holds.
    16351906NOTE: - If L is the list returned, then L[1] is an integer corresponding to the
    16361907@*      dimension, L[2] is an intvec which contains the coefficients of the
     
    16721943RETURN: list
    16731944PURPOSE:Computing K-dimension, Hilbert series and mistletoes at once
    1674 ASSUME: - basering is a Letterplace ring.  G is a Letterplace ideal.
     1945ASSUME: - basering is a Letterplace ring.
    16751946@*      - if you specify a different degree bound degbound,
    1676 @*        degbound <= attrib(basering,uptodeg) should hold.
     1947@*        degbound <= attrib(basering,uptodeg) holds.
    16771948NOTE: - If L is the list returned, then L[1] is an integer, the K-dimension,
    16781949@*      L[2] is an intvec, the Hilbert series and L[3] is an ideal,
     
    17151986RETURN: intvec, containing the coefficients of the Hilbert series
    17161987PURPOSE:Computing the Hilbert series
    1717 ASSUME: - basering is a Letterplace ring.  G is a Letterplace ideal.
     1988ASSUME: - basering is a Letterplace ring.
    17181989@*      - if you specify a different degree bound degbound,
    1719 @*        degbound <= attrib(basering,uptodeg) should hold.
     1990@*        degbound <= attrib(basering,uptodeg) holds.
    17201991NOTE: - If degbound is set, there will be a degree bound added. 0 means no
    17211992@*      degree bound. Default: attrib(basering,uptodeg).
     
    17532024RETURN: int, 1 if K-dimension of the factor algebra is infinite, 0 otherwise
    17542025PURPOSE:Checking a factor algebra for finiteness of the K-dimension
    1755 ASSUME: - basering is a Letterplace ring.  G is a Letterplace ideal.
     2026ASSUME: - basering is a Letterplace ring.
    17562027EXAMPLE: example lpDimCheck; shows examples
    17572028"
     
    17812052RETURN: int, the K-dimension of the factor algebra
    17822053PURPOSE:Computing the K-dimension of a factor algebra, given via an ideal
    1783 ASSUME: - basering is a Letterplace ring. G is a Letterplace ideal.
     2054ASSUME: - basering is a Letterplace ring
    17842055@*      - if you specify a different degree bound degbound,
    1785 @*        degbound <= attrib(basering,uptodeg) should hold.
     2056@*        degbound <= attrib(basering,uptodeg) holds.
    17862057NOTE: - If degbound is set, there will be a degree bound added. 0 means no
    17872058@*      degree bound. Default: attrib(basering, uptodeg).
     
    18402111RETURN: int, the K-dimension of the factor algebra
    18412112PURPOSE:Computing the K-dimension out of given mistletoes
    1842 ASSUME: - basering is a Letterplace ring. G is a Letterplace ideal.
     2113ASSUME: - basering is a Letterplace ring.
    18432114@*      - M contains only monomials
    18442115NOTE:   - The mistletoes have to be ordered lexicographically -> OrdMisLex.
     
    18642135RETURN: ideal, containing the mistletoes, ordered lexicographically
    18652136PURPOSE:A given set of mistletoes is ordered lexicographically
    1866 ASSUME: - basering is a Letterplace ring. G is a Letterplace ideal.
     2137ASSUME: - basering is a Letterplace ring.
    18672138NOTE:   This is preprocessing, it is not needed if the mistletoes are returned
    18682139@*      from the sickle algorithm.
     
    18852156RETURN: ideal
    18862157PURPOSE:Computing the mistletoes of K[X]/<G>
    1887 ASSUME: - basering is a Letterplace ring. G is a Letterplace ideal.
     2158ASSUME: - basering is a Letterplace ring.
    18882159@*      - if you specify a different degree bound degbound,
    1889 @*        degbound <= attrib(basering,uptodeg) should hold.
     2160@*        degbound <= attrib(basering,uptodeg) holds.
    18902161NOTE: - If degbound is set, there will be a degree bound added. 0 means no
    18912162@*      degree bound. Default: attrib(basering,uptodeg).
     
    19232194RETURN: list
    19242195PURPOSE:Computing the K-dimension and the mistletoes
    1925 ASSUME: - basering is a Letterplace ring. G is a Letterplace ideal.
     2196ASSUME: - basering is a Letterplace ring.
    19262197@*      - if you specify a different degree bound degbound,
    1927 @*        degbound <= attrib(basering,uptodeg) should hold.
     2198@*        degbound <= attrib(basering,uptodeg) holds.
    19282199NOTE: - If L is the list returned, then L[1] is an integer, the K-dimension,
    19292200@*      L[2] is an ideal, the mistletoes.
     
    19622233RETURN: list
    19632234PURPOSE:Computing the Hilbert series and the mistletoes
    1964 ASSUME: - basering is a Letterplace ring. G is a Letterplace ideal.
     2235ASSUME: - basering is a Letterplace ring.
    19652236@*      - if you specify a different degree bound degbound,
    1966 @*        degbound <= attrib(basering,uptodeg) should hold.
     2237@*        degbound <= attrib(basering,uptodeg) holds.
    19672238NOTE: - If L is the list returned, then L[1] is an intvec, corresponding to the
    19682239@*      Hilbert series, L[2] is an ideal, the mistletoes.
     
    20042275RETURN: list
    20052276PURPOSE:Allowing the user to access all procs with one command
    2006 ASSUME: - basering is a Letterplace ring. G is a Letterplace ideal.
     2277ASSUME: - basering is a Letterplace ring.
    20072278@*      - if you specify a different degree bound degbound,
    2008 @*        degbound <= attrib(basering,uptodeg) should hold.
     2279@*        degbound <= attrib(basering,uptodeg) holds.
    20092280NOTE:   The returned object will always be a list, but the entries of the
    20102281@*      returned list may be very different
     
    20622333  sickle(G,0,0,1); // computes Hilbert series only
    20632334}
     2335
     2336proc ivMaxIdeal(int l, int lonly)
     2337  "USAGE: lpMaxIdeal(l, lonly); l an integer, lonly an integer
     2338  RETURN: list
     2339  PURPOSE: computes a list of free monomials in intvec presentation
     2340  @*       with length <= l
     2341  @*       if donly <> 0, only monomials of degree d are returned
     2342  ASSUME: - basering is a Letterplace ring.
     2343  NOTE: see also lpMaxIdeal()
     2344  "
     2345{
     2346  if (l < 0) {
     2347    ERROR("l must not be negative")
     2348  }
     2349  list words;
     2350  if (l == 0) {
     2351     words = 0;
     2352     return (words);
     2353  }
     2354  int lV = attrib(basering, "lV"); // variable count
     2355  list prevWords;
     2356  if (l > 1) {
     2357    prevWords = ivMaxIdeal(l - 1, lonly);
     2358  } else {
     2359    prevWords = 0;
     2360  }
     2361  for (int i = 1; i <= size(prevWords); i++) {
     2362    if (size(prevWords[i]) >= l - 1) {
     2363      for (int j = 1; j <= lV; j++) {
     2364        intvec word = prevWords[i];
     2365        word[l] = j;
     2366        words = insert(words, word);
     2367        kill word;
     2368      } kill j;
     2369    }
     2370  } kill i;
     2371  if (!lonly && l > 1) {
     2372    words = prevWords + words;
     2373  }
     2374  return (words);
     2375}
     2376example {
     2377  "EXAMPLE:"; echo = 2;
     2378  ring r = 0,(a,b,c),dp;
     2379  def R = makeLetterplaceRing(7); setring R;
     2380  ivMaxIdeal(1,0);
     2381  ivMaxIdeal(2,0);
     2382  ivMaxIdeal(2,1);
     2383  ivMaxIdeal(4,0);
     2384  ivMaxIdeal(4,1);
     2385}
     2386
     2387proc lpMaxIdeal(int d, int donly)
     2388  "USAGE: lpMaxIdeal(d, donly); d an integer, donly an integer
     2389  RETURN: ideal
     2390  PURPOSE: computes a list of free monomials of degree at most d
     2391  @*       if donly <> 0, only monomials of degree d are returned
     2392  ASSUME: - basering is a Letterplace ring.
     2393  @*      - d <= attrib(basering,uptodeg) holds.
     2394  NOTE: analogous to maxideal(d) in the commutative case
     2395  "
     2396{
     2397  ivL2lpI(ivMaxIdeal(d, donly));
     2398}
     2399example {
     2400  "EXAMPLE:"; echo = 2;
     2401  ring r = 0,(a,b,c),dp;
     2402  def R = makeLetterplaceRing(7); setring R;
     2403  lpMaxIdeal(1,0);
     2404  lpMaxIdeal(2,0);
     2405  lpMaxIdeal(2,1);
     2406  lpMaxIdeal(4,0);
     2407  lpMaxIdeal(4,1);
     2408}
     2409
     2410proc monomialBasis(int d, int donly, ideal J)
     2411  "USAGE: monomialBasis(d, donly, J); d, donly integers, J an ideal
     2412  RETURN: ideal
     2413  PURPOSE: computes a list of free monomials in a Letterplace
     2414  @*       basering R of degree at most d and not contained in <LM(J)>
     2415  @*       if donly <> 0, only monomials of degree d are returned
     2416  ASSUME: - basering is a Letterplace ring.
     2417  @*      - d <= attrib(basering,uptodeg) holds.
     2418  @*      - J is a Groebner basis
     2419  "
     2420{
     2421  int nv = attrib(basering,"uptodeg");
     2422  if ((d>nv) || (d<0) )
     2423  {
     2424    ERROR("incorrect degree");
     2425  }
     2426  nv = attrib(basering,"lV"); // nvars
     2427  if (d==0)
     2428  {
     2429    return(ideal(1));
     2430  }
     2431  /* from now on d>=1 */
     2432  ideal I;
     2433  if (size(J)==0)
     2434  {
     2435    I = lpMaxIdeal(d,donly);
     2436    if (!donly)
     2437    {
     2438      // append 1 as the first element; d>=1
     2439      I = 1, I;
     2440    }
     2441    return( I );
     2442  }
     2443  // ok, Sickle misbehaves: have to remove all
     2444  // elts from J of degree >d
     2445  ideal JJ;
     2446  int j; int sj = ncols(J);
     2447  int cnt=0;
     2448  for(j=1;j<=sj;j++)
     2449  {
     2450    if (deg(J[j]) <= d)
     2451    {
     2452      cnt++;
     2453      JJ[cnt]=lead(J[j]); // only LMs are needed
     2454    }
     2455  }
     2456  if (cnt==0)
     2457  {
     2458    // there are no elements in J of degree <= d
     2459    // return free stuff and the 1
     2460    I = monomialBasis(d, donly, std(0));
     2461    if (!donly)
     2462    {
     2463      I = 1, I;
     2464    }
     2465    return(I);
     2466  }
     2467  // from here on, Ibase is not zero
     2468  ideal Ibase = lpMis2Base(lpSickle(JJ,d)); // the complete K-basis modulo J up to d
     2469  if (!donly)
     2470  {
     2471    // for not donly, give everything back
     2472    // sort by DP starting with smaller terms
     2473    Ibase = sort(Ibase,"Dp")[1];
     2474    return(Ibase);
     2475  }
     2476  /* !donly: pick out only monomials of degree d */
     2477  int i; int si = ncols(Ibase);
     2478  cnt=0;
     2479  I=0;
     2480  for(i=1;i<=si;i++)
     2481  {
     2482    if (deg(Ibase[i]) == d)
     2483    {
     2484      cnt++;
     2485      I[cnt]=Ibase[i];
     2486    }
     2487  }
     2488  kill Ibase;
     2489  return(I);
     2490}
     2491example {
     2492  "EXAMPLE:"; echo = 2;
     2493  ring r = 0,(x,y),dp;
     2494  def R = makeLetterplaceRing(7); setring R;
     2495  ideal J = x(1)*y(2)*x(3) - y(1)*x(2)*y(3);
     2496  option(redSB); option(redTail);
     2497  J = letplaceGBasis(J);
     2498  J;
     2499  monomialBasis(2,1,std(0));
     2500  monomialBasis(2,0,std(0));
     2501  monomialBasis(3,1,J);
     2502  monomialBasis(3,0,J);
     2503}
     2504
     2505
     2506///////////////////////////////////////////////////////////////////////////////
     2507/* vl: stuff for conversion to Magma and to SD
     2508todo: doc, example
     2509 */
     2510static proc extractVars(r)
     2511{
     2512  int i = 1;
     2513  int j = 1;
     2514  string candidate;
     2515  list result = list();
     2516  for (i = 1; i<=nvars(r);i++)
     2517  {
     2518    candidate = string(var(i))[1,find(string(var(i)),"(")-1];
     2519    if (!inList(result, candidate))
     2520    {
     2521      result = insert(result,candidate,size(result));
     2522    }
     2523  }
     2524  return(result);
     2525}
     2526
     2527static proc letterPlacePoly2MagmaString(poly h)
     2528{
     2529  int pos;
     2530  string s = string(h);
     2531  while(find(s,"("))
     2532  {
     2533    pos = find(s,"(");
     2534    while(s[pos]!=")")
     2535    {
     2536      s = s[1,pos-1]+s[pos+1,size(s)-pos];
     2537    }
     2538    if (size(s)!=pos)
     2539    {
     2540      s = s[1,pos-1]+s[pos+1,size(s)-pos]; // The last (")")
     2541    }
     2542    else
     2543    {
     2544      s = s[1,pos-1];
     2545    }
     2546  }
     2547  return(s);
     2548}
     2549
     2550static proc letterPlaceIdeal2SD(ideal I, int upToDeg)
     2551{
     2552  int i;
     2553  print("Don't forget to fill in the formal Data in the file");
     2554  string result = "<?xml version=\"1.0\"?>"+newline+"<FREEALGEBRA createdAt=\"\" createdBy=\"Singular\" id=\"FREEALGEBRA/\">"+newline;
     2555  result = result + "<vars>"+string(extractVars(basering))+"</vars>"+newline;
     2556  result = result + "<basis>"+newline;
     2557  for (i = 1;i<=size(I);i++)
     2558  {
     2559    result = result + "<poly>"+letterPlacePoly2MagmaString(I[i])+"</poly>"+newline;
     2560  }
     2561  result = result + "</basis>"+newline;
     2562  result = result + "<uptoDeg>"+ string(upToDeg)+"</uptoDeg>"+newline;
     2563  result = result + "<Comment></Comment>"+newline;
     2564  result = result + "<Version></Version>"+newline;
     2565  result = result + "</FREEALGEBRA>";
     2566  return(result);
     2567}
     2568
    20642569
    20652570///////////////////////////////////////////////////////////////////////////////
     
    20982603  example lp2ivId;
    20992604  example lpId2ivLi;
    2100 }
    2101 
    2102 
    2103 
    2104 
     2605  example lpSubstitute;
     2606}
    21052607
    21062608/*
    2107   Here are some examples one may try. Just copy them into your console.
    2108   These are relations for braid groups, up to degree d:
    2109 
    2110 
    2111   LIB "fpadim.lib";
    2112   ring r = 0,(x,y,z),dp;
    2113   int d =10; // degree
    2114   def R = makeLetterplaceRing(d);
    2115   setring R;
    2116   ideal I = y(1)*x(2)*y(3) - z(1)*y(2)*z(3), x(1)*y(2)*x(3) - z(1)*x(2)*y(3),
    2117   z(1)*x(2)*z(3) - y(1)*z(2)*x(3), x(1)*x(2)*x(3) + y(1)*y(2)*y(3) +
    2118   z(1)*z(2)*z(3) + x(1)*y(2)*z(3);
    2119   option(prot);
    2120   option(redSB);option(redTail);option(mem);
    2121   ideal J = system("freegb",I,d,3);
    2122   lpDimCheck(J);
    2123   sickle(J,1,1,1,d);//Computes mistletoes, K-dimension and the Hilbert series
    2124 
    2125 
    2126 
    2127   LIB "fpadim.lib";
    2128   ring r = 0,(x,y,z),dp;
    2129   int d =11; // degree
    2130   def R = makeLetterplaceRing(d);
    2131   setring R;
    2132   ideal I = y(1)*x(2)*y(3) - z(1)*y(2)*z(3), x(1)*y(2)*z(3) - z(1)*x(2)*y(3),
    2133   z(1)*x(2)*z(3) - y(1)*z(2)*x(3), x(1)*x(2)*x(3) + y(1)*y(2)*y(3) +
    2134   z(1)*z(2)*z(3) + x(1)*y(2)*z(3);
    2135   option(prot);
    2136   option(redSB);option(redTail);option(mem);
    2137   ideal J = system("freegb",I,d,3);
    2138   lpDimCheck(J);
    2139   sickle(J,1,1,1,d);
    2140 
    2141 
    2142 
    2143   LIB "fpadim.lib";
    2144   ring r = 0,(x,y,z),dp;
    2145   int d  = 6; // degree
    2146   def R  = makeLetterplaceRing(d);
    2147   setring R;
    2148   ideal I = y(1)*x(2)*y(3) - z(1)*y(2)*z(3), x(1)*y(2)*x(3) - z(1)*x(2)*y(3),
    2149   z(1)*x(2)*z(3) - y(1)*z(2)*x(3), x(1)*x(2)*x(3) -2*y(1)*y(2)*y(3) + 3*z(1)*z(2)*z(3) -4*x(1)*y(2)*z(3) + 5*x(1)*z(2)*z(3)- 6*x(1)*y(2)*y(3) +7*x(1)*x(2)*z(3) - 8*x(1)*x(2)*y(3);
    2150   option(prot);
    2151   option(redSB);option(redTail);option(mem);
    2152   ideal J = system("freegb",I,d,3);
    2153   lpDimCheck(J);
    2154   sickle(J,1,1,1,d);
     2609   Here are some examples one may try. Just copy them into your console.
     2610   These are relations for braid groups, up to degree d:
     2611
     2612   LIB "fpadim.lib";
     2613   ring r = 0,(x,y,z),dp;
     2614   int d =10; // degree
     2615   def R = makeLetterplaceRing(d);
     2616   setring R;
     2617   ideal I = y(1)*x(2)*y(3) - z(1)*y(2)*z(3), x(1)*y(2)*x(3) - z(1)*x(2)*y(3),
     2618   z(1)*x(2)*z(3) - y(1)*z(2)*x(3), x(1)*x(2)*x(3) + y(1)*y(2)*y(3) +
     2619   z(1)*z(2)*z(3) + x(1)*y(2)*z(3);
     2620   option(prot);
     2621   option(redSB);option(redTail);option(mem);
     2622   ideal J = system("freegb",I,d,3);
     2623   lpDimCheck(J);
     2624   sickle(J,1,1,1,d);//Computes mistletoes, K-dimension and the Hilbert series
     2625
     2626
     2627
     2628   LIB "fpadim.lib";
     2629   ring r = 0,(x,y,z),dp;
     2630   int d =11; // degree
     2631   def R = makeLetterplaceRing(d);
     2632   setring R;
     2633   ideal I = y(1)*x(2)*y(3) - z(1)*y(2)*z(3), x(1)*y(2)*z(3) - z(1)*x(2)*y(3),
     2634   z(1)*x(2)*z(3) - y(1)*z(2)*x(3), x(1)*x(2)*x(3) + y(1)*y(2)*y(3) +
     2635   z(1)*z(2)*z(3) + x(1)*y(2)*z(3);
     2636   option(prot);
     2637   option(redSB);option(redTail);option(mem);
     2638   ideal J = system("freegb",I,d,3);
     2639   lpDimCheck(J);
     2640   sickle(J,1,1,1,d);
     2641
     2642
     2643
     2644   LIB "fpadim.lib";
     2645   ring r = 0,(x,y,z),dp;
     2646   int d  = 6; // degree
     2647   def R  = makeLetterplaceRing(d);
     2648   setring R;
     2649   ideal I = y(1)*x(2)*y(3) - z(1)*y(2)*z(3), x(1)*y(2)*x(3) - z(1)*x(2)*y(3),
     2650   z(1)*x(2)*z(3) - y(1)*z(2)*x(3), x(1)*x(2)*x(3) -2*y(1)*y(2)*y(3) + 3*z(1)*z(2)*z(3) -4*x(1)*y(2)*z(3) + 5*x(1)*z(2)*z(3)- 6*x(1)*y(2)*y(3) +7*x(1)*x(2)*z(3) - 8*x(1)*x(2)*y(3);
     2651   option(prot);
     2652   option(redSB);option(redTail);option(mem);
     2653   ideal J = system("freegb",I,d,3);
     2654   lpDimCheck(J);
     2655   sickle(J,1,1,1,d);
     2656 */
     2657
     2658/*
     2659   Here are some examples, which can also be found in [studzins]:
     2660
     2661// takes up to 880Mb of memory
     2662LIB "fpadim.lib";
     2663ring r = 0,(x,y,z),dp;
     2664int d =10; // degree
     2665def R = makeLetterplaceRing(d);
     2666setring R;
     2667ideal I =
     2668z(1)*z(2)*z(3)*z(4) + y(1)*x(2)*y(3)*x(4) - x(1)*y(2)*y(3)*x(4) - 3*z(1)*y(2)*x(3)*z(4), x(1)*x(2)*x(3) + y(1)*x(2)*y(3) - x(1)*y(2)*x(3), z(1)*y(2)*x(3)-x(1)*y(2)*z(3) + z(1)*x(2)*z(3);
     2669option(prot);
     2670option(redSB);option(redTail);option(mem);
     2671ideal J = system("freegb",I,d,nvars(r));
     2672lpDimCheck(J);
     2673sickle(J,1,1,1,d); // dimension is 24872
     2674
     2675
     2676LIB "fpadim.lib";
     2677ring r = 0,(x,y,z),dp;
     2678int d =10; // degree
     2679def R = makeLetterplaceRing(d);
     2680setring R;
     2681ideal I = x(1)*y(2) + y(1)*z(2), x(1)*x(2) + x(1)*y(2) - y(1)*x(2) - y(1)*y(2);
     2682option(prot);
     2683option(redSB);option(redTail);option(mem);
     2684ideal J = system("freegb",I,d,3);
     2685lpDimCheck(J);
     2686sickle(J,1,1,1,d);
     2687 */
     2688
     2689
     2690/*
     2691   Example for computing GK dimension:
     2692   returns a ring which contains an ideal I
     2693   run gkDim(I) inside this ring and it should return 2n (the GK dimension
     2694   of n-th Weyl algebra including evaluation operators).
     2695
     2696   static proc createWeylEx(int n, int d)
     2697   "
     2698   "
     2699   {
     2700   int baseringdef;
     2701   if (defined(basering)) // if a basering is defined, it should be saved for later use
     2702   {
     2703   def save = basering;
     2704   baseringdef = 1;
     2705   }
     2706   ring r = 0,(d(1..n),x(1..n),e(1..n)),dp;
     2707   def R = makeLetterplaceRing(d);
     2708   setring R;
     2709   ideal I; int i,j;
     2710
     2711   for (i = 1; i <= n; i++)
     2712   {
     2713   for (j = i+1; j<= n; j++)
     2714   {
     2715   I[size(I)+1] = lpMult(var(i),var(j));
     2716   }
     2717   }
     2718
     2719   for (i = 1; i <= n; i++)
     2720   {
     2721   for (j = i+1; j<= n; j++)
     2722   {
     2723   I[size(I)+1] = lpMult(var(n+i),var(n+j));
     2724   }
     2725   }
     2726   for (i = 1; i <= n; i++)
     2727   {
     2728   for (j = 1; j<= n; j++)
     2729   {
     2730   I[size(I)+1] = lpMult(var(i),var(n+j));
     2731   }
     2732   }
     2733   for (i = 1; i <= n; i++)
     2734   {
     2735   for (j = 1; j<= n; j++)
     2736   {
     2737   I[size(I)+1] = lpMult(var(i),var(2*n+j));
     2738   }
     2739   }
     2740   for (i = 1; i <= n; i++)
     2741   {
     2742   for (j = 1; j<= n; j++)
     2743   {
     2744   I[size(I)+1] = lpMult(var(2*n+i),var(n+j));
     2745   }
     2746   }
     2747   for (i = 1; i <= n; i++)
     2748   {
     2749   for (j = 1; j<= n; j++)
     2750   {
     2751   I[size(I)+1] = lpMult(var(2*n+i),var(2*n+j));
     2752   }
     2753   }
     2754   I = simplify(I,2+4);
     2755   I = letplaceGBasis(I);
     2756   export(I);
     2757   if (baseringdef == 1) {setring save;}
     2758   return(R);
     2759   }
     2760
     2761proc TestGKAuslander3()
     2762{
     2763  ring r = (0,q),(z,x,y),(dp(1),dp(2));
     2764  def R = makeLetterplaceRing(5); // constructs a Letterplace ring
     2765  R; setring R; // sets basering to Letterplace ring
     2766  ideal I;
     2767  I = q*x(1)*y(2) - y(1)*x(2), z(1)*y(2) - y(1)*z(2), z(1)*x(2) - x(1)*z(2);
     2768  I = letplaceGBasis(I);
     2769  lpGkDim(I); // must be 3
     2770  I = x(1)*y(2)*z(3) - y(1)*x(2), z(1)*y(2) - y(1)*z(2), z(1)*x(2) - x(1)*z(2);//gkDim = 2
     2771  I = letplaceGBasis(I); // not finite BUT contains a poly in x,y only
     2772  lpGkDim(I); // must be 4
     2773
     2774  ring r = 0,(y,x,z),dp;
     2775  def R = makeLetterplaceRing(10); // constructs a Letterplace ring
     2776  R; setring R; // sets basering to Letterplace ring
     2777  ideal I;
     2778  I = x(1)*y(2)*z(3) - y(1)*x(2), z(1)*y(2) - y(1)*z(2), z(1)*x(2) - x(1)*z(2);//gkDim = 2
     2779  I = letplaceGBasis(I); // computed as it would be homogenized; infinite
     2780  poly p = x(1)*y(2)*y(3)*x(4)-y(1)*x(2)*x(3)*y(4);
     2781  lpNF(p, I); // 0 as expected
     2782
     2783  // with inverse of z
     2784  ring r = 0,(iz,z,x,y),dp;
     2785  def R = makeLetterplaceRing(11); // constructs a Letterplace ring
     2786  R; setring R; // sets basering to Letterplace ring
     2787  ideal I;
     2788  I = x(1)*y(2)*z(3) - y(1)*x(2), z(1)*y(2) - y(1)*z(2), z(1)*x(2) - x(1)*z(2),
     2789    iz(1)*y(2) - y(1)*iz(2), iz(1)*x(2) - x(1)*iz(2), iz(1)*z(2)-1, z(1)*iz(2) -1;
     2790  I = letplaceGBasis(I); //
     2791  setring r;
     2792  def R2 = makeLetterplaceRing(23); // constructs a Letterplace ring
     2793  setring R2; // sets basering to Letterplace ring
     2794  ideal I = imap(R,I);
     2795  lpGkDim(I);
     2796
     2797
     2798  ring r = 0,(t,z,x,y),(dp(2),dp(2));
     2799  def R = makeLetterplaceRing(20); // constructs a Letterplace ring
     2800  R; setring R; // sets basering to Letterplace ring
     2801  ideal I;
     2802  I = x(1)*y(2)*z(3) - y(1)*x(2)*t(3), z(1)*y(2) - y(1)*z(2), z(1)*x(2) - x(1)*z(2),
     2803    t(1)*y(2) - y(1)*t(2), t(1)*x(2) - x(1)*t(2), t(1)*z(2) - z(1)*t(2);//gkDim = 2
     2804  I = letplaceGBasis(I); // computed as it would be homogenized; infinite
     2805  LIB "elim.lib";
     2806  ideal Inoz = nselect(I,intvec(2,6,10,14,18,22,26,30));
     2807  for(int i=1; i<=20; i++)
     2808  {
     2809    Inoz=subst(Inoz,t(i),1);
     2810  }
     2811  ideal J = x(1)*y(2)*y(3)*x(4)-y(1)*x(2)*x(3)*y(4);
     2812  J = letplaceGBasis(J);
     2813
     2814  poly p = x(1)*y(2)*y(3)*x(4)-y(1)*x(2)*x(3)*y(4);
     2815  lpNF(p, I); // 0 as expected
     2816
     2817  ring r2 = 0,(x,y),dp;
     2818  def R2 = makeLetterplaceRing(50); // constructs a Letterplace ring
     2819  setring R2;
     2820  ideal J = x(1)*y(2)*y(3)*x(4)-y(1)*x(2)*x(3)*y(4);
     2821  J = letplaceGBasis(J);
     2822}
     2823
    21552824*/
    21562825
    2157 /*
    2158   Here are some examples, which can also be found in [studzins]:
    2159 
    2160   // takes up to 880Mb of memory
    2161   LIB "fpadim.lib";
    2162   ring r = 0,(x,y,z),dp;
    2163   int d =10; // degree
    2164   def R = makeLetterplaceRing(d);
    2165   setring R;
    2166   ideal I =
    2167   z(1)*z(2)*z(3)*z(4) + y(1)*x(2)*y(3)*x(4) - x(1)*y(2)*y(3)*x(4) - 3*z(1)*y(2)*x(3)*z(4), x(1)*x(2)*x(3) + y(1)*x(2)*y(3) - x(1)*y(2)*x(3), z(1)*y(2)*x(3)-x(1)*y(2)*z(3) + z(1)*x(2)*z(3);
    2168   option(prot);
    2169   option(redSB);option(redTail);option(mem);
    2170   ideal J = system("freegb",I,d,nvars(r));
    2171   lpDimCheck(J);
    2172   sickle(J,1,1,1,d); // dimension is 24872
    2173 
    2174 
    2175   LIB "fpadim.lib";
    2176   ring r = 0,(x,y,z),dp;
    2177   int d =10; // degree
    2178   def R = makeLetterplaceRing(d);
    2179   setring R;
    2180   ideal I = x(1)*y(2) + y(1)*z(2), x(1)*x(2) + x(1)*y(2) - y(1)*x(2) - y(1)*y(2);
    2181   option(prot);
    2182   option(redSB);option(redTail);option(mem);
    2183   ideal J = system("freegb",I,d,3);
    2184   lpDimCheck(J);
    2185   sickle(J,1,1,1,d);
    2186 */
     2826
     2827/*   more tests : downup algebra A
     2828LIB "fpadim.lib";
     2829ring r = (0,a,b,g),(x,y),Dp;
     2830def R = makeLetterplaceRing(6); // constructs a Letterplace ring
     2831setring R;
     2832poly F1 = g*x(1);
     2833poly F2 = g*y(1);
     2834ideal J = x(1)*x(2)*y(3)-a*x(1)*y(2)*x(3) - b*y(1)*x(2)*x(3) - F1,
     2835x(1)*y(2)*y(3)-a*y(1)*x(2)*y(3) - b*y(1)*y(2)*x(3) - F2;
     2836J = letplaceGBasis(J);
     2837lpGkDim(J); // 3 == correct
     2838
     2839// downup algebra B
     2840LIB "fpadim.lib";
     2841ring r = (0,a,b,g, p(1..7),q(1..7)),(x,y),Dp;
     2842def R = makeLetterplaceRing(6); // constructs a Letterplace ring
     2843setring R;
     2844ideal imn = 1, y(1)*y(2)*y(3), x(1)*y(2), y(1)*x(2), x(1)*x(2), y(1)*y(2), x(1), y(1);
     2845int i;
     2846poly F1, F2;
     2847for(i=1;i<=7;i++)
     2848{
     2849F1 = F1 + p(i)*imn[i];
     2850F2 = F2 + q(i)*imn[i];
     2851}
     2852ideal J = x(1)*x(2)*y(3)-a*x(1)*y(2)*x(3) - b*y(1)*x(2)*x(3) - F1,
     2853x(1)*y(2)*y(3)-a*y(1)*x(2)*y(3) - b*y(1)*y(2)*x(3) - F2;
     2854J = letplaceGBasis(J);
     2855lpGkDim(J); // 3 == correct
     2856
     2857 */
  • Singular/LIB/freegb.lib

    r6b02216 rfbd9e6f  
    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
     10
     11Support: Joint projects LE 2697/2-1 and KR 1907/3-1 of the Priority Programme SPP 1489:
     12'Algorithmische und Experimentelle Methoden in Algebra, Geometrie und Zahlentheorie'
     13of the German DFG
     14and Project II.6 of the transregional collaborative research centre
     15SFB-TRR 195 'Symbolic Tools in Mathematics and their Application' of the German DFG
    1116
    1217PROCEDURES:
    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
     18makeLetterplaceRing(d); creates a ring with d blocks of shifted original variables
     19letplaceGBasis(I); computes two-sided Groebner basis of a letterplace ideal I up to a degree bound
     20lpNF(f,I); two-sided normal form of f with respect to ideal I
    2021setLetterplaceAttributes(R,d,b); supplies ring R with the letterplace structure
    21 
     22freeGBasis(L, n);  computes two-sided Groebner basis of an ideal, encoded via list L, up to degree n
    2223
    2324lpMult(f,g);    letterplace multiplication of letterplace polynomials
    2425shiftPoly(p,i); compute the i-th shift of letterplace polynomial p
    2526lpPower(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
     27lieBracket(a,b[, N]);  compute Lie bracket ab-ba of two letterplace polynomials
     28
     29lp2lstr(K, s);  convert a letterplace ideal into a list of modules
     30lst2str(L[, n]); convert a list (of modules) into polynomials in free algebra via strings
     31mod2str(M[, n]); convert a module into a polynomial in free algebra via strings
    2932vct2str(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
     33
     34serreRelations(A,z); compute the homogeneous part of Serre's relations associated to a generalized Cartan matrix A
     35fullSerreRelations(A,N,C,P,d); compute the ideal of all Serre's relations associated to a generalized Cartan matrix A
     36isVar(p);              check whether p is a power of a single variable
    3637ademRelations(i,j);    compute the ideal of Adem relations for i<2j in char 0
    3738
     
    968969RETURN:  ring
    969970PURPOSE: creates a ring with the ordering, used in letterplace computations
    970 NOTE: if h is given and nonzero, the pure homogeneous letterplace block
    971 @*    ordering will be used.
     971NOTE: h = 0 (default) : Dp ordering will be used
     972h = 2 : weights 1 used for all the variables, a tie breaker is a list of block of original ring
     973h = 1 : the pure homogeneous letterplace block ordering (applicable in the situation of homogeneous input ideals) will be used.
    972974EXAMPLE: example makeLetterplaceRing; shows examples
    973975"
    974976{
    975   int use_old_mlr = 0;
     977  int alternativeVersion = 2; // temporary until makeLetterplaceRing4() is fixed
    976978  if ( size(#)>0 )
    977979  {
    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)
     980    if (typeof(#[1]) == "int")
     981    {
     982      alternativeVersion = #[1];
     983    }
     984  }
     985  if (alternativeVersion == 1)
    988986  {
    989987    def @A = makeLetterplaceRing1(d);
    990988  }
    991   else
    992   {
    993     def @A = makeLetterplaceRing2(d);
     989  else {
     990    if (alternativeVersion == 2)
     991    {
     992      def @A = makeLetterplaceRing2(d);
     993    }
     994    else {
     995      def @A = makeLetterplaceRing4(d);
     996    }
    994997  }
    995998  return(@A);
     
    12051208}
    12061209
     1210static proc makeLetterplaceRing4(int d)
     1211"USAGE:  makeLetterplaceRing2(d); d an integer
     1212RETURN:  ring
     1213PURPOSE: creates a Letterplace ring with a Dp ordering, suitable for
     1214@* the use of non-homogeneous letterplace
     1215NOTE: the matrix for the ordering looks as follows: first row is 1,1,...,1
     1216EXAMPLE: example makeLetterplaceRing2; shows examples
     1217"
     1218{
     1219
     1220  // ToDo future: inherit positive weights in the orig ring
     1221  // complain on nonpositive ones
     1222
     1223  // d = up to degree, will be shifted to d+1
     1224  if (d<1) {"bad d"; return(0);}
     1225
     1226  int uptodeg = d; int lV = nvars(basering);
     1227
     1228  int ppl = printlevel-voice+2;
     1229  string err = "";
     1230
     1231  int i,j,s;
     1232  def save = basering;
     1233  int D = d-1;
     1234  list LR  = ringlist(save);
     1235  list L, tmp, tmp2, tmp3;
     1236  L[1] = LR[1]; // ground field
     1237  L[4] = LR[4]; // quotient ideal
     1238  tmp  = LR[2]; // varnames
     1239  s = size(LR[2]);
     1240  for (i=1; i<=D; i++)
     1241  {
     1242    for (j=1; j<=s; j++)
     1243    {
     1244      tmp[i*s+j] = string(tmp[j])+"("+string(i+1)+")";
     1245    }
     1246  }
     1247  for (i=1; i<=s; i++)
     1248  {
     1249    tmp[i] = string(tmp[i])+"("+string(1)+")";
     1250  }
     1251  L[2] = tmp;
     1252  list OrigNames = LR[2];
     1253
     1254  s = size(LR[3]);
     1255  list ordering;
     1256  ordering[1] = list("Dp",intvec(1: int(d*lV)));
     1257  ordering[2] = LR[3][s]; // module ord to place at the very end
     1258  LR[3] = ordering;
     1259
     1260  L[3] = LR[3];
     1261  attrib(L,"maxExp",1);
     1262  def @R = ring(L);
     1263  def @@R = setLetterplaceAttributes(@R,uptodeg,lV);
     1264  return (@@R);
     1265}
     1266example
     1267{
     1268  "EXAMPLE:"; echo = 2;
     1269  ring r = 0,(x,y,z),(dp(1),dp(2));
     1270  def A = makeLetterplaceRing2(2);
     1271  setring A;
     1272  A;
     1273  attrib(A,"isLetterplaceRing");
     1274  attrib(A,"uptodeg");  // degree bound
     1275  attrib(A,"lV"); // number of variables in the main block
     1276}
     1277
    12071278// P[s;sigma] approach
    12081279static proc makeLetterplaceRing3(int d)
     
    13141385  attrib(A,"lV"); // number of variables in the main block
    13151386}
    1316 
    1317 
    13181387
    13191388/* EXAMPLES:
     
    26002669  if (i>N)
    26012670  {
    2602     ERROR("The total number of elements in input ideals must not exceed the dimension of the ground ring");
     2671    string s1="The total number of elements in input ideals";
     2672    string s2="must not exceed the dimension of the ground ring";
     2673    ERROR(s1+s2);
    26032674  }
    26042675  if (i < N)
     
    30293100*/
    30303101
    3031 //static
    3032 proc lpMultX(poly f, poly g)
     3102static proc lpMultX(poly f, poly g)
    30333103{
    30343104  /* multiplies two polys in a very general setting correctly */
     
    30833153}
    30843154
    3085 // TODO:
    30863155// multiply two letterplace polynomials, lpMult: done
    30873156// reduction/ Normalform? needs kernel stuff
     
    31723241//@* else there wouldn't be an dvec representation
    31733242
    3174 //Mainprocedure for the user
     3243//Main procedure for the user
    31753244
    31763245proc lpNF(poly p, ideal G)
    31773246"USAGE: lpNF(p,G); f letterplace polynomial, ideal I
    31783247RETURN: poly
    3179 PURPOSE: computation of the normalform of p with respect to G
     3248PURPOSE: computation of the normal form of p with respect to G
    31803249ASSUME: p is a Letterplace polynomial, G is a set Letterplace polynomials,
    31813250being a Letterplace Groebner basis (no check for this will be done)
    31823251NOTE: 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
     3252-     For homogenous ideals the shift does not matter
     3253-     For non-homogenous ideals the first shift will be the smallest monomial
    31853254EXAMPLE: example lpNF; shows examples
    31863255"
     
    31893258 G = sort(G)[1];
    31903259 list L = makeDVecI(G);
    3191  return(normalize(lpNormalForm1(p,G,L)));
     3260 return(normalize(lpNormalForm2(p,G,L)));
    31923261}
    31933262example
     
    32143283RETURN: list of intvecs
    32153284PURPOSE: convert G into a list of intvecs, corresponding to the exponent vector
    3216 @* of the leading monomials of G
     3285 of the leading monomials of G
    32173286"
    32183287{int i; list L;
     
    32203289 return(L);
    32213290}
    3222 
    32233291
    32243292static proc delSupZero(intvec I)
     
    32473315}
    32483316
    3249 
    32503317static proc delSupZeroList(list L)
    32513318"USUAGE:delSupZeroList(L); L a list, containing intvecs
     
    33263393}
    33273394
    3328 
    3329 
    3330 //the actual normalform procedure, if a user want not to presort the ideal, just make it not static
    3331 
     3395//the first normal form procedure, if a user want not to presort the ideal, just make it not static
    33323396
    33333397static proc lpNormalForm1(poly p, ideal G, list L)
     
    33583422
    33593423
     3424// new VL; called from lpNF
     3425static proc lpNormalForm2(poly pp, ideal G, list L)
     3426"USUAGE:lpNormalForm2(p,G);
     3427RETURN:poly
     3428PURPOSE:computation of the normal form of p w.r.t. G
     3429ASSUME: p is a Letterplace polynomial, G is a set of Letterplace polynomials
     3430NOTE: Taking the first possible reduction
     3431"
     3432{
     3433 poly one = 1;
     3434 if ( (pp == 0) || (leadmonom(pp) == one) ) { return(pp); }
     3435 poly p = pp; poly q;
     3436 int i; int s; intvec V;
     3437 while ( (p != 0) && (leadmonom(p) != one) )
     3438 {
     3439   //"entered while with p="; p;
     3440   V = makeDVec(delSupZero(leadexp(p)));
     3441   i = 0;
     3442   s = -1;
     3443   //"look for divisor";
     3444   while ( (s == -1) && (i<size(L)) )
     3445   {
     3446     i = i+1;
     3447     s = dShiftDiv(V, L[i])[1];
     3448   }
     3449 // now, out of here: either i=size(L) and s==-1 => no reduction
     3450 // otherwise: i<=size(L) and s!= -1 => reduction
     3451    //"out of divisor search: s="; s; "i="; i;
     3452    if (s != -1)
     3453    {
     3454    //"start reducing with G[i]:";
     3455      p = lpReduce(p,G[i],s); // lm-reduction
     3456      //"reduced to p="; p;
     3457    }
     3458    else
     3459    {
     3460      // ie no lm-reduction possible; proceed with the tail reduction
     3461      q = p-lead(p);
     3462      p = lead(p);
     3463      if (q!=0)
     3464      {
     3465        p = p + lpNormalForm2(q,G,L);
     3466      }
     3467      return(p);
     3468    }
     3469 }
     3470 // out of while when p==0 or p == const
     3471 return(p);
     3472}
     3473
     3474
    33603475
    33613476
     
    35213636// // interface
    35223637
    3523 // proc whichshift(poly p, int numvars)
     3638// static proc whichshift(poly p, int numvars)
    35243639// {
    35253640// // numvars = number of vars of the orig free algebra
     
    35383653
    35393654// LIB "qhmoduli.lib";
    3540 // proc polyshift(poly p,  int numvars)
     3655// static proc polyshift(poly p,  int numvars)
    35413656// {
    35423657//   poly q = p; int i = 0;
     
    36153730  lpMultX(a,b); // seems to work properly
    36163731}
     3732
     3733/* THE FOLLOWING ARE UNDER DEVELOPMENT
     3734// copied following from freegb_wrkcp.lib by Karim Abou Zeid on 07.04.2017:
     3735// makeLetterplaceRingElim(int d)
     3736// makeLetterplaceRingNDO(int d)
     3737// setLetterplaceAttributesElim(def R, int uptodeg, int lV)
     3738// lpElimIdeal(ideal I)
     3739// makeLetterplaceRingWt(int d, intvec W)
     3740
     3741static proc makeLetterplaceRingElim(int d)
     3742"USAGE:  makeLetterplaceRingElim(d); d integers
     3743RETURN:  ring
     3744PURPOSE: creates a ring with an elimination ordering
     3745NOTE: the matrix for the ordering looks as follows: first row is 1,..,0,1,0,..
     3746@* then 0,1,0,...,0,0,1,0... and so on, lastly its lp
     3747@* this ordering is only correct if only polys with same shift are compared
     3748EXAMPLE: example makeLetterplaceRingElim; shows examples
     3749"
     3750{
     3751
     3752  // ToDo future: inherit positive weights in the orig ring
     3753  // complain on nonpositive ones
     3754
     3755  // d = up to degree, will be shifted to d+1
     3756  if (d<1) {"bad d"; return(0);}
     3757
     3758  int uptodeg = d; int lV = nvars(basering);
     3759
     3760  int ppl = printlevel-voice+2;
     3761  string err = "";
     3762
     3763  int i,j,s; intvec iV,iVl;
     3764  def save = basering;
     3765  int D = d-1;
     3766  list LR  = ringlist(save);
     3767  list L, tmp, tmp2, tmp3;
     3768  L[1] = LR[1]; // ground field
     3769  L[4] = LR[4]; // quotient ideal
     3770  tmp  = LR[2]; // varnames
     3771  s = size(LR[2]);
     3772  for (i=1; i<=D; i++)
     3773  {
     3774    for (j=1; j<=s; j++)
     3775    {
     3776      tmp[i*s+j] = string(tmp[j])+"("+string(i+1)+")";
     3777    }
     3778  }
     3779  for (i=1; i<=s; i++)
     3780  {
     3781    tmp[i] = string(tmp[i])+"("+string(1)+")";
     3782  }
     3783  L[2] = tmp;
     3784  L[3] = list();
     3785  list OrigNames = LR[2];
     3786  s = size(LR[3]);
     3787  //creation of first block
     3788
     3789  if (s==2)
     3790  {
     3791    // not a blockord, 1 block + module ord
     3792    tmp = LR[3][s]; // module ord
     3793    for (i = 1; i <= lV;  i++)
     3794    {
     3795      iV = (0: lV);
     3796      iV[i] = 1;
     3797      iVl = iV;
     3798      for (j = 1; j <= D; j++)
     3799       { iVl = iVl,iV; }
     3800      L[3][i] = list("a",iVl);
     3801    }
     3802//    for (i=1; i<=d; i++)
     3803//    {
     3804//      LR[3][s-1+i] = LR[3][1];
     3805//    }
     3806    //    LR[3][s+D] = tmp;
     3807    //iV = (1:(d*lV));
     3808    L[3][lV+1] = list("lp",(1:(d*lV)));
     3809    L[3][lV+2] = tmp;
     3810  }
     3811  else {ERROR("Please set the ordering of basering to dp");}
     3812//  if (s>2)
     3813//  {
     3814//    // there are s-1 blocks
     3815//    int nb = s-1;
     3816//    tmp = LR[3][s]; // module ord to place at the very end
     3817//   tmp2 = LR[3]; tmp2 = tmp2[1..nb];
     3818//    LR[3][1] = list("a",LTO);
     3819//    //tmp3[1] = list("a",intvec(1: int(d*lV))); // deg-ord, insert as the 1st
     3820//    for (i=1; i<=d; i++)
     3821//    {
     3822//      tmp3 = tmp3 + tmp2;
     3823//    }
     3824//    tmp3 = tmp3 + list(tmp);
     3825//    LR[3] = tmp3;
     3826//     for (i=1; i<=d; i++)
     3827//     {
     3828//       for (j=1; j<=nb; j++)
     3829//       {
     3830//         //        LR[3][i*nb+j+1]= LR[3][j];
     3831//         LR[3][i*nb+j+1]= tmp2[j];
     3832//       }
     3833//     }
     3834//     //    size(LR[3]);
     3835//     LR[3][(s-1)*d+2] = tmp;
     3836//     LR[3] = list("a",intvec(1: int(d*lV))) + LR[3]; // deg-ord, insert as the 1st
     3837    // remove everything behind nb*(D+1)+1 ?
     3838    //    tmp = LR[3];
     3839    //    LR[3] = tmp[1..size(tmp)-1];
     3840 // }
     3841 // L[3] = LR[3];
     3842  def @R = ring(L);
     3843  //  setring @R;
     3844  //  int uptodeg = d; int lV = nvars(basering); // were defined before
     3845  def @@R = setLetterplaceAttributesElim(@R,uptodeg,lV);
     3846  return (@@R);
     3847}
     3848example
     3849{
     3850  "EXAMPLE:"; echo = 2;
     3851  ring r = 0,(x,y,z),lp;
     3852  def A = makeLetterplaceRingElim(2);
     3853  setring A;
     3854  A;
     3855  attrib(A,"isLetterplaceRing");
     3856  attrib(A,"uptodeg");  // degree bound
     3857  attrib(A,"lV"); // number of variables in the main block
     3858}
     3859
     3860
     3861
     3862static proc makeLetterplaceRingNDO(int d)
     3863"USAGE:  makeLetterplaceRingNDO(d); d an integer
     3864RETURN:  ring
     3865PURPOSE: creates a ring with a non-degree first ordering, suitable for
     3866@* the use of non-homogeneous letterplace
     3867NOTE: the matrix for the ordering looks as follows:
     3868@*    'd' blocks of shifted original variables
     3869EXAMPLE: example makeLetterplaceRingNDO; shows examples
     3870"
     3871{
     3872
     3873  // ToDo future: inherit positive weights in the orig ring
     3874  // complain on nonpositive ones
     3875
     3876  // d = up to degree, will be shifted to d+1
     3877  if (d<1) {"bad d"; return(0);}
     3878
     3879  int uptodeg = d; int lV = nvars(basering);
     3880
     3881  int ppl = printlevel-voice+2;
     3882  string err = "";
     3883
     3884  int i,j,s;
     3885  def save = basering;
     3886  int D = d-1;
     3887  list LR  = ringlist(save);
     3888  list L, tmp, tmp2, tmp3;
     3889  L[1] = LR[1]; // ground field
     3890  L[4] = LR[4]; // quotient ideal
     3891  tmp  = LR[2]; // varnames
     3892  s = size(LR[2]);
     3893  for (i=1; i<=D; i++)
     3894  {
     3895    for (j=1; j<=s; j++)
     3896    {
     3897      tmp[i*s+j] = string(tmp[j])+"("+string(i+1)+")";
     3898    }
     3899  }
     3900  for (i=1; i<=s; i++)
     3901  {
     3902    tmp[i] = string(tmp[i])+"("+string(1)+")";
     3903  }
     3904  L[2] = tmp;
     3905  list OrigNames = LR[2];
     3906  // ordering: one 1..1 a above
     3907  // ordering: d blocks of the ord on r
     3908  // try to get whether the ord on r is blockord itself
     3909  // TODO: make L(2) ordering! exponent is maximally 2
     3910  s = size(LR[3]);
     3911  if (s==2)
     3912  {
     3913    // not a blockord, 1 block + module ord
     3914    tmp = LR[3][s]; // module ord
     3915    for (i=1; i<=d; i++)
     3916    {
     3917      LR[3][i] = LR[3][1];
     3918    }
     3919    //    LR[3][s+D] = tmp;
     3920    LR[3][d+1] = tmp;
     3921    //LR[3][1] = list("a",intvec(1: int(d*lV))); // deg-ord not wanted here
     3922  }
     3923  if (s>2)
     3924  {
     3925    // there are s-1 blocks
     3926    int nb = s-1;
     3927    tmp = LR[3][s]; // module ord to place at the very end
     3928    tmp2 = LR[3]; tmp2 = tmp2[1..nb];
     3929    //tmp3[1] = list("a",intvec(1: int(d*lV))); // deg-ord not wanted here
     3930    for (i=1; i<=d; i++)
     3931    {
     3932      tmp3 = tmp3 + tmp2;
     3933    }
     3934    tmp3 = tmp3 + list(tmp);
     3935    LR[3] = tmp3;
     3936//     for (i=1; i<=d; i++)
     3937//     {
     3938//       for (j=1; j<=nb; j++)
     3939//       {
     3940//         //        LR[3][i*nb+j+1]= LR[3][j];
     3941//         LR[3][i*nb+j+1]= tmp2[j];
     3942//       }
     3943//     }
     3944//     //    size(LR[3]);
     3945//     LR[3][(s-1)*d+2] = tmp;
     3946//     LR[3] = list("a",intvec(1: int(d*lV))) + LR[3]; // deg-ord, insert as the 1st
     3947    // remove everything behind nb*(D+1)+1 ?
     3948    //    tmp = LR[3];
     3949    //    LR[3] = tmp[1..size(tmp)-1];
     3950  }
     3951  L[3] = LR[3];
     3952  def @R = ring(L);
     3953  //  setring @R;
     3954  //  int uptodeg = d; int lV = nvars(basering); // were defined before
     3955  def @@R = setLetterplaceAttributes(@R,uptodeg,lV);
     3956  return (@@R);
     3957}
     3958example
     3959{
     3960  "EXAMPLE:"; echo = 2;
     3961  ring r = 0,(x,y,z),lp;
     3962  def A = makeLetterplaceRingNDO(2);
     3963  setring A;
     3964  A;
     3965  attrib(A,"isLetterplaceRing");
     3966  attrib(A,"uptodeg");  // degree bound
     3967  attrib(A,"lV"); // number of variables in the main block
     3968}
     3969
     3970static proc setLetterplaceAttributesElim(def R, int uptodeg, int lV)
     3971"USAGE: setLetterplaceAttributesElim(R, d, b, eV); R a ring, b,d, eV integers
     3972RETURN: ring with special attributes set
     3973PURPOSE: sets attributes for a letterplace ring:
     3974@*      'isLetterplaceRing' = true, 'uptodeg' = d, 'lV' = b, 'eV' = eV, where
     3975@*      'uptodeg' stands for the degree bound,
     3976@*      'lV' for the number of variables in the block 0
     3977@*      'eV' for the number of elimination variables
     3978NOTE: Activate the resulting ring by using @code{setring}
     3979"
     3980{
     3981  if (uptodeg*lV != nvars(R))
     3982  {
     3983    ERROR("uptodeg and lV do not agree on the basering!");
     3984  }
     3985
     3986
     3987    // Set letterplace-specific attributes for the output ring!
     3988  attrib(R, "uptodeg", uptodeg);
     3989  attrib(R, "lV", lV);
     3990  attrib(R, "isLetterplaceRing", 1);
     3991  attrib(R, "HasElimOrd", 1);
     3992  return (R);
     3993}
     3994example
     3995{
     3996  "EXAMPLE:"; echo = 2;
     3997  ring r = 0,(x(1),y(1),x(2),y(2),x(3),y(3),x(4),y(4)),dp;
     3998  def R = setLetterplaceAttributesElim(r, 4, 2, 1); setring R;
     3999  attrib(R,"isLetterplaceRing");
     4000  lieBracket(x(1),y(1),2);
     4001}
     4002
     4003
     4004static proc lpElimIdeal(ideal I)
     4005"
     4006does not work for degree reasons (deg function does not work for lp rings -> newone!)
     4007"
     4008{
     4009  def lpring = attrib(basering,"isLetterplaceRing");
     4010  def lpEO =  attrib(basering,"HasElimOrd");
     4011  if ( typeof(lpring)!="int" && typeof(lpEO)!="int")
     4012  {
     4013    ERROR("Ring is not a lp-ring with an elimination ordering");
     4014  }
     4015
     4016  //int nE = attrib(basering, "eV");
     4017
     4018  return(letplaceGBasis(I));
     4019}
     4020
     4021
     4022static proc makeLetterplaceRingWt(int d, intvec W)
     4023"USAGE:  makeLetterplaceRingWt(d,W); d an integer, W a vector of positive integers
     4024RETURN:  ring
     4025PURPOSE: creates a ring with a special ordering, suitable for
     4026@* the use of non-homogeneous letterplace
     4027NOTE: the matrix for the ordering looks as follows: first row is W,W,W,...
     4028@* then there come 'd' blocks of shifted original variables
     4029EXAMPLE: example makeLetterplaceRing2; shows examples
     4030"
     4031{
     4032
     4033  // ToDo future: inherit positive weights in the orig ring
     4034  // complain on nonpositive ones
     4035
     4036  // d = up to degree, will be shifted to d+1
     4037  if (d<1) {"bad d"; return(0);}
     4038
     4039  int uptodeg = d; int lV = nvars(basering);
     4040
     4041  //check weightvector
     4042  if (size(W) <> lV) {"bad weights"; return(0);}
     4043
     4044  int i;
     4045  for (i = 1; i <= size(W); i++) {if (W[i] < 0) {"bad weights"; return(0);}}
     4046  intvec Wt = W;
     4047  for (i = 2; i <= d; i++) {Wt = Wt, W;}
     4048  kill i;
     4049
     4050  int ppl = printlevel-voice+2;
     4051  string err = "";
     4052
     4053  int i,j,s;
     4054  def save = basering;
     4055  int D = d-1;
     4056  list LR  = ringlist(save);
     4057  list L, tmp, tmp2, tmp3;
     4058  L[1] = LR[1]; // ground field
     4059  L[4] = LR[4]; // quotient ideal
     4060  tmp  = LR[2]; // varnames
     4061  s = size(LR[2]);
     4062  for (i=1; i<=D; i++)
     4063  {
     4064    for (j=1; j<=s; j++)
     4065    {
     4066      tmp[i*s+j] = string(tmp[j])+"("+string(i+1)+")";
     4067    }
     4068  }
     4069  for (i=1; i<=s; i++)
     4070  {
     4071    tmp[i] = string(tmp[i])+"("+string(1)+")";
     4072  }
     4073  L[2] = tmp;
     4074  list OrigNames = LR[2];
     4075  // ordering: one 1..1 a above
     4076  // ordering: d blocks of the ord on r
     4077  // try to get whether the ord on r is blockord itself
     4078  // TODO: make L(2) ordering! exponent is maximally 2
     4079  s = size(LR[3]);
     4080  if (s==2)
     4081  {
     4082    // not a blockord, 1 block + module ord
     4083    tmp = LR[3][s]; // module ord
     4084    for (i=1; i<=d; i++)
     4085    {
     4086      LR[3][s-1+i] = LR[3][1];
     4087    }
     4088    //    LR[3][s+D] = tmp;
     4089    LR[3][s+1+D] = tmp;
     4090    LR[3][1] = list("a",Wt); // deg-ord
     4091  }
     4092  if (s>2)
     4093  {
     4094    // there are s-1 blocks
     4095    int nb = s-1;
     4096    tmp = LR[3][s]; // module ord to place at the very end
     4097    tmp2 = LR[3]; tmp2 = tmp2[1..nb];
     4098    tmp3[1] = list("a",Wt); // deg-ord, insert as the 1st
     4099    for (i=1; i<=d; i++)
     4100    {
     4101      tmp3 = tmp3 + tmp2;
     4102    }
     4103    tmp3 = tmp3 + list(tmp);
     4104    LR[3] = tmp3;
     4105
     4106  }
     4107  L[3] = LR[3];
     4108  def @R = ring(L);
     4109  //  setring @R;
     4110  //  int uptodeg = d; int lV = nvars(basering); // were defined before
     4111  def @@R = setLetterplaceAttributes(@R,uptodeg,lV);
     4112  return (@@R);
     4113}
     4114example
     4115{
     4116  "EXAMPLE:"; echo = 2;
     4117  ring r = 0,(x,y,z),(dp(1),dp(2));
     4118  def A = makeLetterplaceRingWt(2,intvec(1,2,3));
     4119  setring A;
     4120  A;
     4121  attrib(A,"isLetterplaceRing");
     4122  attrib(A,"uptodeg");  // degree bound
     4123  attrib(A,"lV"); // number of variables in the main block
     4124}
     4125*/
  • Singular/LIB/olga.lib

    ra135fd rfbd9e6f  
    153153          + " locData has to be defined"));
    154154    }
    155     if (locType == 0) { // monoidal localizations
    156         if (t != "list") {
     155    if (locType == 0)
     156    { // monoidal localizations
     157        if (t != "list")
     158        {
    157159            return(list(0, "for a monoidal localization, locData has to be of"
    158160              + " type list, but is of type " + t));
    159         } else { // locData is of type list
    160             if (size(locData) == 0) {
     161        }
     162        else
     163        { // locData is of type list
     164            if (size(locData) == 0)
     165            {
    161166                return(list(0, "for a monoidal localization, locData has to be"
    162167                  + " a non-empty list"));
    163             } else { // locData is of type list and has at least one entry
    164                 ideal listEntries;
    165                 for (i = 1; i <= size(locData); i++) {
     168            }
     169            else
     170            { // locData is of type list and has at least one entry
     171                if (defined(basering)) {ideal listEntries;}
     172                for (i = 1; i <= size(locData); i++)
     173                {
    166174                    t = typeof(locData[i]);
    167                     if (t != "poly" && t != "int" && t != "number") {
     175                    if (t != "poly" && t != "int" && t != "number")
     176                    {
    168177                        return(list(0, "for a monoidal localization, locData"
    169178                          + " has to be a list of polys, ints or numbers, but"
    170179                          + " entry " + string(i) + " is " + string(locData[i])
    171180                          + ", which is of type " + t));
    172                     } else {
    173                         if (listEntries == 0) {
     181                    }
     182                    else
     183                    {
     184                      if (defined(basering))
     185                      {
     186                        if (size(listEntries) == 0)
     187                        {
    174188                            listEntries = locData[i];
    175                         } else {
     189                        }
     190                        else
     191                        {
    176192                            listEntries = listEntries, locData[i];
    177193                        }
     194                      }
    178195                    }
    179196                }
    180197                // locData is of type list, has at least one entry and all
    181198                //   entries are polys
    182                 if (!inducesCommutativeSubring(listEntries)) {
     199                if (!defined(basering))
     200                {
    183201                    return(list(0, "for a monoidal localization, the variables"
    184202                      + " occurring in the polys in locData have to induce a"
    185203                      + " commutative polynomial subring of basering"));
    186204                }
    187             }
    188         }
    189     }
    190     if (locType == 1) { // geometric localizations
     205                if (!inducesCommutativeSubring(listEntries))
     206                {
     207                    return(list(0, "for a monoidal localization, the variables"
     208                      + " occurring in the polys in locData have to induce a"
     209                      + " commutative polynomial subring of basering"));
     210                }
     211            }
     212        }
     213    }
     214    if (locType == 1)
     215    { // geometric localizations
    191216        int n = nvars(basering) div 2;
    192         if (2*n != nvars(basering)) {
     217        if (2*n != nvars(basering))
     218        {
    193219            return(list(0, "for a geometric localization, basering has to have"
    194220              + " an even number of variables"));
    195         } else {
     221        }
     222        else
     223        {
    196224            int j;
    197             for (i = 1; i <= n; i++) {
    198                 for (j = i + 1; j <= n; j++) {
    199                     if (var(i)*var(j) != var(j)*var(i)) {
     225            for (i = 1; i <= n; i++)
     226            {
     227                for (j = i + 1; j <= n; j++)
     228                {
     229                    if (var(i)*var(j) != var(j)*var(i))
     230                    {
    200231                        return(list(0, "for a geometric localization, the"
    201232                          + " first half of the variables of basering has to"
     
    206237            }
    207238        }
    208         if (t != "ideal") {
     239        if (t != "ideal")
     240        {
    209241            return(list(0, "for a geometric localization, locData has to be of"
    210242              + " type ideal, but is of type " + t));
    211243        }
    212         for (i = 1; i <= size(locData); i++) {
    213             if (!polyVars(locData[i],1..n)) {
     244        for (i = 1; i <= size(locData); i++)
     245        {
     246            if (!polyVars(locData[i],1..n))
     247            {
    214248                return(list(0, "for a geometric localization, locData has to"
    215249                + " be an ideal generated by polynomials containing only"
     
    218252        }
    219253    }
    220     if (locType == 2) { // rational localizations
    221         if (t != "intvec") {
     254    if (locType == 2)
     255    { // rational localizations
     256        if (t != "intvec")
     257        {
    222258            return(list(0, "for a rational localization, locData has to be of"
    223259              + " type intvec, but is of type " + t));
    224         } else { // locData is of type intvec
    225             if(locData == 0) {
     260        }
     261        else
     262        { // locData is of type intvec
     263            if(locData == 0)
     264            {
    226265                return(list(0, "for a rational localization, locData has to be"
    227266                  + " a non-zero intvec"));
    228             } else { // locData is of type intvec and not zero
    229                 if (!admissibleSub(locData)) {
     267            }
     268            else
     269            { // locData is of type intvec and not zero
     270                if (!admissibleSub(locData))
     271                {
    230272                    return(list(0, "for a rational localization, the variables"
    231273                      + " indexed by locData have to generate a sub-G-algebra"
  • Singular/cntrlc.cc

    ra135fd rfbd9e6f  
    3636#endif
    3737
    38 #if defined(unix)
    3938 #include <unistd.h>
    4039 #include <sys/types.h>
     
    6665   static void stack_trace (char *const*args);
    6766 #endif
    68 #endif
    6967
    7068si_link pipeLastLink=NULL;
     
    302300  }
    303301  #endif /* __OPTIMIZE__ */
    304   #if defined(unix)
    305302  #ifdef CALL_GDB
    306303  if (sig!=SIGINT) debug(STACK_TRACE);
    307304  #endif /* CALL_GDB */
    308   #endif /* unix */
    309305  exit(0);
    310306}
     
    410406//}
    411407
    412 #ifdef unix
    413408#  ifndef __OPTIMIZE__
    414409volatile int si_stop_stack_trace_x;
     
    565560
    566561#  endif /* !__OPTIMIZE__ */
    567 #endif /* unix */
    568562
    569563/*2
  • Singular/extra.cc

    ra135fd rfbd9e6f  
    278278    else
    279279/*==================== alarm ==================================*/
    280   #ifdef unix
    281280      if(strcmp(sys_cmd,"alarm")==0)
    282281      {
     
    296295      }
    297296      else
    298   #endif
    299297/*==================== cpu ==================================*/
    300298    if(strcmp(sys_cmd,"cpu")==0)
     
    30103008       if (strcmp(sys_cmd, "hilbroune") == 0)
    30113009       {
    3012          ideal I;
    30133010         if ((h!=NULL) && (h->Typ()==IDEAL_CMD))
    30143011         {
    3015            I=(ideal)h->CopyD();
    3016            slicehilb(I);
     3012           slicehilb((ideal)h->Data());
    30173013         }
    30183014         else return TRUE;
  • Singular/iparith.cc

    ra135fd rfbd9e6f  
    23032303  intvec *module_w=(intvec*)atGet(u,"isHomog",INTVEC_CMD);
    23042304  intvec *iv=hFirstSeries((ideal)u->Data(),module_w,currRing->qideal);
     2305  if (errorreported) return TRUE;
     2306
    23052307  switch((int)(long)v->Data())
    23062308  {
     
    56975699  intvec *module_w=(intvec *)atGet(u,"isHomog",INTVEC_CMD);
    56985700  intvec *iv=hFirstSeries((ideal)u->Data(),module_w,currRing->qideal,wdegree);
     5701  if (errorreported) return TRUE;
     5702
    56995703  switch((int)(long)v->Data())
    57005704  {
  • Singular/libparse.h

    ra135fd rfbd9e6f  
    9898
    9999#  ifdef STANDALONE_PARSER
    100 #ifndef unix
    101 extern FILE* myfopen(char *path, char *mode);
    102 extern size_t myfread(void *ptr, size_t size, size_t nmemb, FILE *stream);
    103 #else
    104100#define myfopen fopen
    105101#define myfread fread
    106 #endif
    107102#  endif
    108103
  • Singular/singular-libs

    ra135fd rfbd9e6f  
    4747        methods.lib modnormal.lib modular.lib multigrading.lib modwalk.lib\
    4848        JMBTest.lib JMSConst.lib \
     49        ncfrac.lib ncloc.lib ncModslimgb.lib\
    4950        nfmodstd.lib nfmodsyz.lib numerAlg.lib numerDecom.lib \
    50         orbitparam.lib \
     51        olga.lib orbitparam.lib \
    5152        parallel.lib polyclass.lib polymake.lib polybori.lib \
    5253        realclassify.lib realizationMatroids.lib resources.lib ringgb.lib \
  • Singular/svd/libs/amp.cpp

    ra135fd rfbd9e6f  
    11#include "svd_si.h"
     2#ifdef HAVE_SVD
    23
    34/************************************************************************
     
    154155    return ref->value;
    155156}
     157#endif
  • Singular/svd/libs/ap.cpp

    ra135fd rfbd9e6f  
    11#include "svd_si.h"
     2#ifdef HAVE_SVD
    23
    34const double ap::machineepsilon = 5E-16;
     
    178179    return m1>m2 ? m2 : m1;
    179180}
     181#endif
  • Singular/svd_si.h

    ra135fd rfbd9e6f  
    1515#include <math.h>
    1616#include "resources/feFopen.h"
    17 
     17#include "kernel/mod2.h"
     18
     19#ifdef HAVE_SVD
    1820/********************************************************************
    1921Checking of the array boundaries mode.
     
    10111013
    10121014
    1013 #endif
    1014 
    10151015/* stuff included from libs/amp.h */
    1016 
    1017 #ifndef _AMP_R_H
    1018 #define _AMP_R_H
    10191016
    10201017#include <omalloc/omalloc.h>
     
    24742471}
    24752472
    2476 #endif
    2477 
    24782473/* stuff included from ./reflections.h */
    24792474
     
    25162511*************************************************************************/
    25172512
    2518 #ifndef _reflections_h
    2519 #define _reflections_h
    2520 
    25212513namespace reflections
    25222514{
     
    27902782    }
    27912783} // namespace
    2792 
    2793 #endif
    27942784
    27952785/* stuff included from ./bidiagonal.h */
     
    28322822OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    28332823*************************************************************************/
    2834 
    2835 #ifndef _bidiagonal_h
    2836 #define _bidiagonal_h
    28372824
    28382825namespace bidiagonal
     
    42444231} // namespace
    42454232
    4246 #endif
    4247 
    42484233/* stuff included from ./qr.h */
    42494234
     
    42864271*************************************************************************/
    42874272
    4288 #ifndef _qr_h
    4289 #define _qr_h
    4290 
    42914273namespace qr
    42924274{
     
    47144696    }
    47154697} // namespace
    4716 
    4717 #endif
    47184698
    47194699/* stuff included from ./lq.h */
     
    47514731*************************************************************************/
    47524732
    4753 #ifndef _lq_h
    4754 #define _lq_h
    4755 
    47564733namespace lq
    47574734{
     
    51705147    }
    51715148} // namespace
    5172 
    5173 #endif
    51745149
    51755150/* stuff included from ./blas.h */
     
    52065181OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    52075182*************************************************************************/
    5208 
    5209 #ifndef _blas_h
    5210 #define _blas_h
    52115183
    52125184namespace blas
     
    58805852} // namespace
    58815853
    5882 #endif
    5883 
    58845854/* stuff included from ./rotations.h */
    58855855
     
    59225892*************************************************************************/
    59235893
    5924 #ifndef _rotations_h
    5925 #define _rotations_h
    5926 
    59275894namespace rotations
    59285895{
     
    62776244    }
    62786245} // namespace
    6279 
    6280 #endif
    62816246
    62826247/* stuff included from ./bdsvd.h */
     
    63196284OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    63206285*************************************************************************/
    6321 
    6322 #ifndef _bdsvd_h
    6323 #define _bdsvd_h
    63246286
    63256287namespace bdsvd
     
    76677629} // namespace
    76687630
    7669 #endif
    7670 
    76717631/* stuff included from ./svd.h */
    76727632
     
    77027662OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    77037663*************************************************************************/
    7704 
    7705 #ifndef _svd_h
    7706 #define _svd_h
    77077664
    77087665/*MAKEHEADER*/
     
    83318288
    83328289#endif
    8333 
     8290#endif
     8291
  • doc/changes_in_singular4.texi

    ra135fd rfbd9e6f  
    9696result of various computations (in particular Groebner bases).
    9797
    98 @subsubheading New libraries depending on Singular 4
    99 @cindex New libraries depending on Singular 4
    100 
    101 In Singular 4 there several new features are implemented within a
    102 dynamic module @code{syzextra.so}, not available in Singular 3.
    103 It implements the low-level functions for Schreyer resolutions and many auxiliary functions.
    104 The following new libraries @ref{deRham_lib}, @ref{schreyer_lib} depend on it:
    105 
    106 @c table @asis
    107 @itemize @bullet
    108 @item @ref{deRham_lib} - computes de Rham cohomology
    109 @item @ref{schreyer_lib} - computes Schreyer resolution via several approaches. It also serves as a high-level wrapper to the dynamic module @code{syzextra.so}
    110 @end itemize
    111 @c @end table
    112 
    11398@subsubheading Path names
    11499@cindex Path names
  • kernel/combinatorics/hilb.cc

    ra135fd rfbd9e6f  
    111111  memcpy(pon, pol, l * sizeof(int));
    112112  if (l > x)
    113   {
     113  {/*pon[i] -= pol[i - x];*/
    114114    for (i = x; i < l; i++)
    115       pon[i] -= pol[i - x];
     115    { int64 t=pon[i];
     116      int64 t2=pol[i - x];
     117      t-=t2;
     118      if ((t>=INT_MIN)&&(t<=INT_MAX)) pon[i]=t;
     119      else if (!errorreported) WerrorS("int overflow in hilb 1");
     120    }
    116121    for (i = l; i < ln; i++)
    117       pon[i] = -pol[i - x];
     122    { /*pon[i] = -pol[i - x];*/
     123      int64 t= -pol[i - x];
     124      if ((t>=INT_MIN)&&(t<=INT_MAX)) pon[i]=t;
     125      else if (!errorreported) WerrorS("int overflow in hilb 2");
     126    }
    118127  }
    119128  else
     
    130139{
    131140  int  l = lp, x, i, j;
    132   int  *p, *pl;
     141  int  *pl;
     142  int  *p;
    133143  p = pol;
    134144  for (i = Nv; i>0; i--)
     
    141151  j = Q0[Nv + 1];
    142152  for (i = 0; i < l; i++)
    143     pl[i + j] += p[i];
     153  { /* pl[i + j] += p[i];*/
     154    int64 t=pl[i+j];
     155    int64 t2=p[i];
     156    t+=t2;
     157    if ((t>=INT_MIN)&&(t<=INT_MAX)) pl[i+j]=t;
     158    else if (!errorreported) WerrorS("int overflow in hilb 3");
     159  }
    144160  x = pure[var[1]];
    145161  if (x!=0)
     
    147163    j += x;
    148164    for (i = 0; i < l; i++)
    149       pl[i + j] -= p[i];
     165    { /* pl[i + j] -= p[i];*/
     166      int64 t=pl[i+j];
     167      int64 t2=p[i];
     168      t-=t2;
     169      if ((t>=INT_MIN)&&(t<=INT_MAX)) pl[i+j]=t;
     170      else if (!errorreported) WerrorS("int overflow in hilb 4");
     171    }
    150172  }
    151173  j += l;
     
    264286
    265287//adds the new polynomial at the coresponding position
    266 //and simplifies the ideal
    267 static ideal SortByDeg_p(ideal I, poly p)
    268 {
    269     int i,j;
    270     if((I == NULL) || (idIs0(I)))
    271     {
    272         ideal res = idInit(1,1);
    273         res->m[0] = p;
    274         return(res);
    275     }
     288//and simplifies the ideal, destroys p
     289static void SortByDeg_p(ideal I, poly p)
     290{
     291  int i,j;
     292  if(idIs0(I))
     293  {
     294    I->m[0] = p;
     295    return;
     296  }
     297  idSkipZeroes(I);
     298  #if 1
     299  for(i = 0; (i<IDELEMS(I)) && (p_Totaldegree(I->m[i],currRing)<=p_Totaldegree(p,currRing)); i++)
     300  {
     301    if(p_DivisibleBy( I->m[i],p, currRing))
     302    {
     303      p_Delete(&p,currRing);
     304      return;
     305    }
     306  }
     307  for(i = IDELEMS(I)-1; (i>=0) && (p_Totaldegree(I->m[i],currRing)>=p_Totaldegree(p,currRing)); i--)
     308  {
     309    if(p_DivisibleBy(p,I->m[i], currRing))
     310    {
     311      p_Delete(&I->m[i],currRing);
     312    }
     313  }
     314  if(idIs0(I))
     315  {
    276316    idSkipZeroes(I);
    277     #if 1
    278     for(i = 0; (i<IDELEMS(I)) && (p_Totaldegree(I->m[i],currRing)<=p_Totaldegree(p,currRing)); i++)
    279     {
    280         if(p_DivisibleBy( I->m[i],p, currRing))
    281         {
    282             return(I);
    283         }
    284     }
    285     for(i = IDELEMS(I)-1; (i>=0) && (p_Totaldegree(I->m[i],currRing)>=p_Totaldegree(p,currRing)); i--)
    286     {
    287         if(p_DivisibleBy(p,I->m[i], currRing))
    288         {
    289             I->m[i] = NULL;
    290         }
    291     }
    292     if(idIs0(I))
    293     {
    294         idSkipZeroes(I);
    295         I->m[0] = p;
    296         return(I);
    297     }
    298     #endif
     317    I->m[0] = p;
     318    return;
     319  }
     320  #endif
     321  idSkipZeroes(I);
     322  //First I take the case when all generators have the same degree
     323  if(p_Totaldegree(I->m[0],currRing) == p_Totaldegree(I->m[IDELEMS(I)-1],currRing))
     324  {
     325    if(p_Totaldegree(p,currRing)<p_Totaldegree(I->m[0],currRing))
     326    {
     327      idInsertPoly(I,p);
     328      idSkipZeroes(I);
     329      for(i=IDELEMS(I)-1;i>=1; i--)
     330      {
     331        I->m[i] = I->m[i-1];
     332      }
     333      I->m[0] = p;
     334      return;
     335    }
     336    if(p_Totaldegree(p,currRing)>=p_Totaldegree(I->m[IDELEMS(I)-1],currRing))
     337    {
     338      idInsertPoly(I,p);
     339      idSkipZeroes(I);
     340      return;
     341    }
     342  }
     343  if(p_Totaldegree(p,currRing)<=p_Totaldegree(I->m[0],currRing))
     344  {
     345    idInsertPoly(I,p);
    299346    idSkipZeroes(I);
    300     //First I take the case when all generators have the same degree
    301     if(p_Totaldegree(I->m[0],currRing) == p_Totaldegree(I->m[IDELEMS(I)-1],currRing))
    302     {
    303         if(p_Totaldegree(p,currRing)<p_Totaldegree(I->m[0],currRing))
    304         {
    305             idInsertPoly(I,p);
    306             idSkipZeroes(I);
    307             for(i=IDELEMS(I)-1;i>=1; i--)
    308             {
    309                 I->m[i] = I->m[i-1];
    310             }
    311             I->m[0] = p;
    312             return(I);
    313         }
    314         if(p_Totaldegree(p,currRing)>=p_Totaldegree(I->m[IDELEMS(I)-1],currRing))
    315         {
    316             idInsertPoly(I,p);
    317             idSkipZeroes(I);
    318             return(I);
    319         }
    320     }
    321     if(p_Totaldegree(p,currRing)<=p_Totaldegree(I->m[0],currRing))
    322     {
    323         idInsertPoly(I,p);
    324         idSkipZeroes(I);
    325         for(i=IDELEMS(I)-1;i>=1; i--)
    326         {
    327             I->m[i] = I->m[i-1];
    328         }
    329         I->m[0] = p;
    330         return(I);
    331     }
    332     if(p_Totaldegree(p,currRing)>=p_Totaldegree(I->m[IDELEMS(I)-1],currRing))
    333     {
    334         idInsertPoly(I,p);
    335         idSkipZeroes(I);
    336         return(I);
    337     }
    338     for(i = IDELEMS(I)-2; ;)
    339     {
    340         if(p_Totaldegree(p,currRing)==p_Totaldegree(I->m[i],currRing))
    341         {
    342             idInsertPoly(I,p);
    343             idSkipZeroes(I);
    344             for(j = IDELEMS(I)-1; j>=i+1;j--)
    345             {
    346                 I->m[j] = I->m[j-1];
    347             }
    348             I->m[i] = p;
    349             return(I);
    350         }
    351         if(p_Totaldegree(p,currRing)>p_Totaldegree(I->m[i],currRing))
    352         {
    353             idInsertPoly(I,p);
    354             idSkipZeroes(I);
    355             for(j = IDELEMS(I)-1; j>=i+2;j--)
    356             {
    357                 I->m[j] = I->m[j-1];
    358             }
    359             I->m[i+1] = p;
    360             return(I);
    361         }
    362         i--;
    363     }
     347    for(i=IDELEMS(I)-1;i>=1; i--)
     348    {
     349      I->m[i] = I->m[i-1];
     350    }
     351    I->m[0] = p;
     352    return;
     353  }
     354  if(p_Totaldegree(p,currRing)>=p_Totaldegree(I->m[IDELEMS(I)-1],currRing))
     355  {
     356    idInsertPoly(I,p);
     357    idSkipZeroes(I);
     358    return;
     359  }
     360  for(i = IDELEMS(I)-2; ;)
     361  {
     362    if(p_Totaldegree(p,currRing)==p_Totaldegree(I->m[i],currRing))
     363    {
     364      idInsertPoly(I,p);
     365      idSkipZeroes(I);
     366      for(j = IDELEMS(I)-1; j>=i+1;j--)
     367      {
     368        I->m[j] = I->m[j-1];
     369      }
     370      I->m[i] = p;
     371      return;
     372    }
     373    if(p_Totaldegree(p,currRing)>p_Totaldegree(I->m[i],currRing))
     374    {
     375      idInsertPoly(I,p);
     376      idSkipZeroes(I);
     377      for(j = IDELEMS(I)-1; j>=i+2;j--)
     378      {
     379        I->m[j] = I->m[j-1];
     380      }
     381      I->m[i+1] = p;
     382      return;
     383    }
     384    i--;
     385  }
    364386}
    365387
     
    367389static ideal SortByDeg(ideal I)
    368390{
    369     if(idIs0(I))
    370     {
    371         return(I);
    372     }
    373     int i;
    374     ideal res;
    375     idSkipZeroes(I);
    376     res = idInit(1,1);
    377     res->m[0] = poly(0);
    378     for(i = 0; i<=IDELEMS(I)-1;i++)
    379     {
    380         res = SortByDeg_p(res, I->m[i]);
    381     }
    382     idSkipZeroes(res);
    383     //idDegSortTest(res);
    384     return(res);
     391  if(idIs0(I))
     392  {
     393    return id_Copy(I,currRing);
     394  }
     395  int i;
     396  ideal res;
     397  idSkipZeroes(I);
     398  res = idInit(1,1);
     399  for(i = 0; i<=IDELEMS(I)-1;i++)
     400  {
     401    SortByDeg_p(res, I->m[i]);
     402    I->m[i]=NULL; // I->m[i] is now in res
     403  }
     404  idSkipZeroes(res);
     405  //idDegSortTest(res);
     406  return(res);
    385407}
    386408
     
    390412    if(idIs0(Iorig))
    391413    {
    392         ideal res = idInit(1,1);
    393         res->m[0] = poly(0);
    394         return(res);
     414      ideal res = idInit(1,1);
     415      res->m[0] = poly(0);
     416      return(res);
    395417    }
    396418    if(idIs0(p))
    397419    {
    398         ideal res = idInit(1,1);
    399         res->m[0] = pOne();
    400         return(res);
    401     }
    402     ideal I = idCopy(Iorig);
     420      ideal res = idInit(1,1);
     421      res->m[0] = pOne();
     422      return(res);
     423    }
     424    ideal I = id_Head(Iorig,currRing);
    403425    ideal res = idInit(IDELEMS(I),1);
    404426    int i,j;
     
    406428    for(i = 0; i<IDELEMS(I); i++)
    407429    {
    408         res->m[i] = p_Copy(I->m[i], currRing);
    409         for(j = 1; (j<=currRing->N) ; j++)
    410         {
    411             dummy = p_GetExp(p->m[0], j, currRing);
    412             if(dummy > 0)
    413             {
    414                 if(p_GetExp(I->m[i], j, currRing) < dummy)
    415                 {
    416                     p_SetExp(res->m[i], j, 0, currRing);
    417                 }
    418                 else
    419                 {
    420                     p_SetExp(res->m[i], j, p_GetExp(I->m[i], j, currRing) - dummy, currRing);
    421                 }
    422             }
    423         }
    424         p_Setm(res->m[i], currRing);
    425         if(p_Totaldegree(res->m[i],currRing) == p_Totaldegree(I->m[i],currRing))
    426         {
    427             res->m[i] = NULL; // pDelete
    428         }
    429         else
    430         {
    431             I->m[i] = NULL; // pDelete
    432         }
     430      res->m[i] = p_Head(I->m[i], currRing);
     431      for(j = 1; (j<=currRing->N) ; j++)
     432      {
     433        dummy = p_GetExp(p->m[0], j, currRing);
     434        if(dummy > 0)
     435        {
     436          if(p_GetExp(I->m[i], j, currRing) < dummy)
     437          {
     438            p_SetExp(res->m[i], j, 0, currRing);
     439          }
     440          else
     441          {
     442            p_SetExp(res->m[i], j, p_GetExp(I->m[i], j, currRing) - dummy, currRing);
     443          }
     444        }
     445      }
     446      p_Setm(res->m[i], currRing);
     447      if(p_Totaldegree(res->m[i],currRing) == p_Totaldegree(I->m[i],currRing))
     448      {
     449        p_Delete(&res->m[i],currRing);
     450      }
     451      else
     452      {
     453        p_Delete(&I->m[i],currRing);
     454      }
    433455    }
    434456    idSkipZeroes(res);
     
    438460      for(i = 0; i<=IDELEMS(res)-1; i++)
    439461      {
    440         I = SortByDeg_p(I,res->m[i]);
    441       }
    442     }
     462        SortByDeg_p(I,res->m[i]);
     463        res->m[i]=NULL; // is now in I
     464      }
     465    }
     466    id_Delete(&res,currRing);
    443467    //idDegSortTest(I);
    444468    return(I);
     
    446470
    447471//id_Add for monomials
    448 static ideal idAddMon(ideal I, ideal p)
    449 {
    450     #if 1
    451     I = SortByDeg_p(I,p->m[0]);
    452     #else
    453     I = id_Add(I,p,currRing);
    454     #endif
    455     //idSkipZeroes(I);
    456     return(I);
     472static void idAddMon(ideal I, ideal p)
     473{
     474  SortByDeg_p(I,p->m[0]);
     475  p->m[0]=NULL; // is now in I
     476  //idSkipZeroes(I);
    457477}
    458478
     
    686706static poly ChoosePJL(ideal I)
    687707{
     708  int i,j,dummy;
     709  bool flag = TRUE;
     710  poly m = p_ISet(1,currRing);
     711  for(i = IDELEMS(I)-1;(i>=0) && (flag);i--)
     712  {
     713    flag = TRUE;
     714    for(j=1;(j<=currRing->N) && (flag);j++)
     715    {
     716      dummy = p_GetExp(I->m[i],j,currRing);
     717      if(dummy >= 2)
     718      {
     719        p_SetExp(m,j,dummy-1,currRing);
     720        p_Setm(m,currRing);
     721        flag = FALSE;
     722      }
     723    }
     724    if(!p_IsOne(m, currRing))
     725    {
     726      return(m);
     727    }
     728  }
     729  p_Delete(&m,currRing);
     730  m = ChoosePVar(I);
     731  return(m);
     732}
     733
     734#if 0
     735//choice JF: last entry just variable with power -1 (xy10z15 -> y9)
     736static poly ChoosePJF(ideal I)
     737{
    688738    int i,j,dummy;
    689739    bool flag = TRUE;
    690740    poly m = p_ISet(1,currRing);
    691     for(i = IDELEMS(I)-1;(i>=0) && (flag);i--)
     741    for(i = 0;(i<=IDELEMS(I)-1) && (flag);i++)
    692742    {
    693743        flag = TRUE;
     
    710760    return(m);
    711761}
    712 
    713 #if 0
    714 //choice JF: last entry just variable with power -1 (xy10z15 -> y9)
    715 static poly ChoosePJF(ideal I)
    716 {
    717     int i,j,dummy;
    718     bool flag = TRUE;
    719     poly m = p_ISet(1,currRing);
    720     for(i = 0;(i<=IDELEMS(I)-1) && (flag);i++)
    721     {
    722         flag = TRUE;
    723         for(j=1;(j<=currRing->N) && (flag);j++)
    724         {
    725             dummy = p_GetExp(I->m[i],j,currRing);
    726             if(dummy >= 2)
    727             {
    728                 p_SetExp(m,j,dummy-1,currRing);
    729                 p_Setm(m,currRing);
    730                 flag = FALSE;
    731             }
    732         }
    733         if(!p_IsOne(m, currRing))
    734         {
    735             return(m);
    736         }
    737     }
    738     m = ChoosePVar(I);
    739     return(m);
    740 }
    741762#endif
    742763
     
    744765static poly ChooseP(ideal I)
    745766{
    746     poly m;
    747     //  TEST TO SEE WHICH ONE IS BETTER
    748     //m = ChoosePXL(I);
    749     //m = ChoosePXF(I);
    750     //m = ChoosePOL(I);
    751     //m = ChoosePOF(I);
    752     //m = ChoosePVL(I);
    753     //m = ChoosePVF(I);
    754     m = ChoosePJL(I);
    755     //m = ChoosePJF(I);
    756     return(m);
     767  poly m;
     768  //  TEST TO SEE WHICH ONE IS BETTER
     769  //m = ChoosePXL(I);
     770  //m = ChoosePXF(I);
     771  //m = ChoosePOL(I);
     772  //m = ChoosePOF(I);
     773  //m = ChoosePVL(I);
     774  //m = ChoosePVF(I);
     775  m = ChoosePJL(I);
     776  //m = ChoosePJF(I);
     777  return(m);
    757778}
    758779
     
    822843    if(JustVar(I) == TRUE)
    823844    {
    824         if(IDELEMS(I) == variables)
    825         {
    826             mpz_init(dummy);
    827             if((variables % 2) == 0)
    828                 {mpz_set_ui(dummy, 1);}
    829             else
    830                 {mpz_set_si(dummy, -1);}
    831             mpz_add(ec, ec, dummy);
    832         }
    833         //mpz_clear(dummy);
    834         return;
     845      if(IDELEMS(I) == variables)
     846      {
     847        mpz_init(dummy);
     848        if((variables % 2) == 0)
     849          mpz_set_ui(dummy, 1);
     850        else
     851          mpz_set_si(dummy, -1);
     852        mpz_add(ec, ec, dummy);
     853        mpz_clear(dummy);
     854      }
     855      return;
    835856    }
    836857    ideal p = idInit(1,1);
     
    845866    for(i = 1;i<=currRing->N;i++)
    846867    {
    847         if(p_GetExp(p->m[0],i,currRing)>0)
    848         {
    849             howmanyvarinp++;
    850         }
     868      if(p_GetExp(p->m[0],i,currRing)>0)
     869      {
     870        howmanyvarinp++;
     871      }
    851872    }
    852873    eulerchar(Ip, variables-howmanyvarinp, ec);
    853874    id_Delete(&Ip, currRing);
    854     I = idAddMon(I,p);
     875    idAddMon(I,p);
     876    id_Delete(&p, currRing);
    855877  }
    856878}
     
    888910static bool IsIn(poly p, ideal I)
    889911{
    890     //assumes that I is ordered by degree
    891     if(idIs0(I))
    892     {
    893         if(p==poly(0))
    894         {
    895             return(TRUE);
    896         }
    897         else
    898         {
    899             return(FALSE);
    900         }
    901     }
     912  //assumes that I is ordered by degree
     913  if(idIs0(I))
     914  {
    902915    if(p==poly(0))
    903916    {
    904         return(FALSE);
    905     }
    906     int i,j;
    907     bool flag;
    908     for(i = 0;i<IDELEMS(I);i++)
    909     {
    910         flag = TRUE;
    911         for(j = 1;(j<=currRing->N) &&(flag);j++)
    912         {
    913             if(p_GetExp(p, j, currRing)<p_GetExp(I->m[i], j, currRing))
    914             {
    915                 flag = FALSE;
    916             }
    917         }
    918         if(flag)
    919         {
    920             return(TRUE);
    921         }
    922     }
     917      return(TRUE);
     918    }
     919    else
     920    {
     921      return(FALSE);
     922    }
     923  }
     924  if(p==poly(0))
     925  {
    923926    return(FALSE);
     927  }
     928  int i,j;
     929  bool flag;
     930  for(i = 0;i<IDELEMS(I);i++)
     931  {
     932    flag = TRUE;
     933    for(j = 1;(j<=currRing->N) &&(flag);j++)
     934    {
     935      if(p_GetExp(p, j, currRing)<p_GetExp(I->m[i], j, currRing))
     936      {
     937        flag = FALSE;
     938      }
     939    }
     940    if(flag)
     941    {
     942      return(TRUE);
     943    }
     944  }
     945  return(FALSE);
    924946}
    925947
     
    927949static poly LCMmon(ideal I)
    928950{
    929     if(idIs0(I))
    930     {
    931         return(NULL);
    932     }
    933     poly m;
    934     int dummy,i,j;
    935     m = p_ISet(1,currRing);
    936     for(i=1;i<=currRing->N;i++)
    937     {
    938         dummy=0;
    939         for(j=IDELEMS(I)-1;j>=0;j--)
    940         {
    941             if(p_GetExp(I->m[j],i,currRing) > dummy)
    942             {
    943                 dummy = p_GetExp(I->m[j],i,currRing);
    944             }
    945         }
    946         p_SetExp(m,i,dummy,currRing);
    947     }
    948     p_Setm(m,currRing);
    949     return(m);
     951  if(idIs0(I))
     952  {
     953    return(NULL);
     954  }
     955  poly m;
     956  int dummy,i,j;
     957  m = p_ISet(1,currRing);
     958  for(i=1;i<=currRing->N;i++)
     959  {
     960    dummy=0;
     961    for(j=IDELEMS(I)-1;j>=0;j--)
     962    {
     963      if(p_GetExp(I->m[j],i,currRing) > dummy)
     964      {
     965        dummy = p_GetExp(I->m[j],i,currRing);
     966      }
     967    }
     968    p_SetExp(m,i,dummy,currRing);
     969  }
     970  p_Setm(m,currRing);
     971  return(m);
    950972}
    951973
     
    964986    for(i=IDELEMS(S)-1;i>=0;i--)
    965987    {
    966         if(IsIn(S->m[i],I))
    967         {
    968             S->m[i]=NULL;
    969             prune++;
    970         }
     988      if(IsIn(S->m[i],I))
     989      {
     990        p_Delete(&S->m[i],currRing);
     991        prune++;
     992      }
    971993    }
    972994    idSkipZeroes(S);
     
    974996    for(i=IDELEMS(I)-1;i>=0;i--)
    975997    {
    976         m = p_Copy(I->m[i],currRing);
    977         for(j=1;j<=currRing->N;j++)
    978         {
    979             dummy = p_GetExp(m,j,currRing);
    980             if(dummy > 0)
    981             {
    982                 p_SetExp(m,j,dummy-1,currRing);
    983             }
    984         }
    985         p_Setm(m, currRing);
    986         if(IsIn(m,S))
    987         {
    988             I->m[i]=NULL;
    989             //printf("\n Deleted, since pi(m) is in S\n");pWrite(m);
    990         }
     998      m = p_Head(I->m[i],currRing);
     999      for(j=1;j<=currRing->N;j++)
     1000      {
     1001        dummy = p_GetExp(m,j,currRing);
     1002        if(dummy > 0)
     1003        {
     1004          p_SetExp(m,j,dummy-1,currRing);
     1005        }
     1006      }
     1007      p_Setm(m, currRing);
     1008      if(IsIn(m,S))
     1009      {
     1010        p_Delete(&I->m[i],currRing);
     1011        //printf("\n Deleted, since pi(m) is in S\n");pWrite(m);
     1012      }
     1013      p_Delete(&m,currRing);
    9911014    }
    9921015    idSkipZeroes(I);
     
    9951018    if(m != NULL)
    9961019    {
    997         for(i=0;i<IDELEMS(S);i++)
    998         {
    999             if(!(p_DivisibleBy(S->m[i], m, currRing)))
    1000             {
    1001                 S->m[i] = NULL;
    1002                 j++;
    1003                 moreprune++;
    1004             }
    1005             else
    1006             {
    1007                 if(pLmEqual(S->m[i],m))
    1008                 {
    1009                     S->m[i] = NULL;
    1010                     moreprune++;
    1011                 }
    1012             }
    1013         }
    1014     idSkipZeroes(S);
    1015     }
     1020      for(i=0;i<IDELEMS(S);i++)
     1021      {
     1022        if(!(p_DivisibleBy(S->m[i], m, currRing)))
     1023        {
     1024          S->m[i] = NULL;
     1025          j++;
     1026          moreprune++;
     1027        }
     1028        else
     1029        {
     1030          if(pLmEqual(S->m[i],m))
     1031          {
     1032            S->m[i] = NULL;
     1033            moreprune++;
     1034          }
     1035        }
     1036      }
     1037      idSkipZeroes(S);
     1038    }
     1039    p_Delete(&m,currRing);
    10161040    /*printf("\n---------------------------\n");
    10171041    printf("\n      I\n");idPrint(I);
     
    10221046    if(idIs0(I))
    10231047    {
    1024         id_Delete(&I, currRing);
    1025         id_Delete(&S, currRing);
    1026         p_Delete(&m, currRing);
    1027         break;
     1048      id_Delete(&I, currRing);
     1049      id_Delete(&S, currRing);
     1050      break;
    10281051    }
    10291052    m = LCMmon(I);
    10301053    if(!p_DivisibleBy(x,m, currRing))
    10311054    {
    1032         //printf("\nx does not divide lcm(I)");
    1033         //printf("\nEmpty set");pWrite(q);
    1034         id_Delete(&I, currRing);
    1035         id_Delete(&S, currRing);
    1036         p_Delete(&m, currRing);
    1037         break;
    1038     }
     1055      //printf("\nx does not divide lcm(I)");
     1056      //printf("\nEmpty set");pWrite(q);
     1057      id_Delete(&I, currRing);
     1058      id_Delete(&S, currRing);
     1059      p_Delete(&m, currRing);
     1060      break;
     1061    }
     1062    p_Delete(&m, currRing);
    10391063    m = SqFree(I);
    10401064    if(m==NULL)
    10411065    {
    1042         //printf("\n      Corner: ");
    1043         //pWrite(q);
    1044         //printf("\n      With the facets of the dual simplex:\n");
    1045         //idPrint(I);
    1046         mpz_t ec;
    1047         mpz_init(ec);
    1048         mpz_ptr ec_ptr = ec;
    1049         eulerchar(I, currRing->N, ec_ptr);
    1050         bool flag = FALSE;
    1051         if(NNN==0)
    1052             {
    1053                 hilbertcoef = (mpz_ptr)omAlloc((NNN+1)*sizeof(mpz_t));
    1054                 hilbpower = (int*)omAlloc((NNN+1)*sizeof(int));
    1055                 mpz_init( &hilbertcoef[NNN]);
    1056                 mpz_set(  &hilbertcoef[NNN], ec);
    1057                 mpz_clear(ec);
    1058                 hilbpower[NNN] = p_Totaldegree(q,currRing);
    1059                 NNN++;
    1060             }
    1061         else
    1062         {
    1063             //I look if the power appears already
    1064             for(i = 0;(i<NNN)&&(flag == FALSE)&&(p_Totaldegree(q,currRing)>=hilbpower[i]);i++)
    1065             {
    1066                 if((hilbpower[i]) == (p_Totaldegree(q,currRing)))
    1067                 {
    1068                     flag = TRUE;
    1069                     mpz_add(&hilbertcoef[i],&hilbertcoef[i],ec_ptr);
    1070                 }
    1071             }
    1072             if(flag == FALSE)
    1073             {
    1074                 hilbertcoef = (mpz_ptr)omRealloc(hilbertcoef, (NNN+1)*sizeof(mpz_t));
    1075                 hilbpower = (int*)omRealloc(hilbpower, (NNN+1)*sizeof(int));
    1076                 mpz_init(&hilbertcoef[NNN]);
    1077                 for(j = NNN; j>i; j--)
    1078                 {
    1079                     mpz_set(&hilbertcoef[j],&hilbertcoef[j-1]);
    1080                     hilbpower[j] = hilbpower[j-1];
    1081                 }
    1082                 mpz_set(  &hilbertcoef[i], ec);
    1083                 mpz_clear(ec);
    1084                 hilbpower[i] = p_Totaldegree(q,currRing);
    1085                 NNN++;
    1086             }
    1087         }
    1088         break;
    1089     }
     1066      //printf("\n      Corner: ");
     1067      //pWrite(q);
     1068      //printf("\n      With the facets of the dual simplex:\n");
     1069      //idPrint(I);
     1070      mpz_t ec;
     1071      mpz_init(ec);
     1072      mpz_ptr ec_ptr = ec;
     1073      eulerchar(I, currRing->N, ec_ptr);
     1074      bool flag = FALSE;
     1075      if(NNN==0)
     1076      {
     1077        hilbertcoef = (mpz_ptr)omAlloc((NNN+1)*sizeof(mpz_t));
     1078        hilbpower = (int*)omAlloc((NNN+1)*sizeof(int));
     1079        mpz_init_set( &hilbertcoef[NNN], ec);
     1080        hilbpower[NNN] = p_Totaldegree(q,currRing);
     1081        NNN++;
     1082      }
     1083      else
     1084      {
     1085        //I look if the power appears already
     1086        for(i = 0;(i<NNN)&&(flag == FALSE)&&(p_Totaldegree(q,currRing)>=hilbpower[i]);i++)
     1087        {
     1088          if((hilbpower[i]) == (p_Totaldegree(q,currRing)))
     1089          {
     1090            flag = TRUE;
     1091            mpz_add(&hilbertcoef[i],&hilbertcoef[i],ec_ptr);
     1092          }
     1093        }
     1094        if(flag == FALSE)
     1095        {
     1096          hilbertcoef = (mpz_ptr)omRealloc(hilbertcoef, (NNN+1)*sizeof(mpz_t));
     1097          hilbpower = (int*)omRealloc(hilbpower, (NNN+1)*sizeof(int));
     1098          mpz_init(&hilbertcoef[NNN]);
     1099          for(j = NNN; j>i; j--)
     1100          {
     1101            mpz_set(&hilbertcoef[j],&hilbertcoef[j-1]);
     1102            hilbpower[j] = hilbpower[j-1];
     1103          }
     1104          mpz_set(  &hilbertcoef[i], ec);
     1105          hilbpower[i] = p_Totaldegree(q,currRing);
     1106          NNN++;
     1107        }
     1108      }
     1109      mpz_clear(ec);
     1110      id_Delete(&I, currRing);
     1111      id_Delete(&S, currRing);
     1112      break;
     1113    }
     1114    else
     1115      p_Delete(&m, currRing);
    10901116    m = ChooseP(I);
    10911117    p = idInit(1,1);
     
    10951121    poly pq = pp_Mult_mm(q,m,currRing);
    10961122    rouneslice(Ip, Sp, pq, x, prune, moreprune, steps, NNN, hilbertcoef,hilbpower);
    1097     //id_Delete(&Ip, currRing);
    1098     //id_Delete(&Sp, currRing);
    1099     S = idAddMon(S,p);
     1123    idAddMon(S,p);
    11001124    p->m[0]=NULL;
    11011125    id_Delete(&p, currRing); // p->m[0] was also in S
     
    11131137    int *hilbpower;
    11141138    ideal S = idInit(1,1);
    1115     poly q = p_ISet(1,currRing);
     1139    poly q = p_One(currRing);
    11161140    ideal X = idInit(1,1);
    11171141    X->m[0]=p_One(currRing);
    11181142    for(i=1;i<=currRing->N;i++)
    11191143    {
    1120             p_SetExp(X->m[0],i,1,currRing);
     1144      p_SetExp(X->m[0],i,1,currRing);
    11211145    }
    11221146    p_Setm(X->m[0],currRing);
    11231147    I = id_Mult(I,X,currRing);
    1124     I = SortByDeg(I);
     1148    ideal Itmp = SortByDeg(I);
     1149    id_Delete(&I,currRing);
     1150    I = Itmp;
    11251151    //printf("\n-------------RouneSlice--------------\n");
    11261152    rouneslice(I,S,q,X->m[0],prune, moreprune, steps, NNN, hilbertcoef, hilbpower);
     1153    id_Delete(&X,currRing);
     1154    p_Delete(&q,currRing);
    11271155    //printf("\nIn total Prune got rid of %i elements\n",prune);
    11281156    //printf("\nIn total More Prune got rid of %i elements\n",moreprune);
    11291157    //printf("\nSteps of rouneslice: %i\n\n", steps);
    1130     mpz_t coefhilb;
    1131     mpz_t dummy;
    1132     mpz_init(coefhilb);
    1133     mpz_init(dummy);
    11341158    printf("\n//  %8d t^0",1);
    11351159    for(i = 0; i<NNN; i++)
    11361160    {
    1137         if(mpz_sgn(&hilbertcoef[i])!=0)
    1138         {
    1139             gmp_printf("\n//  %8Zd t^%d",&hilbertcoef[i],hilbpower[i]);
    1140         }
    1141     }
     1161      if(mpz_sgn(&hilbertcoef[i])!=0)
     1162      {
     1163        gmp_printf("\n//  %8Zd t^%d",&hilbertcoef[i],hilbpower[i]);
     1164      }
     1165    }
     1166    PrintLn();
    11421167    omFreeSize(hilbertcoef, (NNN)*sizeof(mpz_t));
    11431168    omFreeSize(hilbpower, (NNN)*sizeof(int));
     
    13201345{
    13211346  intvec *work, *hseries2;
    1322   int i, j, k, s, t, l;
     1347  int i, j, k, t, l;
     1348  int s;
    13231349  if (hseries1 == NULL)
    13241350    return NULL;
     
    13531379void hDegreeSeries(intvec *s1, intvec *s2, int *co, int *mu)
    13541380{
    1355   int m, i, j, k;
     1381  int i, j, k;
     1382  int m;
    13561383  *co = *mu = 0;
    13571384  if ((s1 == NULL) || (s2 == NULL))
     
    13931420
    13941421  intvec *hseries1 = hFirstSeries(S, modulweight, Q, wdegree, tailRing);
     1422  if (errorreported) return;
    13951423
    13961424  hPrintHilb(hseries1);
  • libpolys/polys/monomials/p_polys.h

    ra135fd rfbd9e6f  
    15241524  }
    15251525  const long* _ordsgn = (long*) r->ordsgn;
     1526#if 1 /* two variants*/
    15261527  if (_v1 > _v2)
    15271528  {
    1528     if (_ordsgn[_i] == 1) return 1;
    1529     return -1;
    1530   }
    1531   if (_ordsgn[_i] == 1) return -1;
    1532   return 1;
    1533 
     1529    return _ordsgn[_i];
     1530  }
     1531  return -(_ordsgn[_i]);
     1532#else
     1533   if (_v1 > _v2)
     1534   {
     1535     if (_ordsgn[_i] == 1) return 1;
     1536     return -1;
     1537   }
     1538   if (_ordsgn[_i] == 1) return -1;
     1539   return 1;
     1540#endif
    15341541}
    15351542
  • omalloc/omAllocSystem.c

    ra135fd rfbd9e6f  
    3333#define _omSizeOfLargeAddr(addr) (malloc_size(addr))
    3434#elif defined(HAVE_MALLOC_USABLE_SIZE)
    35 #include <malloc.h>
     35#include <stdlib.h>
    3636#define _omSizeOfLargeAddr(addr) (malloc_usable_size(addr))
    3737#else
  • omalloc/omMallocSystem.h

    ra135fd rfbd9e6f  
    2020#elif (defined(HAVE_MALLOC_USABLE_SIZE))
    2121/* and this will work under Linux */
    22 #include <malloc.h>
     22#include <stdlib.h>
    2323#define OM_MALLOC_SIZEOF_ADDR(addr) (malloc_usable_size(addr))
    2424#else
Note: See TracChangeset for help on using the changeset viewer.