Changeset 3d391f4 in git


Ignore:
Timestamp:
Jan 30, 2020, 11:58:50 PM (4 years ago)
Author:
Karim Abou Zeid <karim23697@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
636fa5455e699fa8c0a820dd60e00a059f96f8efbbc88372fd4d9c3bc704e6afef375197fdd09810
Parents:
928d43353be8cce56dabc86bd3b35ebd48f1cdd0ed01f112cee60b9d71fdcff8400dab5c67a23882
Message:
Merge branch 'reduce_fix' into stable
Files:
15 added
8 edited

Legend:

Unmodified
Added
Removed
  • Singular/LIB/fpaprops.lib

    red01f11 r3d391f4  
    2828  lpGlDimBound(<GB>);     compute an upper bound for the global dimension of A/<GB>
    2929  lpSubstitute();         substitute a variable with polynomials (ring homomorphism)
    30   lpUfGraph(<GB>);        constructs the Ufnarovskij graph for <LM(GB)>
    3130  lpCalcSubstDegBound(); utility for lpSubstitute
    3231";
     
    4443    example lpGlDimBound;
    4544    example lpSubstitute;
    46     example lpUfGraph;
    4745    example lpCalcSubstDegBound;
    4846};
     
    8381    // also if G is the whole ring
    8482    if (leadmonom(G[i]) == 1) {
    85       ERROR("noetherianity not defined for 0-ring")
     83      ERROR("Noetherianity not defined for 0-ring")
    8684    }
    8785    kill d;
     
    9088  if (l == 1) {
    9189    int n = lpVarBlockSize(basering); // variable count
     90    int ncgenCount = lpNcgenCount(basering);
    9291    int k = size(G);
    93     if (k == n) { // only the field left
     92    if (k == n - ncgenCount) { // only the field left
    9493      return(3); // every field is noetherian
    9594    }
    96     if (k == n-1) { // V = {1} with loop
     95    if (k == n - ncgenCount - 1) { // V = {1} with loop
    9796      return(3);
    9897    }
    99     if (k <= n-2) { // V = {1} with more than one loop
     98    if (k <= n ncgenCount - 2) { // V = {1} with more than one loop
    10099      return(0);
    101100    }
    102101  }
    103102
    104   intmat UG = lpUfGraph(G);
     103  intmat UG = lpUfnarovskiGraph(G)[1];
    105104
    106105  // check special case 2
     
    311310  }
    312311
    313   list VUG = lpUfGraph(G, 1);
     312  list VUG = lpUfnarovskiGraph(G);
    314313  intmat UG = VUG[1]; // the Ufnarovskij graph
    315314  ideal V = VUG[2]; // the vertices of UG (standard words with length = l-1)
     
    419418  }
    420419
    421   list VUG = lpUfGraph(G, 1);
     420  list VUG = lpUfnarovskiGraph(G);
    422421  intmat UG = VUG[1]; // the Ufnarovskij graph
    423422  ideal V = VUG[2]; // the vertices of UG (standard words with length = l-1)
     
    726725}
    727726
    728 proc lpUfGraph(ideal G, list #)
    729 "USAGE: lpUfGraph(G); G a set of monomials in a letterplace ring.
    730 RETURN: intmat or list
    731 NOTE: lpUfGraph(G); returns intmat. lpUfGraph(G,1); returns list L with L[1] an intmat and L[2] an ideal.
    732       The intmat is the Ufnarovskij Graph and the ideal contains the vertices.
    733 PURPOSE: Constructs the Ufnarovskij graph induced by G
    734       the adjacency matrix of the Ufnarovskij graph induced by G
    735 ASSUME: - basering is a Letterplace ring
    736       - G are the leading monomials of a Groebner basis
    737 "
    738 {
    739   dbprint("computing maxDeg");
    740   int l = maxDeg(G);
    741   if (l - 1 == 0) {
    742     // TODO: how should the graph look like when l - 1 = 0 ?
    743     ERROR("Ufnarovskij graph not implemented for l = 1");
    744   }
    745   int lV = lpVarBlockSize(basering);
    746   // TODO: what if l <= 0?
    747   dbprint("computing standard words");
    748   ideal SW = lpStandardWords(G, l - 1); // vertices
    749   int n = ncols(SW);
    750   dbprint("n = " + string(n));
    751   intmat UG[n][n]; // Ufnarovskij graph
    752   for (int i = 1; i <= n; i++) {
    753     for (int j = 1; j <= n; j++) {
    754       dbprint("Ufnarovskii graph: " + string((i-1)*n + j) + "/" + string(n*n) + " entries");
    755       // [Studzinski page 76]
    756       poly v = SW[i];
    757       poly w = SW[j];
    758       intvec v_overlap;
    759       intvec w_overlap;
    760       if (l - 1 > 1) {
    761         v_overlap = leadexp(v);
    762         w_overlap = leadexp(w);
    763         v_overlap = v_overlap[(lV+1) .. (l-1)*lV];
    764         w_overlap = w_overlap[1 .. (l-2)*lV];
    765       }
    766       if (v_overlap == w_overlap && !lpLmDivides(G, v * lpVarAt(w, l - 1))) {
    767         UG[i,j] = 1;
    768       }
    769       kill v; kill w; kill v_overlap; kill w_overlap;
    770     } kill j;
    771   } kill i;
    772   if (size(#) > 0) {
    773     if (typeof(#[1]) == "int") {
    774       if (#[1] != 0) {
    775         list ret = UG;
    776         ret[2] = SW; // the vertices
    777         return (ret);
    778       }
    779     }
    780   }
    781   return (UG);
    782 }
    783 example
    784 {
    785   "EXAMPLE:"; echo = 2;
    786   ring r = 0,(x,y,z),dp;
    787   def R = freeAlgebra(r, 5); // constructs a Letterplace ring
    788   setring R; // sets basering to Letterplace ring
    789   ideal I = x*y, x*z, z*y, z*z;
    790   lpUfGraph(I);
    791   lpUfGraph(I,1);
    792 }
     727// Ufnarovskii graph is now implemented in the dynamic module (freeAlgebra.cc)
     728/* proc lpUfnarovskiGraph(ideal G, list #) */
     729/* "USAGE: lpUfnarovskiGraph(G); G a set of monomials in a letterplace ring. */
     730/* RETURN: intmat or list */
     731/* NOTE: lpUfnarovskiGraph(G); returns intmat. lpUfnarovskiGraph(G,1); returns list L with L[1] an intmat and L[2] an ideal. */
     732/*       The intmat is the Ufnarovskij Graph and the ideal contains the vertices. */
     733/* PURPOSE: Constructs the Ufnarovskij graph induced by G */
     734/*       the adjacency matrix of the Ufnarovskij graph induced by G */
     735/* ASSUME: - basering is a Letterplace ring */
     736/*       - G are the leading monomials of a Groebner basis */
     737/* " */
     738/* { */
     739/*   dbprint("computing maxDeg"); */
     740/*   int l = maxDeg(G); */
     741/*   if (l - 1 == 0) { */
     742/*     // TODO: how should the graph look like when l - 1 = 0 ? */
     743/*     ERROR("Ufnarovskij graph not implemented for l = 1"); */
     744/*   } */
     745/*   int lV = lpVarBlockSize(basering); */
     746/*   // TODO: what if l <= 0? */
     747/*   dbprint("computing standard words"); */
     748/*   ideal SW = lpStandardWords(G, l - 1); // vertices */
     749/*   int n = ncols(SW); */
     750/*   dbprint("n = " + string(n)); */
     751/*   intmat UG[n][n]; // Ufnarovskij graph */
     752/*   for (int i = 1; i <= n; i++) { */
     753/*     for (int j = 1; j <= n; j++) { */
     754/*       dbprint("Ufnarovskii graph: " + string((i-1)*n + j) + "/" + string(n*n) + " entries"); */
     755/*       // [Studzinski page 76] */
     756/*       poly v = SW[i]; */
     757/*       poly w = SW[j]; */
     758/*       intvec v_overlap; */
     759/*       intvec w_overlap; */
     760/*       if (l - 1 > 1) { */
     761/*         v_overlap = leadexp(v); */
     762/*         w_overlap = leadexp(w); */
     763/*         v_overlap = v_overlap[(lV+1) .. (l-1)*lV]; */
     764/*         w_overlap = w_overlap[1 .. (l-2)*lV]; */
     765/*       } */
     766/*       if (v_overlap == w_overlap && !lpLmDivides(G, v * lpVarAt(w, l - 1))) { */
     767/*         UG[i,j] = 1; */
     768/*       } */
     769/*       kill v; kill w; kill v_overlap; kill w_overlap; */
     770/*     } kill j; */
     771/*   } kill i; */
     772/*   if (size(#) > 0) { */
     773/*     if (typeof(#[1]) == "int") { */
     774/*       if (#[1] != 0) { */
     775/*         list ret = UG; */
     776/*         ret[2] = SW; // the vertices */
     777/*         return (ret); */
     778/*       } */
     779/*     } */
     780/*   } */
     781/*   return (UG); */
     782/* } */
     783/* example */
     784/* { */
     785/*   "EXAMPLE:"; echo = 2; */
     786/*   ring r = 0,(x,y,z),dp; */
     787/*   def R = freeAlgebra(r, 5); // constructs a Letterplace ring */
     788/*   setring R; // sets basering to Letterplace ring */
     789/*   ideal I = x*y, x*z, z*y, z*z; */
     790/*   lpUfnarovskiGraph(I); */
     791/*   lpUfnarovskiGraph(I,1); */
     792/* } */
    793793
    794794static proc maxDeg(ideal G)
     
    833833    return (words); // no standard words
    834834  }
    835   int lV = lpVarBlockSize(basering); // variable count
     835  int nVars = lpVarBlockSize(basering) - lpNcgenCount(basering); // variable count
    836836  list prevWords = ivStandardWords(G, length - 1);
    837837  list words;
    838   for (int i = 1; i <= lV; i++) {
     838  for (int i = 1; i <= nVars; i++) {
    839839    for (int j = 1; j <= size(prevWords); j++) {
    840840      intvec word = prevWords[j];
     
    919919
    920920/*   dbprint("computing Ufnarovskii graph"); */
    921 /*   intmat UG = lpUfGraph(G); */
     921/*   intmat UG = lpUfnarovskiGraph(G)[1]; */
    922922/*   if (printlevel >= voice + 1) { */
    923923/*     UG; */
     
    10021002  if (size(G1) > 0) {
    10031003    while (size(G1) > 0) {
    1004       if (lpVarBlockSize(R) > 1) {
     1004      if (lpVarBlockSize(R) - lpNcgenCount(R) > 1) {
    10051005        def @R = R - string(G1[1]);
    10061006        R = @R;
  • Singular/LIB/freegb.lib

    red01f11 r3d391f4  
    2626lpDegBound(R);                   returns the degree bound of a letterplace ring
    2727lpVarBlockSize(R);               returns the size of the letterplace blocks
     28lpNcgenCount(R);                 returns the number of ncgen variables
    2829lpDivision(f,I);                 two-sided division with remainder
    2930lpGBPres2Poly(L,I);              reconstructs a polynomial from the output of lpDivision
     
    10041005  def R = freeAlgebra(r, 7);
    10051006  isFreeAlgebra(R);
     1007}
     1008
     1009proc lpNcgenCount(def R)
     1010"USAGE:  lpNcgenCount(R); R a letterplace ring
     1011RETURN:  int
     1012PURPOSE: returns the number of ncgen variables in the letterplace ring.
     1013EXAMPLE: example ncgenCount; shows examples
     1014"
     1015{
     1016  return(attrib(R, "ncgenCount"));
     1017}
     1018example
     1019{
     1020  "EXAMPLE:"; echo = 2;
     1021  ring r = 0,(x,y,z),dp;
     1022  def R = freeAlgebra(r, 7, 10);
     1023  lpNcgenCount(R); // should be 10
    10061024}
    10071025
  • Singular/attrib.cc

    red01f11 r3d391f4  
    259259      #ifdef HAVE_SHIFTBBA
    260260      PrintS("attr:isLetterplaceRing, type int\n");
     261      PrintS("attr:ncgenCount, type int\n");
    261262      #endif
    262263
     
    331332    res->data=(void *)(long)(((ring)v->Data())->isLPring);
    332333  }
     334  else if ((strcmp(name,"ncgenCount")==0)
     335  &&(/*v->Typ()*/t==RING_CMD))
     336  {
     337    res->rtyp=INT_CMD;
     338    res->data=(void *)(long)(((ring)v->Data())->LPncGenCount);
     339  }
    333340#endif
    334341  else
     
    436443    }
    437444  }
     445  else if ((strcmp(name,"ncgenCount")==0)
     446  &&(/*v->Typ()*/t==RING_CMD))
     447  {
     448    if (c->Typ()==INT_CMD)
     449      ((ring)v->Data())->LPncGenCount=(int)(long)c->Data();
     450    else
     451    {
     452      WerrorS("attribute `ncgenCount` must be int");
     453      return TRUE;
     454    }
     455  }
    438456#endif
    439457  else
  • Singular/dyn_modules/freealgebra/freealgebra.cc

    red01f11 r3d391f4  
    136136static void _computeStandardWords(ideal words, int n, ideal M, int& last)
    137137{
     138  // assume <M> != <1>
    138139  if (n <= 0){
    139140    words->m[0] = pOne();
     
    144145  _computeStandardWords(words, n - 1, M, last);
    145146
    146   int nVars = currRing->isLPring;
     147  int nVars = currRing->isLPring - currRing->LPncGenCount;
    147148
    148149  for (int j = nVars - 1; j >= 0; j--)
     
    158159        }
    159160
    160         int varOffset = ((n - 1) * nVars) + 1;
     161        int varOffset = ((n - 1) * currRing->isLPring) + 1;
    161162        pSetExp(words->m[index], varOffset + j, 1);
    162163        pSetm(words->m[index]);
     
    177178static ideal computeStandardWords(int n, ideal M)
    178179{
    179   int nVars = currRing->isLPring;
     180  int nVars = currRing->isLPring - currRing->LPncGenCount;
    180181
    181182  int maxElems = 1;
     
    190191
    191192// NULL if graph is undefined
    192 static intvec* ufnarovskiGraph(ideal G)
     193static intvec* ufnarovskiGraph(ideal G, ideal &standardWords)
    193194{
    194195  long l = 0;
     
    203204  int lV = currRing->isLPring;
    204205
    205   ideal standardWords = computeStandardWords(l, G);
     206  standardWords = computeStandardWords(l, G);
    206207
    207208  int n = IDELEMS(standardWords);
     
    250251}
    251252
     253static BOOLEAN lpUfnarovskiGraph(leftv res, leftv h)
     254{
     255  const short t[]={1,IDEAL_CMD};
     256  if (iiCheckTypes(h,t,1))
     257  {
     258    ideal I = (ideal) h->Data();
     259    res->rtyp = LIST_CMD;
     260
     261    ideal standardWords;
     262    intvec* graph = ufnarovskiGraph(I, standardWords);
     263
     264    lists li=(lists)omAllocBin(slists_bin);
     265    li->Init(2);
     266    li->m[0].rtyp=INTMAT_CMD;
     267    li->m[1].rtyp=IDEAL_CMD;
     268    li->m[0].data=graph;
     269    li->m[1].data=standardWords;
     270
     271    res->data = li;
     272
     273    if (errorreported) return TRUE;
     274    return FALSE;
     275  }
     276  else return TRUE;
     277}
     278
    252279static std::vector<int> countCycles(const intvec* _G, int v, std::vector<int> path, std::vector<BOOLEAN> visited, std::vector<BOOLEAN> cyclic, std::vector<int> cache)
    253280{
     
    353380      return -2;
    354381    }
     382    if (pGetNCGen(_G->m[i]) != 0)
     383    {
     384      WerrorS("GK-Dim not implemented for bi-modules");
     385      return -2;
     386    }
    355387  }
    356388
     
    377409  {
    378410    int lV = currRing->isLPring;
    379     if (IDELEMS(G) == lV) // V = {1} no edges
     411    int ncGenCount = currRing->LPncGenCount;
     412    if (IDELEMS(G) == lV - ncGenCount) // V = {1} no edges
    380413      return 0;
    381     if (IDELEMS(G) == lV - 1) // V = {1} with loop
     414    if (IDELEMS(G) == lV - ncGenCount - 1) // V = {1} with loop
    382415      return 1;
    383     if (IDELEMS(G) <= lV - 2) // V = {1} with more than one loop
     416    if (IDELEMS(G) <= lV - ncGenCount - 2) // V = {1} with more than one loop
    384417      return -1;
    385418  }
    386419
    387   intvec* UG = ufnarovskiGraph(G);
     420  ideal standardWords;
     421  intvec* UG = ufnarovskiGraph(G, standardWords);
    388422  if (errorreported || UG == NULL) return -2;
    389423  return graphGrowth(UG);
     
    416450  p->iiAddCproc("freealgebra.so","lpVarAt",FALSE,lpVarAt);
    417451  p->iiAddCproc("freealgebra.so","lpGkDim",FALSE,lpGkDim);
     452  p->iiAddCproc("freealgebra.so","lpUfnarovskiGraph",FALSE,lpUfnarovskiGraph);
    418453
    419454  p->iiAddCproc("freealgebra.so","stest",TRUE,stest);
  • Tst/Letterplace.lst

    red01f11 r3d391f4  
    1111
    1212Manual/lpGkDim.tst
     13Manual/lpNoetherian.tst
     14Manual/lpIsPrime.tst
     15Manual/lpIsSemiPrime.tst
     16Manual/lpGlDimBound.tst
    1317Manual/lpKDim.tst
    1418Manual/lpKDimCheck.tst
     19Manual/lpUfnarovskiGraph.tst
    1520Manual/lpMonomialBasis.tst
    1621Manual/lpSickleDim.tst
  • kernel/GBEngine/kutil.cc

    r928d43 r3d391f4  
    93749374void enterSBbaShift (LObject &p,int atS,kStrategy strat, int atR)
    93759375{
     9376  enterSBba(p, atS, strat, atR);
     9377
    93769378  int maxPossibleShift = p_mLPmaxPossibleShift(p.p, strat->tailRing);
    93779379  for (int i = maxPossibleShift; i > 0; i--)
    93789380  {
     9381
    93799382    LObject qq;
    93809383    qq.p = pLPCopyAndShiftLM(p.p, i); // don't use Set() because it'll test the poly order
    93819384    qq.shift = i;
    93829385    strat->initEcart(&qq); // initEcartBBA sets length, pLength, FDeg and ecart
     9386    int atS = posInS(strat, strat->sl, qq.p, qq.ecart); // S needs to stay sorted because this is for example assumed when searching S later
    93839387    enterSBba(qq, atS, strat, -1);
    93849388  }
    9385   enterSBba(p, atS, strat, atR);
    93869389}
    93879390#endif
  • libpolys/polys/shiftop.cc

    red01f11 r3d391f4  
    613613}
    614614
     615BOOLEAN _p_mLPNCGenValid(poly p, const ring r)
     616{
     617  if (p == NULL) return TRUE;
     618  int *e=(int *)omAlloc((r->N+1)*sizeof(int));
     619  p_GetExpV(p,e,r);
     620  int b = _p_mLPNCGenValid(e, r);
     621  omFreeSize((ADDRESS) e, (r->N+1)*sizeof(int));
     622  return b;
     623}
     624
    615625BOOLEAN _p_mLPNCGenValid(int *mExpV, const ring r)
    616626{
     
    634644  }
    635645  return TRUE;
     646}
     647
     648int p_GetNCGen(poly p, const ring r)
     649{
     650  if (p == NULL) return 0;
     651  assume(_p_mLPNCGenValid(p, r));
     652
     653  int lV = r->isLPring;
     654  int degbound = r->N/lV;
     655  int ncGenCount = r->LPncGenCount;
     656  for (int i = 1; i <= degbound; i++)
     657  {
     658    for (int j = i*lV; j > (i*lV - ncGenCount); j--)
     659    {
     660      if (p_GetExp(p, j, r))
     661      {
     662        return j - i*lV + ncGenCount;
     663      }
     664    }
     665  }
     666  return 0;
    636667}
    637668
  • libpolys/polys/shiftop.h

    red01f11 r3d391f4  
    5555BOOLEAN _p_LPLmDivisibleByNoComp(poly a, poly b, const ring r);
    5656
     57BOOLEAN _p_mLPNCGenValid(poly p, const ring r);
    5758BOOLEAN _p_mLPNCGenValid(int *mExpV, const ring r);
    5859
    5960poly p_LPVarAt(poly p, int pos, const ring r);
     61
     62#define pGetNCGen(p) p_GetNCGen(p, currRing)
     63int p_GetNCGen(poly p, const ring r);
    6064
    6165#define pLPSubst(p, n, e) p_LPSubst(p, n, e, r)
Note: See TracChangeset for help on using the changeset viewer.