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)
 
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)
 
long scMult0Int (ideal s, ideal Q=NULL)
 
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 1862 of file hdegree.cc.

1863 {
1864  id_Test(_G, currRing);
1865 
1866  if (rField_is_Ring(currRing)) {
1867  WerrorS("GK-Dim not implemented for rings");
1868  return -2;
1869  }
1870 
1871  for (int i=IDELEMS(_G)-1;i>=0; i--)
1872  {
1873  if (_G->m[i] != NULL)
1874  {
1875  if (pGetComp(_G->m[i]) != 0)
1876  {
1877  WerrorS("GK-Dim not implemented for modules");
1878  return -2;
1879  }
1880  if (pGetNCGen(_G->m[i]) != 0)
1881  {
1882  WerrorS("GK-Dim not implemented for bi-modules");
1883  return -2;
1884  }
1885  }
1886  }
1887 
1888  ideal G = id_Head(_G, currRing); // G = LM(G) (and copy)
1889  idSkipZeroes(G); // remove zeros
1890  id_DelLmEquals(G, currRing); // remove duplicates
1891 
1892  // check if G is the zero ideal
1893  if (IDELEMS(G) == 1 && G->m[0] == NULL)
1894  {
1895  // NOTE: this is needed because if the ideal is <0>, then idSkipZeroes keeps this element, and IDELEMS is still 1!
1896  int lV = currRing->isLPring;
1897  int ncGenCount = currRing->LPncGenCount;
1898  if (lV - ncGenCount == 0)
1899  {
1900  idDelete(&G);
1901  return 0;
1902  }
1903  if (lV - ncGenCount == 1)
1904  {
1905  idDelete(&G);
1906  return 1;
1907  }
1908  if (lV - ncGenCount >= 2)
1909  {
1910  idDelete(&G);
1911  return -1;
1912  }
1913  }
1914 
1915  // get the max deg
1916  long maxDeg = 0;
1917  for (int i = 0; i < IDELEMS(G); i++)
1918  {
1919  maxDeg = si_max(maxDeg, pTotaldegree(G->m[i]));
1920 
1921  // also check whether G = <1>
1922  if (pIsConstantComp(G->m[i]))
1923  {
1924  WerrorS("GK-Dim not defined for 0-ring");
1925  idDelete(&G);
1926  return -2;
1927  }
1928  }
1929 
1930  // early termination if G \subset X
1931  if (maxDeg <= 1)
1932  {
1933  int lV = currRing->isLPring;
1934  int ncGenCount = currRing->LPncGenCount;
1935  if (IDELEMS(G) == lV - ncGenCount) // V = {1} no edges
1936  {
1937  idDelete(&G);
1938  return 0;
1939  }
1940  if (IDELEMS(G) == lV - ncGenCount - 1) // V = {1} with loop
1941  {
1942  idDelete(&G);
1943  return 1;
1944  }
1945  if (IDELEMS(G) <= lV - ncGenCount - 2) // V = {1} with more than one loop
1946  {
1947  idDelete(&G);
1948  return -1;
1949  }
1950  }
1951 
1952  ideal standardWords;
1953  intvec* UG = lp_ufnarovskiGraph(G, standardWords);
1954  if (UG == NULL)
1955  {
1956  idDelete(&G);
1957  return -2;
1958  }
1959  if (errorreported)
1960  {
1961  delete UG;
1962  idDelete(&G);
1963  return -2;
1964  }
1965  int gkDim = graphGrowth(UG);
1966  delete UG;
1967  idDelete(&G);
1968  return gkDim;
1969 }
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:1801
static int graphGrowth(const intvec *G)
Definition: hdegree.cc:1674
#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 2112 of file hdegree.cc.

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

1802 {
1803  long l = 0;
1804  for (int i = 0; i < IDELEMS(G); i++)
1805  l = si_max(pTotaldegree(G->m[i]), l);
1806  l--;
1807  if (l <= 0)
1808  {
1809  WerrorS("Ufnarovski graph not implemented for l <= 0");
1810  return NULL;
1811  }
1812  int lV = currRing->isLPring;
1813 
1814  standardWords = lp_computeNormalWords(l, G);
1815 
1816  int n = IDELEMS(standardWords);
1817  intvec* UG = new intvec(n, n, 0);
1818  for (int i = 0; i < n; i++)
1819  {
1820  for (int j = 0; j < n; j++)
1821  {
1822  poly v = standardWords->m[i];
1823  poly w = standardWords->m[j];
1824 
1825  // check whether v*x1 = x2*w (overlap)
1826  bool overlap = true;
1827  for (int k = 1; k <= (l - 1) * lV; k++)
1828  {
1829  if (pGetExp(v, k + lV) != pGetExp(w, k)) {
1830  overlap = false;
1831  break;
1832  }
1833  }
1834 
1835  if (overlap)
1836  {
1837  // create the overlap
1838  poly p = pMult(pCopy(v), p_LPVarAt(w, l, currRing));
1839 
1840  // check whether the overlap is normal
1841  bool normal = true;
1842  for (int k = 0; k < IDELEMS(G); k++)
1843  {
1844  if (p_LPDivisibleBy(G->m[k], p, currRing))
1845  {
1846  normal = false;
1847  break;
1848  }
1849  }
1850 
1851  if (normal)
1852  {
1853  IMATELEM(*UG, i + 1, j + 1) = 1;
1854  }
1855  }
1856  }
1857  }
1858  return UG;
1859 }
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:1760
#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:776
poly p_LPVarAt(poly p, int pos, const ring r)
Definition: shiftop.cc:845

◆ scComputeHC()

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

Definition at line 1101 of file hdegree.cc.

1102 {
1103  id_LmTest(S, currRing);
1104  if (Q!=NULL) id_LmTest(Q, currRing);
1105 
1106  int i;
1107  int k = ak;
1108  #ifdef HAVE_RINGS
1109  if (rField_is_Ring(currRing) && (currRing->OrdSgn == -1))
1110  {
1111  //consider just monic generators (over rings with zero-divisors)
1112  ideal SS=id_Head(S,currRing);
1113  for(i=0;i<=idElem(S);i++)
1114  {
1115  if((SS->m[i]!=NULL)
1116  && ((p_IsPurePower(SS->m[i],currRing)==0)
1117  ||(!n_IsUnit(pGetCoeff(SS->m[i]), currRing->cf))))
1118  {
1119  p_Delete(&SS->m[i],currRing);
1120  }
1121  }
1122  S=id_Copy(SS,currRing);
1123  idSkipZeroes(S);
1124  }
1125  #if 0
1126  printf("\nThis is HC:\n");
1127  for(int ii=0;ii<=idElem(S);ii++)
1128  {
1129  pWrite(S->m[ii]);
1130  }
1131  //getchar();
1132  #endif
1133  #endif
1134  if(idElem(S) == 0)
1135  return;
1136  hNvar = (currRing->N);
1137  hexist = hInit(S, Q, &hNexist);
1138  if (k!=0)
1139  hComp(hexist, hNexist, k, hexist, &hNstc);
1140  else
1141  hNstc = hNexist;
1142  assume(hNexist > 0);
1143  hwork = (scfmon)omAlloc(hNexist * sizeof(scmon));
1144  hvar = (varset)omAlloc((hNvar + 1) * sizeof(int));
1145  hpure = (scmon)omAlloc((1 + (hNvar * hNvar)) * sizeof(int));
1146  stcmem = hCreate(hNvar - 1);
1147  for (i = hNvar; i>0; i--)
1148  hvar[i] = i;
1150  if ((hNvar > 2) && (hNstc > 10))
1152  memset(hpure, 0, (hNvar + 1) * sizeof(int));
1153  hPure(hexist, 0, &hNstc, hvar, hNvar, hpure, &hNpure);
1154  hLexS(hexist, hNstc, hvar, hNvar);
1155  if (hEdge!=NULL)
1156  pLmFree(hEdge);
1157  hEdge = pInit();
1158  pWork = pInit();
1159  hHedgeStep(hpure, hexist, hNstc, hvar, hNvar,hEdge);
1160  pSetComp(hEdge,ak);
1161  hKill(stcmem, hNvar - 1);
1162  omFreeSize((ADDRESS)hwork, hNexist * sizeof(scmon));
1163  omFreeSize((ADDRESS)hvar, (hNvar + 1) * sizeof(int));
1164  omFreeSize((ADDRESS)hpure, (1 + (hNvar * hNvar)) * sizeof(int));
1166  pLmFree(pWork);
1167 }
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:1041
STATIC_VAR poly pWork
Definition: hdegree.cc:1027
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 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 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
VAR scmon hpure
Definition: hutil.cc:17
void hStaircase(scfmon stc, int *Nstc, varset var, int Nvar)
Definition: hutil.cc:313
void hOrdSupp(scfmon stc, int Nstc, varset var, int Nvar)
Definition: hutil.cc:202
VAR int hNpure
Definition: hutil.cc:19
scfmon hInit(ideal S, ideal Q, int *Nexist)
Definition: hutil.cc:31
VAR scfmon hexist
Definition: hutil.cc:16
VAR int hNstc
Definition: hutil.cc:19
VAR int hNvar
Definition: hutil.cc:19
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:389
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:1226
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:903
#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_LmTest(A, lR)
Definition: simpleideals.h:79

◆ scDegree()

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

Definition at line 926 of file hdegree.cc.

927 {
928  id_Test(S, currRing);
929  if( Q!=NULL ) id_Test(Q, currRing);
930 
931  int co, mu, l;
932  intvec *hseries2;
933  intvec *hseries1 = hFirstSeries(S, modulweight, Q);
934  if (errorreported) return;
935  l = hseries1->length()-1;
936  if (l > 1)
937  hseries2 = hSecondSeries(hseries1);
938  else
939  hseries2 = hseries1;
940  hDegreeSeries(hseries1, hseries2, &co, &mu);
941  if ((l == 1) &&(mu == 0))
942  scPrintDegree((currRing->N)+1, 0);
943  else
944  scPrintDegree(co, mu);
945  if (l>1)
946  delete hseries1;
947  delete hseries2;
948 }
void mu(int **points, int sizePoints)
int length() const
Definition: intvec.h:94
void scPrintDegree(int co, int mu)
Definition: hdegree.cc:912
intvec * hFirstSeries(ideal A, intvec *module_w, ideal Q, intvec *wdegree)
Definition: hilb.cc:1947
void hDegreeSeries(intvec *s1, intvec *s2, int *co, int *mu)
Definition: hilb.cc:732
intvec * hSecondSeries(intvec *hseries1)
Definition: hilb.cc:697

◆ scDimInt()

int scDimInt ( ideal  s,
ideal  Q = NULL 
)

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);
107  hRadical(hrad, &hNrad, hNvar);
108  hSupp(hrad, hNrad, hvar, &hNvar);
109  if (hNvar)
110  {
111  memset(hpure, 0, ((currRing->N) + 1) * sizeof(int));
112  hPure(hrad, 0, &hNrad, hvar, hNvar, hpure, &hNpure);
113  hLexR(hrad, hNrad, hvar, hNvar);
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 }
VAR int hCo
Definition: hdegree.cc:27
void hDimSolve(scmon pure, int Npure, scfmon rad, int Nrad, varset var, int Nvar)
Definition: hdegree.cc:35
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 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:411
#define loop
Definition: structs.h:75

◆ scDimIntRing()

int scDimIntRing ( ideal  s,
ideal  Q = NULL 
)

scDimInt for ring-coefficients

Definition at line 136 of file hdegree.cc.

137 {
138 #ifdef HAVE_RINGS
140  {
141  int i = idPosConstant(vid);
142  if ((i != -1) && (n_IsUnit(pGetCoeff(vid->m[i]),currRing->cf)))
143  { /* ideal v contains unit; dim = -1 */
144  return(-1);
145  }
146  ideal vv = id_Head(vid,currRing);
147  idSkipZeroes(vv);
148  i = idPosConstant(vid);
149  int d;
150  if(i == -1)
151  {
152  d = scDimInt(vv, Q);
153  if(rField_is_Z(currRing))
154  d++;
155  }
156  else
157  {
158  if(n_IsUnit(pGetCoeff(vv->m[i]),currRing->cf))
159  d = -1;
160  else
161  d = scDimInt(vv, Q);
162  }
163  //Anne's Idea for std(4,2x) = 0 bug
164  int dcurr = d;
165  for(unsigned ii=0;ii<(unsigned)IDELEMS(vv);ii++)
166  {
167  if(vv->m[ii] != NULL && !n_IsUnit(pGetCoeff(vv->m[ii]),currRing->cf))
168  {
169  ideal vc = idCopy(vv);
170  poly c = pInit();
171  pSetCoeff0(c,nCopy(pGetCoeff(vv->m[ii])));
172  idInsertPoly(vc,c);
173  idSkipZeroes(vc);
174  for(unsigned jj = 0;jj<(unsigned)IDELEMS(vc)-1;jj++)
175  {
176  if((vc->m[jj]!=NULL)
177  && (n_DivBy(pGetCoeff(vc->m[jj]),pGetCoeff(c),currRing->cf)))
178  {
179  pDelete(&vc->m[jj]);
180  }
181  }
182  idSkipZeroes(vc);
183  i = idPosConstant(vc);
184  if (i != -1) pDelete(&vc->m[i]);
185  dcurr = scDimInt(vc, Q);
186  // the following assumes the ground rings to be either zero- or one-dimensional
187  if((i==-1) && rField_is_Z(currRing))
188  {
189  // should also be activated for other euclidean domains as groundfield
190  dcurr++;
191  }
192  idDelete(&vc);
193  }
194  if(dcurr > d)
195  d = dcurr;
196  }
197  idDelete(&vv);
198  return d;
199  }
200 #endif
201  return scDimInt(vid,Q);
202 }
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: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
#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 286 of file hdegree.cc.

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

◆ scKBase()

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

Definition at line 1449 of file hdegree.cc.

1450 {
1451  if( Q!=NULL) id_Test(Q, currRing);
1452 
1453  int i, di;
1454  poly p;
1455 
1456  if (deg < 0)
1457  {
1458  di = scDimInt(s, Q);
1459  if (di != 0)
1460  {
1461  //Werror("KBase not finite");
1462  return idInit(1,s->rank);
1463  }
1464  }
1465  stcmem = hCreate((currRing->N) - 1);
1466  hexist = hInit(s, Q, &hNexist);
1467  p = last = pInit();
1468  /*pNext(p) = NULL;*/
1469  act = (scmon)omAlloc(((currRing->N) + 1) * sizeof(int));
1470  *act = 0;
1471  if (!hNexist)
1472  {
1473  scAll((currRing->N), deg);
1474  goto ende;
1475  }
1476  if (!hisModule)
1477  {
1478  if (deg < 0) scInKbase(hexist, hNexist, (currRing->N));
1479  else scDegKbase(hexist, hNexist, (currRing->N), deg);
1480  }
1481  else
1482  {
1483  hstc = (scfmon)omAlloc(hNexist * sizeof(scmon));
1484  for (i = 1; i <= hisModule; i++)
1485  {
1486  *act = i;
1487  hComp(hexist, hNexist, i, hstc, &hNstc);
1488  int deg_ei=deg;
1489  if (mv!=NULL) deg_ei -= (*mv)[i-1];
1490  if ((deg < 0) || (deg_ei>=0))
1491  {
1492  if (hNstc)
1493  {
1494  if (deg < 0) scInKbase(hstc, hNstc, (currRing->N));
1495  else scDegKbase(hstc, hNstc, (currRing->N), deg_ei);
1496  }
1497  else
1498  scAll((currRing->N), deg_ei);
1499  }
1500  }
1501  omFreeSize((ADDRESS)hstc, hNexist * sizeof(scmon));
1502  }
1503 ende:
1505  omFreeSize((ADDRESS)act, ((currRing->N) + 1) * sizeof(int));
1506  hKill(stcmem, (currRing->N) - 1);
1507  pLmFree(&p);
1508  if (p == NULL)
1509  return idInit(1,s->rank);
1510 
1511  last = p;
1512  return scIdKbase(p, s->rank);
1513 }
const CanonicalForm int s
Definition: facAbsFact.cc:51
STATIC_VAR poly last
Definition: hdegree.cc:1173
static void scAll(int Nvar, int deg)
Definition: hdegree.cc:1260
static void scDegKbase(scfmon stc, int Nstc, int Nvar, int deg)
Definition: hdegree.cc:1294
STATIC_VAR scmon act
Definition: hdegree.cc:1174
static ideal scIdKbase(poly q, const int rank)
Definition: hdegree.cc:1431
static void scInKbase(scfmon stc, int Nstc, int Nvar)
Definition: hdegree.cc:1375
VAR scfmon hstc
Definition: hutil.cc:16
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:35

◆ scMult0Int()

long scMult0Int ( ideal  s,
ideal  Q = NULL 
)

Definition at line 950 of file hdegree.cc.

951 {
952  id_LmTest(S, currRing);
953  if (Q!=NULL) id_LmTest(Q, currRing);
954 
955  int mc;
956  hexist = hInit(S, Q, &hNexist);
957  if (!hNexist)
958  {
959  hMu = -1;
960  return -1;
961  }
962  else
963  hMu = 0;
964 
965  const ring r = currRing;
966 
967  hwork = (scfmon)omAlloc(hNexist * sizeof(scmon));
968  hvar = (varset)omAlloc(((r->N) + 1) * sizeof(int));
969  hpur0 = (scmon)omAlloc((1 + ((r->N) * (r->N))) * sizeof(int));
970  mc = hisModule;
971  if (!mc)
972  {
973  hstc = hexist;
974  hNstc = hNexist;
975  }
976  else
977  hstc = (scfmon)omAlloc(hNexist * sizeof(scmon));
978  stcmem = hCreate((r->N) - 1);
979  loop
980  {
981  if (mc)
982  {
983  hComp(hexist, hNexist, mc, hstc, &hNstc);
984  if (!hNstc)
985  {
986  hMu = -1;
987  break;
988  }
989  }
990  hNvar = (r->N);
991  for (int i = hNvar; i; i--)
992  hvar[i] = i;
994  hSupp(hstc, hNstc, hvar, &hNvar);
995  if ((hNvar == (r->N)) && (hNstc >= (r->N)))
996  {
997  if ((hNvar > 2) && (hNstc > 10))
999  memset(hpur0, 0, ((r->N) + 1) * sizeof(int));
1000  hPure(hstc, 0, &hNstc, hvar, hNvar, hpur0, &hNpure);
1001  if (hNpure == hNvar)
1002  {
1003  hLexS(hstc, hNstc, hvar, hNvar);
1005  }
1006  else
1007  hMu = -1;
1008  }
1009  else if (hNvar)
1010  hMu = -1;
1011  mc--;
1012  if (mc <= 0 || hMu < 0)
1013  break;
1014  }
1015  hKill(stcmem, (r->N) - 1);
1016  omFreeSize((ADDRESS)hpur0, (1 + ((r->N) * (r->N))) * sizeof(int));
1017  omFreeSize((ADDRESS)hvar, ((r->N) + 1) * sizeof(int));
1018  omFreeSize((ADDRESS)hwork, hNexist * sizeof(scmon));
1020  if (hisModule)
1021  omFreeSize((ADDRESS)hstc, hNexist * sizeof(scmon));
1022  return hMu;
1023 }
static long hZeroMult(scmon pure, scfmon stc, int Nstc, varset var, int Nvar)
Definition: hdegree.cc:621
VAR long hMu
Definition: hdegree.cc:28
VAR scmon hpur0
Definition: hutil.cc:17

◆ scMultInt()

int scMultInt ( ideal  s,
ideal  Q = NULL 
)

Definition at line 903 of file hdegree.cc.

904 {
905  id_Test(S, currRing);
906  if( Q!=NULL ) id_Test(Q, currRing);
907 
908  hDegree(S, Q);
909  return hMu;
910 }
static void hDegree(ideal S, ideal Q)
Definition: hdegree.cc:802

◆ scPrintDegree()

void scPrintDegree ( int  co,
int  mu 
)

Definition at line 912 of file hdegree.cc.

913 {
914  int di = (currRing->N)-co;
915  if (currRing->OrdSgn == 1)
916  {
917  if (di>0)
918  Print("// dimension (proj.) = %d\n// degree (proj.) = %d\n", di-1, mu);
919  else
920  Print("// dimension (affine) = 0\n// degree (affine) = %d\n", mu);
921  }
922  else
923  Print("// dimension (local) = %d\n// multiplicity = %d\n", di, mu);
924 }