My Project
Loading...
Searching...
No Matches
hdegree.cc File Reference
#include "kernel/mod2.h"
#include "misc/intvec.h"
#include "coeffs/numbers.h"
#include "kernel/structs.h"
#include "kernel/ideals.h"
#include "kernel/polys.h"
#include "kernel/combinatorics/hutil.h"
#include "kernel/combinatorics/hilb.h"
#include "kernel/combinatorics/stairc.h"
#include "reporter/reporter.h"
#include <vector>
#include "misc/options.h"
#include "polys/shiftop.h"

Go to the source code of this file.

Functions

void hDimSolve (scmon pure, int Npure, scfmon rad, int Nrad, varset var, int Nvar)
int scDimInt (ideal S, ideal Q)
 ideal dimension
int scDimIntRing (ideal vid, ideal Q)
 scDimInt for ring-coefficients
static void hIndSolve (scmon pure, int Npure, scfmon rad, int Nrad, varset var, int Nvar)
intvecscIndIntvec (ideal S, ideal Q)
static BOOLEAN hNotZero (scfmon rad, int Nrad, varset var, int Nvar)
static void hIndep (scmon pure)
void hIndMult (scmon pure, int Npure, scfmon rad, int Nrad, varset var, int Nvar)
static BOOLEAN hCheck1 (indset sm, scmon pure)
static indset hCheck2 (indset sm, scmon pure)
static void hCheckIndep (scmon pure)
void hIndAllMult (scmon pure, int Npure, scfmon rad, int Nrad, varset var, int Nvar)
static long hZeroMult (scmon pure, scfmon stc, int Nstc, varset var, int Nvar)
static void hProject (scmon pure, varset sel)
static void hDimMult (scmon pure, int Npure, scfmon rad, int Nrad, varset var, int Nvar)
static void hDegree (ideal S, ideal Q)
int scMultInt (ideal S, ideal Q)
void scPrintDegree (int co, int mu)
long scMult0Int (ideal S, ideal Q)
static void hHedge (poly hEdge)
static void hHedgeStep (scmon pure, scfmon stc, int Nstc, varset var, int Nvar, poly hEdge)
void scComputeHC (ideal S, ideal Q, int ak, poly &hEdge)
static void scElKbase ()
static int scMax (int i, scfmon stc, int Nvar)
static int scMin (int i, scfmon stc, int Nvar)
static int scRestrict (int &Nstc, scfmon stc, int Nvar)
static void scAll (int Nvar, int deg)
static void scAllKbase (int Nvar, int ideg, int deg)
static void scDegKbase (scfmon stc, int Nstc, int Nvar, int deg)
static void scInKbase (scfmon stc, int Nstc, int Nvar)
static ideal scIdKbase (poly q, const int rank)
ideal scKBase (int deg, ideal s, ideal Q, intvec *mv)
static std::vector< int > countCycles (const intvec *_G, int v, std::vector< int > path, std::vector< BOOLEAN > visited, std::vector< BOOLEAN > cyclic, std::vector< int > cache)
static int graphGrowth (const intvec *G)
static void _lp_computeNormalWords (ideal words, int &numberOfNormalWords, int length, ideal M, int minDeg, int &last)
static ideal lp_computeNormalWords (int length, ideal M)
static int lp_countNormalWords (int upToLength, ideal M)
intveclp_ufnarovskiGraph (ideal G, ideal &standardWords)
int lp_gkDim (const ideal _G)
static std::vector< std::vector< int > > iv2vv (intvec *M)
static void vvDeleteRow (std::vector< std::vector< int > > &mat, int row)
static void vvDeleteColumn (std::vector< std::vector< int > > &mat, int col)
static BOOLEAN vvIsRowZero (const std::vector< std::vector< int > > &mat, int row)
static BOOLEAN vvIsColumnZero (const std::vector< std::vector< int > > &mat, int col)
static BOOLEAN vvIsZero (const std::vector< std::vector< int > > &mat)
static std::vector< std::vector< int > > vvMult (const std::vector< std::vector< int > > &a, const std::vector< std::vector< int > > &b)
static BOOLEAN isAcyclic (const intvec *G)
int lp_kDim (const ideal _G)

Variables

VAR int hCo
VAR int hMu2
VAR long hMu
VAR omBin indlist_bin = omGetSpecBin(sizeof(indlist))
STATIC_VAR scmon hInd
VAR indset ISet
VAR indset JSet
STATIC_VAR poly pWork
STATIC_VAR poly last
STATIC_VAR scmon act

Function Documentation

◆ _lp_computeNormalWords()

void _lp_computeNormalWords ( ideal words,
int & numberOfNormalWords,
int length,
ideal M,
int minDeg,
int & last )
static

Definition at line 1666 of file hdegree.cc.

1667{
1668 if (length <= 0){
1669 poly one = pOne();
1670 if (p_LPDivisibleBy(M, one, currRing)) // 1 \in M => no normal words at all
1671 {
1672 pDelete(&one);
1673 last = -1;
1674 numberOfNormalWords = 0;
1675 }
1676 else
1677 {
1678 words->m[0] = one;
1679 last = 0;
1680 numberOfNormalWords = 1;
1681 }
1682 return;
1683 }
1684
1685 _lp_computeNormalWords(words, numberOfNormalWords, length - 1, M, minDeg, last);
1686
1687 int nVars = currRing->isLPring - currRing->LPncGenCount;
1688 int numberOfNewNormalWords = 0;
1689
1690 for (int j = nVars - 1; j >= 0; j--)
1691 {
1692 for (int i = last; i >= 0; i--)
1693 {
1694 int index = (j * (last + 1)) + i;
1695
1696 if (words->m[i] != NULL)
1697 {
1698 if (j > 0) {
1699 words->m[index] = pCopy(words->m[i]);
1700 }
1701
1702 int varOffset = ((length - 1) * currRing->isLPring) + 1;
1703 pSetExp(words->m[index], varOffset + j, 1);
1704 pSetm(words->m[index]);
1705 pTest(words->m[index]);
1706
1707 if (length >= minDeg && p_LPDivisibleBy(M, words->m[index], currRing))
1708 {
1709 pDelete(&words->m[index]);
1710 words->m[index] = NULL;
1711 }
1712 else
1713 {
1714 numberOfNewNormalWords++;
1715 }
1716 }
1717 }
1718 }
1719
1720 last = nVars * last + nVars - 1;
1721
1722 numberOfNormalWords += numberOfNewNormalWords;
1723}
int i
Definition cfEzgcd.cc:132
int j
Definition facHensel.cc:110
STATIC_VAR poly last
Definition hdegree.cc:1138
static void _lp_computeNormalWords(ideal words, int &numberOfNormalWords, int length, ideal M, int minDeg, int &last)
Definition hdegree.cc:1666
static BOOLEAN length(leftv result, leftv arg)
Definition interval.cc:257
#define NULL
Definition omList.c:12
static int index(p_Length length, p_Ord ord)
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition polys.cc:13
#define pTest(p)
Definition polys.h:415
#define pDelete(p_ptr)
Definition polys.h:187
#define pSetm(p)
Definition polys.h:272
#define pSetExp(p, i, v)
Definition polys.h:43
#define pCopy(p)
return a copy of the poly
Definition polys.h:186
#define pOne()
Definition polys.h:316
BOOLEAN p_LPDivisibleBy(poly a, poly b, const ring r)
Definition shiftop.cc:776
#define M
Definition sirandom.c:25

◆ countCycles()

std::vector< int > countCycles ( const intvec * _G,
int v,
std::vector< int > path,
std::vector< BOOLEAN > visited,
std::vector< BOOLEAN > cyclic,
std::vector< int > cache )
static

Definition at line 1575 of file hdegree.cc.

1576{
1577 intvec* G = ivCopy(_G); // modifications must be local
1578
1579 if (cache[v] != -2) return cache; // value is already cached
1580
1581 visited[v] = TRUE;
1582 path.push_back(v);
1583
1584 int cycles = 0;
1585 for (int w = 0; w < G->cols(); w++)
1586 {
1587 if (IMATELEM(*G, v + 1, w + 1)) // edge v -> w exists in G
1588 {
1589 if (!visited[w])
1590 { // continue with w
1591 cache = countCycles(G, w, path, visited, cyclic, cache);
1592 if (cache[w] == -1)
1593 {
1594 cache[v] = -1;
1595 return cache;
1596 }
1597 cycles = si_max(cycles, cache[w]);
1598 }
1599 else
1600 { // found new cycle
1601 int pathIndexOfW = -1;
1602 for (int i = path.size() - 1; i >= 0; i--) {
1603 if (cyclic[path[i]] == 1) { // found an already cyclic vertex
1604 cache[v] = -1;
1605 return cache;
1606 }
1607 cyclic[path[i]] = TRUE;
1608
1609 if (path[i] == w) { // end of the cycle
1610 assume(IMATELEM(*G, v + 1, w + 1) != 0);
1611 IMATELEM(*G, v + 1, w + 1) = 0; // remove edge v -> w
1612 pathIndexOfW = i;
1613 break;
1614 } else {
1615 assume(IMATELEM(*G, path[i - 1] + 1, path[i] + 1) != 0);
1616 IMATELEM(*G, path[i - 1] + 1, path[i] + 1) = 0; // remove edge vi-1 -> vi
1617 }
1618 }
1619 assume(pathIndexOfW != -1); // should never happen
1620 for (int i = path.size() - 1; i >= pathIndexOfW; i--) {
1621 cache = countCycles(G, path[i], path, visited, cyclic, cache);
1622 if (cache[path[i]] == -1)
1623 {
1624 cache[v] = -1;
1625 return cache;
1626 }
1627 cycles = si_max(cycles, cache[path[i]] + 1);
1628 }
1629 }
1630 }
1631 }
1632 cache[v] = cycles;
1633
1634 delete G;
1635 return cache;
1636}
static int si_max(const int a, const int b)
Definition auxiliary.h:125
#define TRUE
Definition auxiliary.h:101
const CanonicalForm & w
Definition facAbsFact.cc:51
const Variable & v
< [in] a sqrfree bivariate poly
Definition facBivar.h:39
static std::vector< int > countCycles(const intvec *_G, int v, std::vector< int > path, std::vector< BOOLEAN > visited, std::vector< BOOLEAN > cyclic, std::vector< int > cache)
Definition hdegree.cc:1575
intvec * ivCopy(const intvec *o)
Definition intvec.h:146
#define IMATELEM(M, I, J)
Definition intvec.h:86
STATIC_VAR TreeM * G
Definition janet.cc:31
#define assume(x)
Definition mod2.h:389

◆ graphGrowth()

int graphGrowth ( const intvec * G)
static

Definition at line 1639 of file hdegree.cc.

1640{
1641 // init
1642 int n = G->cols();
1643 std::vector<int> path;
1644 std::vector<BOOLEAN> visited;
1645 std::vector<BOOLEAN> cyclic;
1646 std::vector<int> cache;
1647 visited.resize(n, FALSE);
1648 cyclic.resize(n, FALSE);
1649 cache.resize(n, -2);
1650
1651 // get max number of cycles
1652 int cycles = 0;
1653 for (int v = 0; v < n; v++)
1654 {
1655 cache = countCycles(G, v, path, visited, cyclic, cache);
1656 if (cache[v] == -1)
1657 return -1;
1658 cycles = si_max(cycles, cache[v]);
1659 }
1660 return cycles;
1661}
#define FALSE
Definition auxiliary.h:97

◆ hCheck1()

BOOLEAN hCheck1 ( indset sm,
scmon pure )
static

Definition at line 463 of file hdegree.cc.

464{
465 int iv;
466 intvec *Set;
467 while (sm->nx != NULL)
468 {
469 Set = sm->set;
470 iv=(currRing->N);
471 loop
472 {
473 if (((*Set)[iv-1] == 0) && (pure[iv] == 0))
474 break;
475 iv--;
476 if (iv == 0)
477 return FALSE;
478 }
479 sm = sm->nx;
480 }
481 return TRUE;
482}
#define loop
Definition structs.h:71

◆ hCheck2()

indset hCheck2 ( indset sm,
scmon pure )
static

Definition at line 489 of file hdegree.cc.

490{
491 int iv;
492 intvec *Set;
493 indset be, a1 = NULL;
494 while (sm->nx != NULL)
495 {
496 Set = sm->set;
497 iv=(currRing->N);
498 loop
499 {
500 if ((pure[iv] == 1) && ((*Set)[iv-1] == 1))
501 break;
502 iv--;
503 if (iv == 0)
504 {
505 if (a1 == NULL)
506 {
507 a1 = sm;
508 }
509 else
510 {
511 hMu2--;
512 be->nx = sm->nx;
513 delete Set;
515 sm = be;
516 }
517 break;
518 }
519 }
520 be = sm;
521 sm = sm->nx;
522 }
523 if (a1 != NULL)
524 {
525 return a1;
526 }
527 else
528 {
529 hMu2++;
530 sm->set = new intvec((currRing->N));
531 sm->nx = (indset)omAlloc0Bin(indlist_bin);
532 return sm;
533 }
534}
void * ADDRESS
Definition auxiliary.h:120
VAR omBin indlist_bin
Definition hdegree.cc:29
VAR int hMu2
Definition hdegree.cc:27
indlist * indset
Definition hutil.h:28
#define omAlloc0Bin(bin)
#define omFreeBin(addr, bin)

◆ hCheckIndep()

void hCheckIndep ( scmon pure)
static

Definition at line 541 of file hdegree.cc.

542{
543 intvec *Set;
544 indset res;
545 int iv;
546 if (hCheck1(ISet, pure))
547 {
548 if (hCheck1(JSet, pure))
549 {
550 res = hCheck2(JSet,pure);
551 if (res == NULL)
552 return;
553 Set = res->set;
554 for (iv=(currRing->N); iv; iv--)
555 {
556 (*Set)[iv-1] = (pure[iv]==0);
557 }
558 }
559 }
560}
CanonicalForm res
Definition facAbsFact.cc:60
static indset hCheck2(indset sm, scmon pure)
Definition hdegree.cc:489
static BOOLEAN hCheck1(indset sm, scmon pure)
Definition hdegree.cc:463
VAR indset ISet
Definition hdegree.cc:351
VAR indset JSet
Definition hdegree.cc:351

◆ hDegree()

void hDegree ( ideal S,
ideal Q )
static

Definition at line 800 of file hdegree.cc.

801{
802 id_Test(S, currRing);
803 if( Q!=NULL ) id_Test(Q, currRing);
804
805 int di;
806 int mc;
807 hexist = hInit(S, Q, &hNexist);
808 if (!hNexist)
809 {
810 hCo = 0;
811 hMu = 1;
812 return;
813 }
814 //hWeight();
815 hwork = (scfmon)omAlloc(hNexist * sizeof(scmon));
816 hvar = (varset)omAlloc(((currRing->N) + 1) * sizeof(int));
817 hsel = (varset)omAlloc(((currRing->N) + 1) * sizeof(int));
818 hpure = (scmon)omAlloc((1 + ((currRing->N) * (currRing->N))) * sizeof(int));
819 hpur0 = (scmon)omAlloc((1 + ((currRing->N) * (currRing->N))) * sizeof(int));
820 mc = hisModule;
821 hrad = (scfmon)omAlloc(hNexist * sizeof(scmon));
822 if (!mc)
823 {
824 memcpy(hrad, hexist, hNexist * sizeof(scmon));
825 hstc = hexist;
826 hNrad = hNstc = hNexist;
827 }
828 else
829 hstc = (scfmon)omAlloc(hNexist * sizeof(scmon));
830 radmem = hCreate((currRing->N) - 1);
831 stcmem = hCreate((currRing->N) - 1);
832 hCo = (currRing->N) + 1;
833 di = hCo + 1;
834 loop
835 {
836 if (mc)
837 {
838 hComp(hexist, hNexist, mc, hrad, &hNrad);
839 hNstc = hNrad;
840 memcpy(hstc, hrad, hNrad * sizeof(scmon));
841 }
842 if (hNrad)
843 {
844 hNvar = (currRing->N);
847 if (hNvar)
848 {
849 hCo = hNvar;
850 memset(hpure, 0, ((currRing->N) + 1) * sizeof(int));
851 hPure(hrad, 0, &hNrad, hvar, hNvar, hpure, &hNpure);
854 }
855 }
856 else
857 {
858 hNvar = 1;
859 hCo = 0;
860 }
861 if (hCo < di)
862 {
863 di = hCo;
864 hMu = 0;
865 }
866 if (hNvar && (hCo == di))
867 {
868 if (di && (di < (currRing->N)))
870 else if (!di)
871 hMu++;
872 else
873 {
875 if ((hNvar > 2) && (hNstc > 10))
877 memset(hpur0, 0, ((currRing->N) + 1) * sizeof(int));
878 hPure(hstc, 0, &hNstc, hvar, hNvar, hpur0, &hNpure);
881 }
882 }
883 mc--;
884 if (mc <= 0)
885 break;
886 }
887 hCo = di;
888 hKill(stcmem, (currRing->N) - 1);
889 hKill(radmem, (currRing->N) - 1);
890 omFreeSize((ADDRESS)hpur0, (1 + ((currRing->N) * (currRing->N))) * sizeof(int));
891 omFreeSize((ADDRESS)hpure, (1 + ((currRing->N) * (currRing->N))) * sizeof(int));
892 omFreeSize((ADDRESS)hsel, ((currRing->N) + 1) * sizeof(int));
893 omFreeSize((ADDRESS)hvar, ((currRing->N) + 1) * sizeof(int));
894 omFreeSize((ADDRESS)hwork, hNexist * sizeof(scmon));
895 omFreeSize((ADDRESS)hrad, hNexist * sizeof(scmon));
897 if (hisModule)
898 omFreeSize((ADDRESS)hstc, hNexist * sizeof(scmon));
899}
static long hZeroMult(scmon pure, scfmon stc, int Nstc, varset var, int Nvar)
Definition hdegree.cc:619
static void hDimMult(scmon pure, int Npure, scfmon rad, int Nrad, varset var, int Nvar)
Definition hdegree.cc:724
VAR int hCo
Definition hdegree.cc:27
VAR long hMu
Definition hdegree.cc:28
void hDimSolve(scmon pure, int Npure, scfmon rad, int Nrad, varset var, int Nvar)
Definition hdegree.cc:35
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
VAR scmon hpur0
Definition hutil.cc:17
VAR monf stcmem
Definition hutil.cc:21
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 hSupp(scfmon stc, int Nstc, varset var, int *Nvar)
Definition hutil.cc:174
void hLexR(scfmon rad, int Nrad, varset var, int Nvar)
Definition hutil.cc:565
VAR scmon hpure
Definition hutil.cc:17
VAR scfmon hrad
Definition hutil.cc:16
VAR int hisModule
Definition hutil.cc:20
void hStaircase(scfmon stc, int *Nstc, varset var, int Nvar)
Definition hutil.cc:313
VAR monf radmem
Definition hutil.cc:21
void hOrdSupp(scfmon stc, int Nstc, varset var, int Nvar)
Definition hutil.cc:202
VAR varset hsel
Definition hutil.cc:18
VAR int hNpure
Definition hutil.cc:19
VAR int hNrad
Definition hutil.cc:19
scfmon hInit(ideal S, ideal Q, int *Nexist)
Definition hutil.cc:31
VAR scfmon hexist
Definition hutil.cc:16
void hRadical(scfmon rad, int *Nrad, int Nvar)
Definition hutil.cc:411
VAR int hNstc
Definition hutil.cc:19
VAR int hNvar
Definition hutil.cc:19
scmon * scfmon
Definition hutil.h:15
int * varset
Definition hutil.h:16
int * scmon
Definition hutil.h:14
#define omFreeSize(addr, size)
#define omAlloc(size)
#define id_Test(A, lR)
#define Q
Definition sirandom.c:26

◆ hDimMult()

void hDimMult ( scmon pure,
int Npure,
scfmon rad,
int Nrad,
varset var,
int Nvar )
static

Definition at line 724 of file hdegree.cc.

726{
727 int dn, iv, rad0, b, c, x;
728 scmon pn;
729 scfmon rn;
730 if (Nrad < 2)
731 {
732 dn = Npure + Nrad;
733 if (dn == hCo)
734 {
735 if (!Nrad)
736 hProject(pure, hsel);
737 else
738 {
739 pn = *rad;
740 for (iv = Nvar; iv; iv--)
741 {
742 x = var[iv];
743 if (pn[x])
744 {
745 pure[x] = 1;
746 hProject(pure, hsel);
747 pure[x] = 0;
748 }
749 }
750 }
751 }
752 return;
753 }
754 iv = Nvar;
755 dn = Npure+1;
756 if (dn >= hCo)
757 {
758 if (dn > hCo)
759 return;
760 loop
761 {
762 if(!pure[var[iv]])
763 {
764 if(hNotZero(rad, Nrad, var, iv))
765 {
766 pure[var[iv]] = 1;
767 hProject(pure, hsel);
768 pure[var[iv]] = 0;
769 }
770 }
771 iv--;
772 if (!iv)
773 return;
774 }
775 }
776 while(pure[var[iv]]) iv--;
777 hStepR(rad, Nrad, var, iv, &rad0);
778 iv--;
779 if (rad0 < Nrad)
780 {
781 pn = hGetpure(pure);
782 rn = hGetmem(Nrad, rad, radmem[iv]);
783 pn[var[iv + 1]] = 1;
784 hDimMult(pn, Npure + 1, rn, rad0, var, iv);
785 pn[var[iv + 1]] = 0;
786 b = rad0;
787 c = Nrad;
788 hElimR(rn, &rad0, b, c, var, iv);
789 hPure(rn, b, &c, var, iv, pn, &x);
790 hLex2R(rn, rad0, b, c, var, iv, hwork);
791 rad0 += (c - b);
792 hDimMult(pn, Npure + x, rn, rad0, var, iv);
793 }
794 else
795 {
796 hDimMult(pure, Npure, rad, Nrad, var, iv);
797 }
798}
Variable x
Definition cfModGcd.cc:4090
CanonicalForm b
Definition cfModGcd.cc:4111
static BOOLEAN hNotZero(scfmon rad, int Nrad, varset var, int Nvar)
Definition hdegree.cc:353
static void hProject(scmon pure, varset sel)
Definition hdegree.cc:701
scfmon hGetmem(int lm, scfmon old, monp monmem)
Definition hutil.cc:1023
void hStepR(scfmon rad, int Nrad, varset var, int Nvar, int *a)
Definition hutil.cc:974
void hLex2R(scfmon rad, int e1, int a2, int e2, varset var, int Nvar, scfmon w)
Definition hutil.cc:880
void hElimR(scfmon rad, int *e1, int a2, int e2, varset var, int Nvar)
Definition hutil.cc:742
scmon hGetpure(scmon p)
Definition hutil.cc:1052

◆ hDimSolve()

void hDimSolve ( scmon pure,
int Npure,
scfmon rad,
int Nrad,
varset var,
int Nvar )

Definition at line 35 of file hdegree.cc.

37{
38 int dn, iv, rad0, b, c, x;
39 scmon pn;
40 scfmon rn;
41 if (Nrad < 2)
42 {
43 dn = Npure + Nrad;
44 if (dn < hCo)
45 hCo = dn;
46 return;
47 }
48 if (Npure+1 >= hCo)
49 return;
50 iv = Nvar;
51 while(pure[var[iv]]) iv--;
52 hStepR(rad, Nrad, var, iv, &rad0);
53 if (rad0!=0)
54 {
55 iv--;
56 if (rad0 < Nrad)
57 {
58 pn = hGetpure(pure);
59 rn = hGetmem(Nrad, rad, radmem[iv]);
60 hDimSolve(pn, Npure + 1, rn, rad0, var, iv);
61 b = rad0;
62 c = Nrad;
63 hElimR(rn, &rad0, b, c, var, iv);
64 hPure(rn, b, &c, var, iv, pn, &x);
65 hLex2R(rn, rad0, b, c, var, iv, hwork);
66 rad0 += (c - b);
67 hDimSolve(pn, Npure + x, rn, rad0, var, iv);
68 }
69 else
70 {
71 hDimSolve(pure, Npure, rad, Nrad, var, iv);
72 }
73 }
74 else
75 hCo = Npure + 1;
76}

◆ hHedge()

void hHedge ( poly hEdge)
static

Definition at line 1003 of file hdegree.cc.

1004{
1005 pSetm(pWork);
1006 if (pLmCmp(pWork, hEdge) == currRing->OrdSgn)
1007 {
1008 for (int i = hNvar; i>0; i--)
1009 pSetExp(hEdge,i, pGetExp(pWork,i));
1010 pSetm(hEdge);
1011 }
1012}
STATIC_VAR poly pWork
Definition hdegree.cc:1001
#define pGetExp(p, i)
Exponent.
Definition polys.h:42
#define pLmCmp(p, q)
returns 0|1|-1 if p=q|p>q|p<q w.r.t monomial ordering
Definition polys.h:106

◆ hHedgeStep()

void hHedgeStep ( scmon pure,
scfmon stc,
int Nstc,
varset var,
int Nvar,
poly hEdge )
static

Definition at line 1014 of file hdegree.cc.

1016{
1017 int iv = Nvar -1, k = var[Nvar], a, a0, a1, b, i;
1018 int x/*, x0*/;
1019 scmon pn;
1020 scfmon sn;
1021 if (iv==0)
1022 {
1023 pSetExp(pWork, k, pure[k]);
1024 hHedge(hEdge);
1025 return;
1026 }
1027 else if (Nstc==0)
1028 {
1029 for (i = Nvar; i>0; i--)
1030 pSetExp(pWork, var[i], pure[var[i]]);
1031 hHedge(hEdge);
1032 return;
1033 }
1034 x = a = 0;
1035 pn = hGetpure(pure);
1036 sn = hGetmem(Nstc, stc, stcmem[iv]);
1037 hStepS(sn, Nstc, var, Nvar, &a, &x);
1038 if (a == Nstc)
1039 {
1040 pSetExp(pWork, k, pure[k]);
1041 hHedgeStep(pn, sn, a, var, iv,hEdge);
1042 return;
1043 }
1044 else
1045 {
1046 pSetExp(pWork, k, x);
1047 hHedgeStep(pn, sn, a, var, iv,hEdge);
1048 }
1049 b = a;
1050 loop
1051 {
1052 a0 = a;
1053 // x0 = x;
1054 hStepS(sn, Nstc, var, Nvar, &a, &x);
1055 hElimS(sn, &b, a0, a, var, iv);
1056 a1 = a;
1057 hPure(sn, a0, &a1, var, iv, pn, &i);
1058 hLex2S(sn, b, a0, a1, var, iv, hwork);
1059 b += (a1 - a0);
1060 if (a < Nstc)
1061 {
1062 pSetExp(pWork, k, x);
1063 hHedgeStep(pn, sn, b, var, iv,hEdge);
1064 }
1065 else
1066 {
1067 pSetExp(pWork, k, pure[k]);
1068 hHedgeStep(pn, sn, b, var, iv,hEdge);
1069 return;
1070 }
1071 }
1072}
int k
Definition cfEzgcd.cc:99
static void hHedgeStep(scmon pure, scfmon stc, int Nstc, varset var, int Nvar, poly hEdge)
Definition hdegree.cc:1014
static void hHedge(poly hEdge)
Definition hdegree.cc:1003
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
void hStepS(scfmon stc, int Nstc, varset var, int Nvar, int *a, int *x)
Definition hutil.cc:949

◆ hIndAllMult()

void hIndAllMult ( scmon pure,
int Npure,
scfmon rad,
int Nrad,
varset var,
int Nvar )

Definition at line 562 of file hdegree.cc.

564{
565 int dn, iv, rad0, b, c, x;
566 scmon pn;
567 scfmon rn;
568 if (Nrad < 2)
569 {
570 dn = Npure + Nrad;
571 if (dn > hCo)
572 {
573 if (!Nrad)
574 hCheckIndep(pure);
575 else
576 {
577 pn = *rad;
578 for (iv = Nvar; iv; iv--)
579 {
580 x = var[iv];
581 if (pn[x])
582 {
583 pure[x] = 1;
584 hCheckIndep(pure);
585 pure[x] = 0;
586 }
587 }
588 }
589 }
590 return;
591 }
592 iv = Nvar;
593 while(pure[var[iv]]) iv--;
594 hStepR(rad, Nrad, var, iv, &rad0);
595 iv--;
596 if (rad0 < Nrad)
597 {
598 pn = hGetpure(pure);
599 rn = hGetmem(Nrad, rad, radmem[iv]);
600 pn[var[iv + 1]] = 1;
601 hIndAllMult(pn, Npure + 1, rn, rad0, var, iv);
602 pn[var[iv + 1]] = 0;
603 b = rad0;
604 c = Nrad;
605 hElimR(rn, &rad0, b, c, var, iv);
606 hPure(rn, b, &c, var, iv, pn, &x);
607 hLex2R(rn, rad0, b, c, var, iv, hwork);
608 rad0 += (c - b);
609 hIndAllMult(pn, Npure + x, rn, rad0, var, iv);
610 }
611 else
612 {
613 hIndAllMult(pure, Npure, rad, Nrad, var, iv);
614 }
615}
static void hCheckIndep(scmon pure)
Definition hdegree.cc:541
void hIndAllMult(scmon pure, int Npure, scfmon rad, int Nrad, varset var, int Nvar)
Definition hdegree.cc:562

◆ hIndep()

void hIndep ( scmon pure)
static

Definition at line 368 of file hdegree.cc.

369{
370 int iv;
371 intvec *Set;
372
373 Set = ISet->set = new intvec((currRing->N));
374 for (iv=(currRing->N); iv!=0 ; iv--)
375 {
376 (*Set)[iv-1] = (pure[iv]==0);
377 }
379 hMu++;
380}

◆ hIndMult()

void hIndMult ( scmon pure,
int Npure,
scfmon rad,
int Nrad,
varset var,
int Nvar )

Definition at line 382 of file hdegree.cc.

384{
385 int dn, iv, rad0, b, c, x;
386 scmon pn;
387 scfmon rn;
388 if (Nrad < 2)
389 {
390 dn = Npure + Nrad;
391 if (dn == hCo)
392 {
393 if (Nrad==0)
394 hIndep(pure);
395 else
396 {
397 pn = *rad;
398 for (iv = Nvar; iv!=0; iv--)
399 {
400 x = var[iv];
401 if (pn[x])
402 {
403 pure[x] = 1;
404 hIndep(pure);
405 pure[x] = 0;
406 }
407 }
408 }
409 }
410 return;
411 }
412 iv = Nvar;
413 dn = Npure+1;
414 if (dn >= hCo)
415 {
416 if (dn > hCo)
417 return;
418 loop
419 {
420 if(!pure[var[iv]])
421 {
422 if(hNotZero(rad, Nrad, var, iv))
423 {
424 pure[var[iv]] = 1;
425 hIndep(pure);
426 pure[var[iv]] = 0;
427 }
428 }
429 iv--;
430 if (!iv)
431 return;
432 }
433 }
434 while(pure[var[iv]]) iv--;
435 hStepR(rad, Nrad, var, iv, &rad0);
436 iv--;
437 if (rad0 < Nrad)
438 {
439 pn = hGetpure(pure);
440 rn = hGetmem(Nrad, rad, radmem[iv]);
441 pn[var[iv + 1]] = 1;
442 hIndMult(pn, Npure + 1, rn, rad0, var, iv);
443 pn[var[iv + 1]] = 0;
444 b = rad0;
445 c = Nrad;
446 hElimR(rn, &rad0, b, c, var, iv);
447 hPure(rn, b, &c, var, iv, pn, &x);
448 hLex2R(rn, rad0, b, c, var, iv, hwork);
449 rad0 += (c - b);
450 hIndMult(pn, Npure + x, rn, rad0, var, iv);
451 }
452 else
453 {
454 hIndMult(pure, Npure, rad, Nrad, var, iv);
455 }
456}
void hIndMult(scmon pure, int Npure, scfmon rad, int Nrad, varset var, int Nvar)
Definition hdegree.cc:382
static void hIndep(scmon pure)
Definition hdegree.cc:368

◆ hIndSolve()

void hIndSolve ( scmon pure,
int Npure,
scfmon rad,
int Nrad,
varset var,
int Nvar )
static

Definition at line 205 of file hdegree.cc.

207{
208 int dn, iv, rad0, b, c, x;
209 scmon pn;
210 scfmon rn;
211 if (Nrad < 2)
212 {
213 dn = Npure + Nrad;
214 if (dn < hCo)
215 {
216 hCo = dn;
217 for (iv=(currRing->N); iv; iv--)
218 {
219 if (pure[iv])
220 hInd[iv] = 0;
221 else
222 hInd[iv] = 1;
223 }
224 if (Nrad)
225 {
226 pn = *rad;
227 iv = Nvar;
228 loop
229 {
230 x = var[iv];
231 if (pn[x])
232 {
233 hInd[x] = 0;
234 break;
235 }
236 iv--;
237 }
238 }
239 }
240 return;
241 }
242 if (Npure+1 >= hCo)
243 return;
244 iv = Nvar;
245 while(pure[var[iv]]) iv--;
246 hStepR(rad, Nrad, var, iv, &rad0);
247 if (rad0)
248 {
249 iv--;
250 if (rad0 < Nrad)
251 {
252 pn = hGetpure(pure);
253 rn = hGetmem(Nrad, rad, radmem[iv]);
254 pn[var[iv + 1]] = 1;
255 hIndSolve(pn, Npure + 1, rn, rad0, var, iv);
256 pn[var[iv + 1]] = 0;
257 b = rad0;
258 c = Nrad;
259 hElimR(rn, &rad0, b, c, var, iv);
260 hPure(rn, b, &c, var, iv, pn, &x);
261 hLex2R(rn, rad0, b, c, var, iv, hwork);
262 rad0 += (c - b);
263 hIndSolve(pn, Npure + x, rn, rad0, var, iv);
264 }
265 else
266 {
267 hIndSolve(pure, Npure, rad, Nrad, var, iv);
268 }
269 }
270 else
271 {
272 hCo = Npure + 1;
273 for (x=(currRing->N); x; x--)
274 {
275 if (pure[x])
276 hInd[x] = 0;
277 else
278 hInd[x] = 1;
279 }
280 hInd[var[iv]] = 0;
281 }
282}
STATIC_VAR scmon hInd
Definition hdegree.cc:203
static void hIndSolve(scmon pure, int Npure, scfmon rad, int Nrad, varset var, int Nvar)
Definition hdegree.cc:205

◆ hNotZero()

BOOLEAN hNotZero ( scfmon rad,
int Nrad,
varset var,
int Nvar )
static

Definition at line 353 of file hdegree.cc.

354{
355 int k1, i;
356 k1 = var[Nvar];
357 i = 0;
358 loop
359 {
360 if (rad[i][k1]==0)
361 return FALSE;
362 i++;
363 if (i == Nrad)
364 return TRUE;
365 }
366}

◆ hProject()

void hProject ( scmon pure,
varset sel )
static

Definition at line 701 of file hdegree.cc.

702{
703 int i, i0, k;
704 i0 = 0;
705 for (i = 1; i <= (currRing->N); i++)
706 {
707 if (pure[i])
708 {
709 i0++;
710 sel[i0] = i;
711 }
712 }
713 i = hNstc;
714 memcpy(hwork, hstc, i * sizeof(scmon));
715 hStaircase(hwork, &i, sel, i0);
716 if ((i0 > 2) && (i > 10))
717 hOrdSupp(hwork, i, sel, i0);
718 memset(hpur0, 0, ((currRing->N) + 1) * sizeof(int));
719 hPure(hwork, 0, &i, sel, i0, hpur0, &k);
720 hLexS(hwork, i, sel, i0);
721 hMu += hZeroMult(hpur0, hwork, i, sel, i0);
722}

◆ hZeroMult()

long hZeroMult ( scmon pure,
scfmon stc,
int Nstc,
varset var,
int Nvar )
static

Definition at line 619 of file hdegree.cc.

620{
621 int iv = Nvar -1, a, a0, a1, b, i;
622 long sum;
623 int x, x0;
624 scmon pn;
625 scfmon sn;
626 if (!iv)
627 return pure[var[1]];
628 else if (!Nstc)
629 {
630 sum = 1;
631 for (i = Nvar; i; i--)
632 sum *= pure[var[i]];
633 return sum;
634 }
635 x = a = 0;
636 pn = hGetpure(pure);
637 sn = hGetmem(Nstc, stc, stcmem[iv]);
638 hStepS(sn, Nstc, var, Nvar, &a, &x);
639 if (a == Nstc)
640 {
641 #if SIZEOF_LONG==8
642 return (long)pure[var[Nvar]] * hZeroMult(pn, sn, a, var, iv);
643 #else
644 int64 t=hZeroMult(pn, sn, a, var, iv);
645 t *= pure[var[Nvar]];
646 if ((t>=INT_MIN)&&(t<=INT_MAX)) sum=t;
647 else if (!errorreported) WerrorS("int overflow in vdim 3");
648 return sum;
649 #endif
650 }
651 else
652 {
653 #if SIZEOF_LONG==8
654 sum = x * hZeroMult(pn, sn, a, var, iv);
655 #else
656 int64 t=hZeroMult(pn, sn, a, var, iv);
657 t *= x;
658 if ((t>=INT_MIN)&&(t<=INT_MAX)) sum=t;
659 else if (!errorreported) WerrorS("int overflow in vdim 4");
660 #endif
661 }
662 b = a;
663 loop
664 {
665 a0 = a;
666 x0 = x;
667 hStepS(sn, Nstc, var, Nvar, &a, &x);
668 hElimS(sn, &b, a0, a, var, iv);
669 a1 = a;
670 hPure(sn, a0, &a1, var, iv, pn, &i);
671 hLex2S(sn, b, a0, a1, var, iv, hwork);
672 b += (a1 - a0);
673 if (a < Nstc)
674 {
675 #if SIZEOF_LONG==8
676 sum += (long)(x - x0) * hZeroMult(pn, sn, b, var, iv);
677 #else
678 int64 t=hZeroMult(pn, sn, b, var, iv);
679 t *= (x-x0);
680 t += sum;
681 if ((t>=INT_MIN)&&(t<=INT_MAX)) sum=t;
682 else if (!errorreported) WerrorS("int overflow in vdim 1");
683 #endif
684 }
685 else
686 {
687 #if SIZEOF_LONG==8
688 sum += (long)(pure[var[Nvar]] - x0) * hZeroMult(pn, sn, b, var, iv);
689 #else
690 int64 t=hZeroMult(pn, sn, b, var, iv);
691 t *= (pure[var[Nvar]]-x0);
692 t += sum;
693 if ((t>=INT_MIN)&&(t<=INT_MAX)) sum=t;
694 else if (!errorreported) WerrorS("int overflow in vdim 2");
695 #endif
696 return sum;
697 }
698 }
699}
long int64
Definition auxiliary.h:68
VAR short errorreported
Definition feFopen.cc:23
void WerrorS(const char *s)
Definition feFopen.cc:24

◆ isAcyclic()

BOOLEAN isAcyclic ( const intvec * G)
static

Definition at line 2054 of file hdegree.cc.

2055{
2056 // init
2057 int n = G->cols();
2058 std::vector<int> path;
2059 std::vector<BOOLEAN> visited;
2060 std::vector<BOOLEAN> cyclic;
2061 std::vector<int> cache;
2062 visited.resize(n, FALSE);
2063 cyclic.resize(n, FALSE);
2064 cache.resize(n, -2);
2065
2066 for (int v = 0; v < n; v++)
2067 {
2068 cache = countCycles(G, v, path, visited, cyclic, cache);
2069 // check that there are 0 cycles from v
2070 if (cache[v] != 0)
2071 return FALSE;
2072 }
2073 return TRUE;
2074}

◆ iv2vv()

std::vector< std::vector< int > > iv2vv ( intvec * M)
static

Definition at line 1937 of file hdegree.cc.

1938{
1939 int rows = M->rows();
1940 int cols = M->cols();
1941
1942 std::vector<std::vector<int> > mat(rows, std::vector<int>(cols));
1943
1944 for (int i = 0; i < rows; i++)
1945 {
1946 for (int j = 0; j < cols; j++)
1947 {
1948 mat[i][j] = IMATELEM(*M, i + 1, j + 1);
1949 }
1950 }
1951
1952 return mat;
1953}

◆ lp_computeNormalWords()

ideal lp_computeNormalWords ( int length,
ideal M )
static

Definition at line 1725 of file hdegree.cc.

1726{
1727 long minDeg = IDELEMS(M) > 0 ? pTotaldegree(M->m[0]) : 0;
1728 for (int i = 1; i < IDELEMS(M); i++)
1729 {
1730 minDeg = si_min(minDeg, pTotaldegree(M->m[i]));
1731 }
1732
1733 int nVars = currRing->isLPring - currRing->LPncGenCount;
1734
1735 int maxElems = 1;
1736 for (int i = 0; i < length; i++) // maxElems = nVars^n
1737 maxElems *= nVars;
1738 ideal words = idInit(maxElems);
1739 int last, numberOfNormalWords;
1740 _lp_computeNormalWords(words, numberOfNormalWords, length, M, minDeg, last);
1741 idSkipZeroes(words);
1742 return words;
1743}
static int si_min(const int a, const int b)
Definition auxiliary.h:126
static long pTotaldegree(poly p)
Definition polys.h:283
ideal idInit(int idsize, int rank)
initialise an ideal / module
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
#define IDELEMS(i)

◆ lp_countNormalWords()

int lp_countNormalWords ( int upToLength,
ideal M )
static

Definition at line 1745 of file hdegree.cc.

1746{
1747 long minDeg = IDELEMS(M) > 0 ? pTotaldegree(M->m[0]) : 0;
1748 for (int i = 1; i < IDELEMS(M); i++)
1749 {
1750 minDeg = si_min(minDeg, pTotaldegree(M->m[i]));
1751 }
1752
1753 int nVars = currRing->isLPring - currRing->LPncGenCount;
1754
1755 int maxElems = 1;
1756 for (int i = 0; i < upToLength; i++) // maxElems = nVars^n
1757 maxElems *= nVars;
1758 ideal words = idInit(maxElems);
1759 int last, numberOfNormalWords;
1760 _lp_computeNormalWords(words, numberOfNormalWords, upToLength, M, minDeg, last);
1761 idDelete(&words);
1762 return numberOfNormalWords;
1763}
#define idDelete(H)
delete an ideal
Definition ideals.h:29

◆ lp_gkDim()

int lp_gkDim ( const ideal _G)

Definition at line 1827 of file hdegree.cc.

1828{
1829 id_Test(_G, currRing);
1830
1831 if (rField_is_Ring(currRing)) {
1832 WerrorS("GK-Dim not implemented for rings");
1833 return -2;
1834 }
1835
1836 for (int i=IDELEMS(_G)-1;i>=0; i--)
1837 {
1838 if (_G->m[i] != NULL)
1839 {
1840 if (pGetComp(_G->m[i]) != 0)
1841 {
1842 WerrorS("GK-Dim not implemented for modules");
1843 return -2;
1844 }
1845 if (pGetNCGen(_G->m[i]) != 0)
1846 {
1847 WerrorS("GK-Dim not implemented for bi-modules");
1848 return -2;
1849 }
1850 }
1851 }
1852
1853 ideal G = id_Head(_G, currRing); // G = LM(G) (and copy)
1854 idSkipZeroes(G); // remove zeros
1855 id_DelLmEquals(G, currRing); // remove duplicates
1856
1857 // check if G is the zero ideal
1858 if (IDELEMS(G) == 1 && G->m[0] == NULL)
1859 {
1860 // NOTE: this is needed because if the ideal is <0>, then idSkipZeroes keeps this element, and IDELEMS is still 1!
1861 int lV = currRing->isLPring;
1862 int ncGenCount = currRing->LPncGenCount;
1863 if (lV - ncGenCount == 0)
1864 {
1865 idDelete(&G);
1866 return 0;
1867 }
1868 if (lV - ncGenCount == 1)
1869 {
1870 idDelete(&G);
1871 return 1;
1872 }
1873 if (lV - ncGenCount >= 2)
1874 {
1875 idDelete(&G);
1876 return -1;
1877 }
1878 }
1879
1880 // get the max deg
1881 long maxDeg = 0;
1882 for (int i = 0; i < IDELEMS(G); i++)
1883 {
1884 maxDeg = si_max(maxDeg, pTotaldegree(G->m[i]));
1885
1886 // also check whether G = <1>
1887 if (pIsConstantComp(G->m[i]))
1888 {
1889 WerrorS("GK-Dim not defined for 0-ring");
1890 idDelete(&G);
1891 return -2;
1892 }
1893 }
1894
1895 // early termination if G \subset X
1896 if (maxDeg <= 1)
1897 {
1898 int lV = currRing->isLPring;
1899 int ncGenCount = currRing->LPncGenCount;
1900 if (IDELEMS(G) == lV - ncGenCount) // V = {1} no edges
1901 {
1902 idDelete(&G);
1903 return 0;
1904 }
1905 if (IDELEMS(G) == lV - ncGenCount - 1) // V = {1} with loop
1906 {
1907 idDelete(&G);
1908 return 1;
1909 }
1910 if (IDELEMS(G) <= lV - ncGenCount - 2) // V = {1} with more than one loop
1911 {
1912 idDelete(&G);
1913 return -1;
1914 }
1915 }
1916
1917 ideal standardWords;
1918 intvec* UG = lp_ufnarovskiGraph(G, standardWords);
1919 if (UG == NULL)
1920 {
1921 idDelete(&G);
1922 return -2;
1923 }
1924 if (errorreported)
1925 {
1926 delete UG;
1927 idDelete(&G);
1928 return -2;
1929 }
1930 int gkDim = graphGrowth(UG);
1931 delete UG;
1932 idDelete(&G);
1933 return gkDim;
1934}
static int graphGrowth(const intvec *G)
Definition hdegree.cc:1639
intvec * lp_ufnarovskiGraph(ideal G, ideal &standardWords)
Definition hdegree.cc:1766
#define pGetComp(p)
Component.
Definition polys.h:38
#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
#define rField_is_Ring(R)
Definition ring.h:491
#define pGetNCGen(p)
Definition shiftop.h:65
ideal id_Head(ideal h, const ring r)
returns the ideals of initial terms
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.

◆ lp_kDim()

int lp_kDim ( const ideal _G)

Definition at line 2081 of file hdegree.cc.

2082{
2083 if (rField_is_Ring(currRing)) {
2084 WerrorS("K-Dim not implemented for rings");
2085 return -2;
2086 }
2087
2088 for (int i=IDELEMS(_G)-1;i>=0; i--)
2089 {
2090 if (_G->m[i] != NULL)
2091 {
2092 if (pGetComp(_G->m[i]) != 0)
2093 {
2094 WerrorS("K-Dim not implemented for modules");
2095 return -2;
2096 }
2097 if (pGetNCGen(_G->m[i]) != 0)
2098 {
2099 WerrorS("K-Dim not implemented for bi-modules");
2100 return -2;
2101 }
2102 }
2103 }
2104
2105 ideal G = id_Head(_G, currRing); // G = LM(G) (and copy)
2106 if (TEST_OPT_PROT)
2107 Print("%d original generators\n", IDELEMS(G));
2108 idSkipZeroes(G); // remove zeros
2109 id_DelLmEquals(G, currRing); // remove duplicates
2110 if (TEST_OPT_PROT)
2111 Print("%d non-zero unique generators\n", IDELEMS(G));
2112
2113 // check if G is the zero ideal
2114 if (IDELEMS(G) == 1 && G->m[0] == NULL)
2115 {
2116 // NOTE: this is needed because if the ideal is <0>, then idSkipZeroes keeps this element, and IDELEMS is still 1!
2117 int lV = currRing->isLPring;
2118 int ncGenCount = currRing->LPncGenCount;
2119 if (lV - ncGenCount == 0)
2120 {
2121 idDelete(&G);
2122 return 1;
2123 }
2124 if (lV - ncGenCount == 1)
2125 {
2126 idDelete(&G);
2127 return -1;
2128 }
2129 if (lV - ncGenCount >= 2)
2130 {
2131 idDelete(&G);
2132 return -1;
2133 }
2134 }
2135
2136 // get the max deg
2137 long maxDeg = 0;
2138 for (int i = 0; i < IDELEMS(G); i++)
2139 {
2140 maxDeg = si_max(maxDeg, pTotaldegree(G->m[i]));
2141
2142 // also check whether G = <1>
2143 if (pIsConstantComp(G->m[i]))
2144 {
2145 WerrorS("K-Dim not defined for 0-ring"); // TODO is it minus infinity ?
2146 idDelete(&G);
2147 return -2;
2148 }
2149 }
2150 if (TEST_OPT_PROT)
2151 Print("max deg: %ld\n", maxDeg);
2152
2153
2154 // for normal words of length minDeg ... maxDeg-1
2155 // brute-force the normal words
2156 if (TEST_OPT_PROT)
2157 PrintS("Computing normal words normally...\n");
2158 long numberOfNormalWords = lp_countNormalWords(maxDeg - 1, G);
2159
2160 if (TEST_OPT_PROT)
2161 Print("%ld normal words up to length %ld\n", numberOfNormalWords, maxDeg - 1);
2162
2163 // early termination if G \subset X
2164 if (maxDeg <= 1)
2165 {
2166 int lV = currRing->isLPring;
2167 int ncGenCount = currRing->LPncGenCount;
2168 if (IDELEMS(G) == lV - ncGenCount) // V = {1} no edges
2169 {
2170 idDelete(&G);
2171 return numberOfNormalWords;
2172 }
2173 if (IDELEMS(G) == lV - ncGenCount - 1) // V = {1} with loop
2174 {
2175 idDelete(&G);
2176 return -1;
2177 }
2178 if (IDELEMS(G) <= lV - ncGenCount - 2) // V = {1} with more than one loop
2179 {
2180 idDelete(&G);
2181 return -1;
2182 }
2183 }
2184
2185 if (TEST_OPT_PROT)
2186 PrintS("Computing Ufnarovski graph...\n");
2187
2188 ideal standardWords;
2189 intvec* UG = lp_ufnarovskiGraph(G, standardWords);
2190 if (UG == NULL)
2191 {
2192 idDelete(&G);
2193 return -2;
2194 }
2195 if (errorreported)
2196 {
2197 delete UG;
2198 idDelete(&G);
2199 return -2;
2200 }
2201
2202 if (TEST_OPT_PROT)
2203 Print("Ufnarovski graph is %dx%d.\n", UG->rows(), UG->cols());
2204
2205 if (TEST_OPT_PROT)
2206 PrintS("Checking whether Ufnarovski graph is acyclic...\n");
2207
2208 if (!isAcyclic(UG))
2209 {
2210 // in this case we have infinitely many normal words
2211 return -1;
2212 }
2213
2214 std::vector<std::vector<int> > vvUG = iv2vv(UG);
2215 for (std::vector<std::vector<int> >::size_type i = 0; i < vvUG.size(); i++)
2216 {
2217 if (vvIsRowZero(vvUG, i) && vvIsColumnZero(vvUG, i)) // i is isolated vertex
2218 {
2219 vvDeleteRow(vvUG, i);
2220 vvDeleteColumn(vvUG, i);
2221 i--;
2222 }
2223 }
2224 if (TEST_OPT_PROT)
2225 Print("Simplified Ufnarovski graph to %dx%d.\n", (int)vvUG.size(), (int)vvUG.size());
2226
2227 // for normal words of length >= maxDeg
2228 // use Ufnarovski graph
2229 if (TEST_OPT_PROT)
2230 PrintS("Computing normal words via Ufnarovski graph...\n");
2231 std::vector<std::vector<int> > UGpower = vvUG;
2232 long nUGpower = 1;
2233 while (!vvIsZero(UGpower))
2234 {
2235 if (TEST_OPT_PROT)
2236 PrintS("Start count graph entries.\n");
2237 for (std::vector<std::vector<int> >::size_type i = 0; i < UGpower.size(); i++)
2238 {
2239 for (std::vector<std::vector<int> >::size_type j = 0; j < UGpower[i].size(); j++)
2240 {
2241 numberOfNormalWords += UGpower[i][j];
2242 }
2243 }
2244
2245 if (TEST_OPT_PROT)
2246 {
2247 PrintS("Done count graph entries.\n");
2248 Print("%ld normal words up to length %ld\n", numberOfNormalWords, maxDeg - 1 + nUGpower);
2249 }
2250
2251 if (TEST_OPT_PROT)
2252 PrintS("Start mat mult.\n");
2253 UGpower = vvMult(UGpower, vvUG); // TODO: avoid creation of new intvec
2254 if (TEST_OPT_PROT)
2255 PrintS("Done mat mult.\n");
2256 nUGpower++;
2257 }
2258
2259 delete UG;
2260 idDelete(&G);
2261 return numberOfNormalWords;
2262}
int cols() const
Definition intvec.h:96
int rows() const
Definition intvec.h:97
#define Print
Definition emacs.cc:80
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
static void vvDeleteRow(std::vector< std::vector< int > > &mat, int row)
Definition hdegree.cc:1984
static BOOLEAN vvIsColumnZero(const std::vector< std::vector< int > > &mat, int col)
Definition hdegree.cc:2007
static void vvDeleteColumn(std::vector< std::vector< int > > &mat, int col)
Definition hdegree.cc:1989
static std::vector< std::vector< int > > iv2vv(intvec *M)
Definition hdegree.cc:1937
static int lp_countNormalWords(int upToLength, ideal M)
Definition hdegree.cc:1745
static BOOLEAN isAcyclic(const intvec *G)
Definition hdegree.cc:2054
static BOOLEAN vvIsZero(const std::vector< std::vector< int > > &mat)
Definition hdegree.cc:2017
static BOOLEAN vvIsRowZero(const std::vector< std::vector< int > > &mat, int row)
Definition hdegree.cc:1997
#define TEST_OPT_PROT
Definition options.h:105
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.

1767{
1768 long l = 0;
1769 for (int i = 0; i < IDELEMS(G); i++)
1770 l = si_max(pTotaldegree(G->m[i]), l);
1771 l--;
1772 if (l <= 0)
1773 {
1774 WerrorS("Ufnarovski graph not implemented for l <= 0");
1775 return NULL;
1776 }
1777 int lV = currRing->isLPring;
1778
1779 standardWords = lp_computeNormalWords(l, G);
1780
1781 int n = IDELEMS(standardWords);
1782 intvec* UG = new intvec(n, n, 0);
1783 for (int i = 0; i < n; i++)
1784 {
1785 for (int j = 0; j < n; j++)
1786 {
1787 poly v = standardWords->m[i];
1788 poly w = standardWords->m[j];
1789
1790 // check whether v*x1 = x2*w (overlap)
1791 bool overlap = true;
1792 for (int k = 1; k <= (l - 1) * lV; k++)
1793 {
1794 if (pGetExp(v, k + lV) != pGetExp(w, k)) {
1795 overlap = false;
1796 break;
1797 }
1798 }
1799
1800 if (overlap)
1801 {
1802 // create the overlap
1803 poly p = pMult(pCopy(v), p_LPVarAt(w, l, currRing));
1804
1805 // check whether the overlap is normal
1806 bool normal = true;
1807 for (int k = 0; k < IDELEMS(G); k++)
1808 {
1809 if (p_LPDivisibleBy(G->m[k], p, currRing))
1810 {
1811 normal = false;
1812 break;
1813 }
1814 }
1815
1816 if (normal)
1817 {
1818 IMATELEM(*UG, i + 1, j + 1) = 1;
1819 }
1820 }
1821 }
1822 }
1823 return UG;
1824}
int l
Definition cfEzgcd.cc:100
int p
Definition cfModGcd.cc:4086
static ideal lp_computeNormalWords(int length, ideal M)
Definition hdegree.cc:1725
#define pMult(p, q)
Definition polys.h:208
poly p_LPVarAt(poly p, int pos, const ring r)
Definition shiftop.cc:845

◆ scAll()

void scAll ( int Nvar,
int deg )
static

Definition at line 1225 of file hdegree.cc.

1226{
1227 int i;
1228 int d = deg;
1229 if (d == 0)
1230 {
1231 for (i=Nvar; i; i--) act[i] = 0;
1232 scElKbase();
1233 return;
1234 }
1235 if (Nvar == 1)
1236 {
1237 act[1] = d;
1238 scElKbase();
1239 return;
1240 }
1241 do
1242 {
1243 act[Nvar] = d;
1244 scAll(Nvar-1, deg-d);
1245 d--;
1246 } while (d >= 0);
1247}
static void scElKbase()
Definition hdegree.cc:1141
static void scAll(int Nvar, int deg)
Definition hdegree.cc:1225
STATIC_VAR scmon act
Definition hdegree.cc:1139

◆ scAllKbase()

void scAllKbase ( int Nvar,
int ideg,
int deg )
static

Definition at line 1249 of file hdegree.cc.

1250{
1251 do
1252 {
1253 act[Nvar] = ideg;
1254 scAll(Nvar-1, deg-ideg);
1255 ideg--;
1256 } while (ideg >= 0);
1257}

◆ scComputeHC()

void scComputeHC ( ideal S,
ideal Q,
int ak,
poly & hEdge )

Definition at line 1074 of file hdegree.cc.

1075{
1076 if(idElem(S) == 0)
1077 return;
1078 id_LmTest(S, currRing);
1079 if (Q!=NULL) id_LmTest(Q, currRing);
1080
1081 int i;
1082 int k = ak;
1083 ideal SS=id_Head(S,currRing);
1084 if (rField_is_Ring(currRing) && (currRing->OrdSgn == -1))
1085 {
1086 //consider just monic generators (over rings with zero-divisors)
1087 for(i=0;i<=idElem(S);i++)
1088 {
1089 if((SS->m[i]!=NULL)
1090 && ((p_IsPurePower(SS->m[i],currRing)==0)
1091 ||(!n_IsUnit(pGetCoeff(SS->m[i]), currRing->cf))))
1092 {
1093 p_Delete(&SS->m[i],currRing);
1094 }
1095 }
1096 }
1097 S=SS;
1098 idSkipZeroes(S);
1099 hNvar = (currRing->N);
1100 hexist = hInit(S, Q, &hNexist);
1101 if (hNexist==0) return;
1102 if (k!=0)
1104 else
1105 hNstc = hNexist;
1106 assume(hNexist > 0);
1107 hwork = (scfmon)omAlloc(hNexist * sizeof(scmon));
1108 hvar = (varset)omAlloc((hNvar + 1) * sizeof(int));
1109 hpure = (scmon)omAlloc((1 + (hNvar * hNvar)) * sizeof(int));
1110 stcmem = hCreate(hNvar - 1);
1111 for (i = hNvar; i>0; i--)
1112 hvar[i] = i;
1114 if ((hNvar > 2) && (hNstc > 10))
1116 memset(hpure, 0, (hNvar + 1) * sizeof(int));
1117 hPure(hexist, 0, &hNstc, hvar, hNvar, hpure, &hNpure);
1119 if (hEdge!=NULL)
1120 pLmFree(hEdge);
1121 hEdge = pInit();
1122 pWork = pInit();
1124 pSetComp(hEdge,ak);
1125 hKill(stcmem, hNvar - 1);
1126 omFreeSize((ADDRESS)hwork, hNexist * sizeof(scmon));
1127 omFreeSize((ADDRESS)hvar, (hNvar + 1) * sizeof(int));
1128 omFreeSize((ADDRESS)hpure, (1 + (hNvar * hNvar)) * sizeof(int));
1130 pLmFree(pWork);
1131 idDelete(&S);
1132}
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
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
int p_IsPurePower(const poly p, const ring r)
return i, if head depends only on var(i)
Definition p_polys.cc:1227
static void p_Delete(poly *p, const ring r)
Definition p_polys.h:903
#define pSetComp(p, v)
Definition polys.h:39
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
#define pInit()
allocates a new monomial and initializes everything to 0
Definition polys.h:62
static int idElem(const ideal F)
number of non-zero polys in F
#define id_LmTest(A, lR)

◆ scDegKbase()

void scDegKbase ( scfmon stc,
int Nstc,
int Nvar,
int deg )
static

Definition at line 1259 of file hdegree.cc.

1260{
1261 int Ivar, Istc, i, j;
1262 scfmon sn;
1263 int x, ideg;
1264
1265 if (deg == 0)
1266 {
1267 for (i=Nstc-1; i>=0; i--)
1268 {
1269 for (j=Nvar;j;j--){ if(stc[i][j]) break; }
1270 if (j==0){return;}
1271 }
1272 for (i=Nvar; i; i--) act[i] = 0;
1273 scElKbase();
1274 return;
1275 }
1276 if (Nvar == 1)
1277 {
1278 for (i=Nstc-1; i>=0; i--) if(deg >= stc[i][1]) return;
1279 act[1] = deg;
1280 scElKbase();
1281 return;
1282 }
1283 Ivar = Nvar-1;
1284 sn = hGetmem(Nstc, stc, stcmem[Ivar]);
1285 x = scRestrict(Nstc, sn, Nvar);
1286 if (x <= 0)
1287 {
1288 if (x == 0) return;
1289 ideg = deg;
1290 }
1291 else
1292 {
1293 if (deg < x) ideg = deg;
1294 else ideg = x-1;
1295 if (Nstc == 0)
1296 {
1297 scAllKbase(Nvar, ideg, deg);
1298 return;
1299 }
1300 }
1301 loop
1302 {
1303 x = scMax(Nstc, sn, Nvar);
1304 while (ideg >= x)
1305 {
1306 act[Nvar] = ideg;
1307 scDegKbase(sn, Nstc, Ivar, deg-ideg);
1308 ideg--;
1309 }
1310 if (ideg < 0) return;
1311 Istc = Nstc;
1312 for (i=Nstc-1; i>=0; i--)
1313 {
1314 if (ideg < sn[i][Nvar])
1315 {
1316 Istc--;
1317 sn[i] = NULL;
1318 }
1319 }
1320 if (Istc == 0)
1321 {
1322 scAllKbase(Nvar, ideg, deg);
1323 return;
1324 }
1325 j = 0;
1326 while (sn[j]) j++;
1327 i = j+1;
1328 for (; i<Nstc; i++)
1329 {
1330 if (sn[i])
1331 {
1332 sn[j] = sn[i];
1333 j++;
1334 }
1335 }
1336 Nstc = Istc;
1337 }
1338}
static int scRestrict(int &Nstc, scfmon stc, int Nvar)
Definition hdegree.cc:1174
static void scAllKbase(int Nvar, int ideg, int deg)
Definition hdegree.cc:1249
static void scDegKbase(scfmon stc, int Nstc, int Nvar, int deg)
Definition hdegree.cc:1259
static int scMax(int i, scfmon stc, int Nvar)
Definition hdegree.cc:1150

◆ scDimInt()

int scDimInt ( ideal S,
ideal Q )

ideal dimension

Definition at line 78 of file hdegree.cc.

79{
80 id_Test(S, currRing);
81 if( Q!=NULL ) id_Test(Q, currRing);
82
83 int mc;
84 hexist = hInit(S, Q, &hNexist);
85 if (!hNexist)
86 return (currRing->N);
87 hwork = (scfmon)omAlloc(hNexist * sizeof(scmon));
88 hvar = (varset)omAlloc(((currRing->N) + 1) * sizeof(int));
89 hpure = (scmon)omAlloc((1 + ((currRing->N) * (currRing->N))) * sizeof(int));
90 mc = hisModule;
91 if (!mc)
92 {
93 hrad = hexist;
94 hNrad = hNexist;
95 }
96 else
97 hrad = (scfmon)omAlloc(hNexist * sizeof(scmon));
98 radmem = hCreate((currRing->N) - 1);
99 hCo = (currRing->N) + 1;
100 loop
101 {
102 if (mc)
103 hComp(hexist, hNexist, mc, hrad, &hNrad);
104 if (hNrad)
105 {
106 hNvar = (currRing->N);
109 if (hNvar)
110 {
111 memset(hpure, 0, ((currRing->N) + 1) * sizeof(int));
112 hPure(hrad, 0, &hNrad, hvar, hNvar, hpure, &hNpure);
115 }
116 }
117 else
118 {
119 hCo = 0;
120 break;
121 }
122 mc--;
123 if (mc <= 0)
124 break;
125 }
126 hKill(radmem, (currRing->N) - 1);
127 omFreeSize((ADDRESS)hpure, (1 + ((currRing->N) * (currRing->N))) * sizeof(int));
128 omFreeSize((ADDRESS)hvar, ((currRing->N) + 1) * sizeof(int));
129 omFreeSize((ADDRESS)hwork, hNexist * sizeof(scmon));
131 if (hisModule)
132 omFreeSize((ADDRESS)hrad, hNexist * sizeof(scmon));
133 return (currRing->N) - hCo;
134}

◆ scDimIntRing()

int scDimIntRing ( ideal vid,
ideal Q )

scDimInt for ring-coefficients

Definition at line 136 of file hdegree.cc.

137{
139 {
140 int i = idPosConstant(vid);
141 if ((i != -1) && (n_IsUnit(pGetCoeff(vid->m[i]),currRing->cf)))
142 { /* ideal v contains unit; dim = -1 */
143 return(-1);
144 }
145 ideal vv = id_Head(vid,currRing);
146 idSkipZeroes(vv);
147 i = idPosConstant(vid);
148 int d;
149 if(i == -1)
150 {
151 d = scDimInt(vv, Q);
153 d++;
154 }
155 else
156 {
157 if(n_IsUnit(pGetCoeff(vv->m[i]),currRing->cf))
158 d = -1;
159 else
160 d = scDimInt(vv, Q);
161 }
162 //Anne's Idea for std(4,2x) = 0 bug
163 int dcurr = d;
164 for(unsigned ii=0;ii<(unsigned)IDELEMS(vv);ii++)
165 {
166 if(vv->m[ii] != NULL && !n_IsUnit(pGetCoeff(vv->m[ii]),currRing->cf))
167 {
168 ideal vc = idCopy(vv);
169 poly c = pInit();
170 pSetCoeff0(c,nCopy(pGetCoeff(vv->m[ii])));
171 idInsertPoly(vc,c);
172 idSkipZeroes(vc);
173 for(unsigned jj = 0;jj<(unsigned)IDELEMS(vc)-1;jj++)
174 {
175 if((vc->m[jj]!=NULL)
176 && (n_DivBy(pGetCoeff(vc->m[jj]),pGetCoeff(c),currRing->cf)))
177 {
178 pDelete(&vc->m[jj]);
179 }
180 }
181 idSkipZeroes(vc);
182 i = idPosConstant(vc);
183 if (i != -1) pDelete(&vc->m[i]);
184 dcurr = scDimInt(vc, Q);
185 // the following assumes the ground rings to be either zero- or one-dimensional
186 if((i==-1) && rField_is_Z(currRing))
187 {
188 // should also be activated for other euclidean domains as groundfield
189 dcurr++;
190 }
191 idDelete(&vc);
192 }
193 if(dcurr > d)
194 d = dcurr;
195 }
196 idDelete(&vv);
197 return d;
198 }
199 return scDimInt(vid,Q);
200}
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:747
int scDimInt(ideal S, ideal Q)
ideal dimension
Definition hdegree.cc:78
BOOLEAN idInsertPoly(ideal h1, poly h2)
insert h2 into h1 (if h2 is not the zero polynomial) return TRUE iff h2 was indeed inserted
ideal idCopy(ideal A)
Definition ideals.h:60
#define idPosConstant(I)
index of generator with leading term in ground ring (if any); otherwise -1
Definition ideals.h:37
#define pSetCoeff0(p, n)
Definition monomials.h:59
#define nCopy(n)
Definition numbers.h:15
static BOOLEAN rField_is_Z(const ring r)
Definition ring.h:520

◆ scElKbase()

void scElKbase ( )
static

Definition at line 1141 of file hdegree.cc.

1142{
1143 poly q = pInit();
1144 pSetCoeff0(q,nInit(1));
1145 pSetExpV(q,act);
1146 pNext(q) = NULL;
1147 last = pNext(last) = q;
1148}
#define pNext(p)
Definition monomials.h:36
#define nInit(i)
Definition numbers.h:24
#define pSetExpV(p, e)
Definition polys.h:98

◆ scIdKbase()

ideal scIdKbase ( poly q,
const int rank )
static

Definition at line 1396 of file hdegree.cc.

1397{
1398 ideal res = idInit(pLength(q), rank);
1399 polyset mm = res->m;
1400 do
1401 {
1402 *mm = q; ++mm;
1403
1404 const poly p = pNext(q);
1405 pNext(q) = NULL;
1406 q = p;
1407
1408 } while (q!=NULL);
1409
1410 id_Test(res, currRing); // WRONG RANK!!!???
1411 return res;
1412}
static int pLength(poly a)
Definition p_polys.h:190
poly * polyset
Definition polys.h:260

◆ scIndIntvec()

intvec * scIndIntvec ( ideal S,
ideal Q )

Definition at line 284 of file hdegree.cc.

285{
286 id_Test(S, currRing);
287 if( Q!=NULL ) id_Test(Q, currRing);
288
289 intvec *Set=new intvec((currRing->N));
290 int mc,i;
291 hexist = hInit(S, Q, &hNexist);
292 if (hNexist==0)
293 {
294 for(i=0; i<(currRing->N); i++)
295 (*Set)[i]=1;
296 return Set;
297 }
298 hwork = (scfmon)omAlloc(hNexist * sizeof(scmon));
299 hvar = (varset)omAlloc(((currRing->N) + 1) * sizeof(int));
300 hpure = (scmon)omAlloc((1 + ((currRing->N) * (currRing->N))) * sizeof(int));
301 hInd = (scmon)omAlloc0((1 + (currRing->N)) * sizeof(int));
302 mc = hisModule;
303 if (mc==0)
304 {
305 hrad = hexist;
306 hNrad = hNexist;
307 }
308 else
309 hrad = (scfmon)omAlloc(hNexist * sizeof(scmon));
310 radmem = hCreate((currRing->N) - 1);
311 hCo = (currRing->N) + 1;
312 loop
313 {
314 if (mc!=0)
315 hComp(hexist, hNexist, mc, hrad, &hNrad);
316 if (hNrad!=0)
317 {
318 hNvar = (currRing->N);
321 if (hNvar!=0)
322 {
323 memset(hpure, 0, ((currRing->N) + 1) * sizeof(int));
324 hPure(hrad, 0, &hNrad, hvar, hNvar, hpure, &hNpure);
327 }
328 }
329 else
330 {
331 hCo = 0;
332 break;
333 }
334 mc--;
335 if (mc <= 0)
336 break;
337 }
338 for(i=0; i<(currRing->N); i++)
339 (*Set)[i] = hInd[i+1];
340 hKill(radmem, (currRing->N) - 1);
341 omFreeSize((ADDRESS)hpure, (1 + ((currRing->N) * (currRing->N))) * sizeof(int));
342 omFreeSize((ADDRESS)hInd, (1 + (currRing->N)) * sizeof(int));
343 omFreeSize((ADDRESS)hvar, ((currRing->N) + 1) * sizeof(int));
344 omFreeSize((ADDRESS)hwork, hNexist * sizeof(scmon));
346 if (hisModule)
347 omFreeSize((ADDRESS)hrad, hNexist * sizeof(scmon));
348 return Set;
349}
#define omAlloc0(size)

◆ scInKbase()

void scInKbase ( scfmon stc,
int Nstc,
int Nvar )
static

Definition at line 1340 of file hdegree.cc.

1341{
1342 int Ivar, Istc, i, j;
1343 scfmon sn;
1344 int x, ideg;
1345
1346 if (Nvar == 1)
1347 {
1348 ideg = scMin(Nstc, stc, 1);
1349 while (ideg > 0)
1350 {
1351 ideg--;
1352 act[1] = ideg;
1353 scElKbase();
1354 }
1355 return;
1356 }
1357 Ivar = Nvar-1;
1358 sn = hGetmem(Nstc, stc, stcmem[Ivar]);
1359 x = scRestrict(Nstc, sn, Nvar);
1360 if (x == 0) return;
1361 ideg = x-1;
1362 loop
1363 {
1364 x = scMax(Nstc, sn, Nvar);
1365 while (ideg >= x)
1366 {
1367 act[Nvar] = ideg;
1368 scInKbase(sn, Nstc, Ivar);
1369 ideg--;
1370 }
1371 if (ideg < 0) return;
1372 Istc = Nstc;
1373 for (i=Nstc-1; i>=0; i--)
1374 {
1375 if (ideg < sn[i][Nvar])
1376 {
1377 Istc--;
1378 sn[i] = NULL;
1379 }
1380 }
1381 j = 0;
1382 while (sn[j]) j++;
1383 i = j+1;
1384 for (; i<Nstc; i++)
1385 {
1386 if (sn[i])
1387 {
1388 sn[j] = sn[i];
1389 j++;
1390 }
1391 }
1392 Nstc = Istc;
1393 }
1394}
static int scMin(int i, scfmon stc, int Nvar)
Definition hdegree.cc:1162
static void scInKbase(scfmon stc, int Nstc, int Nvar)
Definition hdegree.cc:1340

◆ scKBase()

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

Definition at line 1414 of file hdegree.cc.

1415{
1416 if( Q!=NULL) id_Test(Q, currRing);
1417
1418 int i, di;
1419 poly p;
1420
1421 if (deg < 0)
1422 {
1423 di = scDimInt(s, Q);
1424 if (di != 0)
1425 {
1426 //Werror("KBase not finite");
1427 return idInit(1,s->rank);
1428 }
1429 }
1430 stcmem = hCreate((currRing->N) - 1);
1431 hexist = hInit(s, Q, &hNexist);
1432 p = last = pInit();
1433 /*pNext(p) = NULL;*/
1434 act = (scmon)omAlloc(((currRing->N) + 1) * sizeof(int));
1435 *act = 0;
1436 if (!hNexist)
1437 {
1438 scAll((currRing->N), deg);
1439 goto ende;
1440 }
1441 if (!hisModule)
1442 {
1443 if (deg < 0) scInKbase(hexist, hNexist, (currRing->N));
1444 else scDegKbase(hexist, hNexist, (currRing->N), deg);
1445 }
1446 else
1447 {
1448 hstc = (scfmon)omAlloc(hNexist * sizeof(scmon));
1449 for (i = 1; i <= hisModule; i++)
1450 {
1451 *act = i;
1453 int deg_ei=deg;
1454 if (mv!=NULL) deg_ei -= (*mv)[i-1];
1455 if ((deg < 0) || (deg_ei>=0))
1456 {
1457 if (hNstc)
1458 {
1459 if (deg < 0) scInKbase(hstc, hNstc, (currRing->N));
1460 else scDegKbase(hstc, hNstc, (currRing->N), deg_ei);
1461 }
1462 else
1463 scAll((currRing->N), deg_ei);
1464 }
1465 }
1466 omFreeSize((ADDRESS)hstc, hNexist * sizeof(scmon));
1467 }
1468ende:
1470 omFreeSize((ADDRESS)act, ((currRing->N) + 1) * sizeof(int));
1471 hKill(stcmem, (currRing->N) - 1);
1472 pLmFree(&p);
1473 if (p == NULL)
1474 return idInit(1,s->rank);
1475
1476 last = p;
1477 return scIdKbase(p, s->rank);
1478}
const CanonicalForm int s
Definition facAbsFact.cc:51
static ideal scIdKbase(poly q, const int rank)
Definition hdegree.cc:1396

◆ scMax()

int scMax ( int i,
scfmon stc,
int Nvar )
static

Definition at line 1150 of file hdegree.cc.

1151{
1152 int x, y=stc[0][Nvar];
1153 for (; i;)
1154 {
1155 i--;
1156 x = stc[i][Nvar];
1157 if (x > y) y = x;
1158 }
1159 return y;
1160}
const CanonicalForm int const CFList const Variable & y
Definition facAbsFact.cc:53

◆ scMin()

int scMin ( int i,
scfmon stc,
int Nvar )
static

Definition at line 1162 of file hdegree.cc.

1163{
1164 int x, y=stc[0][Nvar];
1165 for (; i;)
1166 {
1167 i--;
1168 x = stc[i][Nvar];
1169 if (x < y) y = x;
1170 }
1171 return y;
1172}

◆ scMult0Int()

long scMult0Int ( ideal S,
ideal Q )

Definition at line 924 of file hdegree.cc.

925{
927 if (Q!=NULL) id_LmTest(Q, currRing);
928
929 int mc;
930 hexist = hInit(S, Q, &hNexist);
931 if (!hNexist)
932 {
933 hMu = -1;
934 return -1;
935 }
936 else
937 hMu = 0;
938
939 const ring r = currRing;
940
941 hwork = (scfmon)omAlloc(hNexist * sizeof(scmon));
942 hvar = (varset)omAlloc(((r->N) + 1) * sizeof(int));
943 hpur0 = (scmon)omAlloc((1 + ((r->N) * (r->N))) * sizeof(int));
944 mc = hisModule;
945 if (!mc)
946 {
947 hstc = hexist;
948 hNstc = hNexist;
949 }
950 else
951 hstc = (scfmon)omAlloc(hNexist * sizeof(scmon));
952 stcmem = hCreate((r->N) - 1);
953 loop
954 {
955 if (mc)
956 {
957 hComp(hexist, hNexist, mc, hstc, &hNstc);
958 if (!hNstc)
959 {
960 hMu = -1;
961 break;
962 }
963 }
964 hNvar = (r->N);
965 for (int i = hNvar; i; i--)
966 hvar[i] = i;
969 if ((hNvar == (r->N)) && (hNstc >= (r->N)))
970 {
971 if ((hNvar > 2) && (hNstc > 10))
973 memset(hpur0, 0, ((r->N) + 1) * sizeof(int));
974 hPure(hstc, 0, &hNstc, hvar, hNvar, hpur0, &hNpure);
975 if (hNpure == hNvar)
976 {
979 }
980 else
981 hMu = -1;
982 }
983 else if (hNvar)
984 hMu = -1;
985 mc--;
986 if (mc <= 0 || hMu < 0)
987 break;
988 }
989 hKill(stcmem, (r->N) - 1);
990 omFreeSize((ADDRESS)hpur0, (1 + ((r->N) * (r->N))) * sizeof(int));
991 omFreeSize((ADDRESS)hvar, ((r->N) + 1) * sizeof(int));
992 omFreeSize((ADDRESS)hwork, hNexist * sizeof(scmon));
994 if (hisModule)
995 omFreeSize((ADDRESS)hstc, hNexist * sizeof(scmon));
996 return hMu;
997}

◆ scMultInt()

int scMultInt ( ideal S,
ideal Q )

Definition at line 901 of file hdegree.cc.

902{
903 id_Test(S, currRing);
904 if( Q!=NULL ) id_Test(Q, currRing);
905
906 hDegree(S, Q);
907 return hMu;
908}
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.

911{
912 int di = (currRing->N)-co;
913 if (currRing->OrdSgn == 1)
914 {
915 if (di>0)
916 Print("// dimension (proj.) = %d\n// degree (proj.) = %d\n", di-1, mu);
917 else
918 Print("// dimension (affine) = 0\n// degree (affine) = %d\n", mu);
919 }
920 else
921 Print("// dimension (local) = %d\n// multiplicity = %d\n", di, mu);
922}
static matrix mu(matrix A, const ring R)
Definition matpol.cc:2028

◆ scRestrict()

int scRestrict ( int & Nstc,
scfmon stc,
int Nvar )
static

Definition at line 1174 of file hdegree.cc.

1175{
1176 int x, y;
1177 int i, j, Istc = Nstc;
1178
1179 y = MAX_INT_VAL;
1180 for (i=Nstc-1; i>=0; i--)
1181 {
1182 j = Nvar-1;
1183 loop
1184 {
1185 if(stc[i][j] != 0) break;
1186 j--;
1187 if (j == 0)
1188 {
1189 Istc--;
1190 x = stc[i][Nvar];
1191 if (x < y) y = x;
1192 stc[i] = NULL;
1193 break;
1194 }
1195 }
1196 }
1197 if (Istc < Nstc)
1198 {
1199 for (i=Nstc-1; i>=0; i--)
1200 {
1201 if (stc[i] && (stc[i][Nvar] >= y))
1202 {
1203 Istc--;
1204 stc[i] = NULL;
1205 }
1206 }
1207 j = 0;
1208 while (stc[j]) j++;
1209 i = j+1;
1210 for(; i<Nstc; i++)
1211 {
1212 if (stc[i])
1213 {
1214 stc[j] = stc[i];
1215 j++;
1216 }
1217 }
1218 Nstc = Istc;
1219 return y;
1220 }
1221 else
1222 return -1;
1223}
const int MAX_INT_VAL
Definition mylimits.h:12

◆ vvDeleteColumn()

void vvDeleteColumn ( std::vector< std::vector< int > > & mat,
int col )
static

Definition at line 1989 of file hdegree.cc.

1990{
1991 for (std::vector<std::vector<int> >::size_type i = 0; i < mat.size(); i++)
1992 {
1993 mat[i].erase(mat[i].begin() + col);
1994 }
1995}

◆ vvDeleteRow()

void vvDeleteRow ( std::vector< std::vector< int > > & mat,
int row )
static

Definition at line 1984 of file hdegree.cc.

1985{
1986 mat.erase(mat.begin() + row);
1987}

◆ vvIsColumnZero()

BOOLEAN vvIsColumnZero ( const std::vector< std::vector< int > > & mat,
int col )
static

Definition at line 2007 of file hdegree.cc.

2008{
2009 for (std::vector<std::vector<int> >::size_type i = 0; i < mat.size(); i++)
2010 {
2011 if (mat[i][col] != 0)
2012 return FALSE;
2013 }
2014 return TRUE;
2015}

◆ vvIsRowZero()

BOOLEAN vvIsRowZero ( const std::vector< std::vector< int > > & mat,
int row )
static

Definition at line 1997 of file hdegree.cc.

1998{
1999 for (std::vector<std::vector<int> >::size_type i = 0; i < mat[row].size(); i++)
2000 {
2001 if (mat[row][i] != 0)
2002 return FALSE;
2003 }
2004 return TRUE;
2005}

◆ vvIsZero()

BOOLEAN vvIsZero ( const std::vector< std::vector< int > > & mat)
static

Definition at line 2017 of file hdegree.cc.

2018{
2019 for (std::vector<std::vector<int> >::size_type i = 0; i < mat.size(); i++)
2020 {
2021 if (!vvIsRowZero(mat, i))
2022 return FALSE;
2023 }
2024 return TRUE;
2025}

◆ vvMult()

std::vector< std::vector< int > > vvMult ( const std::vector< std::vector< int > > & a,
const std::vector< std::vector< int > > & b )
static

Definition at line 2027 of file hdegree.cc.

2028{
2029 std::vector<std::vector<int> >::size_type ra = a.size();
2030 std::vector<std::vector<int> >::size_type rb = b.size();
2031 std::vector<std::vector<int> >::size_type ca = a.size() > 0 ? a[0].size() : 0;
2032 std::vector<std::vector<int> >::size_type cb = b.size() > 0 ? b[0].size() : 0;
2033
2034 if (ca != rb)
2035 {
2036 WerrorS("matrix dimensions do not match");
2037 return std::vector<std::vector<int> >();
2038 }
2039
2040 std::vector<std::vector<int> > res(ra, std::vector<int>(cb));
2041 for (std::vector<std::vector<int> >::size_type i = 0; i < ra; i++)
2042 {
2043 for (std::vector<std::vector<int> >::size_type j = 0; j < cb; j++)
2044 {
2045 int sum = 0;
2046 for (std::vector<std::vector<int> >::size_type k = 0; k < ca; k++)
2047 sum += a[i][k] * b[k][j];
2048 res[i][j] = sum;
2049 }
2050 }
2051 return res;
2052}

Variable Documentation

◆ act

Definition at line 1139 of file hdegree.cc.

◆ hCo

VAR int hCo

Definition at line 27 of file hdegree.cc.

◆ hInd

Definition at line 203 of file hdegree.cc.

◆ hMu

VAR long hMu

Definition at line 28 of file hdegree.cc.

◆ hMu2

VAR int hMu2

Definition at line 27 of file hdegree.cc.

◆ indlist_bin

VAR omBin indlist_bin = omGetSpecBin(sizeof(indlist))

Definition at line 29 of file hdegree.cc.

◆ ISet

VAR indset ISet

Definition at line 351 of file hdegree.cc.

◆ JSet

VAR indset JSet

Definition at line 351 of file hdegree.cc.

◆ last

STATIC_VAR poly last

Definition at line 1138 of file hdegree.cc.

◆ pWork

STATIC_VAR poly pWork

Definition at line 1001 of file hdegree.cc.