My Project
Loading...
Searching...
No Matches
hilb.cc File Reference
#include <stdlib.h>
#include "kernel/mod2.h"
#include "misc/mylimits.h"
#include "misc/intvec.h"
#include "kernel/combinatorics/hilb.h"
#include "kernel/combinatorics/stairc.h"
#include "kernel/combinatorics/hutil.h"
#include "polys/monomials/ring.h"
#include "polys/monomials/p_polys.h"
#include "polys/simpleideals.h"
#include "polys/weight.h"
#include "polys/flintconv.h"
#include "polys/flint_mpoly.h"
#include "polys/clapconv.h"
#include "Singular/ipid.h"
#include "kernel/ideals.h"
#include "polys/ext_fields/transext.h"
#include "coeffs/coeffs.h"
#include "kernel/linear_algebra/linearAlgebra.h"
#include "coeffs/numbers.h"
#include <vector>
#include "Singular/ipshell.h"
#include <ctime>
#include <iostream>

Go to the source code of this file.

Macros

#define OVERFLOW_MAX   LONG_MAX
 
#define OVERFLOW_MIN   LONG_MIN
 
#define omsai   1
 

Functions

static void SortByDeg_p (ideal I, poly p)
 
static ideal SortByDeg (ideal I)
 
ideal idQuotMon (ideal Iorig, ideal p)
 
static void idAddMon (ideal I, ideal p)
 
static poly ChoosePVar (ideal I)
 
static poly ChoosePJL (ideal I)
 
static poly ChooseP (ideal I)
 
static poly SearchP (ideal I)
 searches for a monomial of degree d>=2 and divides it by a variable (result monomial of deg d-1)
 
static bool JustVar (ideal I)
 
static void eulerchar (ideal I, int variables, mpz_ptr ec)
 
static poly SqFree (ideal I)
 
static bool IsIn (poly p, ideal I)
 
static poly LCMmon (ideal I)
 
static void rouneslice (ideal I, ideal S, poly q, poly x, int &prune, int &moreprune, int &steps, int &NNN, mpz_ptr &hilbertcoef, int *&hilbpower)
 
void slicehilb (ideal I)
 
intvechSecondSeries (intvec *hseries1)
 
void hDegreeSeries (intvec *s1, intvec *s2, int *co, int *mu)
 
poly hFirst2Second (poly h, const ring Qt, int &co)
 
static void hPrintHilb (poly hseries, const ring Qt, intvec *modul_weight)
 
static ring makeQt ()
 
void hLookSeries (ideal S, intvec *modulweight, ideal Q, intvec *wdegree)
 
static void idInsertMonomial (ideal I, poly p)
 
static int comapreMonoIdBases (ideal J, ideal Ob)
 
static int CountOnIdUptoTruncationIndex (ideal I, int tr)
 
static int comapreMonoIdBases_IG_Case (ideal J, int JCount, ideal Ob, int ObCount)
 
static int positionInOrbit_IG_Case (ideal I, poly w, std::vector< ideal > idorb, std::vector< poly > polist, int trInd, int)
 
static int positionInOrbit_FG_Case (ideal I, poly, std::vector< ideal > idorb, std::vector< poly >, int, int)
 
static int positionInOrbitTruncationCase (ideal I, poly w, std::vector< ideal > idorb, std::vector< poly > polist, int, int trunDegHs)
 
static int monCompare (const void *m, const void *n)
 
static void sortMonoIdeal_pCompare (ideal I)
 
static ideal minimalMonomialGenSet (ideal I)
 
static poly shiftInMon (poly p, int i, int lV, const ring r)
 
static poly deleteInMon (poly w, int i, int lV, const ring r)
 
static void TwordMap (poly p, poly w, int lV, int d, ideal Jwi, bool &flag)
 
static ideal colonIdeal (ideal S, poly w, int lV, ideal Jwi, int trunDegHs)
 
void HilbertSeries_OrbitData (ideal S, int lV, bool IG_CASE, bool mgrad, bool odp, int trunDegHs)
 
ideal RightColonOperation (ideal S, poly w, int lV)
 
static BOOLEAN p_Div_hi (poly p, const int *exp_q, const ring src)
 
static int compare_rp_currRing (const void *pp1, const void *pp2)
 
static void id_DelDiv_hi (ideal id, BOOLEAN *bad, const ring r)
 
static poly hilbert_series (ideal A, const ring src, const intvec *wdegree, 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)
 
intvechFirstSeries0 (ideal A, ideal Q, intvec *wdegree, const ring src, const ring Qt)
 
static ideal getModuleComp (ideal A, int c, const ring src)
 
intvechFirstSeries (ideal A, intvec *module_w, ideal Q, intvec *wdegree)
 
static int hMinModulweight (intvec *modulweight)
 
static void hWDegree (intvec *wdegree)
 
static int64hAddHilb (int Nv, int x, int64 *pol, int *lp)
 
static void hLastHilb (scmon pure, int Nv, varset var, int64 *pol, int lp)
 
static void hHilbEst (scfmon stc, int Nstc, varset var, int Nvar)
 
static void hHilbStep (scmon pure, scfmon stc, int Nstc, varset var, int Nvar, int64 *pol, int Lpol)
 
static intvechSeries (ideal S, intvec *modulweight, intvec *wdegree, ideal Q)
 
intvechFirstSeries1 (ideal S, intvec *modulweight, ideal Q, intvec *wdegree)
 
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)
 
void scDegree (ideal S, intvec *modulweight, ideal Q)
 

Variables

STATIC_VAR int64 ** Qpol
 
STATIC_VAR int64Q0
 
STATIC_VAR int64Ql
 
STATIC_VAR int hLength
 
STATIC_VAR ring hilb_Qt =NULL
 

Macro Definition Documentation

◆ omsai

#define omsai   1

Definition at line 51 of file hilb.cc.

◆ OVERFLOW_MAX

#define OVERFLOW_MAX   LONG_MAX

Definition at line 38 of file hilb.cc.

◆ OVERFLOW_MIN

#define OVERFLOW_MIN   LONG_MIN

Definition at line 39 of file hilb.cc.

Function Documentation

◆ ChooseP()

static poly ChooseP ( ideal I)
static

Definition at line 329 of file hilb.cc.

330{
331 poly m;
332 m = ChoosePJL(I);
333 return(m);
334}
int m
Definition cfEzgcd.cc:128
static poly ChoosePJL(ideal I)
Definition hilb.cc:300

◆ ChoosePJL()

static poly ChoosePJL ( ideal I)
static

Definition at line 300 of file hilb.cc.

301{
302 int i,j,dummy;
303 bool flag = TRUE;
304 poly m = p_ISet(1,currRing);
305 for(i = IDELEMS(I)-1;(i>=0) && (flag);i--)
306 {
307 flag = TRUE;
308 for(j=1;(j<=currRing->N) && (flag);j++)
309 {
310 dummy = p_GetExp(I->m[i],j,currRing);
311 if(dummy >= 2)
312 {
313 p_SetExp(m,j,dummy-1,currRing);
315 flag = FALSE;
316 }
317 }
318 if(!p_IsOne(m, currRing))
319 {
320 return(m);
321 }
322 }
324 m = ChoosePVar(I);
325 return(m);
326}
#define TRUE
Definition auxiliary.h:101
#define FALSE
Definition auxiliary.h:97
int i
Definition cfEzgcd.cc:132
int j
Definition facHensel.cc:110
static poly ChoosePVar(ideal I)
Definition hilb.cc:268
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
Definition p_polys.cc:1298
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 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:471
static BOOLEAN p_IsOne(const poly p, const ring R)
either poly(1) or gen(k)?!
Definition p_polys.h:1987
static void p_Delete(poly *p, const ring r)
Definition p_polys.h:903
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13
#define IDELEMS(i)

◆ ChoosePVar()

static poly ChoosePVar ( ideal I)
static

Definition at line 268 of file hilb.cc.

269{
270 bool flag=TRUE;
271 int i,j;
272 poly res;
273 for(i=1;i<=currRing->N;i++)
274 {
275 flag=TRUE;
276 for(j=IDELEMS(I)-1;(j>=0)&&(flag);j--)
277 {
278 if(p_GetExp(I->m[j], i, currRing)>0)
279 {
280 flag=FALSE;
281 }
282 }
283
284 if(flag == TRUE)
285 {
286 res = p_ISet(1, currRing);
287 p_SetExp(res, i, 1, currRing);
289 return(res);
290 }
291 else
292 {
294 }
295 }
296 return(NULL); //i.e. it is the maximal ideal
297}
CanonicalForm res
Definition facAbsFact.cc:60
#define NULL
Definition omList.c:12

◆ colonIdeal()

static ideal colonIdeal ( ideal S,
poly w,
int lV,
ideal Jwi,
int trunDegHs )
static

Definition at line 1371 of file hilb.cc.

1372{
1373 /*
1374 * It computes the right colon ideal of a two-sided ideal S
1375 * w.r.t. word w and save it in a new object Jwi.
1376 * It keeps S and w unchanged.
1377 */
1378
1379 if(idIs0(S))
1380 {
1381 return(S);
1382 }
1383
1384 int i, d;
1385 d = p_Totaldegree(w, currRing);
1386 if(trunDegHs !=0 && d >= trunDegHs)
1387 {
1389 return(Jwi);
1390 }
1391 bool flag = FALSE;
1392 int SCount = IDELEMS(S);
1393 for(i = 0; i < SCount; i++)
1394 {
1395 TwordMap(S->m[i], w, lV, d, Jwi, flag);
1396 if(flag)
1397 {
1398 break;
1399 }
1400 }
1401
1402 Jwi = minimalMonomialGenSet(Jwi);
1403 return(Jwi);
1404}
const CanonicalForm & w
Definition facAbsFact.cc:51
static void idInsertMonomial(ideal I, poly p)
Definition hilb.cc:888
static void TwordMap(poly p, poly w, int lV, int d, ideal Jwi, bool &flag)
Definition hilb.cc:1310
static ideal minimalMonomialGenSet(ideal I)
Definition hilb.cc:1211
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
poly p_One(const ring r)
Definition p_polys.cc:1314
static long p_Totaldegree(poly p, const ring r)
Definition p_polys.h:1523

◆ comapreMonoIdBases()

static int comapreMonoIdBases ( ideal J,
ideal Ob )
static

Definition at line 915 of file hilb.cc.

916{
917 /*
918 * Monomials of J and Ob are assumed to
919 * be already sorted. J and Ob are
920 * represented by the minimal generating set.
921 */
922 int i, s;
923 s = 1;
924 int JCount = IDELEMS(J);
925 int ObCount = IDELEMS(Ob);
926
927 if(idIs0(J))
928 {
929 return(1);
930 }
931 if(JCount != ObCount)
932 {
933 return(0);
934 }
935
936 for(i = 0; i < JCount; i++)
937 {
938 if(!(p_LmEqual(J->m[i], Ob->m[i], currRing)))
939 {
940 return(0);
941 }
942 }
943 return(s);
944}
const CanonicalForm int s
Definition facAbsFact.cc:51
#define p_LmEqual(p1, p2, r)
Definition p_polys.h:1739

◆ comapreMonoIdBases_IG_Case()

static int comapreMonoIdBases_IG_Case ( ideal J,
int JCount,
ideal Ob,
int ObCount )
static

Definition at line 973 of file hilb.cc.

974{
975 /*
976 * Monomials of J and Ob are assumed to
977 * be already sorted in increasing degrees.
978 * J and Ob are represented by the minimal
979 * generating set. It checks if J and Ob have
980 * same monomials up to deg <=tr.
981 */
982
983 int i, s;
984 s = 1;
985 //when J is null
986 //
987 if(JCount != ObCount)
988 {
989 return(0);
990 }
991
992 if(JCount == 0)
993 {
994 return(1);
995 }
996
997 for(i = 0; i< JCount; i++)
998 {
999 if(!(p_LmEqual(J->m[i], Ob->m[i], currRing)))
1000 {
1001 return(0);
1002 }
1003 }
1004
1005 return(s);
1006}

◆ compare_rp_currRing()

static int compare_rp_currRing ( const void * pp1,
const void * pp2 )
static

Definition at line 1827 of file hilb.cc.

1828{
1829 poly p1=*(poly*)pp1;
1830 poly p2=*(poly*)pp2;
1831 for(int i=currRing->N;i>0;i--)
1832 {
1833 int e1=p_GetExp(p1,i,currRing);
1834 int e2=p_GetExp(p2,i,currRing);
1835 if(e1<e2) return -1;
1836 if(e1>e2) return 1;
1837 }
1838 return 0;
1839}

◆ CountOnIdUptoTruncationIndex()

static int CountOnIdUptoTruncationIndex ( ideal I,
int tr )
static

Definition at line 946 of file hilb.cc.

947{
948 /*
949 * The ideal I must be sorted in increasing total degree.
950 * It counts the number of monomials in I up to
951 * degree less than or equal to tr.
952 */
953
954 //case when I=1;
955 if(p_Totaldegree(I->m[0], currRing) == 0)
956 {
957 return(1);
958 }
959
960 int count = 0;
961 for(int i = 0; i < IDELEMS(I); i++)
962 {
963 if(p_Totaldegree(I->m[i], currRing) > tr)
964 {
965 return (count);
966 }
967 count = count + 1;
968 }
969
970 return(count);
971}
int status int void size_t count
Definition si_signals.h:69

◆ deleteInMon()

static poly deleteInMon ( poly w,
int i,
int lV,
const ring r )
static

Definition at line 1276 of file hilb.cc.

1277{
1278 /*
1279 * deletes the variables up to i^th layer of monomial w
1280 * w remains unchanged
1281 * creates new poly and returns it for the colon ideal
1282 */
1283
1284 poly dw = p_One(currRing);
1285 int *e = (int *)omAlloc((r->N+1)*sizeof(int));
1286 int *s=(int *)omAlloc0((r->N+1)*sizeof(int));
1287 p_GetExpV(w, e, r);
1288 int j, cnt;
1289 cnt = i*lV;
1290 /*
1291 for(j=1;j<=cnt;j++)
1292 {
1293 e[j]=0;
1294 }*/
1295 for(j = (cnt+1); j < (r->N+1); j++)
1296 {
1297 s[j] = e[j];
1298 }
1299
1300 p_SetExpV(dw, s, currRing);//new exponents
1301 omFree(e);
1302 omFree(s);
1303
1305 p_Setm(dw, currRing);
1306
1307 return(dw);
1308}
#define p_GetComp(p, r)
Definition monomials.h:64
#define omAlloc(size)
#define omFree(addr)
#define omAlloc0(size)
static void p_SetExpV(poly p, int *ev, const ring r)
Definition p_polys.h:1560
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition p_polys.h:249
static void p_GetExpV(poly p, int *ev, const ring r)
Definition p_polys.h:1536

◆ eulerchar()

static void eulerchar ( ideal I,
int variables,
mpz_ptr ec )
static

Definition at line 373 of file hilb.cc.

374{
375 loop
376 {
377 mpz_t dummy;
378 if(JustVar(I) == TRUE)
379 {
380 if(IDELEMS(I) == variables)
381 {
382 mpz_init(dummy);
383 if((variables % 2) == 0)
384 mpz_set_ui(dummy, 1);
385 else
386 mpz_set_si(dummy, -1);
387 mpz_add(ec, ec, dummy);
388 mpz_clear(dummy);
389 }
390 return;
391 }
392 ideal p = idInit(1,1);
393 p->m[0] = SearchP(I);
394 //idPrint(I);
395 //idPrint(p);
396 //printf("\nNow get in idQuotMon\n");
397 ideal Ip = idQuotMon(I,p);
398 //idPrint(Ip);
399 //Ip = SortByDeg(Ip);
400 int i,howmanyvarinp = 0;
401 for(i = 1;i<=currRing->N;i++)
402 {
403 if(p_GetExp(p->m[0],i,currRing)>0)
404 {
405 howmanyvarinp++;
406 }
407 }
408 eulerchar(Ip, variables-howmanyvarinp, ec);
409 id_Delete(&Ip, currRing);
410 idAddMon(I,p);
412 }
413}
int p
Definition cfModGcd.cc:4086
static void idAddMon(ideal I, ideal p)
Definition hilb.cc:260
static void eulerchar(ideal I, int variables, mpz_ptr ec)
Definition hilb.cc:373
static poly SearchP(ideal I)
searches for a monomial of degree d>=2 and divides it by a variable (result monomial of deg d-1)
Definition hilb.cc:337
ideal idQuotMon(ideal Iorig, ideal p)
Definition hilb.cc:198
static bool JustVar(ideal I)
Definition hilb.cc:363
STATIC_VAR int variables
ideal idInit(int idsize, int rank)
initialise an ideal / module
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
#define loop
Definition structs.h:71

◆ getModuleComp()

static ideal getModuleComp ( ideal A,
int c,
const ring src )
static

Definition at line 2139 of file hilb.cc.

2140{
2141 ideal res=idInit(IDELEMS(A),A->rank);
2142 for (int i=0;i<IDELEMS(A);i++)
2143 {
2144 if ((A->m[i]!=NULL) && (p_GetComp(A->m[i],src)==c))
2145 res->m[i]=p_Head(A->m[i],src);
2146 }
2147 return res;
2148}
static poly p_Head(const poly p, const ring r)
copy the (leading) term of p
Definition p_polys.h:862
#define A
Definition sirandom.c:24

◆ hAddHilb()

static int64 * hAddHilb ( int Nv,
int x,
int64 * pol,
int * lp )
static

Definition at line 2254 of file hilb.cc.

2255{
2256 int l = *lp, ln, i;
2257 int64 *pon;
2258 *lp = ln = l + x;
2259 pon = Qpol[Nv];
2260 memcpy(pon, pol, l * sizeof(int64));
2261 if (l > x)
2262 {/*pon[i] -= pol[i - x];*/
2263 for (i = x; i < l; i++)
2264 {
2265 #ifndef __SIZEOF_INT128__
2266 int64 t=pon[i];
2267 int64 t2=pol[i - x];
2268 t-=t2;
2269 if ((t>=OVERFLOW_MIN)&&(t<=OVERFLOW_MAX)) pon[i]=t;
2270 else if (!errorreported) WerrorS("int overflow in hilb 1");
2271 #else
2272 __int128 t=pon[i];
2273 __int128 t2=pol[i - x];
2274 t-=t2;
2275 if ((t>=LONG_MIN)&&(t<=LONG_MAX)) pon[i]=t;
2276 else if (!errorreported) WerrorS("long int overflow in hilb 1");
2277 #endif
2278 }
2279 for (i = l; i < ln; i++)
2280 { /*pon[i] = -pol[i - x];*/
2281 #ifndef __SIZEOF_INT128__
2282 int64 t= -pol[i - x];
2283 if ((t>=OVERFLOW_MIN)&&(t<=OVERFLOW_MAX)) pon[i]=t;
2284 else if (!errorreported) WerrorS("int overflow in hilb 2");
2285 #else
2286 __int128 t= -pol[i - x];
2287 if ((t>=LONG_MIN)&&(t<=LONG_MAX)) pon[i]=t;
2288 else if (!errorreported) WerrorS("long int overflow in hilb 2");
2289 #endif
2290 }
2291 }
2292 else
2293 {
2294 for (i = l; i < x; i++)
2295 pon[i] = 0;
2296 for (i = x; i < ln; i++)
2297 pon[i] = -pol[i - x];
2298 }
2299 return pon;
2300}
long int64
Definition auxiliary.h:68
int l
Definition cfEzgcd.cc:100
Variable x
Definition cfModGcd.cc:4090
VAR short errorreported
Definition feFopen.cc:23
void WerrorS(const char *s)
Definition feFopen.cc:24
#define OVERFLOW_MAX
Definition hilb.cc:38
#define OVERFLOW_MIN
Definition hilb.cc:39
STATIC_VAR int64 ** Qpol
Definition hilb.cc:67

◆ 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
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
static poly p_Add_q(poly p, poly q, const ring r)
Definition p_polys.h:938
static poly p_New(const ring, omBin bin)
Definition p_polys.h:666

◆ hDegreeSeries()

void hDegreeSeries ( intvec * s1,
intvec * s2,
int * co,
int * mu )

Definition at line 742 of file hilb.cc.

743{
744 int i, j, k;
745 int m;
746 *co = *mu = 0;
747 if ((s1 == NULL) || (s2 == NULL))
748 return;
749 i = s1->length();
750 j = s2->length();
751 if (j > i)
752 return;
753 m = 0;
754 for(k=j-2; k>=0; k--)
755 m += (*s2)[k];
756 *mu = m;
757 *co = i - j;
758}
int k
Definition cfEzgcd.cc:99
int length() const
Definition intvec.h:95
static matrix mu(matrix A, const ring R)
Definition matpol.cc:2028

◆ hFirst2Second()

poly hFirst2Second ( poly h,
const ring Qt,
int & co )

Definition at line 760 of file hilb.cc.

761{
762 poly o_t=p_One(Qt);p_SetExp(o_t,1,1,Qt);p_Setm(o_t,Qt);
763 o_t=p_Neg(o_t,Qt);
764 o_t=p_Add_q(p_One(Qt),o_t,Qt);
765 poly di1=p_Copy(h,Qt);
766 co=0;
767#if defined(HAVE_FLINT) && (__FLINT_RELEASE >= 20503)
768 poly di2;
769 fmpq_mpoly_ctx_t ctx;
770 convSingRFlintR(ctx,Qt);
771 loop
772 {
773 di2=Flint_Divide_MP(di1,0,o_t,0,ctx,Qt);
774 if (di2==NULL) break;
775 co++;
776 p_Delete(&di1,Qt);
777 di1=di2;
778 }
779#else
780 if (di1!=NULL)
781 {
784 CanonicalForm Di2,dummy;
785 loop
786 {
787 Di2=Di1/O_t;
788 dummy=Di2*O_t;
789 if (dummy!=Di1) break;
790 else Di1=Di2;
791 co++;
792 }
793 p_Delete(&di1,Qt);
794 di1=convFactoryPSingP(Di1,Qt);
795 }
796#endif
797 p_Delete(&o_t,Qt);
798 return di1;
799}
CanonicalForm convSingPFactoryP(poly p, const ring r)
Definition clapconv.cc:138
poly convFactoryPSingP(const CanonicalForm &f, const ring r)
Definition clapconv.cc:40
factory's main class
static poly p_Neg(poly p, const ring r)
Definition p_polys.h:1109
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition p_polys.h:848

◆ hFirstSeries()

intvec * hFirstSeries ( ideal A,
intvec * module_w,
ideal Q,
intvec * wdegree )

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
int max_in()
Definition intvec.h:132
int min_in()
Definition intvec.h:122
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
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 short rVar(const ring r)
#define rVar(r) (r->N)
Definition ring.h:598
BOOLEAN id_IsModule(ideal A, const ring src)
#define Q
Definition sirandom.c:26

◆ hFirstSeries0()

intvec * hFirstSeries0 ( ideal A,
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}
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}
Matrices of numbers.
Definition bigintmat.h:51
int cols() const
Definition bigintmat.h:144
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

◆ 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}
static poly p_Mult_q(poly p, poly q, const ring r)
Definition p_polys.h:1120
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,
intvec * wdegree )

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)

◆ hHilbEst()

static void hHilbEst ( scfmon stc,
int Nstc,
varset var,
int Nvar )
static

Definition at line 2358 of file hilb.cc.

2359{
2360 int i, j;
2361 int x, y, z = 1;
2362 int64 *p;
2363 for (i = Nvar; i>0; i--)
2364 {
2365 x = 0;
2366 for (j = 0; j < Nstc; j++)
2367 {
2368 y = stc[j][var[i]];
2369 if (y > x)
2370 x = y;
2371 }
2372 z += x;
2373 j = i - 1;
2374 if (z > Ql[j])
2375 {
2376 if (z>(MAX_INT_VAL)/2)
2377 {
2378 WerrorS("internal arrays too big");
2379 return;
2380 }
2381 p = (int64 *)omAlloc((unsigned long)z * sizeof(int64));
2382 if (Ql[j]!=0)
2383 {
2384 if (j==0)
2385 memcpy(p, Qpol[j], Ql[j] * sizeof(int64));
2386 omFreeSize((ADDRESS)Qpol[j], Ql[j] * sizeof(int64));
2387 }
2388 if (j==0)
2389 {
2390 for (x = Ql[j]; x < z; x++)
2391 p[x] = 0;
2392 }
2393 Ql[j] = z;
2394 Qpol[j] = p;
2395 }
2396 }
2397}
void * ADDRESS
Definition auxiliary.h:120
const CanonicalForm int const CFList const Variable & y
Definition facAbsFact.cc:53
STATIC_VAR int64 * Ql
Definition hilb.cc:68
const int MAX_INT_VAL
Definition mylimits.h:12
#define omFreeSize(addr, size)

◆ hHilbStep()

static void hHilbStep ( scmon pure,
scfmon stc,
int Nstc,
varset var,
int Nvar,
int64 * pol,
int Lpol )
static

Definition at line 2399 of file hilb.cc.

2401{
2402 int iv = Nvar -1, ln, a, a0, a1, b, i;
2403 int x, x0;
2404 scmon pn;
2405 scfmon sn;
2406 int64 *pon;
2407 if (Nstc==0)
2408 {
2409 hLastHilb(pure, iv, var, pol, Lpol);
2410 return;
2411 }
2412 x = a = 0;
2413 pn = hGetpure(pure);
2414 sn = hGetmem(Nstc, stc, stcmem[iv]);
2415 hStepS(sn, Nstc, var, Nvar, &a, &x);
2416 Q0[iv] = Q0[Nvar];
2417 ln = Lpol;
2418 pon = pol;
2419 if (a == Nstc)
2420 {
2421 x = pure[var[Nvar]];
2422 if (x!=0)
2423 pon = hAddHilb(iv, x, pon, &ln);
2424 hHilbStep(pn, sn, a, var, iv, pon, ln);
2425 return;
2426 }
2427 else
2428 {
2429 pon = hAddHilb(iv, x, pon, &ln);
2430 hHilbStep(pn, sn, a, var, iv, pon, ln);
2431 }
2432 b = a;
2433 x0 = 0;
2434 loop
2435 {
2436 Q0[iv] += (x - x0);
2437 a0 = a;
2438 x0 = x;
2439 hStepS(sn, Nstc, var, Nvar, &a, &x);
2440 hElimS(sn, &b, a0, a, var, iv);
2441 a1 = a;
2442 hPure(sn, a0, &a1, var, iv, pn, &i);
2443 hLex2S(sn, b, a0, a1, var, iv, hwork);
2444 b += (a1 - a0);
2445 ln = Lpol;
2446 if (a < Nstc)
2447 {
2448 pon = hAddHilb(iv, x - x0, pol, &ln);
2449 hHilbStep(pn, sn, b, var, iv, pon, ln);
2450 }
2451 else
2452 {
2453 x = pure[var[Nvar]];
2454 if (x!=0)
2455 pon = hAddHilb(iv, x - x0, pol, &ln);
2456 else
2457 pon = pol;
2458 hHilbStep(pn, sn, b, var, iv, pon, ln);
2459 return;
2460 }
2461 }
2462}
static void hLastHilb(scmon pure, int Nv, varset var, int64 *pol, int lp)
Definition hilb.cc:2302
STATIC_VAR int64 * Q0
Definition hilb.cc:68
static void hHilbStep(scmon pure, scfmon stc, int Nstc, varset var, int Nvar, int64 *pol, int Lpol)
Definition hilb.cc:2399
static int64 * hAddHilb(int Nv, int x, int64 *pol, int *lp)
Definition hilb.cc:2254
void hLex2S(scfmon rad, int e1, int a2, int e2, varset var, int Nvar, scfmon w)
Definition hutil.cc:812
void hElimS(scfmon stc, int *e1, int a2, int e2, varset var, int Nvar)
Definition hutil.cc:672
VAR monf stcmem
Definition hutil.cc:21
scfmon hGetmem(int lm, scfmon old, monp monmem)
Definition hutil.cc:1023
void hPure(scfmon stc, int a, int *Nstc, varset var, int Nvar, scmon pure, int *Npure)
Definition hutil.cc:621
VAR scfmon hwork
Definition hutil.cc:16
void hStepS(scfmon stc, int Nstc, varset var, int Nvar, int *a, int *x)
Definition hutil.cc:949
scmon hGetpure(scmon p)
Definition hutil.cc:1052
scmon * scfmon
Definition hutil.h:15
int * scmon
Definition hutil.h:14

◆ hilbert_series()

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

Definition at line 1925 of file hilb.cc.

1930{
1931 int r=id_Elem(A,src);
1932 poly h=NULL;
1933 if (r==0)
1934 return p_One(Qt);
1935 if (wdegree!=NULL)
1936 {
1937 int* exp=(int*)omAlloc((src->N+1)*sizeof(int));
1938 for(int i=IDELEMS(A)-1; i>=0;i--)
1939 {
1940 if (A->m[i]!=NULL)
1941 {
1942 p_GetExpV(A->m[i],exp,src);
1943 for(int j=src->N;j>0;j--)
1944 {
1945 int w=(*wdegree)[j-1];
1946 if (w<=0)
1947 {
1948 WerrorS("weights must be positive");
1949 return NULL;
1950 }
1951 exp[j]*=w; /* (*wdegree)[j-1] */
1952 }
1953 p_SetExpV(A->m[i],exp,src);
1954 #ifdef PDEBUG
1955 p_Setm(A->m[i],src);
1956 #endif
1957 }
1958 }
1959 omFreeSize(exp,(src->N+1)*sizeof(int));
1960 }
1961 h=p_Init(Qt); pSetCoeff0(h,n_Init(-1,Qt->cf));
1962 p_SetExp(h,1,p_Totaldegree(A->m[0],src),Qt);
1963 //p_Setm(h,Qt);
1964 h=p_Add_q(h,p_One(Qt),Qt); // 1-t
1965 int *exp_q=(int*)omAlloc((src->N+1)*sizeof(int));
1966 BOOLEAN *bad=(BOOLEAN*)omAlloc0(r*sizeof(BOOLEAN));
1967 for (int i=1;i<r;i++)
1968 {
1969 ideal J=id_CopyFirstK(A,i,src);
1970 for(int ii=src->N;ii>0;ii--)
1971 exp_q[ii]=p_GetExp(A->m[i],ii,src);
1972 memset(bad,0,i*sizeof(BOOLEAN));
1973 for(int ii=0;ii<i;ii++)
1974 {
1975 bad[ii]=p_Div_hi(J->m[ii],exp_q,src);
1976 }
1977 id_DelDiv_hi(J,bad,src);
1978 // variant A
1979 // search linear elems:
1980 int k=0;
1981 for (int ii=IDELEMS(J)-1;ii>=0;ii--)
1982 {
1983 if((J->m[ii]!=NULL) && (bad[ii]) && (p_Totaldegree(J->m[ii],src)==1))
1984 {
1985 k++;
1986 p_LmDelete(&J->m[ii],src);
1987 }
1988 }
1989 IDELEMS(J)=idSkipZeroes0(J);
1990 poly h_J=hilbert_series(J,src,NULL,Qt);// J_1
1991 poly tmp;
1992 if (k>0)
1993 {
1994 // hilbert_series of unmodified J:
1995 tmp=p_Init(Qt); pSetCoeff0(tmp,n_Init(-1,Qt->cf));
1996 p_SetExp(tmp,1,1,Qt);
1997 //p_Setm(tmp,Qt);
1998 tmp=p_Add_q(tmp,p_One(Qt),Qt); // 1-t
1999 if (k>1)
2000 {
2001 tmp=p_Power(tmp,k,Qt); // (1-t)^k
2002 }
2003 h_J=p_Mult_q(h_J,tmp,Qt);
2004 }
2005 // forget about J:
2006 id_Delete0(&J,src);
2007 // t^|A_i|
2008 tmp=p_Init(Qt); pSetCoeff0(tmp,n_Init(-1,Qt->cf));
2009 p_SetExp(tmp,1,p_Totaldegree(A->m[i],src),Qt);
2010 //p_Setm(tmp,Qt);
2011 tmp=p_Mult_q(tmp,h_J,Qt);
2012 h=p_Add_q(h,tmp,Qt);
2013 }
2014 omFreeSize(bad,r*sizeof(BOOLEAN));
2015 omFreeSize(exp_q,(src->N+1)*sizeof(int));
2016 //Print("end hilbert_series, r=%d\n",r);
2017 return h;
2018}
bool bad
static BOOLEAN p_Div_hi(poly p, const int *exp_q, const ring src)
Definition hilb.cc:1787
static void id_DelDiv_hi(ideal id, BOOLEAN *bad, const ring r)
Definition hilb.cc:1841
gmp_float exp(const gmp_float &a)
poly p_Power(poly p, int i, const ring r)
Definition p_polys.cc:2201
static poly p_Init(const ring r, omBin bin)
Definition p_polys.h:1336
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)

◆ HilbertSeries_OrbitData()

void HilbertSeries_OrbitData ( ideal S,
int lV,
bool IG_CASE,
bool mgrad,
bool odp,
int trunDegHs )

Definition at line 1406 of file hilb.cc.

1407{
1408
1409 /* new story:
1410 no lV is needed, i.e. it is to be determined
1411 the rest is extracted from the interface input list in extra.cc and makes the input of this proc
1412 called from extra.cc
1413 */
1414
1415 /*
1416 * This is based on iterative right colon operations on a
1417 * two-sided monomial ideal of the free associative algebra.
1418 * The algorithm terminates for those monomial ideals
1419 * whose monomials define "regular formal languages",
1420 * that is, all monomials of the input ideal can be obtained
1421 * from finite languages by applying finite number of
1422 * rational operations.
1423 */
1424
1425 int trInd;
1426 S = minimalMonomialGenSet(S);
1427 if( !idIs0(S) && p_Totaldegree(S->m[0], currRing)==0)
1428 {
1429 PrintS("Hilbert Series:\n 0\n");
1430 return;
1431 }
1432 int (*POS)(ideal, poly, std::vector<ideal>, std::vector<poly>, int, int);
1433 if(trunDegHs != 0)
1434 {
1435 Print("\nTruncation degree = %d\n",trunDegHs);
1437 }
1438 else
1439 {
1440 if(IG_CASE)
1441 {
1442 if(idIs0(S))
1443 {
1444 WerrorS("wrong input: it is not an infinitely gen. case");
1445 return;
1446 }
1447 trInd = p_Totaldegree(S->m[IDELEMS(S)-1], currRing);
1449 }
1450 else
1452 }
1453 std::vector<ideal > idorb;
1454 std::vector< poly > polist;
1455
1456 ideal orb_init = idInit(1, 1);
1457 idorb.push_back(orb_init);
1458
1459 polist.push_back( p_One(currRing));
1460
1461 std::vector< std::vector<int> > posMat;
1462 std::vector<int> posRow(lV,0);
1463 std::vector<int> C;
1464
1465 int ds, is, ps;
1466 unsigned long lpcnt = 0;
1467
1468 poly w, wi;
1469 ideal Jwi;
1470
1471 while(lpcnt < idorb.size())
1472 {
1473 w = NULL;
1474 w = polist[lpcnt];
1475 if(lpcnt >= 1 && idIs0(idorb[lpcnt]) == FALSE)
1476 {
1477 if(p_Totaldegree(idorb[lpcnt]->m[0], currRing) != 0)
1478 {
1479 C.push_back(1);
1480 }
1481 else
1482 C.push_back(0);
1483 }
1484 else
1485 {
1486 C.push_back(1);
1487 }
1488
1489 ds = p_Totaldegree(w, currRing);
1490 lpcnt++;
1491
1492 for(is = 1; is <= lV; is++)
1493 {
1494 wi = NULL;
1495 //make new copy 'wi' of word w=polist[lpcnt]
1496 //and update it (for the colon operation).
1497 //if corresponding to wi, right colon operation gives
1498 //a new (right colon) ideal of S,
1499 //keep 'wi' in the polist else delete it
1500
1501 wi = pCopy(w);
1502 p_SetExp(wi, (ds*lV)+is, 1, currRing);
1503 p_Setm(wi, currRing);
1504 Jwi = NULL;
1505 //Jwi stores (right) colon ideal of S w.r.t. word
1506 //wi if colon operation gives a new ideal place it
1507 //in the vector of ideals 'idorb'
1508 //otherwise delete it
1509
1510 Jwi = idInit(1,1);
1511
1512 Jwi = colonIdeal(S, wi, lV, Jwi, trunDegHs);
1513 ps = (*POS)(Jwi, wi, idorb, polist, trInd, trunDegHs);
1514
1515 if(ps == 0) // finds a new ideal
1516 {
1517 posRow[is-1] = idorb.size();
1518
1519 idorb.push_back(Jwi);
1520 polist.push_back(wi);
1521 }
1522 else // ideal is already there in the set
1523 {
1524 posRow[is-1]=ps-1;
1525 idDelete(&Jwi);
1526 pDelete(&wi);
1527 }
1528 }
1529 posMat.push_back(posRow);
1530 posRow.resize(lV,0);
1531 }
1532 int lO = C.size();//size of the orbit
1533 PrintLn();
1534 Print("maximal length of words = %ld\n", p_Totaldegree(polist[lO-1], currRing));
1535 Print("\nlength of the Orbit = %d", lO);
1536 PrintLn();
1537
1538 if(odp)
1539 {
1540 Print("words description of the Orbit: \n");
1541 for(is = 0; is < lO; is++)
1542 {
1543 pWrite0(polist[is]);
1544 PrintS(" ");
1545 }
1546 PrintLn();
1547 PrintS("\nmaximal degree, #(sum_j R(w,w_j))");
1548 PrintLn();
1549 for(is = 0; is < lO; is++)
1550 {
1551 if(idIs0(idorb[is]))
1552 {
1553 PrintS("NULL\n");
1554 }
1555 else
1556 {
1557 Print("%ld, %d \n",p_Totaldegree(idorb[is]->m[IDELEMS(idorb[is])-1], currRing),IDELEMS(idorb[is]));
1558 }
1559 }
1560 }
1561
1562 for(is = idorb.size()-1; is >= 0; is--)
1563 {
1564 idDelete(&idorb[is]);
1565 }
1566 for(is = polist.size()-1; is >= 0; is--)
1567 {
1568 pDelete(&polist[is]);
1569 }
1570
1571 idorb.resize(0);
1572 polist.resize(0);
1573
1574 int adjMatrix[lO][lO];
1575 memset(adjMatrix, 0, lO*lO*sizeof(int));
1576 int rowCount, colCount;
1577 int tm = 0;
1578 if(!mgrad)
1579 {
1580 for(rowCount = 0; rowCount < lO; rowCount++)
1581 {
1582 for(colCount = 0; colCount < lV; colCount++)
1583 {
1584 tm = posMat[rowCount][colCount];
1585 adjMatrix[rowCount][tm] = adjMatrix[rowCount][tm] + 1;
1586 }
1587 }
1588 }
1589
1590 ring r = currRing;
1591 int npar;
1592 char** tt;
1594 if(!mgrad)
1595 {
1596 tt=(char**)omAlloc(sizeof(char*));
1597 tt[0] = omStrDup("t");
1598 npar = 1;
1599 }
1600 else
1601 {
1602 tt=(char**)omalloc(lV*sizeof(char*));
1603 for(is = 0; is < lV; is++)
1604 {
1605 tt[is] = (char*)omAlloc(7*sizeof(char)); //if required enlarge it later
1606 snprintf (tt[is],7, "t%d", is+1);
1607 }
1608 npar = lV;
1609 }
1610
1611 p.r = rDefault(0, npar, tt);
1613 char** xx = (char**)omAlloc(sizeof(char*));
1614 xx[0] = omStrDup("x");
1615 ring R = rDefault(cf, 1, xx);
1616 rChangeCurrRing(R);//rWrite(R);
1617 /*
1618 * matrix corresponding to the orbit of the ideal
1619 */
1620 matrix mR = mpNew(lO, lO);
1621 matrix cMat = mpNew(lO,1);
1622 poly rc;
1623
1624 if(!mgrad)
1625 {
1626 for(rowCount = 0; rowCount < lO; rowCount++)
1627 {
1628 for(colCount = 0; colCount < lO; colCount++)
1629 {
1630 if(adjMatrix[rowCount][colCount] != 0)
1631 {
1632 MATELEM(mR, rowCount + 1, colCount + 1) = p_ISet(adjMatrix[rowCount][colCount], R);
1633 p_SetCoeff(MATELEM(mR, rowCount + 1, colCount + 1), n_Mult(pGetCoeff(mR->m[lO*rowCount+colCount]),n_Param(1, R->cf), R->cf), R);
1634 }
1635 }
1636 }
1637 }
1638 else
1639 {
1640 for(rowCount = 0; rowCount < lO; rowCount++)
1641 {
1642 for(colCount = 0; colCount < lV; colCount++)
1643 {
1644 rc=NULL;
1645 rc=p_One(R);
1646 p_SetCoeff(rc, n_Mult(pGetCoeff(rc), n_Param(colCount+1, R->cf),R->cf), R);
1647 MATELEM(mR, rowCount +1, posMat[rowCount][colCount]+1)=p_Add_q(rc,MATELEM(mR, rowCount +1, posMat[rowCount][colCount]+1), R);
1648 }
1649 }
1650 }
1651
1652 for(rowCount = 0; rowCount < lO; rowCount++)
1653 {
1654 if(C[rowCount] != 0)
1655 {
1656 MATELEM(cMat, rowCount + 1, 1) = p_ISet(C[rowCount], R);
1657 }
1658 }
1659
1660 matrix u;
1661 unitMatrix(lO, u); //unit matrix
1662 matrix gMat = mp_Sub(u, mR, R);
1663
1664 char* s;
1665
1666 if(odp)
1667 {
1668 PrintS("\nlinear system:\n");
1669 if(!mgrad)
1670 {
1671 for(rowCount = 0; rowCount < lO; rowCount++)
1672 {
1673 Print("H(%d) = ", rowCount+1);
1674 for(colCount = 0; colCount < lV; colCount++)
1675 {
1676 StringSetS(""); nWrite(n_Param(1, R->cf));
1677 s = StringEndS(); PrintS(s);
1678 Print("*"); omFree(s);
1679 Print("H(%d) + ", posMat[rowCount][colCount] + 1);
1680 }
1681 Print(" %d\n", C[rowCount] );
1682 }
1683 PrintS("where H(1) represents the series corresp. to input ideal\n");
1684 PrintS("and i^th summand in the rhs of an eqn. is according\n");
1685 PrintS("to the right colon map corresp. to the i^th variable\n");
1686 }
1687 else
1688 {
1689 for(rowCount = 0; rowCount < lO; rowCount++)
1690 {
1691 Print("H(%d) = ", rowCount+1);
1692 for(colCount = 0; colCount < lV; colCount++)
1693 {
1694 StringSetS(""); nWrite(n_Param(colCount+1, R->cf));
1695 s = StringEndS(); PrintS(s);
1696 Print("*");omFree(s);
1697 Print("H(%d) + ", posMat[rowCount][colCount] + 1);
1698 }
1699 Print(" %d\n", C[rowCount] );
1700 }
1701 PrintS("where H(1) represents the series corresp. to input ideal\n");
1702 }
1703 }
1704 PrintLn();
1705 posMat.resize(0);
1706 C.resize(0);
1707 matrix pMat;
1708 matrix lMat;
1709 matrix uMat;
1710 matrix H_serVec = mpNew(lO, 1);
1711 matrix Hnot;
1712
1713 //std::clock_t start;
1714 //start = std::clock();
1715
1716 luDecomp(gMat, pMat, lMat, uMat, R);
1717 luSolveViaLUDecomp(pMat, lMat, uMat, cMat, H_serVec, Hnot);
1718
1719 //to print system solving time
1720 //if(odp){
1721 //std::cout<<"solving time of the system = "<<(std::clock()-start)/(double)(CLOCKS_PER_SEC / 1000)<<" ms"<<std::endl;}
1722
1723 mp_Delete(&mR, R);
1724 mp_Delete(&u, R);
1725 mp_Delete(&pMat, R);
1726 mp_Delete(&lMat, R);
1727 mp_Delete(&uMat, R);
1728 mp_Delete(&cMat, R);
1729 mp_Delete(&gMat, R);
1730 mp_Delete(&Hnot, R);
1731 //print the Hilbert series and length of the Orbit
1732 PrintLn();
1733 Print("Hilbert series:");
1734 PrintLn();
1735 pWrite(H_serVec->m[0]);
1736 if(!mgrad)
1737 {
1738 omFree(tt[0]);
1739 }
1740 else
1741 {
1742 for(is = lV-1; is >= 0; is--)
1743
1744 omFree( tt[is]);
1745 }
1746 omFree(tt);
1747 omFree(xx[0]);
1748 omFree(xx);
1749 rChangeCurrRing(r);
1750 rKill(R);
1751}
CanonicalForm cf
Definition cfModGcd.cc:4091
poly * m
Definition matpol.h:18
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of 'a' and 'b', i.e., a*b
Definition coeffs.h:637
static FORCE_INLINE number n_Param(const int iParameter, const coeffs r)
return the (iParameter^th) parameter as a NEW number NOTE: parameter numbering: 1....
Definition coeffs.h:776
@ n_transExt
used for all transcendental extensions, i.e., the top-most extension in an extension tower is transce...
Definition coeffs.h:38
coeffs nInitChar(n_coeffType t, void *parameter)
one-time initialisations for new coeffs in case of an error return NULL
Definition numbers.cc:406
#define Print
Definition emacs.cc:80
static int positionInOrbitTruncationCase(ideal I, poly w, std::vector< ideal > idorb, std::vector< poly > polist, int, int trunDegHs)
Definition hilb.cc:1117
static ideal colonIdeal(ideal S, poly w, int lV, ideal Jwi, int trunDegHs)
Definition hilb.cc:1371
static int positionInOrbit_FG_Case(ideal I, poly, std::vector< ideal > idorb, std::vector< poly >, int, int)
Definition hilb.cc:1086
static int positionInOrbit_IG_Case(ideal I, poly w, std::vector< ideal > idorb, std::vector< poly > polist, int trInd, int)
Definition hilb.cc:1008
#define idDelete(H)
delete an ideal
Definition ideals.h:29
void rKill(ring r)
Definition ipshell.cc:6174
bool unitMatrix(const int n, matrix &unitMat, const ring R)
Creates a new matrix which is the (nxn) unit matrix, and returns true in case of success.
void luDecomp(const matrix aMat, matrix &pMat, matrix &lMat, matrix &uMat, const ring R)
LU-decomposition of a given (m x n)-matrix.
bool luSolveViaLUDecomp(const matrix pMat, const matrix lMat, const matrix uMat, const matrix bVec, matrix &xVec, matrix &H)
Solves the linear system A * x = b, where A is an (m x n)-matrix which is given by its LU-decompositi...
void mp_Delete(matrix *a, const ring r)
Definition matpol.cc:874
matrix mp_Sub(matrix a, matrix b, const ring R)
Definition matpol.cc:189
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition matpol.cc:37
#define MATELEM(mat, i, j)
1-based access to matrix
Definition matpol.h:29
ip_smatrix * matrix
Definition matpol.h:43
The main handler for Singular numbers which are suitable for Singular polynomials.
#define nWrite(n)
Definition numbers.h:29
#define omStrDup(s)
#define omalloc(size)
static number p_SetCoeff(poly p, number n, ring r)
Definition p_polys.h:414
void rChangeCurrRing(ring r)
Definition polys.cc:16
#define pDelete(p_ptr)
Definition polys.h:187
void pWrite0(poly p)
Definition polys.h:310
void pWrite(poly p)
Definition polys.h:309
#define pCopy(p)
return a copy of the poly
Definition polys.h:186
void StringSetS(const char *st)
Definition reporter.cc:128
void PrintS(const char *s)
Definition reporter.cc:284
char * StringEndS()
Definition reporter.cc:151
void PrintLn()
Definition reporter.cc:310
ring rDefault(const coeffs cf, int N, char **n, int ord_size, rRingOrder_t *ord, int *block0, int *block1, int **wvhdl, unsigned long bitmask)
Definition ring.cc:103
#define R
Definition sirandom.c:27
struct for passing initialization parameters to naInitChar
Definition transext.h:88

◆ hLastHilb()

static void hLastHilb ( scmon pure,
int Nv,
varset var,
int64 * pol,
int lp )
static

Definition at line 2302 of file hilb.cc.

2303{
2304 int l = lp, x, i, j;
2305 int64 *pl;
2306 int64 *p;
2307 p = pol;
2308 for (i = Nv; i>0; i--)
2309 {
2310 x = pure[var[i + 1]];
2311 if (x!=0)
2312 p = hAddHilb(i, x, p, &l);
2313 }
2314 pl = *Qpol;
2315 j = Q0[Nv + 1];
2316 for (i = 0; i < l; i++)
2317 { /* pl[i + j] += p[i];*/
2318 #ifndef __SIZEOF_INT128__
2319 int64 t=pl[i+j];
2320 int64 t2=p[i];
2321 t+=t2;
2322 if ((t>=OVERFLOW_MIN)&&(t<=OVERFLOW_MAX)) pl[i+j]=t;
2323 else if (!errorreported) WerrorS("int overflow in hilb 3");
2324 #else
2325 __int128 t=pl[i+j];
2326 __int128 t2=p[i];
2327 t+=t2;
2328 if ((t>=LONG_MIN)&&(t<=LONG_MAX)) pl[i+j]=t;
2329 else if (!errorreported) WerrorS("long int overflow in hilb 3");
2330 #endif
2331 }
2332 x = pure[var[1]];
2333 if (x!=0)
2334 {
2335 j += x;
2336 for (i = 0; i < l; i++)
2337 { /* pl[i + j] -= p[i];*/
2338 #ifndef __SIZEOF_INT128__
2339 int64 t=pl[i+j];
2340 int64 t2=p[i];
2341 t-=t2;
2342 if ((t>=OVERFLOW_MIN)&&(t<=OVERFLOW_MAX)) pl[i+j]=t;
2343 else if (!errorreported) WerrorS("int overflow in hilb 4");
2344 #else
2345 __int128 t=pl[i+j];
2346 __int128 t2=p[i];
2347 t-=t2;
2348 if ((t>=LONG_MIN)&&(t<=LONG_MAX)) pl[i+j]=t;
2349 else if (!errorreported) WerrorS("long int overflow in hilb 4");
2350 #endif
2351 }
2352 }
2353 j += l;
2354 if (j > hLength)
2355 hLength = j;
2356}
STATIC_VAR int hLength
Definition hilb.cc:69

◆ hLookSeries()

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

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
static void hPrintHilb(poly hseries, const ring Qt, intvec *modul_weight)
Definition hilb.cc:800

◆ hMinModulweight()

static int hMinModulweight ( intvec * modulweight)
static

Definition at line 2231 of file hilb.cc.

2232{
2233 if(modulweight==NULL) return 0;
2234 return modulweight->min_in();
2235}

◆ 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}

◆ hPrintHilb()

static void hPrintHilb ( poly hseries,
const ring Qt,
intvec * modul_weight )
static

Definition at line 800 of file hilb.cc.

801{
802 if ((modul_weight!=NULL)&&(modul_weight->compare(0)!=0))
803 {
804 char *s=modul_weight->ivString(1,0,1);
805 Print("module weights:%s\n",s);
806 omFree(s);
807 }
808 PrintS("(");p_Write0(hseries,Qt);Print(") / (1-%s)^%d\n",Qt->names[0],currRing->N);
809 int co;
810 poly h2=hFirst2Second(hseries,Qt,co);
811 int di = (currRing->N)-co;
812 if (hseries==NULL) di=0;
813 PrintS("("); p_Write0(h2,Qt); Print(") / (1-%s)^%d\n",Qt->names[0],di);
814 int mu=0;
815 poly p=h2;
816 while(p!=NULL)
817 {
818 mu+=n_Int(pGetCoeff(p),Qt->cf);
819 p_LmDelete(&p,Qt);
820 }
821 if (currRing->OrdSgn == 1)
822 {
823 if (di>0)
824 Print("// dimension (proj.) = %d\n// degree (proj.) = %d\n", di-1, mu);
825 else
826 Print("// dimension (affine) = 0\n// degree (affine) = %d\n", mu);
827 }
828 else
829 Print("// dimension (local) = %d\n// multiplicity = %d\n", di, mu);
830}
poly hFirst2Second(poly h, const ring Qt, int &co)
Definition hilb.cc:760
void p_Write0(poly p, ring lmRing, ring tailRing)
Definition polys0.cc:332

◆ 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}

◆ 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}

◆ hSeries()

static intvec * hSeries ( ideal S,
intvec * modulweight,
intvec * wdegree,
ideal Q )
static

Definition at line 2464 of file hilb.cc.

2466{
2467 intvec *work, *hseries1=NULL;
2468 int mc;
2469 int64 p0;
2470 int i, j, k, l, ii, mw;
2471 hexist = hInit(S, Q, &hNexist);
2472 if (hNexist==0)
2473 {
2474 hseries1=new intvec(2);
2475 (*hseries1)[0]=1;
2476 (*hseries1)[1]=0;
2477 return hseries1;
2478 }
2479
2480 if (wdegree != NULL) hWDegree(wdegree);
2481
2482 p0 = 1;
2483 hwork = (scfmon)omAlloc(hNexist * sizeof(scmon));
2484 hvar = (varset)omAlloc(((currRing->N) + 1) * sizeof(int));
2485 hpure = (scmon)omAlloc((1 + ((currRing->N) * (currRing->N))) * sizeof(int));
2486 stcmem = hCreate((currRing->N) - 1);
2487 Qpol = (int64 **)omAlloc(((currRing->N) + 1) * sizeof(int64 *));
2488 Ql = (int64 *)omAlloc0(((currRing->N) + 1) * sizeof(int64));
2489 Q0 = (int64 *)omAlloc(((currRing->N) + 1) * sizeof(int64));
2490 *Qpol = NULL;
2491 hLength = k = j = 0;
2492 mc = hisModule;
2493 if (mc!=0)
2494 {
2495 mw = hMinModulweight(modulweight);
2496 hstc = (scfmon)omAlloc(hNexist * sizeof(scmon));
2497 }
2498 else
2499 {
2500 mw = 0;
2501 hstc = hexist;
2502 hNstc = hNexist;
2503 }
2504 loop
2505 {
2506 if (mc!=0)
2507 {
2508 hComp(hexist, hNexist, mc, hstc, &hNstc);
2509 if (modulweight != NULL)
2510 j = (*modulweight)[mc-1]-mw;
2511 }
2512 if (hNstc!=0)
2513 {
2514 hNvar = (currRing->N);
2515 for (i = hNvar; i>=0; i--)
2516 hvar[i] = i;
2517 //if (notstc) // TODO: no mon divides another
2519 hSupp(hstc, hNstc, hvar, &hNvar);
2520 if (hNvar!=0)
2521 {
2522 if ((hNvar > 2) && (hNstc > 10))
2525 memset(hpure, 0, ((currRing->N) + 1) * sizeof(int));
2526 hPure(hstc, 0, &hNstc, hvar, hNvar, hpure, &hNpure);
2528 Q0[hNvar] = 0;
2529 hHilbStep(hpure, hstc, hNstc, hvar, hNvar, &p0, 1);
2530 }
2531 }
2532 else
2533 {
2534 if(*Qpol!=NULL)
2535 (**Qpol)++;
2536 else
2537 {
2538 *Qpol = (int64 *)omAlloc(sizeof(int64));
2539 hLength = *Ql = **Qpol = 1;
2540 }
2541 }
2542 if (*Qpol!=NULL)
2543 {
2544 i = hLength;
2545 while ((i > 0) && ((*Qpol)[i - 1] == 0))
2546 i--;
2547 if (i > 0)
2548 {
2549 l = i + j;
2550 if (l > k)
2551 {
2552 work = new intvec(l);
2553 for (ii=0; ii<k; ii++)
2554 (*work)[ii] = (*hseries1)[ii];
2555 if (hseries1 != NULL)
2556 delete hseries1;
2557 hseries1 = work;
2558 k = l;
2559 }
2560 while (i > 0)
2561 {
2562 (*hseries1)[i + j - 1] += (*Qpol)[i - 1];
2563 (*Qpol)[i - 1] = 0;
2564 i--;
2565 }
2566 }
2567 }
2568 mc--;
2569 if (mc <= 0)
2570 break;
2571 }
2572 if (k==0)
2573 {
2574 hseries1=new intvec(2);
2575 (*hseries1)[0]=0;
2576 (*hseries1)[1]=0;
2577 }
2578 else
2579 {
2580 l = k+1;
2581 while ((*hseries1)[l-2]==0) l--;
2582 if (l!=k)
2583 {
2584 work = new intvec(l);
2585 for (ii=l-2; ii>=0; ii--)
2586 (*work)[ii] = (*hseries1)[ii];
2587 delete hseries1;
2588 hseries1 = work;
2589 }
2590 (*hseries1)[l-1] = mw;
2591 }
2592 for (i = 0; i <= (currRing->N); i++)
2593 {
2594 if (Ql[i]!=0)
2595 omFreeSize((ADDRESS)Qpol[i], Ql[i] * sizeof(int64));
2596 }
2597 omFreeSize((ADDRESS)Q0, ((currRing->N) + 1) * sizeof(int64));
2598 omFreeSize((ADDRESS)Ql, ((currRing->N) + 1) * sizeof(int64));
2599 omFreeSize((ADDRESS)Qpol, ((currRing->N) + 1) * sizeof(int64 *));
2600 hKill(stcmem, (currRing->N) - 1);
2601 omFreeSize((ADDRESS)hpure, (1 + ((currRing->N) * (currRing->N))) * sizeof(int));
2602 omFreeSize((ADDRESS)hvar, ((currRing->N) + 1) * sizeof(int));
2603 omFreeSize((ADDRESS)hwork, hNexist * sizeof(scmon));
2605 if (hisModule!=0)
2606 omFreeSize((ADDRESS)hstc, hNexist * sizeof(scmon));
2607 return hseries1;
2608}
static void hHilbEst(scfmon stc, int Nstc, varset var, int Nvar)
Definition hilb.cc:2358
static int hMinModulweight(intvec *modulweight)
Definition hilb.cc:2231
static void hWDegree(intvec *wdegree)
Definition hilb.cc:2237
monf hCreate(int Nvar)
Definition hutil.cc:996
void hComp(scfmon exist, int Nexist, int ak, scfmon stc, int *Nstc)
Definition hutil.cc:154
VAR scfmon hstc
Definition hutil.cc:16
VAR varset hvar
Definition hutil.cc:18
void hKill(monf xmem, int Nvar)
Definition hutil.cc:1010
VAR int hNexist
Definition hutil.cc:19
void hLexS(scfmon stc, int Nstc, varset var, int Nvar)
Definition hutil.cc:506
void hDelete(scfmon ev, int ev_length)
Definition hutil.cc:140
void hSupp(scfmon stc, int Nstc, varset var, int *Nvar)
Definition hutil.cc:174
VAR scmon hpure
Definition hutil.cc:17
VAR int hisModule
Definition hutil.cc:20
void hStaircase(scfmon stc, int *Nstc, varset var, int Nvar)
Definition hutil.cc:313
void hOrdSupp(scfmon stc, int Nstc, varset var, int Nvar)
Definition hutil.cc:202
VAR int hNpure
Definition hutil.cc:19
scfmon hInit(ideal S, ideal Q, int *Nexist)
Definition hutil.cc:31
VAR scfmon hexist
Definition hutil.cc:16
VAR int hNstc
Definition hutil.cc:19
VAR int hNvar
Definition hutil.cc:19
int * varset
Definition hutil.h:16

◆ hWDegree()

static void hWDegree ( intvec * wdegree)
static

Definition at line 2237 of file hilb.cc.

2238{
2239 int i, k;
2240 int x;
2241
2242 for (i=(currRing->N); i; i--)
2243 {
2244 x = (*wdegree)[i-1];
2245 if (x != 1)
2246 {
2247 for (k=hNexist-1; k>=0; k--)
2248 {
2249 hexist[k][i] *= x;
2250 }
2251 }
2252 }
2253}

◆ id_DelDiv_hi()

static void id_DelDiv_hi ( ideal id,
BOOLEAN * bad,
const ring r )
static

Definition at line 1841 of file hilb.cc.

1842{
1843 int k=IDELEMS(id)-1;
1844 while(id->m[k]==NULL) k--;
1845 int kk = k+1;
1846 long *sev=(long*)omAlloc0(kk*sizeof(long));
1847 BOOLEAN only_lm=r->cf->has_simple_Alloc;
1848 if (BIT_SIZEOF_LONG / r->N==0) // 1 bit per exp
1849 {
1850 for (int i=k; i>=0; i--)
1851 {
1852 sev[i]=p_GetShortExpVector0(id->m[i],r);
1853 }
1854 }
1855 else
1856 if (BIT_SIZEOF_LONG / r->N==1) // 1..2 bit per exp
1857 {
1858 for (int i=k; i>=0; i--)
1859 {
1860 sev[i]=p_GetShortExpVector1(id->m[i],r);
1861 }
1862 }
1863 else
1864 {
1865 for (int i=k; i>=0; i--)
1866 {
1867 sev[i]=p_GetShortExpVector(id->m[i],r);
1868 }
1869 }
1870 if (only_lm)
1871 {
1872 for (int i=0; i<k; i++)
1873 {
1874 if (bad[i] && (id->m[i] != NULL))
1875 {
1876 poly m_i=id->m[i];
1877 long sev_i=sev[i];
1878 for (int j=i+1; j<=k; j++)
1879 {
1880 if (id->m[j]!=NULL)
1881 {
1882 if (p_LmShortDivisibleBy(m_i, sev_i, id->m[j],~sev[j],r))
1883 {
1884 p_LmFree(&id->m[j],r);
1885 }
1886 else if (p_LmShortDivisibleBy(id->m[j],sev[j], m_i,~sev_i,r))
1887 {
1888 p_LmFree(&id->m[i],r);
1889 break;
1890 }
1891 }
1892 }
1893 }
1894 }
1895 }
1896 else
1897 {
1898 for (int i=0; i<k; i++)
1899 {
1900 if (bad[i] && (id->m[i] != NULL))
1901 {
1902 poly m_i=id->m[i];
1903 long sev_i=sev[i];
1904 for (int j=i+1; j<=k; j++)
1905 {
1906 if (id->m[j]!=NULL)
1907 {
1908 if (p_LmShortDivisibleBy(m_i, sev_i, id->m[j],~sev[j],r))
1909 {
1910 p_Delete(&id->m[j],r);
1911 }
1912 else if (p_LmShortDivisibleBy(id->m[j],sev[j], m_i,~sev_i,r))
1913 {
1914 p_Delete(&id->m[i],r);
1915 break;
1916 }
1917 }
1918 }
1919 }
1920 }
1921 }
1922 omFreeSize(sev,kk*sizeof(long));
1923}
#define BIT_SIZEOF_LONG
Definition auxiliary.h:80
unsigned long p_GetShortExpVector0(const poly p, const ring r)
Definition p_polys.cc:4940
unsigned long p_GetShortExpVector(const poly p, const ring r)
Definition p_polys.cc:4889
unsigned long p_GetShortExpVector1(const poly p, const ring r)
Definition p_polys.cc:4955
static BOOLEAN p_LmShortDivisibleBy(poly a, unsigned long sev_a, poly b, unsigned long not_sev_b, const ring r)
Definition p_polys.h:1926
static void p_LmFree(poly p, ring)
Definition p_polys.h:685

◆ idAddMon()

static void idAddMon ( ideal I,
ideal p )
static

Definition at line 260 of file hilb.cc.

261{
262 SortByDeg_p(I,p->m[0]);
263 p->m[0]=NULL; // is now in I
264 //idSkipZeroes(I);
265}
static void SortByDeg_p(ideal I, poly p)
Definition hilb.cc:77

◆ idInsertMonomial()

static void idInsertMonomial ( ideal I,
poly p )
static

Definition at line 888 of file hilb.cc.

889{
890 /*
891 * It adds monomial in I and if required,
892 * enlarge the size of poly-set by 16.
893 * It does not make copy of p.
894 */
895
896 if(I == NULL)
897 {
898 return;
899 }
900
901 int j = IDELEMS(I) - 1;
902 while ((j >= 0) && (I->m[j] == NULL))
903 {
904 j--;
905 }
906 j++;
907 if (j == IDELEMS(I))
908 {
909 pEnlargeSet(&(I->m), IDELEMS(I), 16);
910 IDELEMS(I) +=16;
911 }
912 I->m[j] = p;
913}
void pEnlargeSet(poly **p, int l, int increment)
Definition p_polys.cc:3776

◆ idQuotMon()

ideal idQuotMon ( ideal Iorig,
ideal p )

Definition at line 198 of file hilb.cc.

199{
200 if(idIs0(Iorig))
201 {
202 ideal res = idInit(1,1);
203 res->m[0] = poly(0);
204 return(res);
205 }
206 if(idIs0(p))
207 {
208 ideal res = idInit(1,1);
209 res->m[0] = pOne();
210 return(res);
211 }
212 ideal I = id_Head(Iorig,currRing);
213 ideal res = idInit(IDELEMS(I),1);
214 int i,j;
215 int dummy;
216 for(i = 0; i<IDELEMS(I); i++)
217 {
218 res->m[i] = p_Head(I->m[i], currRing);
219 for(j = 1; (j<=currRing->N) ; j++)
220 {
221 dummy = p_GetExp(p->m[0], j, currRing);
222 if(dummy > 0)
223 {
224 if(p_GetExp(I->m[i], j, currRing) < dummy)
225 {
226 p_SetExp(res->m[i], j, 0, currRing);
227 }
228 else
229 {
230 p_SetExp(res->m[i], j, p_GetExp(I->m[i], j, currRing) - dummy, currRing);
231 }
232 }
233 }
234 p_Setm(res->m[i], currRing);
236 {
237 p_Delete(&res->m[i],currRing);
238 }
239 else
240 {
241 p_Delete(&I->m[i],currRing);
242 }
243 }
245 idSkipZeroes(I);
246 if(!idIs0(res))
247 {
248 for(i = 0; i<=IDELEMS(res)-1; i++)
249 {
250 SortByDeg_p(I,res->m[i]);
251 res->m[i]=NULL; // is now in I
252 }
253 }
255 //idDegSortTest(I);
256 return(I);
257}
#define pOne()
Definition polys.h:316

◆ IsIn()

static bool IsIn ( poly p,
ideal I )
static

Definition at line 445 of file hilb.cc.

446{
447 //assumes that I is ordered by degree
448 if(idIs0(I))
449 {
450 if(p==poly(0))
451 {
452 return(TRUE);
453 }
454 else
455 {
456 return(FALSE);
457 }
458 }
459 if(p==poly(0))
460 {
461 return(FALSE);
462 }
463 int i,j;
464 bool flag;
465 for(i = 0;i<IDELEMS(I);i++)
466 {
467 flag = TRUE;
468 for(j = 1;(j<=currRing->N) &&(flag);j++)
469 {
470 if(p_GetExp(p, j, currRing)<p_GetExp(I->m[i], j, currRing))
471 {
472 flag = FALSE;
473 }
474 }
475 if(flag)
476 {
477 return(TRUE);
478 }
479 }
480 return(FALSE);
481}

◆ JustVar()

static bool JustVar ( ideal I)
static

Definition at line 363 of file hilb.cc.

364{
365 if(p_Totaldegree(I->m[IDELEMS(I)-1],currRing)>1)
366 {
367 return(FALSE);
368 }
369 return(TRUE);
370}

◆ LCMmon()

static poly LCMmon ( ideal I)
static

Definition at line 484 of file hilb.cc.

485{
486 if(idIs0(I))
487 {
488 return(NULL);
489 }
490 poly m;
491 int dummy,i,j;
492 m = p_ISet(1,currRing);
493 for(i=1;i<=currRing->N;i++)
494 {
495 dummy=0;
496 for(j=IDELEMS(I)-1;j>=0;j--)
497 {
498 if(p_GetExp(I->m[j],i,currRing) > dummy)
499 {
500 dummy = p_GetExp(I->m[j],i,currRing);
501 }
502 }
503 p_SetExp(m,i,dummy,currRing);
504 }
506 return(m);
507}

◆ makeQt()

static ring makeQt ( )
static

Definition at line 832 of file hilb.cc.

833{
834 ring Qt=(ring) omAlloc0Bin(sip_sring_bin);
835 Qt->cf = nInitChar(n_Q, NULL);
836 Qt->N=1;
837 Qt->names=(char**)omAlloc(sizeof(char_ptr));
838 Qt->names[0]=omStrDup("t");
839 Qt->wvhdl=(int **)omAlloc0(3 * sizeof(int_ptr));
840 Qt->order = (rRingOrder_t *) omAlloc(3 * sizeof(rRingOrder_t *));
841 Qt->block0 = (int *)omAlloc0(3 * sizeof(int *));
842 Qt->block1 = (int *)omAlloc0(3 * sizeof(int *));
843 /* ringorder lp for the first block: var 1 */
844 Qt->order[0] = ringorder_lp;
845 Qt->block0[0] = 1;
846 Qt->block1[0] = 1;
847 /* ringorder C for the second block: no vars */
848 Qt->order[1] = ringorder_C;
849 /* the last block: everything is 0 */
850 Qt->order[2] = (rRingOrder_t)0;
851 rComplete(Qt);
852 return Qt;
853}
@ n_Q
rational (GMP) numbers
Definition coeffs.h:30
#define omAlloc0Bin(bin)
BOOLEAN rComplete(ring r, int force)
this needs to be called whenever a new ring is created: new fields in ring are created (like VarOffse...
Definition ring.cc:3526
VAR omBin sip_sring_bin
Definition ring.cc:43
rRingOrder_t
order stuff
Definition ring.h:69
@ ringorder_lp
Definition ring.h:78
@ ringorder_C
Definition ring.h:74
char * char_ptr
Definition structs.h:49
int * int_ptr
Definition structs.h:50

◆ minimalMonomialGenSet()

static ideal minimalMonomialGenSet ( ideal I)
static

Definition at line 1211 of file hilb.cc.

1212{
1213 /*
1214 * eliminates monomials which
1215 * can be generated by others in I
1216 */
1217 //first sort monomials of the ideal
1218
1219 idSkipZeroes(I);
1220
1222
1223 int i, k;
1224 int ICount = IDELEMS(I);
1225
1226 for(k = ICount - 1; k >=1; k--)
1227 {
1228 for(i = 0; i < k; i++)
1229 {
1230
1231 if(p_LmDivisibleBy(I->m[i], I->m[k], currRing))
1232 {
1233 pDelete(&(I->m[k]));
1234 break;
1235 }
1236 }
1237 }
1238
1239 idSkipZeroes(I);
1240 return(I);
1241}
static void sortMonoIdeal_pCompare(ideal I)
Definition hilb.cc:1198
static BOOLEAN p_LmDivisibleBy(poly a, poly b, const ring r)
Definition p_polys.h:1907

◆ monCompare()

static int monCompare ( const void * m,
const void * n )
static

Definition at line 1191 of file hilb.cc.

1192{
1193 /* compares monomials */
1194
1195 return(p_Compare(*(poly*) m, *(poly*)n, currRing));
1196}
int p_Compare(const poly a, const poly b, const ring R)
Definition p_polys.cc:5005

◆ p_Div_hi()

static BOOLEAN p_Div_hi ( poly p,
const int * exp_q,
const ring src )
static

Definition at line 1787 of file hilb.cc.

1788{
1790 // e=max(0,p-q) for all exps
1791 for(int i=src->N;i>0;i--)
1792 {
1793 int pi=p_GetExp(p,i,src)-exp_q[i];
1794 if (pi<0)
1795 {
1796 pi=0;
1797 bad=TRUE;
1798 }
1799 p_SetExp(p,i,pi,src);
1800 }
1801 #ifdef PDEBUG
1802 p_Setm(p,src);
1803 #endif
1804 return bad;
1805}
#define pi
Definition libparse.cc:1145

◆ positionInOrbit_FG_Case()

static int positionInOrbit_FG_Case ( ideal I,
poly ,
std::vector< ideal > idorb,
std::vector< poly > ,
int ,
int  )
static

Definition at line 1086 of file hilb.cc.

1087{
1088 /*
1089 * It compares the ideal I with ideals in the set 'idorb'.
1090 * I and ideals of 'idorb' are sorted.
1091 *
1092 * It returns 0 if I is not equal to any ideal of 'idorb'
1093 * else returns position of the matched ideal.
1094 */
1095 int ps = 0;
1096 int i, s = 0;
1097 int OrbCount = idorb.size();
1098
1099 if(idIs0(I))
1100 {
1101 return(1);
1102 }
1103
1104 for(i = 1; i < OrbCount; i++)
1105 {
1106 s = comapreMonoIdBases(I, idorb[i]);
1107 if(s)
1108 {
1109 ps = i + 1;
1110 break;
1111 }
1112 }
1113
1114 return(ps);
1115}
static int comapreMonoIdBases(ideal J, ideal Ob)
Definition hilb.cc:915

◆ positionInOrbit_IG_Case()

static int positionInOrbit_IG_Case ( ideal I,
poly w,
std::vector< ideal > idorb,
std::vector< poly > polist,
int trInd,
int  )
static

Definition at line 1008 of file hilb.cc.

1009{
1010 /*
1011 * It compares the ideal I with ideals in the set 'idorb'
1012 * up to total degree =
1013 * trInd - max(deg of w, deg of word in polist) polynomials.
1014 *
1015 * It returns 0 if I is not equal to any ideal in the
1016 * 'idorb' else returns position of the matched ideal.
1017 */
1018
1019 int ps = 0;
1020 int i, s = 0;
1021 int orbCount = idorb.size();
1022
1023 if(idIs0(I))
1024 {
1025 return(1);
1026 }
1027
1028 int degw = p_Totaldegree(w, currRing);
1029 int degp;
1030 int dtr;
1031 int dtrp;
1032
1033 dtr = trInd - degw;
1034 int IwCount;
1035
1036 IwCount = CountOnIdUptoTruncationIndex(I, dtr);
1037
1038 if(IwCount == 0)
1039 {
1040 return(1);
1041 }
1042
1043 int ObCount;
1044
1045 bool flag2 = FALSE;
1046
1047 for(i = 1;i < orbCount; i++)
1048 {
1049 degp = p_Totaldegree(polist[i], currRing);
1050 if(degw > degp)
1051 {
1052 dtr = trInd - degw;
1053
1054 ObCount = 0;
1055 ObCount = CountOnIdUptoTruncationIndex(idorb[i], dtr);
1056 if(ObCount == 0)
1057 {continue;}
1058 if(flag2)
1059 {
1060 IwCount = 0;
1061 IwCount = CountOnIdUptoTruncationIndex(I, dtr);
1062 flag2 = FALSE;
1063 }
1064 }
1065 else
1066 {
1067 flag2 = TRUE;
1068 dtrp = trInd - degp;
1069 ObCount = 0;
1070 ObCount = CountOnIdUptoTruncationIndex(idorb[i], dtrp);
1071 IwCount = 0;
1072 IwCount = CountOnIdUptoTruncationIndex(I, dtrp);
1073 }
1074
1075 s = comapreMonoIdBases_IG_Case(I, IwCount, idorb[i], ObCount);
1076
1077 if(s)
1078 {
1079 ps = i + 1;
1080 break;
1081 }
1082 }
1083 return(ps);
1084}
static int comapreMonoIdBases_IG_Case(ideal J, int JCount, ideal Ob, int ObCount)
Definition hilb.cc:973
static int CountOnIdUptoTruncationIndex(ideal I, int tr)
Definition hilb.cc:946

◆ positionInOrbitTruncationCase()

static int positionInOrbitTruncationCase ( ideal I,
poly w,
std::vector< ideal > idorb,
std::vector< poly > polist,
int ,
int trunDegHs )
static

Definition at line 1117 of file hilb.cc.

1118{
1119 /*
1120 * It compares the ideal I with ideals in the set 'idorb'.
1121 * I and ideals in 'idorb' are sorted.
1122
1123 * returns 0 if I is not equal to any ideal of 'idorb'
1124 * else returns position of the matched ideal.
1125 */
1126
1127 int ps = 0;
1128 int i, s = 0;
1129 int OrbCount = idorb.size();
1130 int dtr=0; int IwCount, ObCount;
1131 dtr = trunDegHs - 1 - p_Totaldegree(w, currRing);
1132
1133 if(idIs0(I))
1134 {
1135 for(i = 1; i < OrbCount; i++)
1136 {
1137 if(p_Totaldegree(w, currRing) == p_Totaldegree(polist[i], currRing))
1138 {
1139 if(idIs0(idorb[i]))
1140 return(i+1);
1141 ObCount=0;
1142 ObCount = CountOnIdUptoTruncationIndex(idorb[i], dtr);
1143 if(ObCount==0)
1144 {
1145 ps = i + 1;
1146 break;
1147 }
1148 }
1149 }
1150
1151 return(ps);
1152 }
1153
1154 IwCount = CountOnIdUptoTruncationIndex(I, dtr);
1155
1156 if(p_Totaldegree(I->m[0], currRing)==0)
1157 {
1158 for(i = 1; i < OrbCount; i++)
1159 {
1160 if(idIs0(idorb[i]))
1161 continue;
1162 if(p_Totaldegree(idorb[i]->m[0], currRing)==0)
1163 {
1164 ps = i + 1;
1165 break;
1166 }
1167 }
1168 return(ps);
1169 }
1170
1171 for(i = 1; i < OrbCount; i++)
1172 {
1173 if(p_Totaldegree(w, currRing) == p_Totaldegree(polist[i], currRing))
1174 {
1175 if(idIs0(idorb[i]))
1176 continue;
1177 ObCount=0;
1178 ObCount = CountOnIdUptoTruncationIndex(idorb[i], dtr);
1179 s = comapreMonoIdBases_IG_Case(I, IwCount, idorb[i], ObCount);
1180 if(s)
1181 {
1182 ps = i + 1;
1183 break;
1184 }
1185 }
1186 }
1187
1188 return(ps);
1189}

◆ RightColonOperation()

ideal RightColonOperation ( ideal S,
poly w,
int lV )

Definition at line 1753 of file hilb.cc.

1754{
1755 /*
1756 * This returns right colon ideal of a monomial two-sided ideal of
1757 * the free associative algebra with respect to a monomial 'w'
1758 * (S:_R w).
1759 */
1760 S = minimalMonomialGenSet(S);
1761 ideal Iw = idInit(1,1);
1762 Iw = colonIdeal(S, w, lV, Iw, 0);
1763 return (Iw);
1764}

◆ rouneslice()

static void rouneslice ( ideal I,
ideal S,
poly q,
poly x,
int & prune,
int & moreprune,
int & steps,
int & NNN,
mpz_ptr & hilbertcoef,
int *& hilbpower )
static

Definition at line 510 of file hilb.cc.

511{
512 loop
513 {
514 (steps)++;
515 int i,j;
516 int dummy;
517 poly m;
518 ideal p;
519 //----------- PRUNING OF S ---------------
520 //S SHOULD IN THIS POINT BE ORDERED BY DEGREE
521 for(i=IDELEMS(S)-1;i>=0;i--)
522 {
523 if(IsIn(S->m[i],I))
524 {
525 p_Delete(&S->m[i],currRing);
526 prune++;
527 }
528 }
529 idSkipZeroes(S);
530 //----------------------------------------
531 for(i=IDELEMS(I)-1;i>=0;i--)
532 {
533 m = p_Head(I->m[i],currRing);
534 for(j=1;j<=currRing->N;j++)
535 {
536 dummy = p_GetExp(m,j,currRing);
537 if(dummy > 0)
538 {
539 p_SetExp(m,j,dummy-1,currRing);
540 }
541 }
542 p_Setm(m, currRing);
543 if(IsIn(m,S))
544 {
545 p_Delete(&I->m[i],currRing);
546 //printf("\n Deleted, since pi(m) is in S\n");pWrite(m);
547 }
549 }
550 idSkipZeroes(I);
551 //----------- MORE PRUNING OF S ------------
552 m = LCMmon(I);
553 if(m != NULL)
554 {
555 for(i=0;i<IDELEMS(S);i++)
556 {
557 if(!(p_DivisibleBy(S->m[i], m, currRing)))
558 {
559 S->m[i] = NULL;
560 j++;
561 moreprune++;
562 }
563 else
564 {
565 if(pLmEqual(S->m[i],m))
566 {
567 S->m[i] = NULL;
568 moreprune++;
569 }
570 }
571 }
572 idSkipZeroes(S);
573 }
575 /*printf("\n---------------------------\n");
576 printf("\n I\n");idPrint(I);
577 printf("\n S\n");idPrint(S);
578 printf("\n q\n");pWrite(q);
579 getchar();*/
580
581 if(idIs0(I))
582 {
583 id_Delete(&I, currRing);
584 id_Delete(&S, currRing);
585 break;
586 }
587 m = LCMmon(I);
589 {
590 //printf("\nx does not divide lcm(I)");
591 //printf("\nEmpty set");pWrite(q);
592 id_Delete(&I, currRing);
593 id_Delete(&S, currRing);
595 break;
596 }
598 m = SqFree(I);
599 if(m==NULL)
600 {
601 //printf("\n Corner: ");
602 //pWrite(q);
603 //printf("\n With the facets of the dual simplex:\n");
604 //idPrint(I);
605 mpz_t ec;
606 mpz_init(ec);
607 mpz_ptr ec_ptr = ec;
608 eulerchar(I, currRing->N, ec_ptr);
609 bool flag = FALSE;
610 if(NNN==0)
611 {
612 hilbertcoef = (mpz_ptr)omAlloc((NNN+1)*sizeof(mpz_t));
613 hilbpower = (int*)omAlloc((NNN+1)*sizeof(int));
614 mpz_init_set( &hilbertcoef[NNN], ec);
615 hilbpower[NNN] = p_Totaldegree(q,currRing);
616 NNN++;
617 }
618 else
619 {
620 //I look if the power appears already
621 for(i = 0;(i<NNN)&&(flag == FALSE)&&(p_Totaldegree(q,currRing)>=hilbpower[i]);i++)
622 {
623 if((hilbpower[i]) == (p_Totaldegree(q,currRing)))
624 {
625 flag = TRUE;
626 mpz_add(&hilbertcoef[i],&hilbertcoef[i],ec_ptr);
627 }
628 }
629 if(flag == FALSE)
630 {
631 hilbertcoef = (mpz_ptr)omRealloc(hilbertcoef, (NNN+1)*sizeof(mpz_t));
632 hilbpower = (int*)omRealloc(hilbpower, (NNN+1)*sizeof(int));
633 mpz_init(&hilbertcoef[NNN]);
634 for(j = NNN; j>i; j--)
635 {
636 mpz_set(&hilbertcoef[j],&hilbertcoef[j-1]);
637 hilbpower[j] = hilbpower[j-1];
638 }
639 mpz_set( &hilbertcoef[i], ec);
640 hilbpower[i] = p_Totaldegree(q,currRing);
641 NNN++;
642 }
643 }
644 mpz_clear(ec);
645 id_Delete(&I, currRing);
646 id_Delete(&S, currRing);
647 break;
648 }
649 else
651 m = ChooseP(I);
652 p = idInit(1,1);
653 p->m[0] = m;
654 ideal Ip = idQuotMon(I,p);
655 ideal Sp = idQuotMon(S,p);
656 poly pq = pp_Mult_mm(q,m,currRing);
657 rouneslice(Ip, Sp, pq, x, prune, moreprune, steps, NNN, hilbertcoef,hilbpower);
658 idAddMon(S,p);
659 p->m[0]=NULL;
660 id_Delete(&p, currRing); // p->m[0] was also in S
661 p_Delete(&pq,currRing);
662 }
663}
void FACTORY_PUBLIC prune(Variable &alpha)
Definition variable.cc:261
static void rouneslice(ideal I, ideal S, poly q, poly x, int &prune, int &moreprune, int &steps, int &NNN, mpz_ptr &hilbertcoef, int *&hilbpower)
Definition hilb.cc:510
static poly SqFree(ideal I)
Definition hilb.cc:416
static poly ChooseP(ideal I)
Definition hilb.cc:329
static poly LCMmon(ideal I)
Definition hilb.cc:484
static bool IsIn(poly p, ideal I)
Definition hilb.cc:445
#define omRealloc(addr, size)
static poly pp_Mult_mm(poly p, poly m, const ring r)
Definition p_polys.h:1033
static BOOLEAN p_DivisibleBy(poly a, poly b, const ring r)
Definition p_polys.h:1916
#define pLmEqual(p1, p2)
Definition polys.h:112

◆ scDegree()

void scDegree ( ideal S,
intvec * modulweight,
ideal Q )

Definition at line 2693 of file hilb.cc.

2694{
2695 int co;
2696 int mu=0;
2697#if 0
2698 if (hilb_Qt==NULL) hilb_Qt=makeQt();
2699 poly h1;
2700 if (id_IsModule(S,currRing))
2702 else
2703 h1 = hFirstSeries0m(S,Q,NULL, modulweight,currRing,hilb_Qt);
2704
2705 poly h2=hFirst2Second(h1,hilb_Qt,co);
2706 int di = (currRing->N)-co;
2707 if (h1==NULL) di=0;
2708 poly p=h2;
2709 while(p!=NULL)
2710 {
2711 mu+=n_Int(pGetCoeff(p),hilb_Qt->cf);
2713 }
2714#else
2716 intvec *hseries1=new intvec(1,h1->cols());
2717 for(int i=0;i<h1->cols();i++)
2718 {
2719 (*hseries1)[i]=n_Int(BIMATELEM(*h1,1,i+1),coeffs_BIGINT);
2720 }
2721 delete h1;
2722 intvec *hseries2;
2723 int l = hseries1->length()-1;
2724 if (l > 1)
2725 hseries2 = hSecondSeries(hseries1);
2726 else
2727 hseries2 = hseries1;
2728 hDegreeSeries(hseries1, hseries2, &co, &mu);
2729 if (l>1)
2730 delete hseries1;
2731 delete hseries2;
2732 if ((l == 1) &&(mu == 0))
2733 scPrintDegree((currRing->N)+1, 0);
2734 else
2735#endif
2736 scPrintDegree(co, mu);
2737}
void scPrintDegree(int co, int mu)
Definition hdegree.cc:910
intvec * hSecondSeries(intvec *hseries1)
Definition hilb.cc:707
bigintmat * hFirstSeries0b(ideal I, ideal Q, intvec *wdegree, intvec *shifts, const ring src, const coeffs biv_cf)
Definition hilb.cc:2655
void hDegreeSeries(intvec *s1, intvec *s2, int *co, int *mu)
Definition hilb.cc:742
VAR coeffs coeffs_BIGINT
Definition polys.cc:14

◆ SearchP()

static poly SearchP ( ideal I)
static

searches for a monomial of degree d>=2 and divides it by a variable (result monomial of deg d-1)

Definition at line 337 of file hilb.cc.

338{
339 int i,j,exp;
340 poly res;
341 if(p_Totaldegree(I->m[IDELEMS(I)-1],currRing)<=1)
342 {
343 res = ChoosePVar(I);
344 return(res);
345 }
346 i = IDELEMS(I)-1;
347 res = p_Copy(I->m[i], currRing);
348 for(j=1;j<=currRing->N;j++)
349 {
350 exp = p_GetExp(I->m[i], j, currRing);
351 if(exp > 0)
352 {
353 p_SetExp(res, j, exp - 1, currRing);
355 break;
356 }
357 }
359 return(res);
360}
const CanonicalForm CFMap CFMap & N
Definition cfEzgcd.cc:56
#define assume(x)
Definition mod2.h:389

◆ shiftInMon()

static poly shiftInMon ( poly p,
int i,
int lV,
const ring r )
static

Definition at line 1243 of file hilb.cc.

1244{
1245 /*
1246 * shifts the variables of monomial p in the i^th layer,
1247 * p remains unchanged,
1248 * creates new poly and returns it for the colon ideal
1249 */
1250 poly smon = p_One(r);
1251 int j, sh, cnt;
1252 cnt = r->N;
1253 sh = i*lV;
1254 int *e=(int *)omAlloc((r->N+1)*sizeof(int));
1255 int *s=(int *)omAlloc0((r->N+1)*sizeof(int));
1256 p_GetExpV(p, e, r);
1257
1258 for(j = 1; j <= cnt; j++)
1259 {
1260 if(e[j] == 1)
1261 {
1262 s[j+sh] = e[j];
1263 }
1264 }
1265
1266 p_SetExpV(smon, s, currRing);
1267 omFree(e);
1268 omFree(s);
1269
1271 p_Setm(smon, currRing);
1272
1273 return(smon);
1274}

◆ slicehilb()

void slicehilb ( ideal I)

Definition at line 666 of file hilb.cc.

667{
668 //printf("Adi changes are here: \n");
669 int i, NNN = 0;
670 int steps = 0, prune = 0, moreprune = 0;
671 mpz_ptr hilbertcoef;
672 int *hilbpower;
673 ideal S = idInit(1,1);
674 poly q = p_One(currRing);
675 ideal X = idInit(1,1);
676 X->m[0]=p_One(currRing);
677 for(i=1;i<=currRing->N;i++)
678 {
679 p_SetExp(X->m[0],i,1,currRing);
680 }
681 p_Setm(X->m[0],currRing);
682 I = id_Mult(I,X,currRing);
683 ideal Itmp = SortByDeg(I);
685 I = Itmp;
686 //printf("\n-------------RouneSlice--------------\n");
687 rouneslice(I,S,q,X->m[0],prune, moreprune, steps, NNN, hilbertcoef, hilbpower);
689 p_Delete(&q,currRing);
690 //printf("\nIn total Prune got rid of %i elements\n",prune);
691 //printf("\nIn total More Prune got rid of %i elements\n",moreprune);
692 //printf("\nSteps of rouneslice: %i\n\n", steps);
693 printf("\n// %8d t^0",1);
694 for(i = 0; i<NNN; i++)
695 {
696 if(mpz_sgn(&hilbertcoef[i])!=0)
697 {
698 gmp_printf("\n// %8Zd t^%d",&hilbertcoef[i],hilbpower[i]);
699 }
700 }
701 PrintLn();
702 omFreeSize(hilbertcoef, (NNN)*sizeof(mpz_t));
703 omFreeSize(hilbpower, (NNN)*sizeof(int));
704 //printf("\n-------------------------------------\n");
705}
static ideal SortByDeg(ideal I)
Definition hilb.cc:177
ideal id_Mult(ideal h1, ideal h2, const ring R)
h1 * h2 one h_i must be an ideal (with at least one column) the other h_i may be a module (with no co...

◆ SortByDeg()

static ideal SortByDeg ( ideal I)
static

Definition at line 177 of file hilb.cc.

178{
179 if(idIs0(I))
180 {
181 return id_Copy(I,currRing);
182 }
183 int i;
184 ideal res;
185 idSkipZeroes(I);
186 res = idInit(1,1);
187 for(i = 0; i<=IDELEMS(I)-1;i++)
188 {
189 SortByDeg_p(res, I->m[i]);
190 I->m[i]=NULL; // I->m[i] is now in res
191 }
193 //idDegSortTest(res);
194 return(res);
195}
ideal id_Copy(ideal h1, const ring r)
copy an ideal

◆ SortByDeg_p()

static void SortByDeg_p ( ideal I,
poly p )
static

Definition at line 77 of file hilb.cc.

78{
79 int i,j;
80 if(idIs0(I))
81 {
82 I->m[0] = p;
83 return;
84 }
85 idSkipZeroes(I);
86 #if 1
87 for(i = 0; (i<IDELEMS(I)) && (p_Totaldegree(I->m[i],currRing)<=p_Totaldegree(p,currRing)); i++)
88 {
89 if(p_DivisibleBy( I->m[i],p, currRing))
90 {
92 return;
93 }
94 }
95 for(i = IDELEMS(I)-1; (i>=0) && (p_Totaldegree(I->m[i],currRing)>=p_Totaldegree(p,currRing)); i--)
96 {
97 if(p_DivisibleBy(p,I->m[i], currRing))
98 {
99 p_Delete(&I->m[i],currRing);
100 }
101 }
102 if(idIs0(I))
103 {
104 idSkipZeroes(I);
105 I->m[0] = p;
106 return;
107 }
108 #endif
109 idSkipZeroes(I);
110 //First I take the case when all generators have the same degree
111 if(p_Totaldegree(I->m[0],currRing) == p_Totaldegree(I->m[IDELEMS(I)-1],currRing))
112 {
114 {
115 idInsertPoly(I,p);
116 idSkipZeroes(I);
117 for(i=IDELEMS(I)-1;i>=1; i--)
118 {
119 I->m[i] = I->m[i-1];
120 }
121 I->m[0] = p;
122 return;
123 }
125 {
126 idInsertPoly(I,p);
127 idSkipZeroes(I);
128 return;
129 }
130 }
132 {
133 idInsertPoly(I,p);
134 idSkipZeroes(I);
135 for(i=IDELEMS(I)-1;i>=1; i--)
136 {
137 I->m[i] = I->m[i-1];
138 }
139 I->m[0] = p;
140 return;
141 }
143 {
144 idInsertPoly(I,p);
145 idSkipZeroes(I);
146 return;
147 }
148 for(i = IDELEMS(I)-2; ;)
149 {
151 {
152 idInsertPoly(I,p);
153 idSkipZeroes(I);
154 for(j = IDELEMS(I)-1; j>=i+1;j--)
155 {
156 I->m[j] = I->m[j-1];
157 }
158 I->m[i] = p;
159 return;
160 }
162 {
163 idInsertPoly(I,p);
164 idSkipZeroes(I);
165 for(j = IDELEMS(I)-1; j>=i+2;j--)
166 {
167 I->m[j] = I->m[j-1];
168 }
169 I->m[i+1] = p;
170 return;
171 }
172 i--;
173 }
174}
BOOLEAN idInsertPoly(ideal h1, poly h2)
insert h2 into h1 (if h2 is not the zero polynomial) return TRUE iff h2 was indeed inserted

◆ sortMonoIdeal_pCompare()

static void sortMonoIdeal_pCompare ( ideal I)
static

Definition at line 1198 of file hilb.cc.

1199{
1200 /*
1201 * sorts monomial ideal in ascending order
1202 * order must be a total degree
1203 */
1204
1205 qsort(I->m, IDELEMS(I), sizeof(poly), monCompare);
1206
1207}
static int monCompare(const void *m, const void *n)
Definition hilb.cc:1191

◆ SqFree()

static poly SqFree ( ideal I)
static

Definition at line 416 of file hilb.cc.

417{
418 int i,j;
419 bool flag=TRUE;
420 poly notsqrfree = NULL;
421 if(p_Totaldegree(I->m[IDELEMS(I)-1],currRing)<=1)
422 {
423 return(notsqrfree);
424 }
425 for(i=IDELEMS(I)-1;(i>=0)&&(flag);i--)
426 {
427 for(j=1;(j<=currRing->N)&&(flag);j++)
428 {
429 if(p_GetExp(I->m[i],j,currRing)>1)
430 {
431 flag=FALSE;
432 notsqrfree = p_ISet(1,currRing);
433 p_SetExp(notsqrfree,j,1,currRing);
434 }
435 }
436 }
437 if(notsqrfree != NULL)
438 {
439 p_Setm(notsqrfree,currRing);
440 }
441 return(notsqrfree);
442}

◆ TwordMap()

static void TwordMap ( poly p,
poly w,
int lV,
int d,
ideal Jwi,
bool & flag )
static

Definition at line 1310 of file hilb.cc.

1311{
1312 /*
1313 * computes T_w(p) in a new poly object and places it
1314 * in Jwi which stores elements of colon ideal of I,
1315 * p and w remain unchanged,
1316 * the new polys for Jwi are constructed by sub-routines
1317 * deleteInMon, shiftInMon, p_MDivide,
1318 * places the result in Jwi and deletes the new polys
1319 * coming in dw, smon, qmon
1320 */
1321 int i;
1322 poly smon, dw;
1323 poly qmonp = NULL;
1324 bool del;
1325
1326 for(i = 0;i <= d - 1; i++)
1327 {
1328 dw = deleteInMon(w, i, lV, currRing);
1329 smon = shiftInMon(p, i, lV, currRing);
1330 del = TRUE;
1331
1332 if(pLmDivisibleBy(smon, w))
1333 {
1334 flag = TRUE;
1335 del = FALSE;
1336
1337 pDelete(&dw);
1338 pDelete(&smon);
1339
1340 //delete all monomials of Jwi
1341 //and make Jwi =1
1342
1343 for(int j = 0;j < IDELEMS(Jwi); j++)
1344 {
1345 pDelete(&Jwi->m[j]);
1346 }
1347
1349 break;
1350 }
1351
1352 if(pLmDivisibleBy(dw, smon))
1353 {
1354 del = FALSE;
1355 qmonp = p_MDivide(smon, dw, currRing);
1356 idInsertMonomial(Jwi, shiftInMon(qmonp, -d, lV, currRing));
1357 pLmFree(&qmonp);
1358 pDelete(&dw);
1359 pDelete(&smon);
1360 }
1361 //in case both if are false, delete dw and smon
1362 if(del)
1363 {
1364 pDelete(&dw);
1365 pDelete(&smon);
1366 }
1367 }
1368
1369}
static poly deleteInMon(poly w, int i, int lV, const ring r)
Definition hilb.cc:1276
static poly shiftInMon(poly p, int i, int lV, const ring r)
Definition hilb.cc:1243
poly p_MDivide(poly a, poly b, const ring r)
Definition p_polys.cc:1493
#define pLmDivisibleBy(a, b)
like pDivisibleBy, except that it is assumed that a!=NULL, b!=NULL
Definition polys.h:141
static void pLmFree(poly p)
frees the space of the monomial m, assumes m != NULL coef is not freed, m is not advanced
Definition polys.h:71

Variable Documentation

◆ hilb_Qt

STATIC_VAR ring hilb_Qt =NULL

Definition at line 855 of file hilb.cc.

◆ hLength

STATIC_VAR int hLength

Definition at line 69 of file hilb.cc.

◆ Q0

Definition at line 68 of file hilb.cc.

◆ Ql

Definition at line 68 of file hilb.cc.

◆ Qpol

STATIC_VAR int64** Qpol

Definition at line 67 of file hilb.cc.