My Project
Functions
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, ring tailRing=currRing)
 
intvecscIndIntvec (ideal S, ideal Q=NULL)
 
int scDimInt (ideal s, ideal Q=NULL)
 ideal dimension More...
 
int scDimIntRing (ideal s, ideal Q=NULL)
 scDimInt for ring-coefficients More...
 
int scMultInt (ideal s, ideal Q=NULL)
 
int scMult0Int (ideal s, ideal Q=NULL, const ring tailRing=currRing)
 
void scPrintDegree (int co, int mu)
 
void scDegree (ideal s, intvec *modulweight, ideal Q=NULL)
 
ideal scKBase (int deg, ideal s, ideal Q=NULL, intvec *mv=NULL)
 
int lp_gkDim (const ideal G)
 
int lp_kDim (const ideal G)
 
intveclp_ufnarovskiGraph (ideal G, ideal &standardWords)
 

Function Documentation

◆ lp_gkDim()

int lp_gkDim ( const ideal  G)

Definition at line 1840 of file hdegree.cc.

1841 {
1842  id_Test(_G, currRing);
1843 
1844  if (rField_is_Ring(currRing)) {
1845  WerrorS("GK-Dim not implemented for rings");
1846  return -2;
1847  }
1848 
1849  for (int i=IDELEMS(_G)-1;i>=0; i--)
1850  {
1851  if (_G->m[i] != NULL)
1852  {
1853  if (pGetComp(_G->m[i]) != 0)
1854  {
1855  WerrorS("GK-Dim not implemented for modules");
1856  return -2;
1857  }
1858  if (pGetNCGen(_G->m[i]) != 0)
1859  {
1860  WerrorS("GK-Dim not implemented for bi-modules");
1861  return -2;
1862  }
1863  }
1864  }
1865 
1866  ideal G = id_Head(_G, currRing); // G = LM(G) (and copy)
1867  idSkipZeroes(G); // remove zeros
1868  id_DelLmEquals(G, currRing); // remove duplicates
1869 
1870  // check if G is the zero ideal
1871  if (IDELEMS(G) == 1 && G->m[0] == NULL)
1872  {
1873  // NOTE: this is needed because if the ideal is <0>, then idSkipZeroes keeps this element, and IDELEMS is still 1!
1874  int lV = currRing->isLPring;
1875  int ncGenCount = currRing->LPncGenCount;
1876  if (lV - ncGenCount == 0)
1877  {
1878  idDelete(&G);
1879  return 0;
1880  }
1881  if (lV - ncGenCount == 1)
1882  {
1883  idDelete(&G);
1884  return 1;
1885  }
1886  if (lV - ncGenCount >= 2)
1887  {
1888  idDelete(&G);
1889  return -1;
1890  }
1891  }
1892 
1893  // get the max deg
1894  long maxDeg = 0;
1895  for (int i = 0; i < IDELEMS(G); i++)
1896  {
1897  maxDeg = si_max(maxDeg, pTotaldegree(G->m[i]));
1898 
1899  // also check whether G = <1>
1900  if (pIsConstantComp(G->m[i]))
1901  {
1902  WerrorS("GK-Dim not defined for 0-ring");
1903  idDelete(&G);
1904  return -2;
1905  }
1906  }
1907 
1908  // early termination if G \subset X
1909  if (maxDeg <= 1)
1910  {
1911  int lV = currRing->isLPring;
1912  int ncGenCount = currRing->LPncGenCount;
1913  if (IDELEMS(G) == lV - ncGenCount) // V = {1} no edges
1914  {
1915  idDelete(&G);
1916  return 0;
1917  }
1918  if (IDELEMS(G) == lV - ncGenCount - 1) // V = {1} with loop
1919  {
1920  idDelete(&G);
1921  return 1;
1922  }
1923  if (IDELEMS(G) <= lV - ncGenCount - 2) // V = {1} with more than one loop
1924  {
1925  idDelete(&G);
1926  return -1;
1927  }
1928  }
1929 
1930  ideal standardWords;
1931  intvec* UG = lp_ufnarovskiGraph(G, standardWords);
1932  if (UG == NULL)
1933  {
1934  idDelete(&G);
1935  return -2;
1936  }
1937  if (errorreported)
1938  {
1939  delete UG;
1940  idDelete(&G);
1941  return -2;
1942  }
1943  int gkDim = graphGrowth(UG);
1944  delete UG;
1945  idDelete(&G);
1946  return gkDim;
1947 }
static int si_max(const int a, const int b)
Definition: auxiliary.h:124
int i
Definition: cfEzgcd.cc:132
Definition: intvec.h:23
VAR short errorreported
Definition: feFopen.cc:23
void WerrorS(const char *s)
Definition: feFopen.cc:24
intvec * lp_ufnarovskiGraph(ideal G, ideal &standardWords)
Definition: hdegree.cc:1779
static int graphGrowth(const intvec *G)
Definition: hdegree.cc:1652
#define idDelete(H)
delete an ideal
Definition: ideals.h:29
STATIC_VAR TreeM * G
Definition: janet.cc:31
#define NULL
Definition: omList.c:12
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:13
static long pTotaldegree(poly p)
Definition: polys.h:282
#define pGetComp(p)
Component.
Definition: polys.h:37
#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:236
#define rField_is_Ring(R)
Definition: ring.h:486
#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.
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
#define IDELEMS(i)
Definition: simpleideals.h:23
#define id_Test(A, lR)
Definition: simpleideals.h:78

◆ lp_kDim()

int lp_kDim ( const ideal  G)

Definition at line 2090 of file hdegree.cc.

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

◆ lp_ufnarovskiGraph()

intvec* lp_ufnarovskiGraph ( ideal  G,
ideal &  standardWords 
)

Definition at line 1779 of file hdegree.cc.

1780 {
1781  long l = 0;
1782  for (int i = 0; i < IDELEMS(G); i++)
1783  l = si_max(pTotaldegree(G->m[i]), l);
1784  l--;
1785  if (l <= 0)
1786  {
1787  WerrorS("Ufnarovski graph not implemented for l <= 0");
1788  return NULL;
1789  }
1790  int lV = currRing->isLPring;
1791 
1792  standardWords = lp_computeNormalWords(l, G);
1793 
1794  int n = IDELEMS(standardWords);
1795  intvec* UG = new intvec(n, n, 0);
1796  for (int i = 0; i < n; i++)
1797  {
1798  for (int j = 0; j < n; j++)
1799  {
1800  poly v = standardWords->m[i];
1801  poly w = standardWords->m[j];
1802 
1803  // check whether v*x1 = x2*w (overlap)
1804  bool overlap = true;
1805  for (int k = 1; k <= (l - 1) * lV; k++)
1806  {
1807  if (pGetExp(v, k + lV) != pGetExp(w, k)) {
1808  overlap = false;
1809  break;
1810  }
1811  }
1812 
1813  if (overlap)
1814  {
1815  // create the overlap
1816  poly p = pMult(pCopy(v), p_LPVarAt(w, l, currRing));
1817 
1818  // check whether the overlap is normal
1819  bool normal = true;
1820  for (int k = 0; k < IDELEMS(G); k++)
1821  {
1822  if (p_LPDivisibleBy(G->m[k], p, currRing))
1823  {
1824  normal = false;
1825  break;
1826  }
1827  }
1828 
1829  if (normal)
1830  {
1831  IMATELEM(*UG, i + 1, j + 1) = 1;
1832  }
1833  }
1834  }
1835  }
1836  return UG;
1837 }
int l
Definition: cfEzgcd.cc:100
int k
Definition: cfEzgcd.cc:99
int p
Definition: cfModGcd.cc:4078
const CanonicalForm & w
Definition: facAbsFact.cc:51
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:39
static ideal lp_computeNormalWords(int length, ideal M)
Definition: hdegree.cc:1738
#define IMATELEM(M, I, J)
Definition: intvec.h:85
#define pMult(p, q)
Definition: polys.h:207
#define pGetExp(p, i)
Exponent.
Definition: polys.h:41
#define pCopy(p)
return a copy of the poly
Definition: polys.h:185
BOOLEAN p_LPDivisibleBy(poly a, poly b, const ring r)
Definition: shiftop.cc:775
poly p_LPVarAt(poly p, int pos, const ring r)
Definition: shiftop.cc:844

◆ scComputeHC()

void scComputeHC ( ideal  s,
ideal  Q,
int  k,
poly &  hEdge,
ring  tailRing = currRing 
)

Definition at line 1079 of file hdegree.cc.

1080 {
1081  id_TestTail(S, currRing, tailRing);
1082  if (Q!=NULL) id_TestTail(Q, currRing, tailRing);
1083 
1084  int i;
1085  int k = ak;
1086  #ifdef HAVE_RINGS
1087  if (rField_is_Ring(currRing) && (currRing->OrdSgn == -1))
1088  {
1089  //consider just monic generators (over rings with zero-divisors)
1090  ideal SS=id_Copy(S,tailRing);
1091  for(i=0;i<=idElem(S);i++)
1092  {
1093  if((SS->m[i]!=NULL)
1094  && ((p_IsPurePower(SS->m[i],tailRing)==0)
1095  ||(!n_IsUnit(pGetCoeff(SS->m[i]), tailRing->cf))))
1096  {
1097  p_Delete(&SS->m[i],tailRing);
1098  }
1099  }
1100  S=id_Copy(SS,tailRing);
1101  idSkipZeroes(S);
1102  }
1103  #if 0
1104  printf("\nThis is HC:\n");
1105  for(int ii=0;ii<=idElem(S);ii++)
1106  {
1107  pWrite(S->m[ii]);
1108  }
1109  //getchar();
1110  #endif
1111  #endif
1112  if(idElem(S) == 0)
1113  return;
1114  hNvar = (currRing->N);
1115  hexist = hInit(S, Q, &hNexist, tailRing); // tailRing?
1116  if (k!=0)
1117  hComp(hexist, hNexist, k, hexist, &hNstc);
1118  else
1119  hNstc = hNexist;
1120  assume(hNexist > 0);
1121  hwork = (scfmon)omAlloc(hNexist * sizeof(scmon));
1122  hvar = (varset)omAlloc((hNvar + 1) * sizeof(int));
1123  hpure = (scmon)omAlloc((1 + (hNvar * hNvar)) * sizeof(int));
1124  stcmem = hCreate(hNvar - 1);
1125  for (i = hNvar; i>0; i--)
1126  hvar[i] = i;
1128  if ((hNvar > 2) && (hNstc > 10))
1130  memset(hpure, 0, (hNvar + 1) * sizeof(int));
1131  hPure(hexist, 0, &hNstc, hvar, hNvar, hpure, &hNpure);
1132  hLexS(hexist, hNstc, hvar, hNvar);
1133  if (hEdge!=NULL)
1134  pLmFree(hEdge);
1135  hEdge = pInit();
1136  pWork = pInit();
1137  hHedgeStep(hpure, hexist, hNstc, hvar, hNvar,hEdge);
1138  pSetComp(hEdge,ak);
1139  hKill(stcmem, hNvar - 1);
1140  omFreeSize((ADDRESS)hwork, hNexist * sizeof(scmon));
1141  omFreeSize((ADDRESS)hvar, (hNvar + 1) * sizeof(int));
1142  omFreeSize((ADDRESS)hpure, (1 + (hNvar * hNvar)) * sizeof(int));
1144  pLmFree(pWork);
1145 }
void * ADDRESS
Definition: auxiliary.h:119
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:515
static void hHedgeStep(scmon pure, scfmon stc, int Nstc, varset var, int Nvar, poly hEdge)
Definition: hdegree.cc:1019
STATIC_VAR poly pWork
Definition: hdegree.cc:1005
monf hCreate(int Nvar)
Definition: hutil.cc:999
void hComp(scfmon exist, int Nexist, int ak, scfmon stc, int *Nstc)
Definition: hutil.cc:157
scfmon hInit(ideal S, ideal Q, int *Nexist, ring tailRing)
Definition: hutil.cc:31
VAR varset hvar
Definition: hutil.cc:18
void hKill(monf xmem, int Nvar)
Definition: hutil.cc:1013
VAR int hNexist
Definition: hutil.cc:19
void hLexS(scfmon stc, int Nstc, varset var, int Nvar)
Definition: hutil.cc:509
void hDelete(scfmon ev, int ev_length)
Definition: hutil.cc:143
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:624
VAR scfmon hwork
Definition: hutil.cc:16
VAR scmon hpure
Definition: hutil.cc:17
void hStaircase(scfmon stc, int *Nstc, varset var, int Nvar)
Definition: hutil.cc:316
void hOrdSupp(scfmon stc, int Nstc, varset var, int Nvar)
Definition: hutil.cc:205
VAR int hNpure
Definition: hutil.cc:19
VAR scfmon hexist
Definition: hutil.cc:16
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
ideal id_Copy(ideal h1, const ring r)
copy an ideal
STATIC_VAR jList * Q
Definition: janet.cc:30
#define assume(x)
Definition: mod2.h:387
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
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define omAlloc(size)
Definition: omAllocDecl.h:210
int p_IsPurePower(const poly p, const ring r)
return i, if head depends only on var(i)
Definition: p_polys.cc:1222
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:873
#define pSetComp(p, v)
Definition: polys.h:38
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:70
void pWrite(poly p)
Definition: polys.h:308
#define pInit()
allocates a new monomial and initializes everything to 0
Definition: polys.h:61
int idElem(const ideal F)
count non-zero elements
#define id_TestTail(A, lR, tR)
Definition: simpleideals.h:77

◆ scDegree()

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

Definition at line 895 of file hdegree.cc.

896 {
897  id_Test(S, currRing);
898  if( Q!=NULL ) id_Test(Q, currRing);
899 
900  int co, mu, l;
901  intvec *hseries2;
902  intvec *hseries1 = hFirstSeries(S, modulweight, Q);
903  if (errorreported) return;
904  l = hseries1->length()-1;
905  if (l > 1)
906  hseries2 = hSecondSeries(hseries1);
907  else
908  hseries2 = hseries1;
909  hDegreeSeries(hseries1, hseries2, &co, &mu);
910  if ((l == 1) &&(mu == 0))
911  scPrintDegree((currRing->N)+1, 0);
912  else
913  scPrintDegree(co, mu);
914  if (l>1)
915  delete hseries1;
916  delete hseries2;
917 }
void mu(int **points, int sizePoints)
int length() const
Definition: intvec.h:94
void scPrintDegree(int co, int mu)
Definition: hdegree.cc:881
void hDegreeSeries(intvec *s1, intvec *s2, int *co, int *mu)
Definition: hilb.cc:1418
intvec * hSecondSeries(intvec *hseries1)
Definition: hilb.cc:1383
intvec * hFirstSeries(ideal S, intvec *modulweight, ideal Q, intvec *wdegree, ring tailRing)
Definition: hilb.cc:1373

◆ scDimInt()

int scDimInt ( ideal  s,
ideal  Q = NULL 
)

ideal dimension

Definition at line 77 of file hdegree.cc.

78 {
79  id_Test(S, currRing);
80  if( Q!=NULL ) id_Test(Q, currRing);
81 
82  int mc;
83  hexist = hInit(S, Q, &hNexist, currRing);
84  if (!hNexist)
85  return (currRing->N);
86  hwork = (scfmon)omAlloc(hNexist * sizeof(scmon));
87  hvar = (varset)omAlloc(((currRing->N) + 1) * sizeof(int));
88  hpure = (scmon)omAlloc((1 + ((currRing->N) * (currRing->N))) * sizeof(int));
89  mc = hisModule;
90  if (!mc)
91  {
92  hrad = hexist;
93  hNrad = hNexist;
94  }
95  else
96  hrad = (scfmon)omAlloc(hNexist * sizeof(scmon));
97  radmem = hCreate((currRing->N) - 1);
98  hCo = (currRing->N) + 1;
99  loop
100  {
101  if (mc)
102  hComp(hexist, hNexist, mc, hrad, &hNrad);
103  if (hNrad)
104  {
105  hNvar = (currRing->N);
106  hRadical(hrad, &hNrad, hNvar);
107  hSupp(hrad, hNrad, hvar, &hNvar);
108  if (hNvar)
109  {
110  memset(hpure, 0, ((currRing->N) + 1) * sizeof(int));
111  hPure(hrad, 0, &hNrad, hvar, hNvar, hpure, &hNpure);
112  hLexR(hrad, hNrad, hvar, hNvar);
114  }
115  }
116  else
117  {
118  hCo = 0;
119  break;
120  }
121  mc--;
122  if (mc <= 0)
123  break;
124  }
125  hKill(radmem, (currRing->N) - 1);
126  omFreeSize((ADDRESS)hpure, (1 + ((currRing->N) * (currRing->N))) * sizeof(int));
127  omFreeSize((ADDRESS)hvar, ((currRing->N) + 1) * sizeof(int));
128  omFreeSize((ADDRESS)hwork, hNexist * sizeof(scmon));
130  if (hisModule)
131  omFreeSize((ADDRESS)hrad, hNexist * sizeof(scmon));
132  return (currRing->N) - hCo;
133 }
VAR int hCo
Definition: hdegree.cc:27
void hDimSolve(scmon pure, int Npure, scfmon rad, int Nrad, varset var, int Nvar)
Definition: hdegree.cc:34
void hSupp(scfmon stc, int Nstc, varset var, int *Nvar)
Definition: hutil.cc:177
void hLexR(scfmon rad, int Nrad, varset var, int Nvar)
Definition: hutil.cc:568
VAR scfmon hrad
Definition: hutil.cc:16
VAR int hisModule
Definition: hutil.cc:20
VAR monf radmem
Definition: hutil.cc:21
VAR int hNrad
Definition: hutil.cc:19
void hRadical(scfmon rad, int *Nrad, int Nvar)
Definition: hutil.cc:414
#define loop
Definition: structs.h:79

◆ scDimIntRing()

int scDimIntRing ( ideal  s,
ideal  Q = NULL 
)

scDimInt for ring-coefficients

Definition at line 135 of file hdegree.cc.

136 {
137 #ifdef HAVE_RINGS
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);
152  if(rField_is_Z(currRing))
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 #endif
200  return scDimInt(vid,Q);
201 }
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:753
int scDimInt(ideal S, ideal Q)
ideal dimension
Definition: hdegree.cc:77
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
#define pDelete(p_ptr)
Definition: polys.h:186
static BOOLEAN rField_is_Z(const ring r)
Definition: ring.h:510

◆ scIndIntvec()

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

Definition at line 285 of file hdegree.cc.

286 {
287  id_Test(S, currRing);
288  if( Q!=NULL ) id_Test(Q, currRing);
289 
290  intvec *Set=new intvec((currRing->N));
291  int mc,i;
292  hexist = hInit(S, Q, &hNexist, currRing);
293  if (hNexist==0)
294  {
295  for(i=0; i<(currRing->N); i++)
296  (*Set)[i]=1;
297  return Set;
298  }
299  hwork = (scfmon)omAlloc(hNexist * sizeof(scmon));
300  hvar = (varset)omAlloc(((currRing->N) + 1) * sizeof(int));
301  hpure = (scmon)omAlloc((1 + ((currRing->N) * (currRing->N))) * sizeof(int));
302  hInd = (scmon)omAlloc0((1 + (currRing->N)) * sizeof(int));
303  mc = hisModule;
304  if (mc==0)
305  {
306  hrad = hexist;
307  hNrad = hNexist;
308  }
309  else
310  hrad = (scfmon)omAlloc(hNexist * sizeof(scmon));
311  radmem = hCreate((currRing->N) - 1);
312  hCo = (currRing->N) + 1;
313  loop
314  {
315  if (mc!=0)
316  hComp(hexist, hNexist, mc, hrad, &hNrad);
317  if (hNrad!=0)
318  {
319  hNvar = (currRing->N);
320  hRadical(hrad, &hNrad, hNvar);
321  hSupp(hrad, hNrad, hvar, &hNvar);
322  if (hNvar!=0)
323  {
324  memset(hpure, 0, ((currRing->N) + 1) * sizeof(int));
325  hPure(hrad, 0, &hNrad, hvar, hNvar, hpure, &hNpure);
326  hLexR(hrad, hNrad, hvar, hNvar);
328  }
329  }
330  else
331  {
332  hCo = 0;
333  break;
334  }
335  mc--;
336  if (mc <= 0)
337  break;
338  }
339  for(i=0; i<(currRing->N); i++)
340  (*Set)[i] = hInd[i+1];
341  hKill(radmem, (currRing->N) - 1);
342  omFreeSize((ADDRESS)hpure, (1 + ((currRing->N) * (currRing->N))) * sizeof(int));
343  omFreeSize((ADDRESS)hInd, (1 + (currRing->N)) * sizeof(int));
344  omFreeSize((ADDRESS)hvar, ((currRing->N) + 1) * sizeof(int));
345  omFreeSize((ADDRESS)hwork, hNexist * sizeof(scmon));
347  if (hisModule)
348  omFreeSize((ADDRESS)hrad, hNexist * sizeof(scmon));
349  return Set;
350 }
STATIC_VAR scmon hInd
Definition: hdegree.cc:204
static void hIndSolve(scmon pure, int Npure, scfmon rad, int Nrad, varset var, int Nvar)
Definition: hdegree.cc:206
#define omAlloc0(size)
Definition: omAllocDecl.h:211

◆ scKBase()

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

Definition at line 1427 of file hdegree.cc.

1428 {
1429  if( Q!=NULL) id_Test(Q, currRing);
1430 
1431  int i, di;
1432  poly p;
1433 
1434  if (deg < 0)
1435  {
1436  di = scDimInt(s, Q);
1437  if (di != 0)
1438  {
1439  //Werror("KBase not finite");
1440  return idInit(1,s->rank);
1441  }
1442  }
1443  stcmem = hCreate((currRing->N) - 1);
1444  hexist = hInit(s, Q, &hNexist, currRing);
1445  p = last = pInit();
1446  /*pNext(p) = NULL;*/
1447  act = (scmon)omAlloc(((currRing->N) + 1) * sizeof(int));
1448  *act = 0;
1449  if (!hNexist)
1450  {
1451  scAll((currRing->N), deg);
1452  goto ende;
1453  }
1454  if (!hisModule)
1455  {
1456  if (deg < 0) scInKbase(hexist, hNexist, (currRing->N));
1457  else scDegKbase(hexist, hNexist, (currRing->N), deg);
1458  }
1459  else
1460  {
1461  hstc = (scfmon)omAlloc(hNexist * sizeof(scmon));
1462  for (i = 1; i <= hisModule; i++)
1463  {
1464  *act = i;
1465  hComp(hexist, hNexist, i, hstc, &hNstc);
1466  int deg_ei=deg;
1467  if (mv!=NULL) deg_ei -= (*mv)[i-1];
1468  if ((deg < 0) || (deg_ei>=0))
1469  {
1470  if (hNstc)
1471  {
1472  if (deg < 0) scInKbase(hstc, hNstc, (currRing->N));
1473  else scDegKbase(hstc, hNstc, (currRing->N), deg_ei);
1474  }
1475  else
1476  scAll((currRing->N), deg_ei);
1477  }
1478  }
1479  omFreeSize((ADDRESS)hstc, hNexist * sizeof(scmon));
1480  }
1481 ende:
1483  omFreeSize((ADDRESS)act, ((currRing->N) + 1) * sizeof(int));
1484  hKill(stcmem, (currRing->N) - 1);
1485  pLmFree(&p);
1486  if (p == NULL)
1487  return idInit(1,s->rank);
1488 
1489  last = p;
1490  return scIdKbase(p, s->rank);
1491 }
const CanonicalForm int s
Definition: facAbsFact.cc:51
STATIC_VAR poly last
Definition: hdegree.cc:1151
static void scAll(int Nvar, int deg)
Definition: hdegree.cc:1238
static void scDegKbase(scfmon stc, int Nstc, int Nvar, int deg)
Definition: hdegree.cc:1272
STATIC_VAR scmon act
Definition: hdegree.cc:1152
static ideal scIdKbase(poly q, const int rank)
Definition: hdegree.cc:1409
static void scInKbase(scfmon stc, int Nstc, int Nvar)
Definition: hdegree.cc:1353
VAR scfmon hstc
Definition: hutil.cc:16
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:35

◆ scMult0Int()

int scMult0Int ( ideal  s,
ideal  Q = NULL,
const ring  tailRing = currRing 
)

Definition at line 993 of file hdegree.cc.

994 {
995  id_TestTail(S, currRing, tailRing);
996  if (Q!=NULL) id_TestTail(Q, currRing, tailRing);
997 
998  hDegree0(S, Q, tailRing);
999  return hMu;
1000 }
VAR int hMu
Definition: hdegree.cc:27
static void hDegree0(ideal S, ideal Q, const ring tailRing)
Definition: hdegree.cc:919

◆ scMultInt()

int scMultInt ( ideal  s,
ideal  Q = NULL 
)

Definition at line 872 of file hdegree.cc.

873 {
874  id_Test(S, currRing);
875  if( Q!=NULL ) id_Test(Q, currRing);
876 
877  hDegree(S, Q);
878  return hMu;
879 }
static void hDegree(ideal S, ideal Q)
Definition: hdegree.cc:771

◆ scPrintDegree()

void scPrintDegree ( int  co,
int  mu 
)

Definition at line 881 of file hdegree.cc.

882 {
883  int di = (currRing->N)-co;
884  if (currRing->OrdSgn == 1)
885  {
886  if (di>0)
887  Print("// dimension (proj.) = %d\n// degree (proj.) = %d\n", di-1, mu);
888  else
889  Print("// dimension (affine) = 0\n// degree (affine) = %d\n", mu);
890  }
891  else
892  Print("// dimension (local) = %d\n// multiplicity = %d\n", di, mu);
893 }