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

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

2124{
2125 poly s=hFirstSeries0p(A,Q,wdegree,src,Qt);
2126 intvec *ss;
2127 if (s==NULL)
2128 ss=new intvec(2);
2129 else
2130 {
2131 ss=new intvec(p_Totaldegree(s,Qt)+2);
2132 while(s!=NULL)
2133 {
2134 int i=p_Totaldegree(s,Qt);
2135 long l=n_Int(pGetCoeff(s),Qt->cf);
2136 (*ss)[i]=n_Int(pGetCoeff(s),Qt->cf);
2137 if((l==0)||(l<=-INT_MAX)||(l>INT_MAX))
2138 {
2139 if(!errorreported) Werror("overflow at t^%d\n",i);
2140 }
2141 else (*ss)[i]=(int)l;
2142 p_LmDelete(&s,Qt);
2143 }
2144 }
2145 return ss;
2146}
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:2080
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

◆ hFirstSeries0p()

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

Definition at line 2080 of file hilb.cc.

2081{
2082 A=id_Head(A,src);
2083 id_Test(A,src);
2084 ideal AA;
2085 if (Q!=NULL)
2086 {
2087 ideal QQ=id_Head(Q,src);
2088 AA=id_SimpleAdd(A,QQ,src);
2089 id_Delete(&QQ,src);
2090 id_Delete(&A,src);
2091 idSkipZeroes(AA);
2092 int c=p_GetComp(AA->m[0],src);
2093 if (c!=0)
2094 {
2095 for(int i=0;i<IDELEMS(AA);i++)
2096 if (AA->m[i]!=NULL) p_SetComp(AA->m[i],c,src);
2097 }
2098 }
2099 else AA=A;
2100 id_DelDiv(AA,src);
2101 IDELEMS(AA)=idSkipZeroes0(AA);
2102 /* sort */
2103 if (IDELEMS(AA)>1)
2104 #ifdef HAVE_QSORT_R
2105 #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__CYGWIN__)
2106 qsort_r(AA->m,IDELEMS(AA),sizeof(poly),src,compare_rp);
2107 #else
2108 qsort_r(AA->m,IDELEMS(AA),sizeof(poly),compare_rp,src);
2109 #endif
2110 #else
2111 {
2112 ring r=currRing;
2113 currRing=src;
2114 qsort(AA->m,IDELEMS(AA),sizeof(poly),compare_rp_currRing);
2115 currRing=r;
2116 }
2117 #endif
2118 poly s=hilbert_series(AA,src,wdegree,Qt);
2119 id_Delete0(&AA,src);
2120 return s;
2121}
static poly hilbert_series(ideal A, const ring src, const intvec *wdegree, const ring Qt)
Definition: hilb.cc:1985
static int compare_rp_currRing(const void *pp1, const void *pp2)
Definition: hilb.cc:1887
#define p_GetComp(p, r)
Definition: monomials.h:64
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 2619 of file hilb.cc.

2620{
2621 id_LmTest(S, currRing);
2622 if (Q!= NULL) id_LmTest(Q, currRing);
2623
2624 intvec *hseries1= hSeries(S, modulweight,wdegree, Q);
2625 if (errorreported) { delete hseries1; hseries1=NULL; }
2626 return hseries1;
2627}
static intvec * hSeries(ideal S, intvec *modulweight, intvec *wdegree, ideal Q)
Definition: hilb.cc:2473
#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 intvec *hseries1 = hFirstSeries(S, modulweight, Q, wdegree);
884 if (errorreported) return;
885
886 {
887 int i, j, l, k;
888 l = hseries1->length()-1;
889 k = (*hseries1)[l];
890 if ((modulweight!=NULL)&&(modulweight->compare(0)!=0))
891 {
892 char *s=modulweight->ivString(1,0,1);
893 Print("module weights:%s\n",s);
894 omFree(s);
895 }
896 for (i = 0; i < l; i++)
897 {
898 j = (*hseries1)[i];
899 if (j != 0)
900 {
901 Print("// %8d t^%d\n", j, i+k);
902 }
903 }
904 }
905
906 const int l = hseries1->length()-1;
907
908 intvec *hseries2 = (l > 1) ? hSecondSeries(hseries1) : hseries1;
909
910 int co, mu;
911 hDegreeSeries(hseries1, hseries2, &co, &mu);
912
913 PrintLn();
914 {
915 int i, j, l, k;
916 l = hseries2->length()-1;
917 k = (*hseries2)[l];
918 if ((modulweight!=NULL)&&(modulweight->compare(0)!=0))
919 {
920 char *s=modulweight->ivString(1,0,1);
921 Print("module weights:%s\n",s);
922 omFree(s);
923 }
924 for (i = 0; i < l; i++)
925 {
926 j = (*hseries2)[i];
927 if (j != 0)
928 {
929 Print("// %8d t^%d\n", j, i+k);
930 }
931 }
932 if ((l == 1) &&(mu == 0))
934 else
935 scPrintDegree(co, mu);
936 if (l>1)
937 delete hseries1;
938 delete hseries2;
939 }
940 }
941}
int k
Definition: cfEzgcd.cc:99
void mu(int **points, int sizePoints)
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
int j
Definition: facHensel.cc:110
void scPrintDegree(int co, int mu)
Definition: hdegree.cc:912
intvec * hSecondSeries(intvec *hseries1)
Definition: hilb.cc:706
intvec * hFirstSeries(ideal A, intvec *module_w, ideal Q, intvec *wdegree)
Definition: hilb.cc:2159
static void hPrintHilb(poly hseries, const ring Qt, intvec *modul_weight)
Definition: hilb.cc:759
void hDegreeSeries(intvec *s1, intvec *s2, int *co, int *mu)
Definition: hilb.cc:741
#define omFree(addr)
Definition: omAllocDecl.h:261
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:901
void PrintLn()
Definition: reporter.cc:310

◆ 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}
#define loop
Definition: structs.h:75