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 2036 of file hilb.cc.

2037 {
2038  static ring hilb_Qt=NULL;
2039  if (hilb_Qt==NULL) hilb_Qt=makeQt();
2040  if (!isModule(A,currRing))
2041  return hFirstSeries0(A,Q,wdegree,currRing,hilb_Qt);
2042  intvec *res=NULL;
2043  int w_max=0,w_min=0;
2044  if (module_w!=NULL)
2045  {
2046  w_max=module_w->max_in();
2047  w_min=module_w->min_in();
2048  }
2049  for(int c=1;c<=A->rank;c++)
2050  {
2051  ideal Ac=getModuleComp(A,c,currRing);
2052  intvec *res_c=hFirstSeries0(Ac,Q,wdegree,currRing,hilb_Qt);
2053  id_Delete(&Ac,currRing);
2054  intvec *tmp=NULL;
2055  if (res==NULL)
2056  res=new intvec(res_c->length()+(w_max-w_min));
2057  if ((module_w==NULL) || ((*module_w)[c-1]==0)) tmp=ivAdd(res,res_c);
2058  else tmp=ivAddShift(res, res_c,(*module_w)[c-1]-w_min);
2059  delete res_c;
2060  if (tmp!=NULL)
2061  {
2062  delete res;
2063  res=tmp;
2064  }
2065  }
2066  (*res)[res->length()-1]=w_min;
2067  return res;
2068 }
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:2020
static ring makeQt()
Definition: hilb.cc:1929
static ideal getModuleComp(ideal A, int c, const ring src)
Definition: hilb.cc:2009
intvec * hFirstSeries0(ideal A, ideal Q, intvec *wdegree, const ring src, const ring Qt)
Definition: hilb.cc:1952
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 1952 of file hilb.cc.

1953 {
1954  A=id_Head(A,src);
1955  id_Test(A,src);
1956  ideal AA;
1957  if (Q!=NULL)
1958  {
1959  ideal QQ=id_Head(Q,src);
1960  AA=id_SimpleAdd(A,QQ,src);
1961  id_Delete(&QQ,src);
1962  id_Delete(&A,src);
1963  idSkipZeroes(AA);
1964  int c=p_GetComp(AA->m[0],src);
1965  if (c!=0)
1966  {
1967  for(int i=0;i<IDELEMS(AA);i++)
1968  if (AA->m[i]!=NULL) p_SetComp(AA->m[i],c,src);
1969  }
1970  }
1971  else AA=A;
1972  id_DelDiv(AA,src);
1973  idSkipZeroes(AA);
1974  /* sort */
1975  if (IDELEMS(AA)>1)
1976  #ifdef HAVE_QSORT_R
1977  #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__CYGWIN__)
1978  qsort_r(AA->m,IDELEMS(AA),sizeof(poly),src,compare_rp);
1979  #else
1980  qsort_r(AA->m,IDELEMS(AA),sizeof(poly),compare_rp,src);
1981  #endif
1982  #else
1983  {
1984  ring r=currRing;
1985  currRing=src;
1986  qsort(AA->m,IDELEMS(AA),sizeof(poly),compare_rp_currRing);
1987  currRing=r;
1988  }
1989  #endif
1990  poly s=hilbert_series(AA,src,wdegree,Qt);
1991  id_Delete(&AA,src);
1992  intvec *ss;
1993  if (s==NULL)
1994  ss=new intvec(2);
1995  else
1996  {
1997  ss=new intvec(p_Totaldegree(s,Qt)+2);
1998  while(s!=NULL)
1999  {
2000  int i=p_Totaldegree(s,Qt);
2001  (*ss)[i]=n_Int(pGetCoeff(s),Qt->cf);
2002  if((*ss)[i]==0) Print("overflow at t^%d\n",i);
2003  p_LmDelete(&s,Qt);
2004  }
2005  }
2006  return ss;
2007 }
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:544
#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:1830
static int compare_rp_currRing(const void *pp1, const void *pp2)
Definition: hilb.cc:1747
#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:721
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:245
static long p_Totaldegree(poly p, const ring r)
Definition: p_polys.h:1505
ideal id_Head(ideal h, const ring r)
returns the ideals of initial terms
void id_DelDiv(ideal id, const ring r)
delete id[j], if LT(j) == coeff*mon*LT(i) and vice versa, i.e., delete id[i], if LT(i) == coeff*mon*L...
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:87

◆ hilbert_series()

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

Definition at line 1830 of file hilb.cc.

1836 {
1837  int r=id_Elem(A,src);
1838  poly h=NULL;
1839  if (r==0)
1840  return p_One(Qt);
1841  if (wdegree!=NULL)
1842  {
1843  int* exp=(int*)omAlloc((src->N+1)*sizeof(int));
1844  for(int i=IDELEMS(A)-1; i>=0;i--)
1845  {
1846  if (A->m[i]!=NULL)
1847  {
1848  p_GetExpV(A->m[i],exp,src);
1849  for(int j=src->N;j>0;j--)
1850  {
1851  int w=(*wdegree)[j-1];
1852  if (w<=0)
1853  {
1854  WerrorS("weights must be positive");
1855  return NULL;
1856  }
1857  exp[j]*=w; /* (*wdegree)[j-1] */
1858  }
1859  p_SetExpV(A->m[i],exp,src);
1860  #ifdef PDEBUG
1861  p_Setm(A->m[i],src);
1862  #endif
1863  }
1864  }
1865  omFreeSize(exp,(src->N+1)*sizeof(int));
1866  }
1867  h=p_One(Qt);
1868  p_SetExp(h,1,p_Totaldegree(A->m[0],src),Qt);
1869  p_Setm(h,Qt);
1870  h=p_Neg(h,Qt);
1871  h=p_Add_q(h,p_One(Qt),Qt); // 1-t
1872  int *exp_q=(int*)omAlloc((src->N+1)*sizeof(int));
1873  for (int i=1;i<r;i++)
1874  {
1875  //ideal J=id_Copy(A,src);
1876  //for (int ii=i;ii<r;ii++) p_Delete(&J->m[ii],src);
1877  //idSkipZeroes(J);
1878  ideal J=id_CopyFirstK(A,i,src);
1879  for(int ii=src->N;ii>0;ii--)
1880  exp_q[ii]=p_GetExp(A->m[i],ii,src);
1881  BOOLEAN *bad=(BOOLEAN*)omAlloc0(i*sizeof(BOOLEAN));
1882  for(int ii=0;ii<i;ii++)
1883  {
1884  bad[ii]=p_Div_hi(J->m[ii],exp_q,src);
1885  }
1886  id_DelDiv_hi(J,bad,src);
1887  // search linear elems:
1888  int k=0;
1889  for (int ii=IDELEMS(J)-1;ii>=0;ii--)
1890  {
1891  if((J->m[ii]!=NULL) && (p_Totaldegree(J->m[ii],src)==1))
1892  {
1893  k++;
1894  p_LmDelete(&J->m[ii],src);
1895  }
1896  }
1897  idSkipZeroes(J);
1898  poly h_J=hilbert_series(J,src,NULL,Qt);// J_1
1899  poly tmp;
1900  if (k>0)
1901  {
1902  // hilbert_series of unmodified J:
1903  tmp=p_One(Qt);
1904  p_SetExp(tmp,1,1,Qt);
1905  p_Setm(tmp,Qt);
1906  tmp=p_Neg(tmp,Qt);
1907  tmp=p_Add_q(tmp,p_One(Qt),Qt); // 1-t
1908  if (k>1)
1909  {
1910  tmp=p_Power(tmp,k,Qt); // (1-t)^k
1911  }
1912  h_J=p_Mult_q(h_J,tmp,Qt);
1913  }
1914  // forget about J:
1915  id_Delete(&J,src);
1916  // t^|A_i|
1917  tmp=p_One(Qt);
1918  p_SetExp(tmp,1,p_Totaldegree(A->m[i],src),Qt);
1919  p_Setm(tmp,Qt);
1920  tmp=p_Neg(tmp,Qt);
1921  tmp=p_Mult_q(tmp,h_J,Qt);
1922  h=p_Add_q(h,tmp,Qt);
1923  }
1924  omFreeSize(exp_q,(src->N+1)*sizeof(int));
1925  //Print("end hilbert_series, r=%d\n",r);
1926  return h;
1927 }
int BOOLEAN
Definition: auxiliary.h:87
int k
Definition: cfEzgcd.cc:99
const CanonicalForm & w
Definition: facAbsFact.cc:51
bool bad
Definition: facFactorize.cc:64
int j
Definition: facHensel.cc:110
void WerrorS(const char *s)
Definition: feFopen.cc:24
static BOOLEAN p_Div_hi(poly p, const int *exp_q, const ring src)
Definition: hilb.cc:1707
static void id_DelDiv_hi(ideal id, BOOLEAN *bad, const ring r)
Definition: hilb.cc:1761
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
#define omAlloc0(size)
Definition: omAllocDecl.h:211
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:1105
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:934
static poly p_Mult_q(poly p, poly q, const ring r)
Definition: p_polys.h:1112
static void p_SetExpV(poly p, int *ev, const ring r)
Definition: p_polys.h:1542
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:486
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:231
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:467
static void p_GetExpV(poly p, int *ev, const ring r)
Definition: p_polys.h:1518
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:77

◆ 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:2036
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:592
#define id_LmTest(A, lR)
Definition: simpleideals.h:88

◆ 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