My Project
Functions
hilb.h File Reference
#include "polys/monomials/ring.h"
#include "kernel/polys.h"
#include "misc/intvec.h"

Go to the source code of this file.

Functions

intvechFirstSeries (ideal S, intvec *modulweight, ideal Q=NULL, intvec *wdegree=NULL)
 
intvechFirstSeries0 (ideal S, ideal Q, intvec *wdegree, const ring src, const ring Qt)
 
poly hilbert_series (ideal A, const ring src, const intvec *wdegree, const ring Qt)
 
intvechSecondSeries (intvec *hseries1)
 
void hLookSeries (ideal S, intvec *modulweight, ideal Q=NULL, intvec *wdegree=NULL)
 

Function Documentation

◆ hFirstSeries()

intvec* hFirstSeries ( ideal  S,
intvec modulweight,
ideal  Q = NULL,
intvec wdegree = NULL 
)

Definition at line 1947 of file hilb.cc.

1948 {
1949  static ring hilb_Qt=NULL;
1950  if (hilb_Qt==NULL) hilb_Qt=makeQt();
1951  if (!isModule(A,currRing))
1952  return hFirstSeries0(A,Q,wdegree,currRing,hilb_Qt);
1953  intvec *res=NULL;
1954  int w_max=0,w_min=0;
1955  if (module_w!=NULL)
1956  {
1957  w_max=module_w->max_in();
1958  w_min=module_w->min_in();
1959  }
1960  for(int c=1;c<=A->rank;c++)
1961  {
1962  ideal Ac=getModuleComp(A,c,currRing);
1963  intvec *res_c=hFirstSeries0(Ac,Q,wdegree,currRing,hilb_Qt);
1964  id_Delete(&Ac,currRing);
1965  intvec *tmp=NULL;
1966  if (res==NULL)
1967  res=new intvec(res_c->length()+(w_max-w_min));
1968  if ((module_w==NULL) || ((*module_w)[c-1]==0)) tmp=ivAdd(res,res_c);
1969  else tmp=ivAddShift(res, res_c,(*module_w)[c-1]-w_min);
1970  delete res_c;
1971  if (tmp!=NULL)
1972  {
1973  delete res;
1974  res=tmp;
1975  }
1976  }
1977  (*res)[res->length()-1]=w_min;
1978  return res;
1979 }
Definition: intvec.h:23
int length() const
Definition: intvec.h:94
CanonicalForm res
Definition: facAbsFact.cc:60
static BOOLEAN isModule(ideal A, const ring src)
Definition: hilb.cc:1931
static ring makeQt()
Definition: hilb.cc:1840
static ideal getModuleComp(ideal A, int c, const ring src)
Definition: hilb.cc:1920
intvec * hFirstSeries0(ideal A, ideal Q, intvec *wdegree, const ring src, const ring Qt)
Definition: hilb.cc:1863
intvec * ivAddShift(intvec *a, intvec *b, int s)
Definition: intvec.cc:279
intvec * ivAdd(intvec *a, intvec *b)
Definition: intvec.cc:249
STATIC_VAR jList * Q
Definition: janet.cc:30
#define NULL
Definition: omList.c:12
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
#define A
Definition: sirandom.c:24

◆ hFirstSeries0()

intvec* hFirstSeries0 ( ideal  S,
ideal  Q,
intvec wdegree,
const ring  src,
const ring  Qt 
)

Definition at line 1863 of file hilb.cc.

1864 {
1865  A=id_Head(A,src);
1866  id_Test(A,src);
1867  ideal AA;
1868  if (Q!=NULL)
1869  {
1870  ideal QQ=id_Head(Q,src);
1871  AA=id_SimpleAdd(A,QQ,src);
1872  id_Delete(&QQ,src);
1873  id_Delete(&A,src);
1874  idSkipZeroes(AA);
1875  int c=p_GetComp(AA->m[0],src);
1876  if (c!=0)
1877  {
1878  for(int i=0;i<IDELEMS(AA);i++)
1879  if (AA->m[i]!=NULL) p_SetComp(AA->m[i],c,src);
1880  }
1881  }
1882  else AA=A;
1883  id_DelDiv_Sorted(AA,src);
1884  idSkipZeroes(AA);
1885  /* sort */
1886  if (IDELEMS(AA)>1)
1887  #ifdef HAVE_QSORT_R
1888  #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__CYGWIN__)
1889  qsort_r(AA->m,IDELEMS(AA),sizeof(poly),src,compare_rp);
1890  #else
1891  qsort_r(AA->m,IDELEMS(AA),sizeof(poly),compare_rp,src);
1892  #endif
1893  #else
1894  {
1895  ring r=currRing;
1896  currRing=src;
1897  qsort(AA->m,IDELEMS(AA),sizeof(poly),compare_rp_currRing);
1898  currRing=r;
1899  }
1900  #endif
1901  poly s=hilbert_series(AA,src,wdegree,Qt);
1902  id_Delete(&AA,src);
1903  intvec *ss;
1904  if (s==NULL)
1905  ss=new intvec(2);
1906  else
1907  {
1908  ss=new intvec(p_Totaldegree(s,Qt)+2);
1909  while(s!=NULL)
1910  {
1911  int i=p_Totaldegree(s,Qt);
1912  (*ss)[i]=n_Int(pGetCoeff(s),Qt->cf);
1913  if((*ss)[i]==0) Print("overflow at t^%d\n",i);
1914  p_LmDelete(&s,Qt);
1915  }
1916  }
1917  return ss;
1918 }
int i
Definition: cfEzgcd.cc:132
static FORCE_INLINE long n_Int(number &n, const coeffs r)
conversion of n to an int; 0 if not possible in Z/pZ: the representing int lying in (-p/2 ....
Definition: coeffs.h:547
#define Print
Definition: emacs.cc:80
const CanonicalForm int s
Definition: facAbsFact.cc:51
poly hilbert_series(ideal A, const ring src, const intvec *wdegree, const ring Qt)
Definition: hilb.cc:1753
static int compare_rp_currRing(const void *pp1, const void *pp2)
Definition: hilb.cc:1739
#define p_GetComp(p, r)
Definition: monomials.h:64
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy
Definition: monomials.h:44
static void p_LmDelete(poly p, const ring r)
Definition: p_polys.h:725
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:249
static long p_Totaldegree(poly p, const ring r)
Definition: p_polys.h:1509
void id_DelDiv_Sorted(ideal id, const ring r)
delete id[j], if LT(j) == coeff*mon*LT(i) (j>i)
ideal id_Head(ideal h, const ring r)
returns the ideals of initial terms
ideal id_SimpleAdd(ideal h1, ideal h2, const ring R)
concat the lists h1 and h2 without zeros
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
#define IDELEMS(i)
Definition: simpleideals.h:23
#define id_Test(A, lR)
Definition: simpleideals.h:78

◆ hilbert_series()

poly hilbert_series ( ideal  A,
const ring  src,
const intvec wdegree,
const ring  Qt 
)

Definition at line 1753 of file hilb.cc.

1759 {
1760  int r=id_Elem(A,src);
1761  poly h=NULL;
1762  if (r==0)
1763  return p_One(Qt);
1764  if (wdegree!=NULL)
1765  {
1766  int* exp=(int*)omAlloc((src->N+1)*sizeof(int));
1767  for(int i=IDELEMS(A)-1; i>=0;i--)
1768  {
1769  if (A->m[i]!=NULL)
1770  {
1771  p_GetExpV(A->m[i],exp,src);
1772  for(int j=src->N;j>0;j--)
1773  exp[j]*=ABS((*wdegree)[j-1]);
1774  p_SetExpV(A->m[i],exp,src);
1775  #ifdef PDEBUG
1776  p_Setm(A->m[i],src);
1777  #endif
1778  }
1779  }
1780  omFreeSize(exp,(src->N+1)*sizeof(int));
1781  }
1782  h=p_One(Qt);
1783  p_SetExp(h,1,p_Totaldegree(A->m[0],src),Qt);
1784  p_Setm(h,Qt);
1785  h=p_Neg(h,Qt);
1786  h=p_Add_q(h,p_One(Qt),Qt); // 1-t
1787  int *exp_q=(int*)omAlloc((src->N+1)*sizeof(int));
1788  for (int i=1;i<r;i++)
1789  {
1790  //ideal J=id_Copy(A,src);
1791  //for (int ii=i;ii<r;ii++) p_Delete(&J->m[ii],src);
1792  //idSkipZeroes(J);
1793  ideal J=id_CopyFirstK(A,i,src);
1794  for(int ii=1;ii<=src->N;ii++)
1795  exp_q[ii]=p_GetExp(A->m[i],ii,src);
1796  for(int ii=0;ii<i;ii++) p_Div_hi(J->m[ii],exp_q,src);
1797  id_DelDiv_Sorted(J,src);
1798  // search linear elems:
1799  int k=0;
1800  for (int ii=IDELEMS(J)-1;ii>=0;ii--)
1801  {
1802  if((J->m[ii]!=NULL) && (p_Totaldegree(J->m[ii],src)==1))
1803  {
1804  k++;
1805  p_Delete(&J->m[ii],src);
1806  }
1807  }
1808  idSkipZeroes(J);
1809  poly h_J=hilbert_series(J,src,NULL,Qt);// J_1
1810  poly tmp;
1811  if (k>0)
1812  {
1813  // hilbert_series of unmodified J:
1814  tmp=p_One(Qt);
1815  p_SetExp(tmp,1,1,Qt);
1816  p_Setm(tmp,Qt);
1817  tmp=p_Neg(tmp,Qt);
1818  tmp=p_Add_q(tmp,p_One(Qt),Qt); // 1-t
1819  if (k>1)
1820  {
1821  tmp=p_Power(tmp,k,Qt); // (1-t)^k
1822  }
1823  h_J=p_Mult_q(h_J,tmp,Qt);
1824  }
1825  // forget about J:
1826  id_Delete(&J,src);
1827  // t^|A_i|
1828  tmp=p_One(Qt);
1829  p_SetExp(tmp,1,p_Totaldegree(A->m[i],src),Qt);
1830  p_Setm(tmp,Qt);
1831  tmp=p_Neg(tmp,Qt);
1832  tmp=p_Mult_q(tmp,h_J,Qt);
1833  h=p_Add_q(h,tmp,Qt);
1834  }
1835  omFreeSize(exp_q,(src->N+1)*sizeof(int));
1836  //Print("end hilbert_series, r=%d\n",r);
1837  return h;
1838 }
static int ABS(int v)
Definition: auxiliary.h:112
int k
Definition: cfEzgcd.cc:99
int j
Definition: facHensel.cc:110
static void p_Div_hi(poly p, const int *exp_q, const ring src)
Definition: hilb.cc:1707
STATIC_VAR Poly * h
Definition: janet.cc:971
gmp_float exp(const gmp_float &a)
Definition: mpr_complex.cc:357
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define omAlloc(size)
Definition: omAllocDecl.h:210
poly p_Power(poly p, int i, const ring r)
Definition: p_polys.cc:2193
poly p_One(const ring r)
Definition: p_polys.cc:1313
static poly p_Neg(poly p, const ring r)
Definition: p_polys.h:1109
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:938
static poly p_Mult_q(poly p, poly q, const ring r)
Definition: p_polys.h:1116
static void p_SetExpV(poly p, int *ev, const ring r)
Definition: p_polys.h:1546
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent @Note: VarOffset encodes the position in p->exp
Definition: p_polys.h:490
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:235
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent @Note: the integer VarOffset encodes:
Definition: p_polys.h:471
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:903
static void p_GetExpV(poly p, int *ev, const ring r)
Definition: p_polys.h:1522
ideal id_CopyFirstK(const ideal ide, const int k, const ring r)
copies the first k (>= 1) entries of the given ideal/module and returns these as a new ideal/module (...
#define id_Elem(F, R)
Definition: simpleideals.h:68

◆ hLookSeries()

void hLookSeries ( ideal  S,
intvec modulweight,
ideal  Q = NULL,
intvec wdegree = NULL 
)

Definition at line 776 of file hilb.cc.

777 {
778  id_LmTest(S, currRing);
779 
780  intvec *hseries1 = hFirstSeries(S, modulweight, Q, wdegree);
781  if (errorreported) return;
782 
783  hPrintHilb(hseries1,modulweight);
784 
785  const int l = hseries1->length()-1;
786 
787  intvec *hseries2 = (l > 1) ? hSecondSeries(hseries1) : hseries1;
788 
789  int co, mu;
790  hDegreeSeries(hseries1, hseries2, &co, &mu);
791 
792  PrintLn();
793  hPrintHilb(hseries2,modulweight);
794  if ((l == 1) &&(mu == 0))
795  scPrintDegree(rVar(currRing)+1, 0);
796  else
797  scPrintDegree(co, mu);
798  if (l>1)
799  delete hseries1;
800  delete hseries2;
801 }
int l
Definition: cfEzgcd.cc:100
void mu(int **points, int sizePoints)
VAR short errorreported
Definition: feFopen.cc:23
void scPrintDegree(int co, int mu)
Definition: hdegree.cc:912
static void hPrintHilb(intvec *hseries, intvec *modul_weight)
Definition: hilb.cc:750
intvec * hFirstSeries(ideal A, intvec *module_w, ideal Q, intvec *wdegree)
Definition: hilb.cc:1947
void hDegreeSeries(intvec *s1, intvec *s2, int *co, int *mu)
Definition: hilb.cc:732
intvec * hSecondSeries(intvec *hseries1)
Definition: hilb.cc:697
void PrintLn()
Definition: reporter.cc:310
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:593
#define id_LmTest(A, lR)
Definition: simpleideals.h:79

◆ hSecondSeries()

intvec* hSecondSeries ( intvec hseries1)

Definition at line 697 of file hilb.cc.

698 {
699  intvec *work, *hseries2;
700  int i, j, k, t, l;
701  int s;
702  if (hseries1 == NULL)
703  return NULL;
704  work = new intvec(hseries1);
705  k = l = work->length()-1;
706  s = 0;
707  for (i = k-1; i >= 0; i--)
708  s += (*work)[i];
709  loop
710  {
711  if ((s != 0) || (k == 1))
712  break;
713  s = 0;
714  t = (*work)[k-1];
715  k--;
716  for (i = k-1; i >= 0; i--)
717  {
718  j = (*work)[i];
719  (*work)[i] = -t;
720  s += t;
721  t += j;
722  }
723  }
724  hseries2 = new intvec(k+1);
725  for (i = k-1; i >= 0; i--)
726  (*hseries2)[i] = (*work)[i];
727  (*hseries2)[k] = (*work)[l];
728  delete work;
729  return hseries2;
730 }
#define loop
Definition: structs.h:75