Loading...
Searching...
No Matches
stairc.h File Reference
`#include "polys/monomials/ring.h"`
`#include "kernel/polys.h"`
`#include "misc/intvec.h"`

Go to the source code of this file.

## Functions

void | scComputeHC (ideal s, ideal Q, int k, poly &hEdge)
intvec * | scIndIntvec (ideal S, ideal Q=NULL)
int | scDimInt (ideal s, ideal Q=NULL)
| ideal dimension
int | scDimIntRing (ideal s, ideal Q=NULL)
| scDimInt for ring-coefficients
int | scMultInt (ideal s, ideal Q=NULL)
long | scMult0Int (ideal s, ideal Q=NULL)
void | scDegree (ideal s, intvec *modulweight, ideal Q=NULL)
void | scPrintDegree (int co, int mu)
ideal | scKBase (int deg, ideal s, ideal Q=NULL, intvec *mv=NULL)
int | lp_gkDim (const ideal G)
int | lp_kDim (const ideal G)
intvec * | lp_ufnarovskiGraph (ideal G, ideal &standardWords)

## Function Documentation

## lp_gkDim()

int lp_gkDim | ( | const ideal | G | ) |

Definition at line 1827 of file hdegree.cc.

{
id_Test(_G, currRing);
if (rField_is_Ring(currRing)) {
WerrorS("GK-Dim not implemented for rings");
return -2;
}
for (int i=IDELEMS(_G)-1;i>=0; i--)
{
if (_G->m[i] != NULL)
{
if (pGetComp(_G->m[i]) != 0)
{
WerrorS("GK-Dim not implemented for modules");
return -2;
}
if (pGetNCGen(_G->m[i]) != 0)
{
WerrorS("GK-Dim not implemented for bi-modules");
return -2;
}
}
}
ideal G = id_Head(_G, currRing); // G = LM(G) (and copy)
idSkipZeroes(G); // remove zeros
id_DelLmEquals(G, currRing); // remove duplicates
// check if G is the zero ideal
if (IDELEMS(G) == 1 && G->m[0] == NULL)
{
// NOTE: this is needed because if the ideal is <0>, then idSkipZeroes keeps this element, and IDELEMS is still 1!
int lV = currRing->isLPring;
int ncGenCount = currRing->LPncGenCount;
if (lV - ncGenCount == 0)
{
idDelete(&G);
return 0;
}
if (lV - ncGenCount == 1)
{
idDelete(&G);
return 1;
}
if (lV - ncGenCount >= 2)
{
idDelete(&G);
return -1;
}
}
// get the max deg
long maxDeg = 0;
for (int i = 0; i < IDELEMS(G); i++)
{
maxDeg = si_max(maxDeg, pTotaldegree(G->m[i]));
// also check whether G = <1>
if (pIsConstantComp(G->m[i]))
{
WerrorS("GK-Dim not defined for 0-ring");
idDelete(&G);
return -2;
}
}
// early termination if G \subset X
if (maxDeg <= 1)
{
int lV = currRing->isLPring;
int ncGenCount = currRing->LPncGenCount;
if (IDELEMS(G) == lV - ncGenCount) // V = {1} no edges
{
idDelete(&G);
return 0;
}
if (IDELEMS(G) == lV - ncGenCount - 1) // V = {1} with loop
{
idDelete(&G);
return 1;
}
if (IDELEMS(G) <= lV - ncGenCount - 2) // V = {1} with more than one loop
{
idDelete(&G);
return -1;
}
}
ideal standardWords;
intvec* UG = lp_ufnarovskiGraph(G, standardWords);
if (UG == NULL)
{
idDelete(&G);
return -2;
}
if (errorreported)
{
delete UG;
idDelete(&G);
return -2;
}
int gkDim = graphGrowth(UG);
delete UG;
idDelete(&G);
return gkDim;
}
si_max
static int si_max(const int a, const int b)
Definition auxiliary.h:125
i
int i
Definition cfEzgcd.cc:132
intvec
Definition intvec.h:24
errorreported
VAR short errorreported
Definition feFopen.cc:23
WerrorS
void WerrorS(const char *s)
Definition feFopen.cc:24
graphGrowth
static int graphGrowth(const intvec *G)
Definition hdegree.cc:1639
lp_ufnarovskiGraph
intvec * lp_ufnarovskiGraph(ideal G, ideal &standardWords)
Definition hdegree.cc:1766
idDelete
#define idDelete(H)
delete an ideal
Definition ideals.h:29
G
STATIC_VAR TreeM * G
Definition janet.cc:31
NULL
#define NULL
Definition omList.c:12
currRing
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13
pTotaldegree
static long pTotaldegree(poly p)
Definition polys.h:283
pGetComp
#define pGetComp(p)
Component.
Definition polys.h:38
pIsConstantComp
#define pIsConstantComp(p)
return true if p is either NULL, or if all exponents of p are 0, Comp of p might be !...
Definition polys.h:237
rField_is_Ring
#define rField_is_Ring(R)
Definition ring.h:491
pGetNCGen
#define pGetNCGen(p)
Definition shiftop.h:65
id_Head
ideal id_Head(ideal h, const ring r)
returns the ideals of initial terms
Definition simpleideals.cc:1483
id_DelLmEquals
void id_DelLmEquals(ideal id, const ring r)
Delete id[j], if Lm(j) == Lm(i) and both LC(j), LC(i) are units and j > i.
Definition simpleideals.cc:354
idSkipZeroes
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
Definition simpleideals.cc:201
IDELEMS
#define IDELEMS(i)
Definition simpleideals.h:23
id_Test
#define id_Test(A, lR)
Definition simpleideals.h:89

## lp_kDim()

int lp_kDim | ( | const ideal | G | ) |

Definition at line 2081 of file hdegree.cc.

{
if (rField_is_Ring(currRing)) {
WerrorS("K-Dim not implemented for rings");
return -2;
}
for (int i=IDELEMS(_G)-1;i>=0; i--)
{
if (_G->m[i] != NULL)
{
if (pGetComp(_G->m[i]) != 0)
{
WerrorS("K-Dim not implemented for modules");
return -2;
}
if (pGetNCGen(_G->m[i]) != 0)
{
WerrorS("K-Dim not implemented for bi-modules");
return -2;
}
}
}
ideal G = id_Head(_G, currRing); // G = LM(G) (and copy)
if (TEST_OPT_PROT)
Print("%d original generators\n", IDELEMS(G));
idSkipZeroes(G); // remove zeros
id_DelLmEquals(G, currRing); // remove duplicates
if (TEST_OPT_PROT)
Print("%d non-zero unique generators\n", IDELEMS(G));
// check if G is the zero ideal
if (IDELEMS(G) == 1 && G->m[0] == NULL)
{
// NOTE: this is needed because if the ideal is <0>, then idSkipZeroes keeps this element, and IDELEMS is still 1!
int lV = currRing->isLPring;
int ncGenCount = currRing->LPncGenCount;
if (lV - ncGenCount == 0)
{
idDelete(&G);
return 1;
}
if (lV - ncGenCount == 1)
{
idDelete(&G);
return -1;
}
if (lV - ncGenCount >= 2)
{
idDelete(&G);
return -1;
}
}
// get the max deg
long maxDeg = 0;
for (int i = 0; i < IDELEMS(G); i++)
{
maxDeg = si_max(maxDeg, pTotaldegree(G->m[i]));
// also check whether G = <1>
if (pIsConstantComp(G->m[i]))
{
WerrorS("K-Dim not defined for 0-ring"); // TODO is it minus infinity ?
idDelete(&G);
return -2;
}
}
if (TEST_OPT_PROT)
Print("max deg: %ld\n", maxDeg);
// for normal words of length minDeg ... maxDeg-1
// brute-force the normal words
if (TEST_OPT_PROT)
PrintS("Computing normal words normally...\n");
long numberOfNormalWords = lp_countNormalWords(maxDeg - 1, G);
if (TEST_OPT_PROT)
Print("%ld normal words up to length %ld\n", numberOfNormalWords, maxDeg - 1);
// early termination if G \subset X
if (maxDeg <= 1)
{
int lV = currRing->isLPring;
int ncGenCount = currRing->LPncGenCount;
if (IDELEMS(G) == lV - ncGenCount) // V = {1} no edges
{
idDelete(&G);
return numberOfNormalWords;
}
if (IDELEMS(G) == lV - ncGenCount - 1) // V = {1} with loop
{
idDelete(&G);
return -1;
}
if (IDELEMS(G) <= lV - ncGenCount - 2) // V = {1} with more than one loop
{
idDelete(&G);
return -1;
}
}
if (TEST_OPT_PROT)
PrintS("Computing Ufnarovski graph...\n");
ideal standardWords;
intvec* UG = lp_ufnarovskiGraph(G, standardWords);
if (UG == NULL)
{
idDelete(&G);
return -2;
}
if (errorreported)
{
delete UG;
idDelete(&G);
return -2;
}
if (TEST_OPT_PROT)
Print("Ufnarovski graph is %dx%d.\n", UG->rows(), UG->cols());
if (TEST_OPT_PROT)
PrintS("Checking whether Ufnarovski graph is acyclic...\n");
if (!isAcyclic(UG))
{
// in this case we have infinitely many normal words
return -1;
}
std::vector<std::vector<int> > vvUG = iv2vv(UG);
for (std::vector<std::vector<int> >::size_type i = 0; i < vvUG.size(); i++)
{
if (vvIsRowZero(vvUG, i) && vvIsColumnZero(vvUG, i)) // i is isolated vertex
{
vvDeleteRow(vvUG, i);
vvDeleteColumn(vvUG, i);
i--;
}
}
if (TEST_OPT_PROT)
Print("Simplified Ufnarovski graph to %dx%d.\n", (int)vvUG.size(), (int)vvUG.size());
// for normal words of length >= maxDeg
// use Ufnarovski graph
if (TEST_OPT_PROT)
PrintS("Computing normal words via Ufnarovski graph...\n");
std::vector<std::vector<int> > UGpower = vvUG;
long nUGpower = 1;
while (!vvIsZero(UGpower))
{
if (TEST_OPT_PROT)
PrintS("Start count graph entries.\n");
for (std::vector<std::vector<int> >::size_type i = 0; i < UGpower.size(); i++)
{
for (std::vector<std::vector<int> >::size_type j = 0; j < UGpower[i].size(); j++)
{
numberOfNormalWords += UGpower[i][j];
}
}
if (TEST_OPT_PROT)
{
PrintS("Done count graph entries.\n");
Print("%ld normal words up to length %ld\n", numberOfNormalWords, maxDeg - 1 + nUGpower);
}
if (TEST_OPT_PROT)
PrintS("Start mat mult.\n");
UGpower = vvMult(UGpower, vvUG); // TODO: avoid creation of new intvec
if (TEST_OPT_PROT)
PrintS("Done mat mult.\n");
nUGpower++;
}
delete UG;
idDelete(&G);
return numberOfNormalWords;
}
intvec::cols
int cols() const
Definition intvec.h:96
intvec::rows
int rows() const
Definition intvec.h:97
Print
#define Print
Definition emacs.cc:80
j
int j
Definition facHensel.cc:110
vvMult
static std::vector< std::vector< int > > vvMult(const std::vector< std::vector< int > > &a, const std::vector< std::vector< int > > &b)
Definition hdegree.cc:2027
vvDeleteRow
static void vvDeleteRow(std::vector< std::vector< int > > &mat, int row)
Definition hdegree.cc:1984
vvIsColumnZero
static BOOLEAN vvIsColumnZero(const std::vector< std::vector< int > > &mat, int col)
Definition hdegree.cc:2007
vvDeleteColumn
static void vvDeleteColumn(std::vector< std::vector< int > > &mat, int col)
Definition hdegree.cc:1989
iv2vv
static std::vector< std::vector< int > > iv2vv(intvec *M)
Definition hdegree.cc:1937
lp_countNormalWords
static int lp_countNormalWords(int upToLength, ideal M)
Definition hdegree.cc:1745
isAcyclic
static BOOLEAN isAcyclic(const intvec *G)
Definition hdegree.cc:2054
vvIsZero
static BOOLEAN vvIsZero(const std::vector< std::vector< int > > &mat)
Definition hdegree.cc:2017
vvIsRowZero
static BOOLEAN vvIsRowZero(const std::vector< std::vector< int > > &mat, int row)
Definition hdegree.cc:1997
TEST_OPT_PROT
#define TEST_OPT_PROT
Definition options.h:105
PrintS
void PrintS(const char *s)
Definition reporter.cc:288

## lp_ufnarovskiGraph()

intvec * lp_ufnarovskiGraph | ( | ideal | G,
|  | ideal & | standardWords )

Definition at line 1766 of file hdegree.cc.

{
long l = 0;
for (int i = 0; i < IDELEMS(G); i++)
l = si_max(pTotaldegree(G->m[i]), l);
l--;
if (l <= 0)
{
WerrorS("Ufnarovski graph not implemented for l <= 0");
return NULL;
}
int lV = currRing->isLPring;
standardWords = lp_computeNormalWords(l, G);
int n = IDELEMS(standardWords);
intvec* UG = new intvec(n, n, 0);
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
poly v = standardWords->m[i];
poly w = standardWords->m[j];
// check whether v*x1 = x2*w (overlap)
bool overlap = true;
for (int k = 1; k <= (l - 1) * lV; k++)
{
if (pGetExp(v, k + lV) != pGetExp(w, k)) {
overlap = false;
break;
}
}
if (overlap)
{
// create the overlap
poly p = pMult(pCopy(v), p_LPVarAt(w, l, currRing));
// check whether the overlap is normal
bool normal = true;
for (int k = 0; k < IDELEMS(G); k++)
{
if (p_LPDivisibleBy(G->m[k], p, currRing))
{
normal = false;
break;
}
}
if (normal)
{
IMATELEM(*UG, i + 1, j + 1) = 1;
}
}
}
}
return UG;
}
l
int l
Definition cfEzgcd.cc:100
k
int k
Definition cfEzgcd.cc:99
p
int p
Definition cfModGcd.cc:4086
w
const CanonicalForm & w
Definition facAbsFact.cc:51
v
const Variable & v
< [in] a sqrfree bivariate poly
Definition facBivar.h:39
lp_computeNormalWords
static ideal lp_computeNormalWords(int length, ideal M)
Definition hdegree.cc:1725
IMATELEM
#define IMATELEM(M, I, J)
Definition intvec.h:86
pMult
#define pMult(p, q)
Definition polys.h:208
pGetExp
#define pGetExp(p, i)
Exponent.
Definition polys.h:42
pCopy
#define pCopy(p)
return a copy of the poly
Definition polys.h:186
p_LPDivisibleBy
BOOLEAN p_LPDivisibleBy(poly a, poly b, const ring r)
Definition shiftop.cc:776
p_LPVarAt
poly p_LPVarAt(poly p, int pos, const ring r)
Definition shiftop.cc:845

## scComputeHC()

void scComputeHC | ( | ideal | s,
|  | ideal | Q,
|  | int | k,
|  | poly & | hEdge )

Definition at line 1074 of file hdegree.cc.

{
if(idElem(S) == 0)
return;
id_LmTest(S, currRing);
if (Q!=NULL) id_LmTest(Q, currRing);
int i;
int k = ak;
ideal SS=id_Head(S,currRing);
if (rField_is_Ring(currRing) && (currRing->OrdSgn == -1))
{
//consider just monic generators (over rings with zero-divisors)
for(i=0;i<=idElem(S);i++)
{
if((SS->m[i]!=NULL)
&& ((p_IsPurePower(SS->m[i],currRing)==0)
||(!n_IsUnit(pGetCoeff(SS->m[i]), currRing->cf))))
{
p_Delete(&SS->m[i],currRing);
}
}
}
S=SS;
idSkipZeroes(S);
hNvar = (currRing->N);
hexist = hInit(S, Q, &hNexist);
if (hNexist==0) return;
if (k!=0)
hComp(hexist, hNexist, k, hexist, &hNstc);
else
hNstc = hNexist;
assume(hNexist > 0);
hwork = (scfmon)omAlloc(hNexist * sizeof(scmon));
hvar = (varset)omAlloc((hNvar + 1) * sizeof(int));
hpure = (scmon)omAlloc((1 + (hNvar * hNvar)) * sizeof(int));
stcmem = hCreate(hNvar - 1);
for (i = hNvar; i>0; i--)
hvar[i] = i;
hStaircase(hexist, &hNstc, hvar, hNvar);
if ((hNvar > 2) && (hNstc > 10))
hOrdSupp(hexist, hNstc, hvar, hNvar);
memset(hpure, 0, (hNvar + 1) * sizeof(int));
hPure(hexist, 0, &hNstc, hvar, hNvar, hpure, &hNpure);
hLexS(hexist, hNstc, hvar, hNvar);
if (hEdge!=NULL)
pLmFree(hEdge);
hEdge = pInit();
pWork = pInit();
hHedgeStep(hpure, hexist, hNstc, hvar, hNvar,hEdge);
pSetComp(hEdge,ak);
hKill(stcmem, hNvar - 1);
omFreeSize((ADDRESS)hwork, hNexist * sizeof(scmon));
omFreeSize((ADDRESS)hvar, (hNvar + 1) * sizeof(int));
omFreeSize((ADDRESS)hpure, (1 + (hNvar * hNvar)) * sizeof(int));
hDelete(hexist, hNexist);
pLmFree(pWork);
idDelete(&S);
}
ADDRESS
void * ADDRESS
Definition auxiliary.h:120
n_IsUnit
static FORCE_INLINE BOOLEAN n_IsUnit(number n, const coeffs r)
TRUE iff n has a multiplicative inverse in the given coeff field/ring r.
Definition coeffs.h:521
hHedgeStep
static void hHedgeStep(scmon pure, scfmon stc, int Nstc, varset var, int Nvar, poly hEdge)
Definition hdegree.cc:1014
pWork
STATIC_VAR poly pWork
Definition hdegree.cc:1001
hCreate
monf hCreate(int Nvar)
Definition hutil.cc:996
hComp
void hComp(scfmon exist, int Nexist, int ak, scfmon stc, int *Nstc)
Definition hutil.cc:154
hvar
VAR varset hvar
Definition hutil.cc:18
hKill
void hKill(monf xmem, int Nvar)
Definition hutil.cc:1010
hNexist
VAR int hNexist
Definition hutil.cc:19
hLexS
void hLexS(scfmon stc, int Nstc, varset var, int Nvar)
Definition hutil.cc:506
hDelete
void hDelete(scfmon ev, int ev_length)
Definition hutil.cc:140
stcmem
VAR monf stcmem
Definition hutil.cc:21
hPure
void hPure(scfmon stc, int a, int *Nstc, varset var, int Nvar, scmon pure, int *Npure)
Definition hutil.cc:621
hwork
VAR scfmon hwork
Definition hutil.cc:16
hpure
VAR scmon hpure
Definition hutil.cc:17
hStaircase
void hStaircase(scfmon stc, int *Nstc, varset var, int Nvar)
Definition hutil.cc:313
hOrdSupp
void hOrdSupp(scfmon stc, int Nstc, varset var, int Nvar)
Definition hutil.cc:202
hNpure
VAR int hNpure
Definition hutil.cc:19
hInit
scfmon hInit(ideal S, ideal Q, int *Nexist)
Definition hutil.cc:31
hexist
VAR scfmon hexist
Definition hutil.cc:16
hNstc
VAR int hNstc
Definition hutil.cc:19
hNvar
VAR int hNvar
Definition hutil.cc:19
scfmon
scmon * scfmon
Definition hutil.h:15
varset
int * varset
Definition hutil.h:16
scmon
int * scmon
Definition hutil.h:14
assume
#define assume(x)
Definition mod2.h:389
pGetCoeff
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
omFreeSize
#define omFreeSize(addr, size)
Definition omAllocDecl.h:260
omAlloc
#define omAlloc(size)
Definition omAllocDecl.h:210
p_IsPurePower
int p_IsPurePower(const poly p, const ring r)
return i, if head depends only on var(i)
Definition p_polys.cc:1227
p_Delete
static void p_Delete(poly *p, const ring r)
Definition p_polys.h:903
pSetComp
#define pSetComp(p, v)
Definition polys.h:39
pLmFree
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
pInit
#define pInit()
allocates a new monomial and initializes everything to 0
Definition polys.h:62
idElem
static int idElem(const ideal F)
number of non-zero polys in F
Definition simpleideals.h:69
id_LmTest
#define id_LmTest(A, lR)
Definition simpleideals.h:90
Q
#define Q
Definition sirandom.c:26

## scDegree()

void scDegree | ( | ideal | s,
|  | intvec * | modulweight,
|  | ideal | Q = NULL )

Definition at line 2057 of file hilb.cc.

{
int co;
int mu=0;
#if 0
if (hilb_Qt==NULL) hilb_Qt=makeQt();
poly h1;
if (id_IsModule(S,currRing))
h1 = hFirstSeries0p(S,Q,NULL,currRing,hilb_Qt);
else
h1 = hFirstSeries0m(S,Q,NULL, modulweight,currRing,hilb_Qt);
poly h2=hFirst2Second(h1,hilb_Qt,co);
int di = (currRing->N)-co;
if (h1==NULL) di=0;
poly p=h2;
while(p!=NULL)
{
mu+=n_Int(pGetCoeff(p),hilb_Qt->cf);
p_LmDelete(&p,hilb_Qt);
}
#else
bigintmat *h1=hFirstSeries0b(S,Q,NULL,modulweight,currRing,coeffs_BIGINT);
intvec *hseries1=new intvec(1,h1->cols());
for(int i=0;i<h1->cols();i++)
{
(*hseries1)[i]=n_Int(BIMATELEM(*h1,1,i+1),coeffs_BIGINT);
}
delete h1;
intvec *hseries2;
int l = hseries1->length()-1;
if (l > 1)
hseries2 = hSecondSeries(hseries1);
else
hseries2 = hseries1;
hDegreeSeries(hseries1, hseries2, &co, &mu);
if (l>1)
delete hseries1;
delete hseries2;
if ((l == 1) &&(mu == 0))
scPrintDegree((currRing->N)+1, 0);
else
#endif
scPrintDegree(co, mu);
}
BIMATELEM
#define BIMATELEM(M, I, J)
Definition bigintmat.h:133
bigintmat
Matrices of numbers.
Definition bigintmat.h:51
bigintmat::cols
int cols() const
Definition bigintmat.h:144
intvec::length
int length() const
Definition intvec.h:95
n_Int
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
scPrintDegree
void scPrintDegree(int co, int mu)
Definition hdegree.cc:910
hFirstSeries0m
poly hFirstSeries0m(ideal A, ideal Q, intvec *wdegree, intvec *shifts, const ring src, const ring Qt)
Definition hilb.cc:1427
hFirstSeries0p
poly hFirstSeries0p(ideal A, ideal Q, intvec *wdegree, const ring src, const ring Qt)
Definition hilb.cc:1384
hSecondSeries
intvec * hSecondSeries(intvec *hseries1)
Definition hilb.cc:71
makeQt
static ring makeQt()
Definition hilb.cc:196
hFirst2Second
poly hFirst2Second(poly h, const ring Qt, int &co)
Definition hilb.cc:124
hFirstSeries0b
bigintmat * hFirstSeries0b(ideal I, ideal Q, intvec *wdegree, intvec *shifts, const ring src, const coeffs biv_cf)
Definition hilb.cc:2019
hDegreeSeries
void hDegreeSeries(intvec *s1, intvec *s2, int *co, int *mu)
Definition hilb.cc:106
hilb_Qt
STATIC_VAR ring hilb_Qt
Definition hilb.cc:219
mu
static matrix mu(matrix A, const ring R)
Definition matpol.cc:2028
p_LmDelete
static void p_LmDelete(poly p, const ring r)
Definition p_polys.h:725
coeffs_BIGINT
VAR coeffs coeffs_BIGINT
Definition polys.cc:14
id_IsModule
BOOLEAN id_IsModule(ideal A, const ring src)
Definition simpleideals.cc:1011

## scDimInt()

int scDimInt | ( | ideal | s,
|  | ideal | Q = NULL )

ideal dimension

Definition at line 78 of file hdegree.cc.

{
id_Test(S, currRing);
if( Q!=NULL ) id_Test(Q, currRing);
int mc;
hexist = hInit(S, Q, &hNexist);
if (!hNexist)
return (currRing->N);
hwork = (scfmon)omAlloc(hNexist * sizeof(scmon));
hvar = (varset)omAlloc(((currRing->N) + 1) * sizeof(int));
hpure = (scmon)omAlloc((1 + ((currRing->N) * (currRing->N))) * sizeof(int));
mc = hisModule;
if (!mc)
{
hrad = hexist;
hNrad = hNexist;
}
else
hrad = (scfmon)omAlloc(hNexist * sizeof(scmon));
radmem = hCreate((currRing->N) - 1);
hCo = (currRing->N) + 1;
loop
{
if (mc)
hComp(hexist, hNexist, mc, hrad, &hNrad);
if (hNrad)
{
hNvar = (currRing->N);
hRadical(hrad, &hNrad, hNvar);
hSupp(hrad, hNrad, hvar, &hNvar);
if (hNvar)
{
memset(hpure, 0, ((currRing->N) + 1) * sizeof(int));
hPure(hrad, 0, &hNrad, hvar, hNvar, hpure, &hNpure);
hLexR(hrad, hNrad, hvar, hNvar);
hDimSolve(hpure, hNpure, hrad, hNrad, hvar, hNvar);
}
}
else
{
hCo = 0;
break;
}
mc--;
if (mc <= 0)
break;
}
hKill(radmem, (currRing->N) - 1);
omFreeSize((ADDRESS)hpure, (1 + ((currRing->N) * (currRing->N))) * sizeof(int));
omFreeSize((ADDRESS)hvar, ((currRing->N) + 1) * sizeof(int));
omFreeSize((ADDRESS)hwork, hNexist * sizeof(scmon));
hDelete(hexist, hNexist);
if (hisModule)
omFreeSize((ADDRESS)hrad, hNexist * sizeof(scmon));
return (currRing->N) - hCo;
}
hCo
VAR int hCo
Definition hdegree.cc:27
hDimSolve
void hDimSolve(scmon pure, int Npure, scfmon rad, int Nrad, varset var, int Nvar)
Definition hdegree.cc:35
hSupp
void hSupp(scfmon stc, int Nstc, varset var, int *Nvar)
Definition hutil.cc:174
hLexR
void hLexR(scfmon rad, int Nrad, varset var, int Nvar)
Definition hutil.cc:565
hrad
VAR scfmon hrad
Definition hutil.cc:16
hisModule
VAR int hisModule
Definition hutil.cc:20
radmem
VAR monf radmem
Definition hutil.cc:21
hNrad
VAR int hNrad
Definition hutil.cc:19
hRadical
void hRadical(scfmon rad, int *Nrad, int Nvar)
Definition hutil.cc:411
loop
#define loop
Definition structs.h:71

## scDimIntRing()

int scDimIntRing | ( | ideal | s,
|  | ideal | Q = NULL )

scDimInt for ring-coefficients

Definition at line 136 of file hdegree.cc.

{
if (rField_is_Ring(currRing))
{
int i = idPosConstant(vid);
if ((i != -1) && (n_IsUnit(pGetCoeff(vid->m[i]),currRing->cf)))
{ /* ideal v contains unit; dim = -1 */
return(-1);
}
ideal vv = id_Head(vid,currRing);
idSkipZeroes(vv);
i = idPosConstant(vid);
int d;
if(i == -1)
{
d = scDimInt(vv, Q);
if(rField_is_Z(currRing))
d++;
}
else
{
if(n_IsUnit(pGetCoeff(vv->m[i]),currRing->cf))
d = -1;
else
d = scDimInt(vv, Q);
}
//Anne's Idea for std(4,2x) = 0 bug
int dcurr = d;
for(unsigned ii=0;ii<(unsigned)IDELEMS(vv);ii++)
{
if(vv->m[ii] != NULL && !n_IsUnit(pGetCoeff(vv->m[ii]),currRing->cf))
{
ideal vc = idCopy(vv);
poly c = pInit();
pSetCoeff0(c,nCopy(pGetCoeff(vv->m[ii])));
idInsertPoly(vc,c);
idSkipZeroes(vc);
for(unsigned jj = 0;jj<(unsigned)IDELEMS(vc)-1;jj++)
{
if((vc->m[jj]!=NULL)
&& (n_DivBy(pGetCoeff(vc->m[jj]),pGetCoeff(c),currRing->cf)))
{
pDelete(&vc->m[jj]);
}
}
idSkipZeroes(vc);
i = idPosConstant(vc);
if (i != -1) pDelete(&vc->m[i]);
dcurr = scDimInt(vc, Q);
// the following assumes the ground rings to be either zero- or one-dimensional
if((i==-1) && rField_is_Z(currRing))
{
// should also be activated for other euclidean domains as groundfield
dcurr++;
}
idDelete(&vc);
}
if(dcurr > d)
d = dcurr;
}
idDelete(&vv);
return d;
}
return scDimInt(vid,Q);
}
n_DivBy
static FORCE_INLINE BOOLEAN n_DivBy(number a, number b, const coeffs r)
test whether 'a' is divisible 'b'; for r encoding a field: TRUE iff 'b' does not represent zero in Z:...
Definition coeffs.h:750
scDimInt
int scDimInt(ideal S, ideal Q)
ideal dimension
Definition hdegree.cc:78
idInsertPoly
BOOLEAN idInsertPoly(ideal h1, poly h2)
insert h2 into h1 (if h2 is not the zero polynomial) return TRUE iff h2 was indeed inserted
Definition simpleideals.cc:832
idCopy
ideal idCopy(ideal A)
Definition ideals.h:60
idPosConstant
#define idPosConstant(I)
index of generator with leading term in ground ring (if any); otherwise -1
Definition ideals.h:37
pSetCoeff0
#define pSetCoeff0(p, n)
Definition monomials.h:59
nCopy
#define nCopy(n)
Definition numbers.h:15
pDelete
#define pDelete(p_ptr)
Definition polys.h:187
rField_is_Z
static BOOLEAN rField_is_Z(const ring r)
Definition ring.h:515

## scIndIntvec()

intvec * scIndIntvec | ( | ideal | S,
|  | ideal | Q = NULL )

Definition at line 284 of file hdegree.cc.

{
id_Test(S, currRing);
if( Q!=NULL ) id_Test(Q, currRing);
intvec *Set=new intvec((currRing->N));
int mc,i;
hexist = hInit(S, Q, &hNexist);
if (hNexist==0)
{
for(i=0; i<(currRing->N); i++)
(*Set)[i]=1;
return Set;
}
hwork = (scfmon)omAlloc(hNexist * sizeof(scmon));
hvar = (varset)omAlloc(((currRing->N) + 1) * sizeof(int));
hpure = (scmon)omAlloc((1 + ((currRing->N) * (currRing->N))) * sizeof(int));
hInd = (scmon)omAlloc0((1 + (currRing->N)) * sizeof(int));
mc = hisModule;
if (mc==0)
{
hrad = hexist;
hNrad = hNexist;
}
else
hrad = (scfmon)omAlloc(hNexist * sizeof(scmon));
radmem = hCreate((currRing->N) - 1);
hCo = (currRing->N) + 1;
loop
{
if (mc!=0)
hComp(hexist, hNexist, mc, hrad, &hNrad);
if (hNrad!=0)
{
hNvar = (currRing->N);
hRadical(hrad, &hNrad, hNvar);
hSupp(hrad, hNrad, hvar, &hNvar);
if (hNvar!=0)
{
memset(hpure, 0, ((currRing->N) + 1) * sizeof(int));
hPure(hrad, 0, &hNrad, hvar, hNvar, hpure, &hNpure);
hLexR(hrad, hNrad, hvar, hNvar);
hIndSolve(hpure, hNpure, hrad, hNrad, hvar, hNvar);
}
}
else
{
hCo = 0;
break;
}
mc--;
if (mc <= 0)
break;
}
for(i=0; i<(currRing->N); i++)
(*Set)[i] = hInd[i+1];
hKill(radmem, (currRing->N) - 1);
omFreeSize((ADDRESS)hpure, (1 + ((currRing->N) * (currRing->N))) * sizeof(int));
omFreeSize((ADDRESS)hInd, (1 + (currRing->N)) * sizeof(int));
omFreeSize((ADDRESS)hvar, ((currRing->N) + 1) * sizeof(int));
omFreeSize((ADDRESS)hwork, hNexist * sizeof(scmon));
hDelete(hexist, hNexist);
if (hisModule)
omFreeSize((ADDRESS)hrad, hNexist * sizeof(scmon));
return Set;
}
hInd
STATIC_VAR scmon hInd
Definition hdegree.cc:203
hIndSolve
static void hIndSolve(scmon pure, int Npure, scfmon rad, int Nrad, varset var, int Nvar)
Definition hdegree.cc:205
omAlloc0
#define omAlloc0(size)
Definition omAllocDecl.h:211

## scKBase()

ideal scKBase | ( | int | deg,
|  | ideal | s,
|  | ideal | Q = NULL,
|  | intvec * | mv = NULL )

Definition at line 1414 of file hdegree.cc.

{
if( Q!=NULL) id_Test(Q, currRing);
int i, di;
poly p;
if (deg < 0)
{
di = scDimInt(s, Q);
if (di != 0)
{
//Werror("KBase not finite");
return idInit(1,s->rank);
}
}
stcmem = hCreate((currRing->N) - 1);
hexist = hInit(s, Q, &hNexist);
p = last = pInit();
/*pNext(p) = NULL;*/
act = (scmon)omAlloc(((currRing->N) + 1) * sizeof(int));
*act = 0;
if (!hNexist)
{
scAll((currRing->N), deg);
goto ende;
}
if (!hisModule)
{
if (deg < 0) scInKbase(hexist, hNexist, (currRing->N));
else scDegKbase(hexist, hNexist, (currRing->N), deg);
}
else
{
hstc = (scfmon)omAlloc(hNexist * sizeof(scmon));
for (i = 1; i <= hisModule; i++)
{
*act = i;
hComp(hexist, hNexist, i, hstc, &hNstc);
int deg_ei=deg;
if (mv!=NULL) deg_ei -= (*mv)[i-1];
if ((deg < 0) || (deg_ei>=0))
{
if (hNstc)
{
if (deg < 0) scInKbase(hstc, hNstc, (currRing->N));
else scDegKbase(hstc, hNstc, (currRing->N), deg_ei);
}
else
scAll((currRing->N), deg_ei);
}
}
omFreeSize((ADDRESS)hstc, hNexist * sizeof(scmon));
}
ende:
hDelete(hexist, hNexist);
omFreeSize((ADDRESS)act, ((currRing->N) + 1) * sizeof(int));
hKill(stcmem, (currRing->N) - 1);
pLmFree(&p);
if (p == NULL)
return idInit(1,s->rank);
last = p;
return scIdKbase(p, s->rank);
}
s
const CanonicalForm int s
Definition facAbsFact.cc:51
last
STATIC_VAR poly last
Definition hdegree.cc:1138
scAll
static void scAll(int Nvar, int deg)
Definition hdegree.cc:1225
scDegKbase
static void scDegKbase(scfmon stc, int Nstc, int Nvar, int deg)
Definition hdegree.cc:1259
act
STATIC_VAR scmon act
Definition hdegree.cc:1139
scIdKbase
static ideal scIdKbase(poly q, const int rank)
Definition hdegree.cc:1396
scInKbase
static void scInKbase(scfmon stc, int Nstc, int Nvar)
Definition hdegree.cc:1340
hstc
VAR scfmon hstc
Definition hutil.cc:16
idInit
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition simpleideals.cc:35

## scMult0Int()

long scMult0Int | ( | ideal | s,
|  | ideal | Q = NULL )

Definition at line 924 of file hdegree.cc.

{
id_LmTest(S, currRing);
if (Q!=NULL) id_LmTest(Q, currRing);
int mc;
hexist = hInit(S, Q, &hNexist);
if (!hNexist)
{
hMu = -1;
return -1;
}
else
hMu = 0;
const ring r = currRing;
hwork = (scfmon)omAlloc(hNexist * sizeof(scmon));
hvar = (varset)omAlloc(((r->N) + 1) * sizeof(int));
hpur0 = (scmon)omAlloc((1 + ((r->N) * (r->N))) * sizeof(int));
mc = hisModule;
if (!mc)
{
hstc = hexist;
hNstc = hNexist;
}
else
hstc = (scfmon)omAlloc(hNexist * sizeof(scmon));
stcmem = hCreate((r->N) - 1);
loop
{
if (mc)
{
hComp(hexist, hNexist, mc, hstc, &hNstc);
if (!hNstc)
{
hMu = -1;
break;
}
}
hNvar = (r->N);
for (int i = hNvar; i; i--)
hvar[i] = i;
hStaircase(hstc, &hNstc, hvar, hNvar);
hSupp(hstc, hNstc, hvar, &hNvar);
if ((hNvar == (r->N)) && (hNstc >= (r->N)))
{
if ((hNvar > 2) && (hNstc > 10))
hOrdSupp(hstc, hNstc, hvar, hNvar);
memset(hpur0, 0, ((r->N) + 1) * sizeof(int));
hPure(hstc, 0, &hNstc, hvar, hNvar, hpur0, &hNpure);
if (hNpure == hNvar)
{
hLexS(hstc, hNstc, hvar, hNvar);
hMu += hZeroMult(hpur0, hstc, hNstc, hvar, hNvar);
}
else
hMu = -1;
}
else if (hNvar)
hMu = -1;
mc--;
if (mc <= 0 || hMu < 0)
break;
}
hKill(stcmem, (r->N) - 1);
omFreeSize((ADDRESS)hpur0, (1 + ((r->N) * (r->N))) * sizeof(int));
omFreeSize((ADDRESS)hvar, ((r->N) + 1) * sizeof(int));
omFreeSize((ADDRESS)hwork, hNexist * sizeof(scmon));
hDelete(hexist, hNexist);
if (hisModule)
omFreeSize((ADDRESS)hstc, hNexist * sizeof(scmon));
return hMu;
}
hZeroMult
static long hZeroMult(scmon pure, scfmon stc, int Nstc, varset var, int Nvar)
Definition hdegree.cc:619
hMu
VAR long hMu
Definition hdegree.cc:28
hpur0
VAR scmon hpur0
Definition hutil.cc:17

## scMultInt()

int scMultInt | ( | ideal | s,
|  | ideal | Q = NULL )

Definition at line 901 of file hdegree.cc.

{
id_Test(S, currRing);
if( Q!=NULL ) id_Test(Q, currRing);
hDegree(S, Q);
return hMu;
}
hDegree
static void hDegree(ideal S, ideal Q)
Definition hdegree.cc:800

## scPrintDegree()

void scPrintDegree | ( | int | co,
|  | int | mu )

Definition at line 910 of file hdegree.cc.

{
int di = (currRing->N)-co;
if (currRing->OrdSgn == 1)
{
if (di>0)
Print("// dimension (proj.) = %d\n// degree (proj.) = %d\n", di-1, mu);
else
Print("// dimension (affine) = 0\n// degree (affine) = %d\n", mu);
}
else
Print("// dimension (local) = %d\n// multiplicity = %d\n", di, mu);
}