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)
 
intvechFirstSeries1 (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 2055 of file hilb.cc.

2056{
2057 intvec* res;
2058 #if 0
2059 // find degree bound
2060 int a,b,prod;
2061 a=rVar(currRing);
2062 b=1;
2063 prod=a;
2064 while(prod<(1<<15) && (a>1))
2065 {
2066 a--;b++;
2067 prod*=a;
2068 prod/=b;
2069 }
2070 if (a==1) b=(1<<15);
2071 // check degree bound
2072 BOOLEAN large_deg=FALSE;
2073 int max=0;
2074 for(int i=IDELEMS(A)-1;i>=0;i--)
2075 {
2076 if (A->m[i]!=NULL)
2077 {
2078 int mm=p_Totaldegree(A->m[i],currRing);
2079 if (mm>max)
2080 {
2081 max=mm;
2082 if (max>=b)
2083 {
2084 large_deg=TRUE;
2085 break;
2086 }
2087 }
2088 }
2089 }
2090 if (!large_deg)
2091 {
2092 void (*WerrorS_save)(const char *s) = WerrorS_callback;
2094 res=hFirstSeries1(A,module_w,Q,wdegree);
2095 WerrorS_callback=WerrorS_save;
2096 if (errorreported==0)
2097 {
2098 return res;
2099 }
2100 else errorreported=0;// retry with other alg.:
2101 }
2102 #endif
2103
2104 static ring hilb_Qt=NULL;
2105 if (hilb_Qt==NULL) hilb_Qt=makeQt();
2106 if (!isModule(A,currRing))
2107 return hFirstSeries0(A,Q,wdegree,currRing,hilb_Qt);
2108 res=NULL;
2109 int w_max=0,w_min=0;
2110 if (module_w!=NULL)
2111 {
2112 w_max=module_w->max_in();
2113 w_min=module_w->min_in();
2114 }
2115 for(int c=1;c<=A->rank;c++)
2116 {
2117 ideal Ac=getModuleComp(A,c,currRing);
2118 intvec *res_c=hFirstSeries0(Ac,Q,wdegree,currRing,hilb_Qt);
2119 id_Delete(&Ac,currRing);
2120 intvec *tmp=NULL;
2121 if (res==NULL)
2122 res=new intvec(res_c->length()+(w_max-w_min));
2123 if ((module_w==NULL) || ((*module_w)[c-1]==0)) tmp=ivAdd(res,res_c);
2124 else tmp=ivAddShift(res, res_c,(*module_w)[c-1]-w_min);
2125 delete res_c;
2126 if (tmp!=NULL)
2127 {
2128 delete res;
2129 res=tmp;
2130 }
2131 }
2132 (*res)[res->length()-1]=w_min;
2133 return res;
2134}
int BOOLEAN
Definition: auxiliary.h:87
#define TRUE
Definition: auxiliary.h:100
#define FALSE
Definition: auxiliary.h:96
int i
Definition: cfEzgcd.cc:132
CanonicalForm b
Definition: cfModGcd.cc:4103
Definition: intvec.h:23
int length() const
Definition: intvec.h:94
const CanonicalForm int s
Definition: facAbsFact.cc:51
CanonicalForm res
Definition: facAbsFact.cc:60
fq_nmod_poly_t prod
Definition: facHensel.cc:100
static int max(int a, int b)
Definition: fast_mult.cc:264
VAR void(* WerrorS_callback)(const char *s)
Definition: feFopen.cc:21
VAR short errorreported
Definition: feFopen.cc:23
static BOOLEAN isModule(ideal A, const ring src)
Definition: hilb.cc:2033
static ring makeQt()
Definition: hilb.cc:1940
static ideal getModuleComp(ideal A, int c, const ring src)
Definition: hilb.cc:2022
intvec * hFirstSeries0(ideal A, ideal Q, intvec *wdegree, const ring src, const ring Qt)
Definition: hilb.cc:1963
static void WerrorS_dummy(const char *)
Definition: hilb.cc:2051
intvec * hFirstSeries1(ideal S, intvec *modulweight, ideal Q, intvec *wdegree)
Definition: hilb.cc:2516
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
static long p_Totaldegree(poly p, const ring r)
Definition: p_polys.h:1507
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:592
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
#define IDELEMS(i)
Definition: simpleideals.h:23
#define A
Definition: sirandom.c:24

◆ hFirstSeries0()

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

Definition at line 1963 of file hilb.cc.

1964{
1965 A=id_Head(A,src);
1966 id_Test(A,src);
1967 ideal AA;
1968 if (Q!=NULL)
1969 {
1970 ideal QQ=id_Head(Q,src);
1971 AA=id_SimpleAdd(A,QQ,src);
1972 id_Delete(&QQ,src);
1973 id_Delete(&A,src);
1974 idSkipZeroes(AA);
1975 int c=p_GetComp(AA->m[0],src);
1976 if (c!=0)
1977 {
1978 for(int i=0;i<IDELEMS(AA);i++)
1979 if (AA->m[i]!=NULL) p_SetComp(AA->m[i],c,src);
1980 }
1981 }
1982 else AA=A;
1983 id_DelDiv(AA,src);
1984 IDELEMS(AA)=idSkipZeroes0(AA);
1985 /* sort */
1986 if (IDELEMS(AA)>1)
1987 #ifdef HAVE_QSORT_R
1988 #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__CYGWIN__)
1989 qsort_r(AA->m,IDELEMS(AA),sizeof(poly),src,compare_rp);
1990 #else
1991 qsort_r(AA->m,IDELEMS(AA),sizeof(poly),compare_rp,src);
1992 #endif
1993 #else
1994 {
1995 ring r=currRing;
1996 currRing=src;
1997 qsort(AA->m,IDELEMS(AA),sizeof(poly),compare_rp_currRing);
1998 currRing=r;
1999 }
2000 #endif
2001 poly s=hilbert_series(AA,src,wdegree,Qt);
2002 id_Delete0(&AA,src);
2003 intvec *ss;
2004 if (s==NULL)
2005 ss=new intvec(2);
2006 else
2007 {
2008 ss=new intvec(p_Totaldegree(s,Qt)+2);
2009 while(s!=NULL)
2010 {
2011 int i=p_Totaldegree(s,Qt);
2012 long l=n_Int(pGetCoeff(s),Qt->cf);
2013 (*ss)[i]=n_Int(pGetCoeff(s),Qt->cf);
2014 if((l==0)||(l<=-INT_MAX)||(l>INT_MAX)) Print("overflow at t^%d\n",i);
2015 else (*ss)[i]=(int)l;
2016 p_LmDelete(&s,Qt);
2017 }
2018 }
2019 return ss;
2020}
int l
Definition: cfEzgcd.cc:100
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
poly hilbert_series(ideal A, const ring src, const intvec *wdegree, const ring Qt)
Definition: hilb.cc:1844
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:723
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition: p_polys.h:247
int idSkipZeroes0(ideal ide)
void id_Delete0(ideal *h, ring r)
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 id_Test(A, lR)
Definition: simpleideals.h:89

◆ hFirstSeries1()

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

Definition at line 2516 of file hilb.cc.

2517{
2518 id_LmTest(S, currRing);
2519 if (Q!= NULL) id_LmTest(Q, currRing);
2520
2521 intvec *hseries1= hSeries(S, modulweight,wdegree, Q);
2522 if (errorreported) { delete hseries1; hseries1=NULL; }
2523 return hseries1;
2524}
static intvec * hSeries(ideal S, intvec *modulweight, intvec *wdegree, ideal Q)
Definition: hilb.cc:2370
#define id_LmTest(A, lR)
Definition: simpleideals.h:90

◆ hilbert_series()

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

Definition at line 1844 of file hilb.cc.

1850{
1851 int r=id_Elem(A,src);
1852 poly h=NULL;
1853 if (r==0)
1854 return p_One(Qt);
1855 if (wdegree!=NULL)
1856 {
1857 int* exp=(int*)omAlloc((src->N+1)*sizeof(int));
1858 for(int i=IDELEMS(A)-1; i>=0;i--)
1859 {
1860 if (A->m[i]!=NULL)
1861 {
1862 p_GetExpV(A->m[i],exp,src);
1863 for(int j=src->N;j>0;j--)
1864 {
1865 int w=(*wdegree)[j-1];
1866 if (w<=0)
1867 {
1868 WerrorS("weights must be positive");
1869 return NULL;
1870 }
1871 exp[j]*=w; /* (*wdegree)[j-1] */
1872 }
1873 p_SetExpV(A->m[i],exp,src);
1874 #ifdef PDEBUG
1875 p_Setm(A->m[i],src);
1876 #endif
1877 }
1878 }
1879 omFreeSize(exp,(src->N+1)*sizeof(int));
1880 }
1881 h=p_Init(Qt); pSetCoeff0(h,n_Init(-1,Qt->cf));
1882 p_SetExp(h,1,p_Totaldegree(A->m[0],src),Qt);
1883 //p_Setm(h,Qt);
1884 h=p_Add_q(h,p_One(Qt),Qt); // 1-t
1885 int *exp_q=(int*)omAlloc((src->N+1)*sizeof(int));
1886 BOOLEAN *bad=(BOOLEAN*)omAlloc0(r*sizeof(BOOLEAN));
1887 for (int i=1;i<r;i++)
1888 {
1889 ideal J=id_CopyFirstK(A,i,src);
1890 for(int ii=src->N;ii>0;ii--)
1891 exp_q[ii]=p_GetExp(A->m[i],ii,src);
1892 memset(bad,0,i*sizeof(BOOLEAN));
1893 for(int ii=0;ii<i;ii++)
1894 {
1895 bad[ii]=p_Div_hi(J->m[ii],exp_q,src);
1896 }
1897 id_DelDiv_hi(J,bad,src);
1898 // variant A
1899 // search linear elems:
1900 int k=0;
1901 for (int ii=IDELEMS(J)-1;ii>=0;ii--)
1902 {
1903 if((J->m[ii]!=NULL) && (bad[ii]) && (p_Totaldegree(J->m[ii],src)==1))
1904 {
1905 k++;
1906 p_LmDelete(&J->m[ii],src);
1907 }
1908 }
1909 IDELEMS(J)=idSkipZeroes0(J);
1910 poly h_J=hilbert_series(J,src,NULL,Qt);// J_1
1911 poly tmp;
1912 if (k>0)
1913 {
1914 // hilbert_series of unmodified J:
1915 tmp=p_Init(Qt); pSetCoeff0(tmp,n_Init(-1,Qt->cf));
1916 p_SetExp(tmp,1,1,Qt);
1917 //p_Setm(tmp,Qt);
1918 tmp=p_Add_q(tmp,p_One(Qt),Qt); // 1-t
1919 if (k>1)
1920 {
1921 tmp=p_Power(tmp,k,Qt); // (1-t)^k
1922 }
1923 h_J=p_Mult_q(h_J,tmp,Qt);
1924 }
1925 // forget about J:
1926 id_Delete0(&J,src);
1927 // t^|A_i|
1928 tmp=p_Init(Qt); pSetCoeff0(tmp,n_Init(-1,Qt->cf));
1929 p_SetExp(tmp,1,p_Totaldegree(A->m[i],src),Qt);
1930 //p_Setm(tmp,Qt);
1931 tmp=p_Mult_q(tmp,h_J,Qt);
1932 h=p_Add_q(h,tmp,Qt);
1933 }
1934 omFreeSize(bad,r*sizeof(BOOLEAN));
1935 omFreeSize(exp_q,(src->N+1)*sizeof(int));
1936 //Print("end hilbert_series, r=%d\n",r);
1937 return h;
1938}
int k
Definition: cfEzgcd.cc:99
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:535
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
#define pSetCoeff0(p, n)
Definition: monomials.h:59
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:2197
poly p_One(const ring r)
Definition: p_polys.cc:1313
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:936
static poly p_Mult_q(poly p, poly q, const ring r)
Definition: p_polys.h:1114
static void p_SetExpV(poly p, int *ev, const ring r)
Definition: p_polys.h:1544
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:488
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:233
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:469
static void p_GetExpV(poly p, int *ev, const ring r)
Definition: p_polys.h:1520
static poly p_Init(const ring r, omBin bin)
Definition: p_polys.h:1320
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:79

◆ hLookSeries()

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

Definition at line 776 of file hilb.cc.

777{
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))
796 else
797 scPrintDegree(co, mu);
798 if (l>1)
799 delete hseries1;
800 delete hseries2;
801}
void mu(int **points, int sizePoints)
void scPrintDegree(int co, int mu)
Definition: hdegree.cc:912
intvec * hSecondSeries(intvec *hseries1)
Definition: hilb.cc:697
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:2055
void hDegreeSeries(intvec *s1, intvec *s2, int *co, int *mu)
Definition: hilb.cc:732
void PrintLn()
Definition: reporter.cc:310

◆ 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