My Project
Loading...
Searching...
No Matches
hilb.h File Reference
#include "polys/monomials/ring.h"
#include "kernel/polys.h"
#include "misc/intvec.h"
#include "coeffs/bigintmat.h"

Go to the source code of this file.

Functions

intvechFirstSeries (ideal S, intvec *modulweight, ideal Q=NULL, intvec *wdegree=NULL)
intvechFirstSeries1 (ideal S, intvec *modulweight, ideal Q=NULL, intvec *wdegree=NULL)
intvechFirstSeries0 (ideal S, ideal Q, intvec *wdegree, const ring src, const ring Qt)
poly hFirstSeries0p (ideal A, ideal Q, intvec *wdegree, const ring src, const ring Qt)
bigintmathPoly2BIV (poly h, const ring Qt, const coeffs biv_cf)
poly hBIV2Poly (bigintmat *b, const ring Qt, const coeffs biv_cf)
bigintmathFirstSeries0b (ideal I, ideal Q, intvec *wdegree, intvec *shifts, const ring src, const coeffs biv_cf)
bigintmathSecondSeries0b (ideal I, ideal Q, intvec *wdegree, intvec *shifts, const ring src, const coeffs biv_cf)
poly hFirstSeries0m (ideal A, ideal Q, intvec *wdegree, intvec *shifts, const ring src, const ring Qt)
intvechSecondSeries (intvec *hseries1)
void hLookSeries (ideal S, intvec *modulweight, ideal Q=NULL, intvec *wdegree=NULL)

Function Documentation

◆ hBIV2Poly()

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

Definition at line 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
#define NULL
Definition omList.c:12
static poly p_Add_q(poly p, poly q, const ring r)
Definition p_polys.h:938
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent @Note: VarOffset encodes the position in p->exp
Definition p_polys.h:490
static void p_Setm(poly p, const ring r)
Definition p_polys.h:235
static poly p_New(const ring, omBin bin)
Definition p_polys.h:666

◆ hFirstSeries()

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

Definition at line 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
#define FALSE
Definition auxiliary.h:97
int i
Definition cfEzgcd.cc:132
int length() const
Definition intvec.h:95
const CanonicalForm int s
Definition facAbsFact.cc:51
CanonicalForm res
Definition facAbsFact.cc:60
fq_nmod_poly_t prod
Definition facHensel.cc:100
static int max(int a, int b)
Definition fast_mult.cc:264
VAR void(* WerrorS_callback)(const char *s)
Definition feFopen.cc:21
VAR short errorreported
Definition feFopen.cc:23
static ring makeQt()
Definition hilb.cc: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 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
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 IDELEMS(i)
#define A
Definition sirandom.c:24
#define Q
Definition sirandom.c:26

◆ hFirstSeries0()

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

Definition at line 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}
int l
Definition cfEzgcd.cc:100
static FORCE_INLINE long n_Int(number &n, const coeffs r)
conversion of n to an int; 0 if not possible in Z/pZ: the representing int lying in (-p/2 ....
Definition coeffs.h: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}
int m
Definition cfEzgcd.cc:128
Matrices of numbers.
Definition bigintmat.h:51
int cols() const
Definition bigintmat.h:144
int min_in()
Definition intvec.h:122
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition coeffs.h: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
static void p_Delete(poly *p, const ring r)
Definition p_polys.h:903

◆ hFirstSeries0m()

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

Definition at line 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}
#define p_GetComp(p, r)
Definition monomials.h:64
poly p_One(const ring r)
Definition p_polys.cc:1314
static poly p_Mult_q(poly p, poly q, const ring r)
Definition p_polys.h:1125
static unsigned long p_SetComp(poly p, unsigned long c, ring r)
Definition p_polys.h:249
ideal id_Head(ideal h, const ring r)
returns the ideals of initial terms
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size

◆ hFirstSeries0p()

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

Definition at line 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 = NULL,
intvec * wdegree = NULL )

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)

◆ hLookSeries()

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

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
#define Print
Definition emacs.cc:80
static void hPrintHilb(poly hseries, const ring Qt, intvec *modul_weight)
Definition hilb.cc:164
#define omFree(addr)

◆ 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}
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition p_polys.h:848

◆ hSecondSeries()

intvec * hSecondSeries ( intvec * hseries1)

Definition at line 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}
int k
Definition cfEzgcd.cc:99
int j
Definition facHensel.cc:110
#define loop
Definition structs.h:71

◆ hSecondSeries0b()

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

Definition at line 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}
poly hFirst2Second(poly h, const ring Qt, int &co)
Definition hilb.cc:124