My Project
Loading...
Searching...
No Matches
hilb.h File Reference
#include "polys/monomials/ring.h"
#include "kernel/polys.h"
#include "misc/intvec.h"
#include "coeffs/bigintmat.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)
 
bigintmathPoly2BIV (poly h, const ring Qt, const coeffs biv_cf)
 
poly hBIV2Poly (bigintmat *b, const ring Qt, const coeffs biv_cf)
 
bigintmathFirstSeries0b (ideal I, ideal Q, intvec *wdegree, intvec *shifts, const ring src, const coeffs biv_cf)
 
bigintmathSecondSeries0b (ideal I, ideal Q, intvec *wdegree, intvec *shifts, const ring src, const coeffs biv_cf)
 
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

◆ hBIV2Poly()

poly hBIV2Poly ( bigintmat * b,
const ring Qt,
const coeffs biv_cf )

Definition at line 2641 of file hilb.cc.

2642{
2643 poly p=NULL;
2644 nMapFunc f=n_SetMap(biv_cf,Qt->cf);
2645 for(int d=0;d<b->rows()-1;d++)
2646 {
2647 poly h=p_New(Qt);
2648 p_SetExp(h,1,d,Qt);p_Setm(h,Qt);
2649 pSetCoeff0(h,f(BIMATELEM(*b,1,d+1),biv_cf,Qt->cf));
2650 p=p_Add_q(p,h,Qt);
2651 }
2652 return p;
2653}
#define BIMATELEM(M, I, J)
Definition bigintmat.h:133
int p
Definition cfModGcd.cc:4086
CanonicalForm b
Definition cfModGcd.cc:4111
FILE * f
Definition checklibs.c:9
static FORCE_INLINE nMapFunc n_SetMap(const coeffs src, const coeffs dst)
set the mapping function pointers for translating numbers from src to dst
Definition coeffs.h:701
number(* nMapFunc)(number a, const coeffs src, const coeffs dst)
maps "a", which lives in src, into dst
Definition coeffs.h:80
STATIC_VAR Poly * h
Definition janet.cc:971
#define pSetCoeff0(p, n)
Definition monomials.h:59
#define NULL
Definition omList.c:12
static poly p_Add_q(poly p, poly q, const ring r)
Definition p_polys.h:938
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 poly p_New(const ring, omBin bin)
Definition p_polys.h:666

◆ hFirstSeries()

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

Definition at line 2150 of file hilb.cc.

2151{
2152 intvec* res;
2153 #if 0
2154 // find degree bound
2155 int a,b,prod;
2156 a=rVar(currRing);
2157 b=1;
2158 prod=a;
2159 while(prod<(1<<15) && (a>1))
2160 {
2161 a--;b++;
2162 prod*=a;
2163 prod/=b;
2164 }
2165 if (a==1) b=(1<<15);
2166 // check degree bound
2167 BOOLEAN large_deg=FALSE;
2168 int max=0;
2169 for(int i=IDELEMS(A)-1;i>=0;i--)
2170 {
2171 if (A->m[i]!=NULL)
2172 {
2173 int mm=p_Totaldegree(A->m[i],currRing);
2174 if (mm>max)
2175 {
2176 max=mm;
2177 if (max>=b)
2178 {
2179 large_deg=TRUE;
2180 break;
2181 }
2182 }
2183 }
2184 }
2185 if (!large_deg)
2186 {
2187 void (*WerrorS_save)(const char *s) = WerrorS_callback;
2189 res=hFirstSeries1(A,module_w,Q,wdegree);
2190 WerrorS_callback=WerrorS_save;
2191 if (errorreported==0)
2192 {
2193 return res;
2194 }
2195 else errorreported=0;// retry with other alg.:
2196 }
2197 #endif
2198
2199 if (hilb_Qt==NULL) hilb_Qt=makeQt();
2200 if (!id_IsModule(A,currRing))
2201 return hFirstSeries0(A,Q,wdegree,currRing,hilb_Qt);
2202 res=NULL;
2203 int w_max=0,w_min=0;
2204 if (module_w!=NULL)
2205 {
2206 w_max=module_w->max_in();
2207 w_min=module_w->min_in();
2208 }
2209 for(int c=1;c<=A->rank;c++)
2210 {
2211 ideal Ac=getModuleComp(A,c,currRing);
2212 intvec *res_c=hFirstSeries0(Ac,Q,wdegree,currRing,hilb_Qt);
2213 id_Delete(&Ac,currRing);
2214 intvec *tmp=NULL;
2215 if (res==NULL)
2216 res=new intvec(res_c->length()+(w_max-w_min));
2217 if ((module_w==NULL) || ((*module_w)[c-1]==0)) tmp=ivAdd(res,res_c);
2218 else tmp=ivAddShift(res, res_c,(*module_w)[c-1]-w_min);
2219 delete res_c;
2220 if (tmp!=NULL)
2221 {
2222 delete res;
2223 res=tmp;
2224 }
2225 }
2226 (*res)[res->length()-1]=w_min;
2227 return res;
2228}
int BOOLEAN
Definition auxiliary.h:88
#define TRUE
Definition auxiliary.h:101
#define FALSE
Definition auxiliary.h:97
int i
Definition cfEzgcd.cc:132
int length() const
Definition intvec.h:95
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 ring makeQt()
Definition hilb.cc:832
static ideal getModuleComp(ideal A, int c, const ring src)
Definition hilb.cc:2139
intvec * hFirstSeries0(ideal A, ideal Q, intvec *wdegree, const ring src, const ring Qt)
Definition hilb.cc:2114
intvec * hFirstSeries1(ideal S, intvec *modulweight, ideal Q, intvec *wdegree)
Definition hilb.cc:2610
STATIC_VAR ring hilb_Qt
Definition hilb.cc:855
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:5639
static long p_Totaldegree(poly p, const ring r)
Definition p_polys.h:1523
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:598
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
BOOLEAN id_IsModule(ideal A, const ring src)
#define IDELEMS(i)
#define A
Definition sirandom.c:24
#define Q
Definition sirandom.c:26

◆ hFirstSeries0()

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

Definition at line 2114 of file hilb.cc.

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

◆ hFirstSeries0b()

bigintmat * hFirstSeries0b ( ideal I,
ideal Q,
intvec * wdegree,
intvec * shifts,
const ring src,
const coeffs biv_cf )

Definition at line 2655 of file hilb.cc.

2656{
2657 if (hilb_Qt==NULL) hilb_Qt=makeQt();
2658 poly h;
2659 int m=0;
2660 if (id_IsModule(I,src))
2661 {
2662 h=hFirstSeries0m(I,Q,wdegree,shifts,src,hilb_Qt);
2663 if (shifts!=NULL) m=shifts->min_in();
2664 }
2665 else
2666 h=hFirstSeries0p(I,Q,wdegree,src,hilb_Qt);
2667 bigintmat *biv=hPoly2BIV(h,hilb_Qt,biv_cf);
2668 if (m!=0)
2669 {
2670 n_Delete(&BIMATELEM(*biv,1,biv->cols()),biv_cf);
2671 BIMATELEM(*biv,1,biv->cols())=n_Init(m,biv_cf);
2672 }
2673 p_Delete(&h,hilb_Qt);
2674 return biv;
2675}
int m
Definition cfEzgcd.cc:128
Matrices of numbers.
Definition bigintmat.h:51
int cols() const
Definition bigintmat.h:144
int min_in()
Definition intvec.h:122
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition coeffs.h:459
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:539
poly hFirstSeries0m(ideal A, ideal Q, intvec *wdegree, intvec *shifts, const ring src, const ring Qt)
Definition hilb.cc:2063
bigintmat * hPoly2BIV(poly h, const ring Qt, const coeffs biv_cf)
Definition hilb.cc:2620
static void p_Delete(poly *p, const ring r)
Definition p_polys.h:903

◆ hFirstSeries0m()

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

Definition at line 2063 of file hilb.cc.

2064{
2065 int rk=A->rank;
2066 poly h=NULL;
2067 for(int i=1;i<=rk;i++)
2068 {
2069 ideal AA=id_Head(A,src);
2070 BOOLEAN have_terms=FALSE;
2071 for(int ii=0;ii<IDELEMS(AA);ii++)
2072 {
2073 if (AA->m[ii]!=NULL)
2074 {
2075 if(p_GetComp(AA->m[ii],src)!=i)
2076 p_Delete(&AA->m[ii],src);
2077 else
2078 {
2079 p_SetComp(AA->m[ii],0,src);
2080 p_Setm(AA->m[ii],src);
2081 have_terms=TRUE;
2082 }
2083 }
2084 }
2085 poly h_i=NULL;
2086 //int sh=0;
2087 if (have_terms)
2088 {
2089 idSkipZeroes(AA);
2090 h_i=hFirstSeries0p(AA,Q,wdegree,src,Qt);
2091 }
2092 else
2093 {
2094 h_i=p_One(Qt);
2095 }
2096 id_Delete(&AA,src);
2097 poly s=p_One(Qt);
2098 if (shifts!=NULL)
2099 {
2100 int m=shifts->min_in();
2101 int sh=(*shifts)[i-1]-m;
2102 if (sh!=0)
2103 {
2104 p_SetExp(s,1,sh,Qt);
2105 p_Setm(s,Qt);
2106 }
2107 }
2108 h_i=p_Mult_q(h_i,s,Qt);
2109 h=p_Add_q(h,h_i,Qt);
2110 }
2111 return h;
2112}
#define p_GetComp(p, r)
Definition monomials.h:64
poly p_One(const ring r)
Definition p_polys.cc:1314
static poly p_Mult_q(poly p, poly q, const ring r)
Definition p_polys.h:1120
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition p_polys.h:249
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 2020 of file hilb.cc.

2021{
2022 A=id_Head(A,src);
2023 id_Test(A,src);
2024 ideal AA;
2025 if (Q!=NULL)
2026 {
2027 ideal QQ=id_Head(Q,src);
2028 AA=id_SimpleAdd(A,QQ,src);
2029 id_Delete(&QQ,src);
2030 id_Delete(&A,src);
2031 idSkipZeroes(AA);
2032 int c=p_GetComp(AA->m[0],src);
2033 if (c!=0)
2034 {
2035 for(int i=0;i<IDELEMS(AA);i++)
2036 if (AA->m[i]!=NULL) p_SetComp(AA->m[i],c,src);
2037 }
2038 }
2039 else AA=A;
2040 id_DelDiv(AA,src);
2041 IDELEMS(AA)=idSkipZeroes0(AA);
2042 /* sort */
2043 if (IDELEMS(AA)>1)
2044 #ifdef HAVE_QSORT_R
2045 #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__CYGWIN__)
2046 qsort_r(AA->m,IDELEMS(AA),sizeof(poly),src,compare_rp);
2047 #else
2048 qsort_r(AA->m,IDELEMS(AA),sizeof(poly),compare_rp,src);
2049 #endif
2050 #else
2051 {
2052 ring r=currRing;
2053 currRing=src;
2054 qsort(AA->m,IDELEMS(AA),sizeof(poly),compare_rp_currRing);
2055 currRing=r;
2056 }
2057 #endif
2058 poly s=hilbert_series(AA,src,wdegree,Qt);
2059 id_Delete0(&AA,src);
2060 return s;
2061}
static poly hilbert_series(ideal A, const ring src, const intvec *wdegree, const ring Qt)
Definition hilb.cc:1925
static int compare_rp_currRing(const void *pp1, const void *pp2)
Definition hilb.cc:1827
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)

◆ hFirstSeries1()

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

Definition at line 2610 of file hilb.cc.

2611{
2612 id_LmTest(S, currRing);
2613 if (Q!= NULL) id_LmTest(Q, currRing);
2614
2615 intvec *hseries1= hSeries(S, modulweight,wdegree, Q);
2616 if (errorreported) { delete hseries1; hseries1=NULL; }
2617 return hseries1;
2618}
static intvec * hSeries(ideal S, intvec *modulweight, intvec *wdegree, ideal Q)
Definition hilb.cc:2464
#define id_LmTest(A, lR)

◆ hLookSeries()

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

Definition at line 856 of file hilb.cc.

857{
859
860 if (!id_IsModule(S,currRing))
861 {
862 if (hilb_Qt==NULL) hilb_Qt=makeQt();
863 poly hseries=hFirstSeries0p(S,Q,wdegree,currRing,hilb_Qt);
864
865 hPrintHilb(hseries,hilb_Qt,wdegree);
866 p_Delete(&hseries,hilb_Qt);
867 }
868 else
869 {
870 if (hilb_Qt==NULL) hilb_Qt=makeQt();
871 poly hseries=hFirstSeries0m(S,Q,wdegree,modulweight,currRing,hilb_Qt);
872 if ((modulweight!=NULL)&&(modulweight->compare(0)!=0))
873 {
874 char *s=modulweight->ivString(1,0,1);
875 Print("module weights:%s\n",s);
876 omFree(s);
877 }
878 hPrintHilb(hseries,hilb_Qt,wdegree);
879 p_Delete(&hseries,hilb_Qt);
880 }
881}
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
static void hPrintHilb(poly hseries, const ring Qt, intvec *modul_weight)
Definition hilb.cc:800
#define omFree(addr)

◆ hPoly2BIV()

bigintmat * hPoly2BIV ( poly h,
const ring Qt,
const coeffs biv_cf )

Definition at line 2620 of file hilb.cc.

2621{
2622 int td=0;
2623 nMapFunc f;
2624 if (h!=NULL)
2625 {
2626 td=p_Totaldegree(h,Qt);
2627 h=p_Copy(h,Qt);
2628 f=n_SetMap(Qt->cf,biv_cf);
2629 }
2630 bigintmat* biv=new bigintmat(1,td+2,biv_cf);
2631 while(h!=NULL)
2632 {
2633 int d=p_Totaldegree(h,Qt);
2634 n_Delete(&BIMATELEM(*biv,1,d+1),biv_cf);
2635 BIMATELEM(*biv,1,d+1)=f(pGetCoeff(h),Qt->cf,biv_cf);
2636 p_LmDelete(&h,Qt);
2637 }
2638 return biv;
2639}
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition p_polys.h:848

◆ hSecondSeries()

intvec * hSecondSeries ( intvec * hseries1)

Definition at line 707 of file hilb.cc.

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

◆ hSecondSeries0b()

bigintmat * hSecondSeries0b ( ideal I,
ideal Q,
intvec * wdegree,
intvec * shifts,
const ring src,
const coeffs biv_cf )

Definition at line 2677 of file hilb.cc.

2678{
2679 if (hilb_Qt==NULL) hilb_Qt=makeQt();
2680 poly h;
2681 if (id_IsModule(I,src))
2682 h=hFirstSeries0m(I,Q,wdegree,shifts,src,hilb_Qt);
2683 else
2684 h=hFirstSeries0p(I,Q,wdegree,src,hilb_Qt);
2685 int co;
2686 poly h2=hFirst2Second(h,hilb_Qt,co);
2687 p_Delete(&h,hilb_Qt);
2688 bigintmat *biv=hPoly2BIV(h2,hilb_Qt,biv_cf);
2689 p_Delete(&h2,hilb_Qt);
2690 return biv;
2691}
poly hFirst2Second(poly h, const ring Qt, int &co)
Definition hilb.cc:760