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

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

◆ colonIdeal()

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

Definition at line 735 of file hilb.cc.

736{
737 /*
738 * It computes the right colon ideal of a two-sided ideal S
739 * w.r.t. word w and save it in a new object Jwi.
740 * It keeps S and w unchanged.
741 */
742
743 if(idIs0(S))
744 {
745 return(S);
746 }
747
748 int i, d;
750 if(trunDegHs !=0 && d >= trunDegHs)
751 {
753 return(Jwi);
754 }
755 bool flag = FALSE;
756 int SCount = IDELEMS(S);
757 for(i = 0; i < SCount; i++)
758 {
759 TwordMap(S->m[i], w, lV, d, Jwi, flag);
760 if(flag)
761 {
762 break;
763 }
764 }
765
766 Jwi = minimalMonomialGenSet(Jwi);
767 return(Jwi);
768}
#define FALSE
Definition auxiliary.h:97
int i
Definition cfEzgcd.cc:132
const CanonicalForm & w
Definition facAbsFact.cc:51
static void idInsertMonomial(ideal I, poly p)
Definition hilb.cc:252
static void TwordMap(poly p, poly w, int lV, int d, ideal Jwi, bool &flag)
Definition hilb.cc:674
static ideal minimalMonomialGenSet(ideal I)
Definition hilb.cc:575
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:1528
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13
#define IDELEMS(i)

◆ comapreMonoIdBases()

int comapreMonoIdBases ( ideal J,
ideal Ob )
static

Definition at line 279 of file hilb.cc.

280{
281 /*
282 * Monomials of J and Ob are assumed to
283 * be already sorted. J and Ob are
284 * represented by the minimal generating set.
285 */
286 int i, s;
287 s = 1;
288 int JCount = IDELEMS(J);
289 int ObCount = IDELEMS(Ob);
290
291 if(idIs0(J))
292 {
293 return(1);
294 }
295 if(JCount != ObCount)
296 {
297 return(0);
298 }
299
300 for(i = 0; i < JCount; i++)
301 {
302 if(!(p_LmEqual(J->m[i], Ob->m[i], currRing)))
303 {
304 return(0);
305 }
306 }
307 return(s);
308}
const CanonicalForm int s
Definition facAbsFact.cc:51
#define p_LmEqual(p1, p2, r)
Definition p_polys.h:1744

◆ comapreMonoIdBases_IG_Case()

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

Definition at line 337 of file hilb.cc.

338{
339 /*
340 * Monomials of J and Ob are assumed to
341 * be already sorted in increasing degrees.
342 * J and Ob are represented by the minimal
343 * generating set. It checks if J and Ob have
344 * same monomials up to deg <=tr.
345 */
346
347 int i, s;
348 s = 1;
349 //when J is null
350 //
351 if(JCount != ObCount)
352 {
353 return(0);
354 }
355
356 if(JCount == 0)
357 {
358 return(1);
359 }
360
361 for(i = 0; i< JCount; i++)
362 {
363 if(!(p_LmEqual(J->m[i], Ob->m[i], currRing)))
364 {
365 return(0);
366 }
367 }
368
369 return(s);
370}

◆ compare_rp_currRing()

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

Definition at line 1191 of file hilb.cc.

1192{
1193 poly p1=*(poly*)pp1;
1194 poly p2=*(poly*)pp2;
1195 for(int i=currRing->N;i>0;i--)
1196 {
1197 int e1=p_GetExp(p1,i,currRing);
1198 int e2=p_GetExp(p2,i,currRing);
1199 if(e1<e2) return -1;
1200 if(e1>e2) return 1;
1201 }
1202 return 0;
1203}
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

◆ CountOnIdUptoTruncationIndex()

int CountOnIdUptoTruncationIndex ( ideal I,
int tr )
static

Definition at line 310 of file hilb.cc.

311{
312 /*
313 * The ideal I must be sorted in increasing total degree.
314 * It counts the number of monomials in I up to
315 * degree less than or equal to tr.
316 */
317
318 //case when I=1;
319 if(p_Totaldegree(I->m[0], currRing) == 0)
320 {
321 return(1);
322 }
323
324 int count = 0;
325 for(int i = 0; i < IDELEMS(I); i++)
326 {
327 if(p_Totaldegree(I->m[i], currRing) > tr)
328 {
329 return (count);
330 }
331 count = count + 1;
332 }
333
334 return(count);
335}
int status int void size_t count
Definition si_signals.h:69

◆ deleteInMon()

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

Definition at line 640 of file hilb.cc.

641{
642 /*
643 * deletes the variables up to i^th layer of monomial w
644 * w remains unchanged
645 * creates new poly and returns it for the colon ideal
646 */
647
648 poly dw = p_One(currRing);
649 int *e = (int *)omAlloc((r->N+1)*sizeof(int));
650 int *s=(int *)omAlloc0((r->N+1)*sizeof(int));
651 p_GetExpV(w, e, r);
652 int j, cnt;
653 cnt = i*lV;
654 /*
655 for(j=1;j<=cnt;j++)
656 {
657 e[j]=0;
658 }*/
659 for(j = (cnt+1); j < (r->N+1); j++)
660 {
661 s[j] = e[j];
662 }
663
664 p_SetExpV(dw, s, currRing);//new exponents
665 omFree(e);
666 omFree(s);
667
669 p_Setm(dw, currRing);
670
671 return(dw);
672}
int j
Definition facHensel.cc:110
#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:1565
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition p_polys.h:249
static void p_Setm(poly p, const ring r)
Definition p_polys.h:235
static void p_GetExpV(poly p, int *ev, const ring r)
Definition p_polys.h:1541

◆ getModuleComp()

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

Definition at line 1501 of file hilb.cc.

1502{
1503 ideal res=idInit(IDELEMS(A),A->rank);
1504 for (int i=0;i<IDELEMS(A);i++)
1505 {
1506 if ((A->m[i]!=NULL) && (p_GetComp(A->m[i],src)==c))
1507 res->m[i]=p_Head(A->m[i],src);
1508 }
1509 return res;
1510}
CanonicalForm res
Definition facAbsFact.cc:60
#define NULL
Definition omList.c:12
static poly p_Head(const poly p, const ring r)
copy the (leading) term of p
Definition p_polys.h:862
ideal idInit(int idsize, int rank)
initialise an ideal / module
#define A
Definition sirandom.c:24

◆ hAddHilb()

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

Definition at line 1616 of file hilb.cc.

1617{
1618 int l = *lp, ln, i;
1619 int64 *pon;
1620 *lp = ln = l + x;
1621 pon = Qpol[Nv];
1622 memcpy(pon, pol, l * sizeof(int64));
1623 if (l > x)
1624 {/*pon[i] -= pol[i - x];*/
1625 for (i = x; i < l; i++)
1626 {
1627 #ifndef __SIZEOF_INT128__
1628 int64 t=pon[i];
1629 int64 t2=pol[i - x];
1630 t-=t2;
1631 if ((t>=OVERFLOW_MIN)&&(t<=OVERFLOW_MAX)) pon[i]=t;
1632 else if (!errorreported) WerrorS("int overflow in hilb 1");
1633 #else
1634 __int128 t=pon[i];
1635 __int128 t2=pol[i - x];
1636 t-=t2;
1637 if ((t>=LONG_MIN)&&(t<=LONG_MAX)) pon[i]=t;
1638 else if (!errorreported) WerrorS("long int overflow in hilb 1");
1639 #endif
1640 }
1641 for (i = l; i < ln; i++)
1642 { /*pon[i] = -pol[i - x];*/
1643 #ifndef __SIZEOF_INT128__
1644 int64 t= -pol[i - x];
1645 if ((t>=OVERFLOW_MIN)&&(t<=OVERFLOW_MAX)) pon[i]=t;
1646 else if (!errorreported) WerrorS("int overflow in hilb 2");
1647 #else
1648 __int128 t= -pol[i - x];
1649 if ((t>=LONG_MIN)&&(t<=LONG_MAX)) pon[i]=t;
1650 else if (!errorreported) WerrorS("long int overflow in hilb 2");
1651 #endif
1652 }
1653 }
1654 else
1655 {
1656 for (i = l; i < x; i++)
1657 pon[i] = 0;
1658 for (i = x; i < ln; i++)
1659 pon[i] = -pol[i - x];
1660 }
1661 return pon;
1662}
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 2003 of file hilb.cc.

2004{
2005 poly p=NULL;
2006 nMapFunc f=n_SetMap(biv_cf,Qt->cf);
2007 for(int d=0;d<b->rows()-1;d++)
2008 {
2009 poly h=p_New(Qt);
2010 p_SetExp(h,1,d,Qt);p_Setm(h,Qt);
2011 pSetCoeff0(h,f(BIMATELEM(*b,1,d+1),biv_cf,Qt->cf));
2012 p=p_Add_q(p,h,Qt);
2013 }
2014 return p;
2015}
#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:703
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 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 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 106 of file hilb.cc.

107{
108 int i, j, k;
109 int m;
110 *co = *mu = 0;
111 if ((s1 == NULL) || (s2 == NULL))
112 return;
113 i = s1->length();
114 j = s2->length();
115 if (j > i)
116 return;
117 m = 0;
118 for(k=j-2; k>=0; k--)
119 m += (*s2)[k];
120 *mu = m;
121 *co = i - j;
122}
int m
Definition cfEzgcd.cc:128
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 124 of file hilb.cc.

125{
126 poly o_t=p_One(Qt);p_SetExp(o_t,1,1,Qt);p_Setm(o_t,Qt);
127 o_t=p_Neg(o_t,Qt);
128 o_t=p_Add_q(p_One(Qt),o_t,Qt);
129 poly di1=p_Copy(h,Qt);
130 co=0;
131#if defined(HAVE_FLINT) && (__FLINT_RELEASE >= 20503)
132 poly di2;
133 fmpq_mpoly_ctx_t ctx;
134 convSingRFlintR(ctx,Qt);
135 loop
136 {
137 di2=Flint_Divide_MP(di1,0,o_t,0,ctx,Qt);
138 if (di2==NULL) break;
139 co++;
140 p_Delete(&di1,Qt);
141 di1=di2;
142 }
143#else
144 if (di1!=NULL)
145 {
148 CanonicalForm Di2,dummy;
149 loop
150 {
151 Di2=Di1/O_t;
152 dummy=Di2*O_t;
153 if (dummy!=Di1) break;
154 else Di1=Di2;
155 co++;
156 }
157 p_Delete(&di1,Qt);
158 di1=convFactoryPSingP(Di1,Qt);
159 }
160#endif
161 p_Delete(&o_t,Qt);
162 return di1;
163}
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:1114
static void p_Delete(poly *p, const ring r)
Definition p_polys.h:903
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition p_polys.h:848
#define loop
Definition structs.h:71

◆ hFirstSeries()

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

Definition at line 1512 of file hilb.cc.

1513{
1514 intvec* res;
1515 #if 0
1516 // find degree bound
1517 int a,b,prod;
1518 a=rVar(currRing);
1519 b=1;
1520 prod=a;
1521 while(prod<(1<<15) && (a>1))
1522 {
1523 a--;b++;
1524 prod*=a;
1525 prod/=b;
1526 }
1527 if (a==1) b=(1<<15);
1528 // check degree bound
1529 BOOLEAN large_deg=FALSE;
1530 int max=0;
1531 for(int i=IDELEMS(A)-1;i>=0;i--)
1532 {
1533 if (A->m[i]!=NULL)
1534 {
1535 int mm=p_Totaldegree(A->m[i],currRing);
1536 if (mm>max)
1537 {
1538 max=mm;
1539 if (max>=b)
1540 {
1541 large_deg=TRUE;
1542 break;
1543 }
1544 }
1545 }
1546 }
1547 if (!large_deg)
1548 {
1549 void (*WerrorS_save)(const char *s) = WerrorS_callback;
1551 res=hFirstSeries1(A,module_w,Q,wdegree);
1552 WerrorS_callback=WerrorS_save;
1553 if (errorreported==0)
1554 {
1555 return res;
1556 }
1557 else errorreported=0;// retry with other alg.:
1558 }
1559 #endif
1560
1561 if (hilb_Qt==NULL) hilb_Qt=makeQt();
1562 if (!id_IsModule(A,currRing))
1563 return hFirstSeries0(A,Q,wdegree,currRing,hilb_Qt);
1564 res=NULL;
1565 int w_max=0,w_min=0;
1566 if (module_w!=NULL)
1567 {
1568 w_max=module_w->max_in();
1569 w_min=module_w->min_in();
1570 }
1571 for(int c=1;c<=A->rank;c++)
1572 {
1573 ideal Ac=getModuleComp(A,c,currRing);
1574 intvec *res_c=hFirstSeries0(Ac,Q,wdegree,currRing,hilb_Qt);
1575 id_Delete(&Ac,currRing);
1576 intvec *tmp=NULL;
1577 if (res==NULL)
1578 res=new intvec(res_c->length()+(w_max-w_min));
1579 if ((module_w==NULL) || ((*module_w)[c-1]==0)) tmp=ivAdd(res,res_c);
1580 else tmp=ivAddShift(res, res_c,(*module_w)[c-1]-w_min);
1581 delete res_c;
1582 if (tmp!=NULL)
1583 {
1584 delete res;
1585 res=tmp;
1586 }
1587 }
1588 (*res)[res->length()-1]=w_min;
1589 return res;
1590}
int BOOLEAN
Definition auxiliary.h:88
#define TRUE
Definition auxiliary.h:101
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:196
static ideal getModuleComp(ideal A, int c, const ring src)
Definition hilb.cc:1501
intvec * hFirstSeries0(ideal A, ideal Q, intvec *wdegree, const ring src, const ring Qt)
Definition hilb.cc:1476
intvec * hFirstSeries1(ideal S, intvec *modulweight, ideal Q, intvec *wdegree)
Definition hilb.cc:1972
STATIC_VAR ring hilb_Qt
Definition hilb.cc:219
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:5665
static short rVar(const ring r)
define rVar(r) (r->N)
Definition ring.h:603
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
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 1476 of file hilb.cc.

1477{
1478 poly s=hFirstSeries0p(A,Q,wdegree,src,Qt);
1479 intvec *ss;
1480 if (s==NULL)
1481 ss=new intvec(2);
1482 else
1483 {
1484 ss=new intvec(p_Totaldegree(s,Qt)+2);
1485 while(s!=NULL)
1486 {
1487 int i=p_Totaldegree(s,Qt);
1488 long l=n_Int(pGetCoeff(s),Qt->cf);
1489 (*ss)[i]=n_Int(pGetCoeff(s),Qt->cf);
1490 if((l==0)||(l<=-INT_MAX)||(l>INT_MAX))
1491 {
1492 if(!errorreported) Werror("overflow in hilb at t^%d\n",i);
1493 }
1494 else (*ss)[i]=(int)l;
1495 p_LmDelete(&s,Qt);
1496 }
1497 }
1498 return ss;
1499}
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:550
poly hFirstSeries0p(ideal A, ideal Q, intvec *wdegree, const ring src, const ring Qt)
Definition hilb.cc:1384
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 2017 of file hilb.cc.

2018{
2019 if (hilb_Qt==NULL) hilb_Qt=makeQt();
2020 poly h;
2021 int m=0;
2022 if (id_IsModule(I,src))
2023 {
2024 h=hFirstSeries0m(I,Q,wdegree,shifts,src,hilb_Qt);
2025 if (shifts!=NULL) m=shifts->min_in();
2026 }
2027 else
2028 h=hFirstSeries0p(I,Q,wdegree,src,hilb_Qt);
2029 bigintmat *biv=hPoly2BIV(h,hilb_Qt,biv_cf);
2030 if (m!=0)
2031 {
2032 n_Delete(&BIMATELEM(*biv,1,biv->cols()),biv_cf);
2033 BIMATELEM(*biv,1,biv->cols())=n_Init(m,biv_cf);
2034 }
2035 p_Delete(&h,hilb_Qt);
2036 return biv;
2037}
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:461
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:541
poly hFirstSeries0m(ideal A, ideal Q, intvec *wdegree, intvec *shifts, const ring src, const ring Qt)
Definition hilb.cc:1425
bigintmat * hPoly2BIV(poly h, const ring Qt, const coeffs biv_cf)
Definition hilb.cc:1982

◆ hFirstSeries0m()

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

Definition at line 1425 of file hilb.cc.

1426{
1427 int rk=A->rank;
1428 poly h=NULL;
1429 for(int i=1;i<=rk;i++)
1430 {
1431 ideal AA=id_Head(A,src);
1432 BOOLEAN have_terms=FALSE;
1433 for(int ii=0;ii<IDELEMS(AA);ii++)
1434 {
1435 if (AA->m[ii]!=NULL)
1436 {
1437 if(p_GetComp(AA->m[ii],src)!=i)
1438 p_Delete(&AA->m[ii],src);
1439 else
1440 {
1441 p_SetComp(AA->m[ii],0,src);
1442 p_Setm(AA->m[ii],src);
1443 have_terms=TRUE;
1444 }
1445 }
1446 }
1447 poly h_i=NULL;
1448 //int sh=0;
1449 if (have_terms)
1450 {
1451 idSkipZeroes(AA);
1452 h_i=hFirstSeries0p(AA,Q,wdegree,src,Qt);
1453 }
1454 else
1455 {
1456 h_i=p_One(Qt);
1457 }
1458 id_Delete(&AA,src);
1459 poly s=p_One(Qt);
1460 if (shifts!=NULL)
1461 {
1462 int m=shifts->min_in();
1463 int sh=(*shifts)[i-1]-m;
1464 if (sh!=0)
1465 {
1466 p_SetExp(s,1,sh,Qt);
1467 p_Setm(s,Qt);
1468 }
1469 }
1470 h_i=p_Mult_q(h_i,s,Qt);
1471 h=p_Add_q(h,h_i,Qt);
1472 }
1473 return h;
1474}
static poly p_Mult_q(poly p, poly q, const ring r)
Definition p_polys.h:1125
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 1384 of file hilb.cc.

1385{
1386 A=id_Head(A,src);
1387 id_Test(A,src);
1388 ideal AA;
1389 if (Q!=NULL)
1390 {
1391 ideal QQ=id_Head(Q,src);
1392 AA=id_SimpleMove(A,QQ,src);
1393 idSkipZeroes(AA);
1394 int c=p_GetComp(AA->m[0],src);
1395 if (c!=0)
1396 {
1397 for(int i=0;i<IDELEMS(AA);i++)
1398 if (AA->m[i]!=NULL) p_SetComp(AA->m[i],c,src);
1399 }
1400 }
1401 else AA=A;
1402 id_DelDiv(AA,src);
1403 IDELEMS(AA)=idSkipZeroes0(AA);
1404 /* sort */
1405 if (IDELEMS(AA)>1)
1406 #ifdef HAVE_QSORT_R
1407 #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__CYGWIN__)
1408 qsort_r(AA->m,IDELEMS(AA),sizeof(poly),src,compare_rp);
1409 #else
1410 qsort_r(AA->m,IDELEMS(AA),sizeof(poly),compare_rp,src);
1411 #endif
1412 #else
1413 {
1414 ring r=currRing;
1415 currRing=src;
1416 qsort(AA->m,IDELEMS(AA),sizeof(poly),compare_rp_currRing);
1417 currRing=r;
1418 }
1419 #endif
1420 poly s=hilbert_series(AA,src,wdegree,Qt);
1421 id_Delete0(&AA,src);
1422 return s;
1423}
static poly hilbert_series(ideal A, const ring src, const intvec *wdegree, const ring Qt)
Definition hilb.cc:1289
static int compare_rp_currRing(const void *pp1, const void *pp2)
Definition hilb.cc:1191
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_SimpleMove(ideal h1, ideal h2, const ring R)
concat the lists h1 and h2 without zeros, destroys h1,h2
#define id_Test(A, lR)

◆ hFirstSeries1()

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

Definition at line 1972 of file hilb.cc.

1973{
1974 id_LmTest(S, currRing);
1975 if (Q!= NULL) id_LmTest(Q, currRing);
1976
1977 intvec *hseries1= hSeries(S, modulweight,wdegree, Q);
1978 if (errorreported) { delete hseries1; hseries1=NULL; }
1979 return hseries1;
1980}
static intvec * hSeries(ideal S, intvec *modulweight, intvec *wdegree, ideal Q)
Definition hilb.cc:1826
#define id_LmTest(A, lR)

◆ hHilbEst()

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

Definition at line 1720 of file hilb.cc.

1721{
1722 int i, j;
1723 int x, y, z = 1;
1724 int64 *p;
1725 for (i = Nvar; i>0; i--)
1726 {
1727 x = 0;
1728 for (j = 0; j < Nstc; j++)
1729 {
1730 y = stc[j][var[i]];
1731 if (y > x)
1732 x = y;
1733 }
1734 z += x;
1735 j = i - 1;
1736 if (z > Ql[j])
1737 {
1738 if (z>(MAX_INT_VAL)/2)
1739 {
1740 WerrorS("internal arrays too big");
1741 return;
1742 }
1743 p = (int64 *)omAlloc((unsigned long)z * sizeof(int64));
1744 if (Ql[j]!=0)
1745 {
1746 if (j==0)
1747 memcpy(p, Qpol[j], Ql[j] * sizeof(int64));
1748 omFreeSize((ADDRESS)Qpol[j], Ql[j] * sizeof(int64));
1749 }
1750 if (j==0)
1751 {
1752 for (x = Ql[j]; x < z; x++)
1753 p[x] = 0;
1754 }
1755 Ql[j] = z;
1756 Qpol[j] = p;
1757 }
1758 }
1759}
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()

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

Definition at line 1761 of file hilb.cc.

1763{
1764 int iv = Nvar -1, ln, a, a0, a1, b, i;
1765 int x, x0;
1766 scmon pn;
1767 scfmon sn;
1768 int64 *pon;
1769 if (Nstc==0)
1770 {
1771 hLastHilb(pure, iv, var, pol, Lpol);
1772 return;
1773 }
1774 x = a = 0;
1775 pn = hGetpure(pure);
1776 sn = hGetmem(Nstc, stc, stcmem[iv]);
1777 hStepS(sn, Nstc, var, Nvar, &a, &x);
1778 Q0[iv] = Q0[Nvar];
1779 ln = Lpol;
1780 pon = pol;
1781 if (a == Nstc)
1782 {
1783 x = pure[var[Nvar]];
1784 if (x!=0)
1785 pon = hAddHilb(iv, x, pon, &ln);
1786 hHilbStep(pn, sn, a, var, iv, pon, ln);
1787 return;
1788 }
1789 else
1790 {
1791 pon = hAddHilb(iv, x, pon, &ln);
1792 hHilbStep(pn, sn, a, var, iv, pon, ln);
1793 }
1794 b = a;
1795 x0 = 0;
1796 loop
1797 {
1798 Q0[iv] += (x - x0);
1799 a0 = a;
1800 x0 = x;
1801 hStepS(sn, Nstc, var, Nvar, &a, &x);
1802 hElimS(sn, &b, a0, a, var, iv);
1803 a1 = a;
1804 hPure(sn, a0, &a1, var, iv, pn, &i);
1805 hLex2S(sn, b, a0, a1, var, iv, hwork);
1806 b += (a1 - a0);
1807 ln = Lpol;
1808 if (a < Nstc)
1809 {
1810 pon = hAddHilb(iv, x - x0, pol, &ln);
1811 hHilbStep(pn, sn, b, var, iv, pon, ln);
1812 }
1813 else
1814 {
1815 x = pure[var[Nvar]];
1816 if (x!=0)
1817 pon = hAddHilb(iv, x - x0, pol, &ln);
1818 else
1819 pon = pol;
1820 hHilbStep(pn, sn, b, var, iv, pon, ln);
1821 return;
1822 }
1823 }
1824}
static void hLastHilb(scmon pure, int Nv, varset var, int64 *pol, int lp)
Definition hilb.cc:1664
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:1761
static int64 * hAddHilb(int Nv, int x, int64 *pol, int *lp)
Definition hilb.cc:1616
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()

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

Definition at line 1289 of file hilb.cc.

1294{
1295 int r=id_Elem(A,src);
1296 poly h=NULL;
1297 if (r==0)
1298 return p_One(Qt);
1299 if (wdegree!=NULL)
1300 {
1301 int* exp=(int*)omAlloc((src->N+1)*sizeof(int));
1302 for(int i=IDELEMS(A)-1; i>=0;i--)
1303 {
1304 if (A->m[i]!=NULL)
1305 {
1306 p_GetExpV(A->m[i],exp,src);
1307 for(int j=src->N;j>0;j--)
1308 {
1309 int w=(*wdegree)[j-1];
1310 if (w<=0)
1311 {
1312 WerrorS("weights must be positive");
1313 return NULL;
1314 }
1315 exp[j]*=w; /* (*wdegree)[j-1] */
1316 }
1317 p_SetExpV(A->m[i],exp,src);
1318 #ifdef PDEBUG
1319 p_Setm(A->m[i],src);
1320 #endif
1321 }
1322 }
1323 omFreeSize(exp,(src->N+1)*sizeof(int));
1324 }
1325 h=p_Init(Qt); pSetCoeff0(h,n_Init(-1,Qt->cf));
1326 p_SetExp(h,1,p_Totaldegree(A->m[0],src),Qt);
1327 //p_Setm(h,Qt);
1328 h=p_Add_q(h,p_One(Qt),Qt); // 1-t
1329 int *exp_q=(int*)omAlloc((src->N+1)*sizeof(int));
1330 BOOLEAN *bad=(BOOLEAN*)omAlloc0(r*sizeof(BOOLEAN));
1331 for (int i=1;i<r;i++)
1332 {
1333 ideal J=id_CopyFirstK(A,i,src);
1334 for(int ii=src->N;ii>0;ii--)
1335 exp_q[ii]=p_GetExp(A->m[i],ii,src);
1336 memset(bad,0,i*sizeof(BOOLEAN));
1337 for(int ii=0;ii<i;ii++)
1338 {
1339 bad[ii]=p_Div_hi(J->m[ii],exp_q,src);
1340 }
1341 id_DelDiv_hi(J,bad,src);
1342 // variant A
1343 // search linear elems:
1344 int k=0;
1345 for (int ii=IDELEMS(J)-1;ii>=0;ii--)
1346 {
1347 if((J->m[ii]!=NULL) && (bad[ii]) && (p_Totaldegree(J->m[ii],src)==1))
1348 {
1349 k++;
1350 p_LmDelete(&J->m[ii],src);
1351 }
1352 }
1353 IDELEMS(J)=idSkipZeroes0(J);
1354 poly h_J=hilbert_series(J,src,NULL,Qt);// J_1
1355 poly tmp;
1356 if (k>0)
1357 {
1358 // hilbert_series of unmodified J:
1359 tmp=p_Init(Qt); pSetCoeff0(tmp,n_Init(-1,Qt->cf));
1360 p_SetExp(tmp,1,1,Qt);
1361 //p_Setm(tmp,Qt);
1362 tmp=p_Add_q(tmp,p_One(Qt),Qt); // 1-t
1363 if (k>1)
1364 {
1365 tmp=p_Power(tmp,k,Qt); // (1-t)^k
1366 }
1367 h_J=p_Mult_q(h_J,tmp,Qt);
1368 }
1369 // forget about J:
1370 id_Delete0(&J,src);
1371 // t^|A_i|
1372 tmp=p_Init(Qt); pSetCoeff0(tmp,n_Init(-1,Qt->cf));
1373 p_SetExp(tmp,1,p_Totaldegree(A->m[i],src),Qt);
1374 //p_Setm(tmp,Qt);
1375 tmp=p_Mult_q(tmp,h_J,Qt);
1376 h=p_Add_q(h,tmp,Qt);
1377 }
1378 omFreeSize(bad,r*sizeof(BOOLEAN));
1379 omFreeSize(exp_q,(src->N+1)*sizeof(int));
1380 //Print("end hilbert_series, r=%d\n",r);
1381 return h;
1382}
bool bad
static BOOLEAN p_Div_hi(poly p, const int *exp_q, const ring src)
Definition hilb.cc:1151
static void id_DelDiv_hi(ideal id, BOOLEAN *bad, const ring r)
Definition hilb.cc:1205
gmp_float exp(const gmp_float &a)
poly p_Power(poly p, int i, const ring r)
Definition p_polys.cc:2245
static poly p_Init(const ring r, omBin bin)
Definition p_polys.h:1341
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 770 of file hilb.cc.

771{
772
773 /* new story:
774 no lV is needed, i.e. it is to be determined
775 the rest is extracted from the interface input list in extra.cc and makes the input of this proc
776 called from extra.cc
777 */
778
779 /*
780 * This is based on iterative right colon operations on a
781 * two-sided monomial ideal of the free associative algebra.
782 * The algorithm terminates for those monomial ideals
783 * whose monomials define "regular formal languages",
784 * that is, all monomials of the input ideal can be obtained
785 * from finite languages by applying finite number of
786 * rational operations.
787 */
788
789 int trInd;
791 if( !idIs0(S) && p_Totaldegree(S->m[0], currRing)==0)
792 {
793 PrintS("Hilbert Series:\n 0\n");
794 return;
795 }
796 int (*POS)(ideal, poly, std::vector<ideal>, std::vector<poly>, int, int);
797 if(trunDegHs != 0)
798 {
799 Print("\nTruncation degree = %d\n",trunDegHs);
801 }
802 else
803 {
804 if(IG_CASE)
805 {
806 if(idIs0(S))
807 {
808 WerrorS("wrong input: it is not an infinitely gen. case");
809 return;
810 }
811 trInd = p_Totaldegree(S->m[IDELEMS(S)-1], currRing);
813 }
814 else
816 }
817 std::vector<ideal > idorb;
818 std::vector< poly > polist;
819
820 ideal orb_init = idInit(1, 1);
821 idorb.push_back(orb_init);
822
823 polist.push_back( p_One(currRing));
824
825 std::vector< std::vector<int> > posMat;
826 std::vector<int> posRow(lV,0);
827 std::vector<int> C;
828
829 int ds, is, ps;
830 unsigned long lpcnt = 0;
831
832 poly w, wi;
833 ideal Jwi;
834
835 while(lpcnt < idorb.size())
836 {
837 w = NULL;
838 w = polist[lpcnt];
839 if(lpcnt >= 1 && idIs0(idorb[lpcnt]) == FALSE)
840 {
841 if(p_Totaldegree(idorb[lpcnt]->m[0], currRing) != 0)
842 {
843 C.push_back(1);
844 }
845 else
846 C.push_back(0);
847 }
848 else
849 {
850 C.push_back(1);
851 }
852
853 ds = p_Totaldegree(w, currRing);
854 lpcnt++;
855
856 for(is = 1; is <= lV; is++)
857 {
858 wi = NULL;
859 //make new copy 'wi' of word w=polist[lpcnt]
860 //and update it (for the colon operation).
861 //if corresponding to wi, right colon operation gives
862 //a new (right colon) ideal of S,
863 //keep 'wi' in the polist else delete it
864
865 wi = pCopy(w);
866 p_SetExp(wi, (ds*lV)+is, 1, currRing);
867 p_Setm(wi, currRing);
868 Jwi = NULL;
869 //Jwi stores (right) colon ideal of S w.r.t. word
870 //wi if colon operation gives a new ideal place it
871 //in the vector of ideals 'idorb'
872 //otherwise delete it
873
874 Jwi = idInit(1,1);
875
876 Jwi = colonIdeal(S, wi, lV, Jwi, trunDegHs);
877 ps = (*POS)(Jwi, wi, idorb, polist, trInd, trunDegHs);
878
879 if(ps == 0) // finds a new ideal
880 {
881 posRow[is-1] = idorb.size();
882
883 idorb.push_back(Jwi);
884 polist.push_back(wi);
885 }
886 else // ideal is already there in the set
887 {
888 posRow[is-1]=ps-1;
889 idDelete(&Jwi);
890 pDelete(&wi);
891 }
892 }
893 posMat.push_back(posRow);
894 posRow.resize(lV,0);
895 }
896 int lO = C.size();//size of the orbit
897 PrintLn();
898 Print("maximal length of words = %ld\n", p_Totaldegree(polist[lO-1], currRing));
899 Print("\nlength of the Orbit = %d", lO);
900 PrintLn();
901
902 if(odp)
903 {
904 Print("words description of the Orbit: \n");
905 for(is = 0; is < lO; is++)
906 {
907 pWrite0(polist[is]);
908 PrintS(" ");
909 }
910 PrintLn();
911 PrintS("\nmaximal degree, #(sum_j R(w,w_j))");
912 PrintLn();
913 for(is = 0; is < lO; is++)
914 {
915 if(idIs0(idorb[is]))
916 {
917 PrintS("NULL\n");
918 }
919 else
920 {
921 Print("%ld, %d \n",p_Totaldegree(idorb[is]->m[IDELEMS(idorb[is])-1], currRing),IDELEMS(idorb[is]));
922 }
923 }
924 }
925
926 for(is = idorb.size()-1; is >= 0; is--)
927 {
928 idDelete(&idorb[is]);
929 }
930 for(is = polist.size()-1; is >= 0; is--)
931 {
932 pDelete(&polist[is]);
933 }
934
935 idorb.resize(0);
936 polist.resize(0);
937
938 int adjMatrix[lO][lO];
939 memset(adjMatrix, 0, lO*lO*sizeof(int));
940 int rowCount, colCount;
941 int tm = 0;
942 if(!mgrad)
943 {
944 for(rowCount = 0; rowCount < lO; rowCount++)
945 {
946 for(colCount = 0; colCount < lV; colCount++)
947 {
948 tm = posMat[rowCount][colCount];
949 adjMatrix[rowCount][tm] = adjMatrix[rowCount][tm] + 1;
950 }
951 }
952 }
953
954 ring r = currRing;
955 int npar;
956 char** tt;
958 if(!mgrad)
959 {
960 tt=(char**)omAlloc(2*sizeof(char*));
961 tt[0] = omStrDup("t");
962 npar = 1;
963 }
964 else
965 {
966 tt=(char**)omalloc(lV*sizeof(char*));
967 for(is = 0; is < lV; is++)
968 {
969 tt[is] = (char*)omAlloc(12*sizeof(char)); //if required enlarge it later
970 snprintf (tt[is],12, "t%d", is+1);
971 }
972 npar = lV;
973 }
974
975 p.r = rDefault(0, npar, tt);
977 char** xx = (char**)omAlloc(sizeof(char*));
978 xx[0] = omStrDup("x");
979 ring R = rDefault(cf, 1, xx);
980 rChangeCurrRing(R);//rWrite(R);
981 /*
982 * matrix corresponding to the orbit of the ideal
983 */
984 matrix mR = mpNew(lO, lO);
985 matrix cMat = mpNew(lO,1);
986 poly rc;
987
988 if(!mgrad)
989 {
990 for(rowCount = 0; rowCount < lO; rowCount++)
991 {
992 for(colCount = 0; colCount < lO; colCount++)
993 {
994 if(adjMatrix[rowCount][colCount] != 0)
995 {
996 MATELEM(mR, rowCount + 1, colCount + 1) = p_ISet(adjMatrix[rowCount][colCount], R);
997 p_SetCoeff(MATELEM(mR, rowCount + 1, colCount + 1), n_Mult(pGetCoeff(mR->m[lO*rowCount+colCount]),n_Param(1, R->cf), R->cf), R);
998 }
999 }
1000 }
1001 }
1002 else
1003 {
1004 for(rowCount = 0; rowCount < lO; rowCount++)
1005 {
1006 for(colCount = 0; colCount < lV; colCount++)
1007 {
1008 rc=NULL;
1009 rc=p_One(R);
1010 p_SetCoeff(rc, n_Mult(pGetCoeff(rc), n_Param(colCount+1, R->cf),R->cf), R);
1011 MATELEM(mR, rowCount +1, posMat[rowCount][colCount]+1)=p_Add_q(rc,MATELEM(mR, rowCount +1, posMat[rowCount][colCount]+1), R);
1012 }
1013 }
1014 }
1015
1016 for(rowCount = 0; rowCount < lO; rowCount++)
1017 {
1018 if(C[rowCount] != 0)
1019 {
1020 MATELEM(cMat, rowCount + 1, 1) = p_ISet(C[rowCount], R);
1021 }
1022 }
1023
1024 matrix u;
1025 unitMatrix(lO, u); //unit matrix
1026 matrix gMat = mp_Sub(u, mR, R);
1027
1028 char* s;
1029
1030 if(odp)
1031 {
1032 PrintS("\nlinear system:\n");
1033 if(!mgrad)
1034 {
1035 for(rowCount = 0; rowCount < lO; rowCount++)
1036 {
1037 Print("H(%d) = ", rowCount+1);
1038 for(colCount = 0; colCount < lV; colCount++)
1039 {
1040 StringSetS(""); nWrite(n_Param(1, R->cf));
1041 s = StringEndS(); PrintS(s);
1042 Print("*"); omFree(s);
1043 Print("H(%d) + ", posMat[rowCount][colCount] + 1);
1044 }
1045 Print(" %d\n", C[rowCount] );
1046 }
1047 PrintS("where H(1) represents the series corresp. to input ideal\n");
1048 PrintS("and i^th summand in the rhs of an eqn. is according\n");
1049 PrintS("to the right colon map corresp. to the i^th variable\n");
1050 }
1051 else
1052 {
1053 for(rowCount = 0; rowCount < lO; rowCount++)
1054 {
1055 Print("H(%d) = ", rowCount+1);
1056 for(colCount = 0; colCount < lV; colCount++)
1057 {
1058 StringSetS(""); nWrite(n_Param(colCount+1, R->cf));
1059 s = StringEndS(); PrintS(s);
1060 Print("*");omFree(s);
1061 Print("H(%d) + ", posMat[rowCount][colCount] + 1);
1062 }
1063 Print(" %d\n", C[rowCount] );
1064 }
1065 PrintS("where H(1) represents the series corresp. to input ideal\n");
1066 }
1067 }
1068 PrintLn();
1069 posMat.resize(0);
1070 C.resize(0);
1071 matrix pMat;
1072 matrix lMat;
1073 matrix uMat;
1074 matrix H_serVec = mpNew(lO, 1);
1075 matrix Hnot;
1076
1077 //std::clock_t start;
1078 //start = std::clock();
1079
1080 luDecomp(gMat, pMat, lMat, uMat, R);
1081 luSolveViaLUDecomp(pMat, lMat, uMat, cMat, H_serVec, Hnot);
1082
1083 //to print system solving time
1084 //if(odp){
1085 //std::cout<<"solving time of the system = "<<(std::clock()-start)/(double)(CLOCKS_PER_SEC / 1000)<<" ms"<<std::endl;}
1086
1087 mp_Delete(&mR, R);
1088 mp_Delete(&u, R);
1089 mp_Delete(&pMat, R);
1090 mp_Delete(&lMat, R);
1091 mp_Delete(&uMat, R);
1092 mp_Delete(&cMat, R);
1093 mp_Delete(&gMat, R);
1094 mp_Delete(&Hnot, R);
1095 //print the Hilbert series and length of the Orbit
1096 PrintLn();
1097 Print("Hilbert series:");
1098 PrintLn();
1099 pWrite(H_serVec->m[0]);
1100 if(!mgrad)
1101 {
1102 omFree(tt[0]);
1103 }
1104 else
1105 {
1106 for(is = lV-1; is >= 0; is--)
1107
1108 omFree( tt[is]);
1109 }
1110 omFree(tt);
1111 omFree(xx[0]);
1112 omFree(xx);
1113 rChangeCurrRing(r);
1114 rKill(R);
1115}
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:639
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:775
@ 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:412
#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:481
static ideal colonIdeal(ideal S, poly w, int lV, ideal Jwi, int trunDegHs)
Definition hilb.cc:735
static int positionInOrbit_FG_Case(ideal I, poly, std::vector< ideal > idorb, std::vector< poly >, int, int)
Definition hilb.cc:450
static int positionInOrbit_IG_Case(ideal I, poly w, std::vector< ideal > idorb, std::vector< poly > polist, int trInd, int)
Definition hilb.cc:372
#define idDelete(H)
delete an ideal
Definition ideals.h:29
void rKill(ring r)
Definition ipshell.cc:6181
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)
poly p_ISet(long i, const ring r)
returns the poly representing the integer i
Definition p_polys.cc:1298
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:288
char * StringEndS()
Definition reporter.cc:151
void PrintLn()
Definition reporter.cc:314
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()

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

Definition at line 1664 of file hilb.cc.

1665{
1666 int l = lp, x, i, j;
1667 int64 *pl;
1668 int64 *p;
1669 p = pol;
1670 for (i = Nv; i>0; i--)
1671 {
1672 x = pure[var[i + 1]];
1673 if (x!=0)
1674 p = hAddHilb(i, x, p, &l);
1675 }
1676 pl = *Qpol;
1677 j = Q0[Nv + 1];
1678 for (i = 0; i < l; i++)
1679 { /* pl[i + j] += p[i];*/
1680 #ifndef __SIZEOF_INT128__
1681 int64 t=pl[i+j];
1682 int64 t2=p[i];
1683 t+=t2;
1684 if ((t>=OVERFLOW_MIN)&&(t<=OVERFLOW_MAX)) pl[i+j]=t;
1685 else if (!errorreported) WerrorS("int overflow in hilb 3");
1686 #else
1687 __int128 t=pl[i+j];
1688 __int128 t2=p[i];
1689 t+=t2;
1690 if ((t>=LONG_MIN)&&(t<=LONG_MAX)) pl[i+j]=t;
1691 else if (!errorreported) WerrorS("long int overflow in hilb 3");
1692 #endif
1693 }
1694 x = pure[var[1]];
1695 if (x!=0)
1696 {
1697 j += x;
1698 for (i = 0; i < l; i++)
1699 { /* pl[i + j] -= p[i];*/
1700 #ifndef __SIZEOF_INT128__
1701 int64 t=pl[i+j];
1702 int64 t2=p[i];
1703 t-=t2;
1704 if ((t>=OVERFLOW_MIN)&&(t<=OVERFLOW_MAX)) pl[i+j]=t;
1705 else if (!errorreported) WerrorS("int overflow in hilb 4");
1706 #else
1707 __int128 t=pl[i+j];
1708 __int128 t2=p[i];
1709 t-=t2;
1710 if ((t>=LONG_MIN)&&(t<=LONG_MAX)) pl[i+j]=t;
1711 else if (!errorreported) WerrorS("long int overflow in hilb 4");
1712 #endif
1713 }
1714 }
1715 j += l;
1716 if (j > hLength)
1717 hLength = j;
1718}
STATIC_VAR int hLength
Definition hilb.cc:69

◆ hLookSeries()

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

Definition at line 220 of file hilb.cc.

221{
223
224 if (!id_IsModule(S,currRing))
225 {
226 if (hilb_Qt==NULL) hilb_Qt=makeQt();
227 poly hseries=hFirstSeries0p(S,Q,wdegree,currRing,hilb_Qt);
228
229 hPrintHilb(hseries,hilb_Qt,wdegree);
230 p_Delete(&hseries,hilb_Qt);
231 }
232 else
233 {
234 if (hilb_Qt==NULL) hilb_Qt=makeQt();
235 poly hseries=hFirstSeries0m(S,Q,wdegree,modulweight,currRing,hilb_Qt);
236 if ((modulweight!=NULL)&&(modulweight->compare(0)!=0))
237 {
238 char *s=modulweight->ivString(1,0,1);
239 Print("module weights:%s\n",s);
240 omFree(s);
241 }
242 hPrintHilb(hseries,hilb_Qt,wdegree);
243 p_Delete(&hseries,hilb_Qt);
244 }
245}
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:164

◆ hMinModulweight()

int hMinModulweight ( intvec * modulweight)
static

Definition at line 1593 of file hilb.cc.

1594{
1595 if(modulweight==NULL) return 0;
1596 return modulweight->min_in();
1597}

◆ hPoly2BIV()

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

Definition at line 1982 of file hilb.cc.

1983{
1984 int td=0;
1985 nMapFunc f;
1986 if (h!=NULL)
1987 {
1988 td=p_Totaldegree(h,Qt);
1989 h=p_Copy(h,Qt);
1990 f=n_SetMap(Qt->cf,biv_cf);
1991 }
1992 bigintmat* biv=new bigintmat(1,td+2,biv_cf);
1993 while(h!=NULL)
1994 {
1995 int d=p_Totaldegree(h,Qt);
1996 n_Delete(&BIMATELEM(*biv,1,d+1),biv_cf);
1997 BIMATELEM(*biv,1,d+1)=f(pGetCoeff(h),Qt->cf,biv_cf);
1998 p_LmDelete(&h,Qt);
1999 }
2000 return biv;
2001}

◆ hPrintHilb()

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

Definition at line 164 of file hilb.cc.

165{
166 if ((modul_weight!=NULL)&&(modul_weight->compare(0)!=0))
167 {
168 char *s=modul_weight->ivString(1,0,1);
169 Print("module weights:%s\n",s);
170 omFree(s);
171 }
172 PrintS("(");p_Write0(hseries,Qt);Print(") / (1-%s)^%d\n",Qt->names[0],currRing->N);
173 int co;
174 poly h2=hFirst2Second(hseries,Qt,co);
175 int di = (currRing->N)-co;
176 if (hseries==NULL) di=0;
177 PrintS("("); p_Write0(h2,Qt); Print(") / (1-%s)^%d\n",Qt->names[0],di);
178 int mu=0;
179 poly p=h2;
180 while(p!=NULL)
181 {
182 mu+=n_Int(pGetCoeff(p),Qt->cf);
183 p_LmDelete(&p,Qt);
184 }
185 if (currRing->OrdSgn == 1)
186 {
187 if (di>0)
188 Print("// dimension (proj.) = %d\n// degree (proj.) = %d\n", di-1, mu);
189 else
190 Print("// dimension (affine) = 0\n// degree (affine) = %d\n", mu);
191 }
192 else
193 Print("// dimension (local) = %d\n// multiplicity = %d\n", di, mu);
194}
poly hFirst2Second(poly h, const ring Qt, int &co)
Definition hilb.cc:124
void p_Write0(poly p, ring lmRing, ring tailRing)
Definition polys0.cc:332

◆ hSecondSeries()

intvec * hSecondSeries ( intvec * hseries1)

Definition at line 71 of file hilb.cc.

72{
73 intvec *work, *hseries2;
74 int i, j, k, t, l;
75 int s;
76 if (hseries1 == NULL)
77 return NULL;
78 work = new intvec(hseries1);
79 k = l = work->length()-1;
80 s = 0;
81 for (i = k-1; i >= 0; i--)
82 s += (*work)[i];
83 loop
84 {
85 if ((s != 0) || (k == 1))
86 break;
87 s = 0;
88 t = (*work)[k-1];
89 k--;
90 for (i = k-1; i >= 0; i--)
91 {
92 j = (*work)[i];
93 (*work)[i] = -t;
94 s += t;
95 t += j;
96 }
97 }
98 hseries2 = new intvec(k+1);
99 for (i = k-1; i >= 0; i--)
100 (*hseries2)[i] = (*work)[i];
101 (*hseries2)[k] = (*work)[l];
102 delete work;
103 return hseries2;
104}

◆ hSecondSeries0b()

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

Definition at line 2039 of file hilb.cc.

2040{
2041 if (hilb_Qt==NULL) hilb_Qt=makeQt();
2042 poly h;
2043 if (id_IsModule(I,src))
2044 h=hFirstSeries0m(I,Q,wdegree,shifts,src,hilb_Qt);
2045 else
2046 h=hFirstSeries0p(I,Q,wdegree,src,hilb_Qt);
2047 int co;
2048 poly h2=hFirst2Second(h,hilb_Qt,co);
2049 p_Delete(&h,hilb_Qt);
2050 bigintmat *biv=hPoly2BIV(h2,hilb_Qt,biv_cf);
2051 p_Delete(&h2,hilb_Qt);
2052 return biv;
2053}

◆ hSeries()

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

Definition at line 1826 of file hilb.cc.

1828{
1829 intvec *work, *hseries1=NULL;
1830 int mc;
1831 int64 p0;
1832 int i, j, k, l, ii, mw;
1833 hexist = hInit(S, Q, &hNexist);
1834 if (hNexist==0)
1835 {
1836 hseries1=new intvec(2);
1837 (*hseries1)[0]=1;
1838 (*hseries1)[1]=0;
1839 return hseries1;
1840 }
1841
1842 if (wdegree != NULL) hWDegree(wdegree);
1843
1844 p0 = 1;
1845 hwork = (scfmon)omAlloc(hNexist * sizeof(scmon));
1846 hvar = (varset)omAlloc(((currRing->N) + 1) * sizeof(int));
1847 hpure = (scmon)omAlloc((1 + ((currRing->N) * (currRing->N))) * sizeof(int));
1848 stcmem = hCreate((currRing->N) - 1);
1849 Qpol = (int64 **)omAlloc(((currRing->N) + 1) * sizeof(int64 *));
1850 Ql = (int64 *)omAlloc0(((currRing->N) + 1) * sizeof(int64));
1851 Q0 = (int64 *)omAlloc(((currRing->N) + 1) * sizeof(int64));
1852 *Qpol = NULL;
1853 hLength = k = j = 0;
1854 mc = hisModule;
1855 if (mc!=0)
1856 {
1857 mw = hMinModulweight(modulweight);
1858 hstc = (scfmon)omAlloc(hNexist * sizeof(scmon));
1859 }
1860 else
1861 {
1862 mw = 0;
1863 hstc = hexist;
1864 hNstc = hNexist;
1865 }
1866 loop
1867 {
1868 if (mc!=0)
1869 {
1870 hComp(hexist, hNexist, mc, hstc, &hNstc);
1871 if (modulweight != NULL)
1872 j = (*modulweight)[mc-1]-mw;
1873 }
1874 if (hNstc!=0)
1875 {
1876 hNvar = (currRing->N);
1877 for (i = hNvar; i>=0; i--)
1878 hvar[i] = i;
1879 //if (notstc) // TODO: no mon divides another
1881 hSupp(hstc, hNstc, hvar, &hNvar);
1882 if (hNvar!=0)
1883 {
1884 if ((hNvar > 2) && (hNstc > 10))
1887 memset(hpure, 0, ((currRing->N) + 1) * sizeof(int));
1888 hPure(hstc, 0, &hNstc, hvar, hNvar, hpure, &hNpure);
1890 Q0[hNvar] = 0;
1891 hHilbStep(hpure, hstc, hNstc, hvar, hNvar, &p0, 1);
1892 }
1893 }
1894 else
1895 {
1896 if(*Qpol!=NULL)
1897 (**Qpol)++;
1898 else
1899 {
1900 *Qpol = (int64 *)omAlloc(sizeof(int64));
1901 hLength = *Ql = **Qpol = 1;
1902 }
1903 }
1904 if (*Qpol!=NULL)
1905 {
1906 i = hLength;
1907 while ((i > 0) && ((*Qpol)[i - 1] == 0))
1908 i--;
1909 if (i > 0)
1910 {
1911 l = i + j;
1912 if (l > k)
1913 {
1914 work = new intvec(l);
1915 for (ii=0; ii<k; ii++)
1916 (*work)[ii] = (*hseries1)[ii];
1917 if (hseries1 != NULL)
1918 delete hseries1;
1919 hseries1 = work;
1920 k = l;
1921 }
1922 while (i > 0)
1923 {
1924 (*hseries1)[i + j - 1] += (*Qpol)[i - 1];
1925 (*Qpol)[i - 1] = 0;
1926 i--;
1927 }
1928 }
1929 }
1930 mc--;
1931 if (mc <= 0)
1932 break;
1933 }
1934 if (k==0)
1935 {
1936 hseries1=new intvec(2);
1937 (*hseries1)[0]=0;
1938 (*hseries1)[1]=0;
1939 }
1940 else
1941 {
1942 l = k+1;
1943 while ((*hseries1)[l-2]==0) l--;
1944 if (l!=k)
1945 {
1946 work = new intvec(l);
1947 for (ii=l-2; ii>=0; ii--)
1948 (*work)[ii] = (*hseries1)[ii];
1949 delete hseries1;
1950 hseries1 = work;
1951 }
1952 (*hseries1)[l-1] = mw;
1953 }
1954 for (i = 0; i <= (currRing->N); i++)
1955 {
1956 if (Ql[i]!=0)
1957 omFreeSize((ADDRESS)Qpol[i], Ql[i] * sizeof(int64));
1958 }
1959 omFreeSize((ADDRESS)Q0, ((currRing->N) + 1) * sizeof(int64));
1960 omFreeSize((ADDRESS)Ql, ((currRing->N) + 1) * sizeof(int64));
1961 omFreeSize((ADDRESS)Qpol, ((currRing->N) + 1) * sizeof(int64 *));
1962 hKill(stcmem, (currRing->N) - 1);
1963 omFreeSize((ADDRESS)hpure, (1 + ((currRing->N) * (currRing->N))) * sizeof(int));
1964 omFreeSize((ADDRESS)hvar, ((currRing->N) + 1) * sizeof(int));
1965 omFreeSize((ADDRESS)hwork, hNexist * sizeof(scmon));
1967 if (hisModule!=0)
1968 omFreeSize((ADDRESS)hstc, hNexist * sizeof(scmon));
1969 return hseries1;
1970}
static void hHilbEst(scfmon stc, int Nstc, varset var, int Nvar)
Definition hilb.cc:1720
static int hMinModulweight(intvec *modulweight)
Definition hilb.cc:1593
static void hWDegree(intvec *wdegree)
Definition hilb.cc:1599
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()

void hWDegree ( intvec * wdegree)
static

Definition at line 1599 of file hilb.cc.

1600{
1601 int i, k;
1602 int x;
1603
1604 for (i=(currRing->N); i; i--)
1605 {
1606 x = (*wdegree)[i-1];
1607 if (x != 1)
1608 {
1609 for (k=hNexist-1; k>=0; k--)
1610 {
1611 hexist[k][i] *= x;
1612 }
1613 }
1614 }
1615}

◆ id_DelDiv_hi()

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

Definition at line 1205 of file hilb.cc.

1206{
1207 int k=IDELEMS(id)-1;
1208 while(id->m[k]==NULL) k--;
1209 int kk = k+1;
1210 long *sev=(long*)omAlloc0(kk*sizeof(long));
1211 BOOLEAN only_lm=r->cf->has_simple_Alloc;
1212 if (BIT_SIZEOF_LONG / r->N==0) // 1 bit per exp
1213 {
1214 for (int i=k; i>=0; i--)
1215 {
1216 sev[i]=p_GetShortExpVector0(id->m[i],r);
1217 }
1218 }
1219 else
1220 if (BIT_SIZEOF_LONG / r->N==1) // 1..2 bit per exp
1221 {
1222 for (int i=k; i>=0; i--)
1223 {
1224 sev[i]=p_GetShortExpVector1(id->m[i],r);
1225 }
1226 }
1227 else
1228 {
1229 for (int i=k; i>=0; i--)
1230 {
1231 sev[i]=p_GetShortExpVector(id->m[i],r);
1232 }
1233 }
1234 if (only_lm)
1235 {
1236 for (int i=0; i<k; i++)
1237 {
1238 if (bad[i] && (id->m[i] != NULL))
1239 {
1240 poly m_i=id->m[i];
1241 long sev_i=sev[i];
1242 for (int j=i+1; j<=k; j++)
1243 {
1244 if (id->m[j]!=NULL)
1245 {
1246 if (p_LmShortDivisibleBy(m_i, sev_i, id->m[j],~sev[j],r))
1247 {
1248 p_LmFree(&id->m[j],r);
1249 }
1250 else if (p_LmShortDivisibleBy(id->m[j],sev[j], m_i,~sev_i,r))
1251 {
1252 p_LmFree(&id->m[i],r);
1253 break;
1254 }
1255 }
1256 }
1257 }
1258 }
1259 }
1260 else
1261 {
1262 for (int i=0; i<k; i++)
1263 {
1264 if (bad[i] && (id->m[i] != NULL))
1265 {
1266 poly m_i=id->m[i];
1267 long sev_i=sev[i];
1268 for (int j=i+1; j<=k; j++)
1269 {
1270 if (id->m[j]!=NULL)
1271 {
1272 if (p_LmShortDivisibleBy(m_i, sev_i, id->m[j],~sev[j],r))
1273 {
1274 p_Delete(&id->m[j],r);
1275 }
1276 else if (p_LmShortDivisibleBy(id->m[j],sev[j], m_i,~sev_i,r))
1277 {
1278 p_Delete(&id->m[i],r);
1279 break;
1280 }
1281 }
1282 }
1283 }
1284 }
1285 }
1286 omFreeSize(sev,kk*sizeof(long));
1287}
#define BIT_SIZEOF_LONG
Definition auxiliary.h:80
unsigned long p_GetShortExpVector0(const poly p, const ring r)
Definition p_polys.cc:4998
unsigned long p_GetShortExpVector(const poly p, const ring r)
Definition p_polys.cc:4947
unsigned long p_GetShortExpVector1(const poly p, const ring r)
Definition p_polys.cc:5013
static BOOLEAN p_LmShortDivisibleBy(poly a, unsigned long sev_a, poly b, unsigned long not_sev_b, const ring r)
Definition p_polys.h:1931
static void p_LmFree(poly p, ring)
Definition p_polys.h:685

◆ idInsertMonomial()

void idInsertMonomial ( ideal I,
poly p )
static

Definition at line 252 of file hilb.cc.

253{
254 /*
255 * It adds monomial in I and if required,
256 * enlarge the size of poly-set by 16.
257 * It does not make copy of p.
258 */
259
260 if(I == NULL)
261 {
262 return;
263 }
264
265 int j = IDELEMS(I) - 1;
266 while ((j >= 0) && (I->m[j] == NULL))
267 {
268 j--;
269 }
270 j++;
271 if (j == IDELEMS(I))
272 {
273 pEnlargeSet(&(I->m), IDELEMS(I), 16);
274 IDELEMS(I) +=16;
275 }
276 I->m[j] = p;
277}
void pEnlargeSet(poly **p, int l, int increment)
Definition p_polys.cc:3821

◆ makeQt()

ring makeQt ( )
static

Definition at line 196 of file hilb.cc.

197{
198 ring Qt=(ring) omAlloc0Bin(sip_sring_bin);
199 Qt->cf = nInitChar(n_Q, NULL);
200 Qt->N=1;
201 Qt->names=(char**)omAlloc(sizeof(char_ptr));
202 Qt->names[0]=omStrDup("t");
203 Qt->wvhdl=(int **)omAlloc0(3 * sizeof(int_ptr));
204 Qt->order = (rRingOrder_t *) omAlloc(3 * sizeof(rRingOrder_t *));
205 Qt->block0 = (int *)omAlloc0(3 * sizeof(int *));
206 Qt->block1 = (int *)omAlloc0(3 * sizeof(int *));
207 /* ringorder lp for the first block: var 1 */
208 Qt->order[0] = ringorder_lp;
209 Qt->block0[0] = 1;
210 Qt->block1[0] = 1;
211 /* ringorder C for the second block: no vars */
212 Qt->order[1] = ringorder_C;
213 /* the last block: everything is 0 */
214 Qt->order[2] = (rRingOrder_t)0;
215 rComplete(Qt);
216 return Qt;
217}
@ 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:3527
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()

ideal minimalMonomialGenSet ( ideal I)
static

Definition at line 575 of file hilb.cc.

576{
577 /*
578 * eliminates monomials which
579 * can be generated by others in I
580 */
581 //first sort monomials of the ideal
582
583 idSkipZeroes(I);
584
586
587 int i, k;
588 int ICount = IDELEMS(I);
589
590 for(k = ICount - 1; k >=1; k--)
591 {
592 for(i = 0; i < k; i++)
593 {
594
595 if(p_LmDivisibleBy(I->m[i], I->m[k], currRing))
596 {
597 pDelete(&(I->m[k]));
598 break;
599 }
600 }
601 }
602
603 idSkipZeroes(I);
604 return(I);
605}
static void sortMonoIdeal_pCompare(ideal I)
Definition hilb.cc:562
static BOOLEAN p_LmDivisibleBy(poly a, poly b, const ring r)
Definition p_polys.h:1912

◆ monCompare()

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

Definition at line 555 of file hilb.cc.

556{
557 /* compares monomials */
558
559 return(p_Compare(*(poly*) m, *(poly*)n, currRing));
560}
int p_Compare(const poly a, const poly b, const ring R)
Definition p_polys.cc:5063

◆ p_Div_hi()

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

Definition at line 1151 of file hilb.cc.

1152{
1154 // e=max(0,p-q) for all exps
1155 for(int i=src->N;i>0;i--)
1156 {
1157 int pi=p_GetExp(p,i,src)-exp_q[i];
1158 if (pi<0)
1159 {
1160 pi=0;
1161 bad=TRUE;
1162 }
1163 p_SetExp(p,i,pi,src);
1164 }
1165 #ifdef PDEBUG
1166 p_Setm(p,src);
1167 #endif
1168 return bad;
1169}
#define pi
Definition libparse.cc:1145

◆ positionInOrbit_FG_Case()

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

Definition at line 450 of file hilb.cc.

451{
452 /*
453 * It compares the ideal I with ideals in the set 'idorb'.
454 * I and ideals of 'idorb' are sorted.
455 *
456 * It returns 0 if I is not equal to any ideal of 'idorb'
457 * else returns position of the matched ideal.
458 */
459 int ps = 0;
460 int i, s = 0;
461 int OrbCount = idorb.size();
462
463 if(idIs0(I))
464 {
465 return(1);
466 }
467
468 for(i = 1; i < OrbCount; i++)
469 {
470 s = comapreMonoIdBases(I, idorb[i]);
471 if(s)
472 {
473 ps = i + 1;
474 break;
475 }
476 }
477
478 return(ps);
479}
static int comapreMonoIdBases(ideal J, ideal Ob)
Definition hilb.cc:279

◆ positionInOrbit_IG_Case()

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

Definition at line 372 of file hilb.cc.

373{
374 /*
375 * It compares the ideal I with ideals in the set 'idorb'
376 * up to total degree =
377 * trInd - max(deg of w, deg of word in polist) polynomials.
378 *
379 * It returns 0 if I is not equal to any ideal in the
380 * 'idorb' else returns position of the matched ideal.
381 */
382
383 int ps = 0;
384 int i, s = 0;
385 int orbCount = idorb.size();
386
387 if(idIs0(I))
388 {
389 return(1);
390 }
391
392 int degw = p_Totaldegree(w, currRing);
393 int degp;
394 int dtr;
395 int dtrp;
396
397 dtr = trInd - degw;
398 int IwCount;
399
400 IwCount = CountOnIdUptoTruncationIndex(I, dtr);
401
402 if(IwCount == 0)
403 {
404 return(1);
405 }
406
407 int ObCount;
408
409 bool flag2 = FALSE;
410
411 for(i = 1;i < orbCount; i++)
412 {
413 degp = p_Totaldegree(polist[i], currRing);
414 if(degw > degp)
415 {
416 dtr = trInd - degw;
417
418 ObCount = 0;
419 ObCount = CountOnIdUptoTruncationIndex(idorb[i], dtr);
420 if(ObCount == 0)
421 {continue;}
422 if(flag2)
423 {
424 IwCount = 0;
425 IwCount = CountOnIdUptoTruncationIndex(I, dtr);
426 flag2 = FALSE;
427 }
428 }
429 else
430 {
431 flag2 = TRUE;
432 dtrp = trInd - degp;
433 ObCount = 0;
434 ObCount = CountOnIdUptoTruncationIndex(idorb[i], dtrp);
435 IwCount = 0;
436 IwCount = CountOnIdUptoTruncationIndex(I, dtrp);
437 }
438
439 s = comapreMonoIdBases_IG_Case(I, IwCount, idorb[i], ObCount);
440
441 if(s)
442 {
443 ps = i + 1;
444 break;
445 }
446 }
447 return(ps);
448}
static int comapreMonoIdBases_IG_Case(ideal J, int JCount, ideal Ob, int ObCount)
Definition hilb.cc:337
static int CountOnIdUptoTruncationIndex(ideal I, int tr)
Definition hilb.cc:310

◆ positionInOrbitTruncationCase()

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

Definition at line 481 of file hilb.cc.

482{
483 /*
484 * It compares the ideal I with ideals in the set 'idorb'.
485 * I and ideals in 'idorb' are sorted.
486
487 * returns 0 if I is not equal to any ideal of 'idorb'
488 * else returns position of the matched ideal.
489 */
490
491 int ps = 0;
492 int i, s = 0;
493 int OrbCount = idorb.size();
494 int dtr=0; int IwCount, ObCount;
495 dtr = trunDegHs - 1 - p_Totaldegree(w, currRing);
496
497 if(idIs0(I))
498 {
499 for(i = 1; i < OrbCount; i++)
500 {
502 {
503 if(idIs0(idorb[i]))
504 return(i+1);
505 ObCount=0;
506 ObCount = CountOnIdUptoTruncationIndex(idorb[i], dtr);
507 if(ObCount==0)
508 {
509 ps = i + 1;
510 break;
511 }
512 }
513 }
514
515 return(ps);
516 }
517
518 IwCount = CountOnIdUptoTruncationIndex(I, dtr);
519
520 if(p_Totaldegree(I->m[0], currRing)==0)
521 {
522 for(i = 1; i < OrbCount; i++)
523 {
524 if(idIs0(idorb[i]))
525 continue;
526 if(p_Totaldegree(idorb[i]->m[0], currRing)==0)
527 {
528 ps = i + 1;
529 break;
530 }
531 }
532 return(ps);
533 }
534
535 for(i = 1; i < OrbCount; i++)
536 {
538 {
539 if(idIs0(idorb[i]))
540 continue;
541 ObCount=0;
542 ObCount = CountOnIdUptoTruncationIndex(idorb[i], dtr);
543 s = comapreMonoIdBases_IG_Case(I, IwCount, idorb[i], ObCount);
544 if(s)
545 {
546 ps = i + 1;
547 break;
548 }
549 }
550 }
551
552 return(ps);
553}

◆ RightColonOperation()

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

Definition at line 1117 of file hilb.cc.

1118{
1119 /*
1120 * This returns right colon ideal of a monomial two-sided ideal of
1121 * the free associative algebra with respect to a monomial 'w'
1122 * (S:_R w).
1123 */
1124 S = minimalMonomialGenSet(S);
1125 ideal Iw = idInit(1,1);
1126 Iw = colonIdeal(S, w, lV, Iw, 0);
1127 return (Iw);
1128}

◆ scDegree()

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

Definition at line 2055 of file hilb.cc.

2056{
2057 int co;
2058 int mu=0;
2059#if 0
2060 if (hilb_Qt==NULL) hilb_Qt=makeQt();
2061 poly h1;
2062 if (id_IsModule(S,currRing))
2064 else
2065 h1 = hFirstSeries0m(S,Q,NULL, modulweight,currRing,hilb_Qt);
2066
2067 poly h2=hFirst2Second(h1,hilb_Qt,co);
2068 int di = (currRing->N)-co;
2069 if (h1==NULL) di=0;
2070 poly p=h2;
2071 while(p!=NULL)
2072 {
2073 mu+=n_Int(pGetCoeff(p),hilb_Qt->cf);
2075 }
2076#else
2078 intvec *hseries1=new intvec(1,h1->cols());
2079 for(int i=0;i<h1->cols();i++)
2080 {
2081 (*hseries1)[i]=n_Int(BIMATELEM(*h1,1,i+1),coeffs_BIGINT);
2082 }
2083 delete h1;
2084 intvec *hseries2;
2085 int l = hseries1->length()-1;
2086 if (l > 1)
2087 hseries2 = hSecondSeries(hseries1);
2088 else
2089 hseries2 = hseries1;
2090 hDegreeSeries(hseries1, hseries2, &co, &mu);
2091 if (l>1)
2092 delete hseries1;
2093 delete hseries2;
2094 if ((l == 1) &&(mu == 0))
2095 scPrintDegree((currRing->N)+1, 0);
2096 else
2097#endif
2098 scPrintDegree(co, mu);
2099}
void scPrintDegree(int co, int mu)
Definition hdegree.cc:910
intvec * hSecondSeries(intvec *hseries1)
Definition hilb.cc:71
bigintmat * hFirstSeries0b(ideal I, ideal Q, intvec *wdegree, intvec *shifts, const ring src, const coeffs biv_cf)
Definition hilb.cc:2017
void hDegreeSeries(intvec *s1, intvec *s2, int *co, int *mu)
Definition hilb.cc:106
VAR coeffs coeffs_BIGINT
Definition polys.cc:14

◆ shiftInMon()

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

Definition at line 607 of file hilb.cc.

608{
609 /*
610 * shifts the variables of monomial p in the i^th layer,
611 * p remains unchanged,
612 * creates new poly and returns it for the colon ideal
613 */
614 poly smon = p_One(r);
615 int j, sh, cnt;
616 cnt = r->N;
617 sh = i*lV;
618 int *e=(int *)omAlloc((r->N+1)*sizeof(int));
619 int *s=(int *)omAlloc0((r->N+1)*sizeof(int));
620 p_GetExpV(p, e, r);
621
622 for(j = 1; j <= cnt; j++)
623 {
624 if(e[j] == 1)
625 {
626 s[j+sh] = e[j];
627 }
628 }
629
630 p_SetExpV(smon, s, currRing);
631 omFree(e);
632 omFree(s);
633
635 p_Setm(smon, currRing);
636
637 return(smon);
638}

◆ sortMonoIdeal_pCompare()

void sortMonoIdeal_pCompare ( ideal I)
static

Definition at line 562 of file hilb.cc.

563{
564 /*
565 * sorts monomial ideal in ascending order
566 * order must be a total degree
567 */
568
569 qsort(I->m, IDELEMS(I), sizeof(poly), monCompare);
570
571}
static int monCompare(const void *m, const void *n)
Definition hilb.cc:555

◆ TwordMap()

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

Definition at line 674 of file hilb.cc.

675{
676 /*
677 * computes T_w(p) in a new poly object and places it
678 * in Jwi which stores elements of colon ideal of I,
679 * p and w remain unchanged,
680 * the new polys for Jwi are constructed by sub-routines
681 * deleteInMon, shiftInMon, p_MDivide,
682 * places the result in Jwi and deletes the new polys
683 * coming in dw, smon, qmon
684 */
685 int i;
686 poly smon, dw;
687 poly qmonp = NULL;
688 bool del;
689
690 for(i = 0;i <= d - 1; i++)
691 {
692 dw = deleteInMon(w, i, lV, currRing);
693 smon = shiftInMon(p, i, lV, currRing);
694 del = TRUE;
695
696 if(pLmDivisibleBy(smon, w))
697 {
698 flag = TRUE;
699 del = FALSE;
700
701 pDelete(&dw);
702 pDelete(&smon);
703
704 //delete all monomials of Jwi
705 //and make Jwi =1
706
707 for(int j = 0;j < IDELEMS(Jwi); j++)
708 {
709 pDelete(&Jwi->m[j]);
710 }
711
713 break;
714 }
715
716 if(pLmDivisibleBy(dw, smon))
717 {
718 del = FALSE;
719 qmonp = p_MDivide(smon, dw, currRing);
720 idInsertMonomial(Jwi, shiftInMon(qmonp, -d, lV, currRing));
721 pLmFree(&qmonp);
722 pDelete(&dw);
723 pDelete(&smon);
724 }
725 //in case both if are false, delete dw and smon
726 if(del)
727 {
728 pDelete(&dw);
729 pDelete(&smon);
730 }
731 }
732
733}
static poly deleteInMon(poly w, int i, int lV, const ring r)
Definition hilb.cc:640
static poly shiftInMon(poly p, int i, int lV, const ring r)
Definition hilb.cc:607
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 219 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.