Changeset 5d623c in git for kernel


Ignore:
Timestamp:
Dec 2, 2016, 6:49:32 PM (7 years ago)
Author:
Sharwan Tiwari <shrawant@…>
Branches:
(u'spielwiese', '2a584933abf2a2d3082034c7586d38bb6de1a30a')
Children:
665dab88a13186ce5e6abca704e42280baad6b91
Parents:
174bcf3262ce524919d5ef06586fee3331f4cd94
Message:
multi-graded Hilbert series of non-commutative monomial algebras
Location:
kernel/combinatorics
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • kernel/combinatorics/hilb.cc

    r174bcf r5d623c  
    3737#include <coeffs/numbers.h>
    3838#include <vector>
     39#include <Singular/ipshell.h>
    3940
    4041#endif
     
    16851686      if(p_LmDivisibleBy(I->m[i], I->m[k], currRing))
    16861687      {
    1687         pDelete(&(I->m[k]));//this is not req.
     1688        pDelete(&(I->m[k]));
    16881689        break;
    16891690      }
     
    18561857}
    18571858
    1858 
    1859 void HilbertSeries_OrbitData(ideal S, int lV, bool IG_CASE )
     1859void HilbertSeries_OrbitData(ideal S, int lV, bool IG_CASE, bool mgrad, bool odp)
    18601860{
    18611861  /*
     
    18751875  if(IG_CASE)
    18761876  {
     1877    if(idIs0(S))
     1878    {
     1879      WerrorS("wrong input:not the infinitely gen. case");
     1880        return;
     1881    }
    18771882    trInd = p_Totaldegree(S->m[IDELEMS(S)-1], currRing);
    18781883    POS = &positionInOrbit_IG_Case;
     
    18911896  polist.push_back( p_One(currRing));
    18921897
    1893   std::vector< std::vector<int> > mat;
    1894   std::vector<int> row;
    1895   row.push_back(0);
    1896 
     1898  std::vector< std::vector<int> > posMat;
     1899  std::vector<int> posRow(lV,0);         
    18971900  std::vector<int> C;
    18981901
    1899   int ds, is, ps, sz;
     1902  int ds, is, ps;
    19001903  int lpcnt = 0;
    19011904
     
    19431946      Jwi = colonIdeal(S, wi, lV, Jwi);
    19441947      ps = (*POS)(Jwi, wi, idorb, polist, trInd);
    1945 
    1946       if(ps == 0)  // found new colon ideal
     1948     
     1949      if(ps == 0)  // finds a new ideal
    19471950      {
     1951        posRow[is-1] = idorb.size();
    19481952
    19491953        idorb.push_back(Jwi);
    19501954        polist.push_back(wi);
    1951         row.push_back(1);
    19521955      }
    1953       else // there is a same ideal in the orbit
     1956      else // ideal is already there in the orbit
    19541957      {
    1955         row[ps-1] = row[ps-1] + 1;
     1958        posRow[is-1]=ps-1;     
    19561959        idDelete(&Jwi);
    19571960        pDelete(&wi);
    19581961      }
    19591962    }
    1960     mat.push_back(row);
    1961     sz = row.size();
    1962     row.clear();
    1963     row.resize(sz, 0);
     1963    posMat.push_back(posRow);
     1964    posRow.resize(lV,0); 
     1965  }
     1966  int lO = C.size();//size of the orbit
     1967  PrintLn();
     1968  Print("Maximal length of words = %ld\n", p_Totaldegree(polist[lO-1], currRing));
     1969  Print("\nOrbit length = %d\n", lO);
     1970  PrintLn();
     1971 
     1972  if(odp)
     1973  {
     1974    Print("Words description of the Orbit: \n");
     1975    for(is = 0; is < lO; is++)
     1976    {
     1977      pWrite0(polist[is]);
     1978      PrintS("    ");
     1979    }
     1980    PrintLn();
    19641981  }
    19651982
     
    19751992  idorb.resize(0);
    19761993  polist.resize(0);
    1977 
    1978   row.resize(0);
    1979 
     1994 
     1995  int adjMatrix[lO][lO];
     1996  memset(adjMatrix, 0, lO*lO*sizeof(int));
    19801997  int rowCount, colCount;
    1981 #if 0
    1982   for(rowCount = 0; rowCount < mat.size(); rowCount++)
    1983   {
    1984     for(colCount = 0; colCount  < mat[rowCount].size(); colCount++)
    1985     {
    1986       Print("%d,",mat[rowCount][colCount]);
    1987     }
    1988     PrintLn();
    1989   }
    1990   printf("rhs column matrix::\n");
    1991   for(colCount = 0; colCount < C.size(); colCount++)
    1992   printf("%d,",C[colCount]);
    1993   //printf("\nlength of the Orbit==%ld\n", C.size());
    1994 #endif
     1998  int tm = 0;
     1999  if(!mgrad)
     2000  {
     2001    for(rowCount = 0; rowCount < lO; rowCount++)
     2002    {
     2003      for(colCount = 0; colCount < lV; colCount++)
     2004      {
     2005        tm = posMat[rowCount][colCount];
     2006        adjMatrix[rowCount][tm] = adjMatrix[rowCount][tm] + 1;
     2007      }
     2008    }
     2009  }
     2010 
    19952011  ring r = currRing;
    1996   char** tt=(char**)omalloc(sizeof(char*));
    1997   tt[0] = omStrDup("t");
     2012  int npar;
     2013  char** tt;
    19982014  TransExtInfo p;
    1999   p.r = rDefault(0, 1, tt);
    2000   coeffs cf = nInitChar(n_transExt,&p);
    2001 
     2015  if(!mgrad)
     2016  {
     2017    tt=(char**)omalloc(sizeof(char*));
     2018    tt[0] = omStrDup("t");
     2019    npar = 1;
     2020  }
     2021  else
     2022  {
     2023    tt=(char**)omalloc(lV*sizeof(char*));
     2024    for(is = 0; is < lV; is++)
     2025    {
     2026      tt[is] = (char*)omalloc(7*sizeof(char)); //if required enlarge it later
     2027      sprintf (tt[is], "t(%d)", is+1);
     2028    }
     2029    npar = lV;
     2030  }
     2031
     2032  p.r = rDefault(0, npar, tt);
     2033  coeffs cf = nInitChar(n_transExt, &p);
    20022034  char** xx = (char**)omalloc(sizeof(char*));
    20032035  xx[0] = omStrDup("x");
    20042036  ring R = rDefault(cf, 1, xx);
    2005   rChangeCurrRing(R);
     2037  rChangeCurrRing(R);//rWrite(R);
    20062038  /*
    20072039   * matrix corresponding to the orbit of the ideal
    20082040   */
    2009   int lO = C.size();//size of the orbit
    20102041  matrix mR = mpNew(lO, lO);
    20112042  matrix cMat = mpNew(lO,1);
     2043  poly rc;
     2044 
     2045  if(!mgrad)
     2046  {
     2047    for(rowCount = 0; rowCount < lO; rowCount++)
     2048    {
     2049      for(colCount = 0; colCount < lO; colCount++)
     2050      {
     2051        if(adjMatrix[rowCount][colCount] != 0)
     2052        {
     2053          MATELEM(mR, rowCount + 1, colCount + 1) = p_ISet(adjMatrix[rowCount][colCount], R);
     2054          p_SetCoeff(MATELEM(mR, rowCount + 1, colCount + 1), n_Mult(pGetCoeff(mR->m[lO*rowCount+colCount]),n_Param(1, R->cf), R->cf), R);
     2055        }
     2056      }
     2057    }
     2058  }
     2059  else
     2060  {
     2061     for(rowCount = 0; rowCount < lO; rowCount++)
     2062     {
     2063       for(colCount = 0; colCount < lV; colCount++)
     2064       {
     2065          rc=NULL;
     2066          rc=p_One(R);
     2067          p_SetCoeff(rc, n_Mult(pGetCoeff(rc), n_Param(colCount+1, R->cf),R->cf), R);
     2068          MATELEM(mR, rowCount +1, posMat[rowCount][colCount]+1)=p_Add_q(rc,MATELEM(mR, rowCount +1, posMat[rowCount][colCount]+1), R);
     2069       }
     2070     }
     2071  }
    20122072
    20132073  for(rowCount = 0; rowCount < lO; rowCount++)
    20142074  {
    2015     for(colCount = 0; colCount < mat[rowCount].size(); colCount++)
    2016     {
    2017       if(mat[rowCount][colCount] != 0)
     2075    if(C[rowCount] != 0)
     2076    {
     2077      MATELEM(cMat, rowCount + 1, 1) = p_ISet(C[rowCount], R);
     2078    }
     2079  }
     2080 
     2081  matrix u;
     2082  unitMatrix(lO, u); //unit matrix
     2083  matrix gMat = mp_Sub(u, mR, R);
     2084  char* s;
     2085  if(odp)
     2086  {
     2087    PrintS("\nlinear system:\n");
     2088    if(!mgrad)
     2089    {
     2090      for(rowCount = 0; rowCount < lO; rowCount++)
    20182091      {
    2019        MATELEM(mR, rowCount + 1, colCount + 1) = p_ISet(mat[rowCount][colCount], R);
    2020         p_SetCoeff(MATELEM(mR, rowCount + 1, colCount + 1), n_Mult(pGetCoeff(mR->m[lO*rowCount+colCount]),n_Param(1, R->cf), R->cf), R);
     2092        Print("H(%d) = ", rowCount+1);
     2093        for(colCount = 0; colCount < lV; colCount++)
     2094        {   
     2095          StringSetS(""); nWrite(n_Param(1, R->cf));
     2096          s = StringEndS(); PrintS(s);
     2097          Print("*"); omFree(s);
     2098          Print("H(%d) + ", posMat[rowCount][colCount] + 1);
     2099        }
     2100        Print(" %d\n", C[rowCount] );
    20212101      }
    2022     }
    2023     if(C[rowCount] != 0)
    2024     {
    2025       cMat->m[rowCount] = p_ISet(C[rowCount], R);
    2026     }
    2027     mat[rowCount].resize(0);
    2028   }
    2029   mat.resize(0);
     2102      PrintS("where H(1) represents the series corresp. to input ideal\n");
     2103      PrintS("and i^th summand in the rhs of an eqn. is according\n");
     2104      PrintS("to the right colon map corresp. to the i^th variable\n");
     2105    }
     2106    else
     2107    {
     2108      for(rowCount = 0; rowCount < lO; rowCount++)
     2109      {
     2110        Print("H(%d) = ", rowCount+1);
     2111        for(colCount = 0; colCount < lV; colCount++)
     2112        {
     2113           StringSetS(""); nWrite(n_Param(colCount+1, R->cf));
     2114           s = StringEndS(); PrintS(s);
     2115           Print("*");omFree(s);
     2116           Print("H(%d) + ", posMat[rowCount][colCount] + 1);
     2117        }
     2118        Print(" %d\n", C[rowCount] );
     2119      }
     2120      PrintS("where H(1) represents the series corresp. to input ideal\n");
     2121    }
     2122  }
     2123  posMat.resize(0);
    20302124  C.resize(0);
    2031   matrix u;
    2032   unitMatrix(lO,u); //unit matrix
    2033   matrix gMat=mp_Sub(u,mR,R);
    20342125  matrix pMat;
    20352126  matrix lMat;
     
    20402131  luSolveViaLUDecomp(pMat, lMat, uMat, cMat, H_serVec, Hnot);
    20412132
    2042   mp_Delete(&mR,R);
    2043   mp_Delete(&u,R);
    2044   mp_Delete(&pMat,R);
    2045   mp_Delete(&lMat,R);
    2046   mp_Delete(&uMat,R);
    2047   mp_Delete(&cMat,R);
    2048   mp_Delete(&gMat,R);
    2049   mp_Delete(&Hnot,R);
     2133  mp_Delete(&mR, R);
     2134  mp_Delete(&u, R);
     2135  mp_Delete(&pMat, R);
     2136  mp_Delete(&lMat, R);
     2137  mp_Delete(&uMat, R);
     2138  mp_Delete(&cMat, R);
     2139  mp_Delete(&gMat, R);
     2140  mp_Delete(&Hnot, R);
    20502141  //print the Hilbert series and Orbit length
    20512142  PrintLn();
     2143  Print("Hilbert series:");
     2144  PrintLn();
    20522145  pWrite(H_serVec->m[0]);
    2053   Print("\nOrbit size = %d\n", lO);
    2054 
    2055   omFree(tt[0]);
     2146  PrintLn();
     2147  if(!mgrad)
     2148  {
     2149    omFree(tt[0]);
     2150  }
     2151  else
     2152  {
     2153    for(is = lV-1; is >= 0; is--)
     2154
     2155      omFree( tt[is]);
     2156  }
    20562157  omFree(tt);
    20572158  omFree(xx[0]);
    20582159  omFree(xx);
    20592160  rChangeCurrRing(r);
    2060   rDelete(R);
    2061 }
    2062 
    2063 
     2161  rKill(R);
     2162}
  • kernel/combinatorics/hutil.h

    r174bcf r5d623c  
    8484scfmon hInit(ideal S, ideal Q, int * Nexist, ring tailRing);
    8585void slicehilb(ideal I);
    86 void HilbertSeries_OrbitData(ideal S, int lV, bool ig);
     86void HilbertSeries_OrbitData(ideal S, int lV, bool ig, bool mgrad, bool odp);
    8787#endif
Note: See TracChangeset for help on using the changeset viewer.