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 hFirstSeries0p (ideal A, ideal Q, intvec *wdegree, const ring src, const ring Qt)
 
poly hFirstSeries0m (ideal A, ideal Q, intvec *wdegree, intvec *shifts, const ring src, 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 2155 of file hilb.cc.

2156{
2157 intvec* res;
2158 #if 0
2159 // find degree bound
2160 int a,b,prod;
2161 a=rVar(currRing);
2162 b=1;
2163 prod=a;
2164 while(prod<(1<<15) && (a>1))
2165 {
2166 a--;b++;
2167 prod*=a;
2168 prod/=b;
2169 }
2170 if (a==1) b=(1<<15);
2171 // check degree bound
2172 BOOLEAN large_deg=FALSE;
2173 int max=0;
2174 for(int i=IDELEMS(A)-1;i>=0;i--)
2175 {
2176 if (A->m[i]!=NULL)
2177 {
2178 int mm=p_Totaldegree(A->m[i],currRing);
2179 if (mm>max)
2180 {
2181 max=mm;
2182 if (max>=b)
2183 {
2184 large_deg=TRUE;
2185 break;
2186 }
2187 }
2188 }
2189 }
2190 if (!large_deg)
2191 {
2192 void (*WerrorS_save)(const char *s) = WerrorS_callback;
2194 res=hFirstSeries1(A,module_w,Q,wdegree);
2195 WerrorS_callback=WerrorS_save;
2196 if (errorreported==0)
2197 {
2198 return res;
2199 }
2200 else errorreported=0;// retry with other alg.:
2201 }
2202 #endif
2203
2204 if (hilb_Qt==NULL) hilb_Qt=makeQt();
2205 if (!isModule(A,currRing))
2206 return hFirstSeries0(A,Q,wdegree,currRing,hilb_Qt);
2207 res=NULL;
2208 int w_max=0,w_min=0;
2209 if (module_w!=NULL)
2210 {
2211 w_max=module_w->max_in();
2212 w_min=module_w->min_in();
2213 }
2214 for(int c=1;c<=A->rank;c++)
2215 {
2216 ideal Ac=getModuleComp(A,c,currRing);
2217 intvec *res_c=hFirstSeries0(Ac,Q,wdegree,currRing,hilb_Qt);
2218 id_Delete(&Ac,currRing);
2219 intvec *tmp=NULL;
2220 if (res==NULL)
2221 res=new intvec(res_c->length()+(w_max-w_min));
2222 if ((module_w==NULL) || ((*module_w)[c-1]==0)) tmp=ivAdd(res,res_c);
2223 else tmp=ivAddShift(res, res_c,(*module_w)[c-1]-w_min);
2224 delete res_c;
2225 if (tmp!=NULL)
2226 {
2227 delete res;
2228 res=tmp;
2229 }
2230 }
2231 (*res)[res->length()-1]=w_min;
2232 return res;
2233}
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:851
static ring makeQt()
Definition: hilb.cc:827
static ideal getModuleComp(ideal A, int c, const ring src)
Definition: hilb.cc:2144
intvec * hFirstSeries0(ideal A, ideal Q, intvec *wdegree, const ring src, const ring Qt)
Definition: hilb.cc:2119
static ring hilb_Qt
Definition: hilb.cc:850
intvec * hFirstSeries1(ideal S, intvec *modulweight, ideal Q, intvec *wdegree)
Definition: hilb.cc:2615
intvec * ivAddShift(intvec *a, intvec *b, int s)
Definition: intvec.cc:279
intvec * ivAdd(intvec *a, intvec *b)
Definition: intvec.cc:249
static void WerrorS_dummy(const char *)
Definition: iparith.cc:5584
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 2119 of file hilb.cc.

2120{
2121 poly s=hFirstSeries0p(A,Q,wdegree,src,Qt);
2122 intvec *ss;
2123 if (s==NULL)
2124 ss=new intvec(2);
2125 else
2126 {
2127 ss=new intvec(p_Totaldegree(s,Qt)+2);
2128 while(s!=NULL)
2129 {
2130 int i=p_Totaldegree(s,Qt);
2131 long l=n_Int(pGetCoeff(s),Qt->cf);
2132 (*ss)[i]=n_Int(pGetCoeff(s),Qt->cf);
2133 if((l==0)||(l<=-INT_MAX)||(l>INT_MAX))
2134 {
2135 if(!errorreported) Werror("overflow at t^%d\n",i);
2136 }
2137 else (*ss)[i]=(int)l;
2138 p_LmDelete(&s,Qt);
2139 }
2140 }
2141 return ss;
2142}
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
poly hFirstSeries0p(ideal A, ideal Q, intvec *wdegree, const ring src, const ring Qt)
Definition: hilb.cc:2033
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
void Werror(const char *fmt,...)
Definition: reporter.cc:189

◆ hFirstSeries0m()

poly hFirstSeries0m ( ideal  A,
ideal  Q,
intvec wdegree,
intvec shifts,
const ring  src,
const ring  Qt 
)

Definition at line 2076 of file hilb.cc.

2077{
2078 int rk=A->rank;
2079 poly h=NULL;
2080 for(int i=1;i<=rk;i++)
2081 {
2082 ideal AA=id_Head(A,src);
2083 BOOLEAN have_terms=FALSE;
2084 for(int ii=0;ii<IDELEMS(AA);ii++)
2085 {
2086 if (AA->m[ii]!=NULL)
2087 {
2088 if(p_GetComp(AA->m[ii],src)!=i)
2089 p_Delete(&AA->m[ii],src);
2090 else
2091 have_terms=TRUE;
2092 }
2093 }
2094 poly h_i;
2095 //int sh=0;
2096 if (have_terms)
2097 {
2098 idSkipZeroes(AA);
2099 h_i=hFirstSeries0p(AA,Q,wdegree,src,Qt);
2100 }
2101 else
2102 {
2103 h_i=p_One(Qt);
2104 }
2105 poly s=p_One(Qt);
2106 if (shifts!=NULL)
2107 {
2108 //sh=(*shifts)[i-1];
2109 p_SetExp(s,1,(*shifts)[i-1],Qt);
2110 p_Setm(s,Qt);
2111 }
2112 h_i=p_Mult_q(h_i,s,Qt);
2113 //Print("comp %d (sh:%d):",i,sh); p_Write(h_i,Qt);
2114 h=p_Add_q(h,h_i,Qt);
2115 }
2116 return h;
2117}
STATIC_VAR Poly * h
Definition: janet.cc:971
#define p_GetComp(p, r)
Definition: monomials.h:64
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 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 void p_Delete(poly *p, const ring r)
Definition: p_polys.h:901
ideal id_Head(ideal h, const ring r)
returns the ideals of initial terms
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size

◆ hFirstSeries0p()

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

Definition at line 2033 of file hilb.cc.

2034{
2035 A=id_Head(A,src);
2036 id_Test(A,src);
2037 ideal AA;
2038 if (Q!=NULL)
2039 {
2040 ideal QQ=id_Head(Q,src);
2041 AA=id_SimpleAdd(A,QQ,src);
2042 id_Delete(&QQ,src);
2043 id_Delete(&A,src);
2044 idSkipZeroes(AA);
2045 int c=p_GetComp(AA->m[0],src);
2046 if (c!=0)
2047 {
2048 for(int i=0;i<IDELEMS(AA);i++)
2049 if (AA->m[i]!=NULL) p_SetComp(AA->m[i],c,src);
2050 }
2051 }
2052 else AA=A;
2053 id_DelDiv(AA,src);
2054 IDELEMS(AA)=idSkipZeroes0(AA);
2055 /* sort */
2056 if (IDELEMS(AA)>1)
2057 #ifdef HAVE_QSORT_R
2058 #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__CYGWIN__)
2059 qsort_r(AA->m,IDELEMS(AA),sizeof(poly),src,compare_rp);
2060 #else
2061 qsort_r(AA->m,IDELEMS(AA),sizeof(poly),compare_rp,src);
2062 #endif
2063 #else
2064 {
2065 ring r=currRing;
2066 currRing=src;
2067 qsort(AA->m,IDELEMS(AA),sizeof(poly),compare_rp_currRing);
2068 currRing=r;
2069 }
2070 #endif
2071 poly s=hilbert_series(AA,src,wdegree,Qt);
2072 id_Delete0(&AA,src);
2073 return s;
2074}
static poly hilbert_series(ideal A, const ring src, const intvec *wdegree, const ring Qt)
Definition: hilb.cc:1938
static int compare_rp_currRing(const void *pp1, const void *pp2)
Definition: hilb.cc:1840
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)
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
#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 2615 of file hilb.cc.

2616{
2617 id_LmTest(S, currRing);
2618 if (Q!= NULL) id_LmTest(Q, currRing);
2619
2620 intvec *hseries1= hSeries(S, modulweight,wdegree, Q);
2621 if (errorreported) { delete hseries1; hseries1=NULL; }
2622 return hseries1;
2623}
static intvec * hSeries(ideal S, intvec *modulweight, intvec *wdegree, ideal Q)
Definition: hilb.cc:2469
#define id_LmTest(A, lR)
Definition: simpleideals.h:90

◆ hLookSeries()

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

Definition at line 869 of file hilb.cc.

870{
872
873 if (!isModule(S,currRing))
874 {
875 if (hilb_Qt==NULL) hilb_Qt=makeQt();
876 poly hseries=hFirstSeries0p(S,Q,wdegree,currRing,hilb_Qt);
877
878 hPrintHilb(hseries,hilb_Qt,wdegree);
879 p_Delete(&hseries,hilb_Qt);
880 }
881 else
882 {
883 if (hilb_Qt==NULL) hilb_Qt=makeQt();
884 poly hseries=hFirstSeries0m(S,Q,wdegree,modulweight,currRing,hilb_Qt);
885 if ((modulweight!=NULL)&&(modulweight->compare(0)!=0))
886 {
887 char *s=modulweight->ivString(1,0,1);
888 Print("module weights:%s\n",s);
889 omFree(s);
890 }
891 hPrintHilb(hseries,hilb_Qt,wdegree);
892 p_Delete(&hseries,hilb_Qt);
893 }
894}
int compare(const intvec *o) const
Definition: intvec.cc:206
char * ivString(int not_mat=1, int spaces=0, int dim=2) const
Definition: intvec.cc:58
#define Print
Definition: emacs.cc:80
poly hFirstSeries0m(ideal A, ideal Q, intvec *wdegree, intvec *shifts, const ring src, const ring Qt)
Definition: hilb.cc:2076
static void hPrintHilb(poly hseries, const ring Qt, intvec *modul_weight)
Definition: hilb.cc:759
#define omFree(addr)
Definition: omAllocDecl.h:261

◆ hSecondSeries()

intvec * hSecondSeries ( intvec hseries1)

Definition at line 706 of file hilb.cc.

707{
708 intvec *work, *hseries2;
709 int i, j, k, t, l;
710 int s;
711 if (hseries1 == NULL)
712 return NULL;
713 work = new intvec(hseries1);
714 k = l = work->length()-1;
715 s = 0;
716 for (i = k-1; i >= 0; i--)
717 s += (*work)[i];
718 loop
719 {
720 if ((s != 0) || (k == 1))
721 break;
722 s = 0;
723 t = (*work)[k-1];
724 k--;
725 for (i = k-1; i >= 0; i--)
726 {
727 j = (*work)[i];
728 (*work)[i] = -t;
729 s += t;
730 t += j;
731 }
732 }
733 hseries2 = new intvec(k+1);
734 for (i = k-1; i >= 0; i--)
735 (*hseries2)[i] = (*work)[i];
736 (*hseries2)[k] = (*work)[l];
737 delete work;
738 return hseries2;
739}
int k
Definition: cfEzgcd.cc:99
int j
Definition: facHensel.cc:110
#define loop
Definition: structs.h:75