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 1839 of file hdegree.cc.

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

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

1779{
1780 long l = 0;
1781 for (int i = 0; i < IDELEMS(G); i++)
1782 l = si_max(pTotaldegree(G->m[i]), l);
1783 l--;
1784 if (l <= 0)
1785 {
1786 WerrorS("Ufnarovski graph not implemented for l <= 0");
1787 return NULL;
1788 }
1789 int lV = currRing->isLPring;
1790
1791 standardWords = lp_computeNormalWords(l, G);
1792
1793 int n = IDELEMS(standardWords);
1794 intvec* UG = new intvec(n, n, 0);
1795 for (int i = 0; i < n; i++)
1796 {
1797 for (int j = 0; j < n; j++)
1798 {
1799 poly v = standardWords->m[i];
1800 poly w = standardWords->m[j];
1801
1802 // check whether v*x1 = x2*w (overlap)
1803 bool overlap = true;
1804 for (int k = 1; k <= (l - 1) * lV; k++)
1805 {
1806 if (pGetExp(v, k + lV) != pGetExp(w, k)) {
1807 overlap = false;
1808 break;
1809 }
1810 }
1811
1812 if (overlap)
1813 {
1814 // create the overlap
1815 poly p = pMult(pCopy(v), p_LPVarAt(w, l, currRing));
1816
1817 // check whether the overlap is normal
1818 bool normal = true;
1819 for (int k = 0; k < IDELEMS(G); k++)
1820 {
1821 if (p_LPDivisibleBy(G->m[k], p, currRing))
1822 {
1823 normal = false;
1824 break;
1825 }
1826 }
1827
1828 if (normal)
1829 {
1830 IMATELEM(*UG, i + 1, j + 1) = 1;
1831 }
1832 }
1833 }
1834 }
1835 return UG;
1836}
int l
Definition: cfEzgcd.cc:100
int k
Definition: cfEzgcd.cc:99
int p
Definition: cfModGcd.cc:4080
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:1737
#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:773
poly p_LPVarAt(poly p, int pos, const ring r)
Definition: shiftop.cc:835

◆ scComputeHC()

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

Definition at line 1078 of file hdegree.cc.

1079{
1080 id_TestTail(S, currRing, tailRing);
1081 if (Q!=NULL) id_TestTail(Q, currRing, tailRing);
1082
1083 int i;
1084 int k = ak;
1085 #ifdef HAVE_RINGS
1086 if (rField_is_Ring(currRing) && (currRing->OrdSgn == -1))
1087 {
1088 //consider just monic generators (over rings with zero-divisors)
1089 ideal SS=id_Copy(S,tailRing);
1090 for(i=0;i<=idElem(S);i++)
1091 {
1092 if((SS->m[i]!=NULL)
1093 && ((p_IsPurePower(SS->m[i],tailRing)==0)
1094 ||(!n_IsUnit(pGetCoeff(SS->m[i]), tailRing->cf))))
1095 {
1096 p_Delete(&SS->m[i],tailRing);
1097 }
1098 }
1099 S=id_Copy(SS,tailRing);
1100 idSkipZeroes(S);
1101 }
1102 #if 0
1103 printf("\nThis is HC:\n");
1104 for(int ii=0;ii<=idElem(S);ii++)
1105 {
1106 pWrite(S->m[ii]);
1107 }
1108 //getchar();
1109 #endif
1110 #endif
1111 if(idElem(S) == 0)
1112 return;
1113 hNvar = (currRing->N);
1114 hexist = hInit(S, Q, &hNexist, tailRing); // tailRing?
1115 if (k!=0)
1117 else
1118 hNstc = hNexist;
1119 assume(hNexist > 0);
1120 hwork = (scfmon)omAlloc(hNexist * sizeof(scmon));
1121 hvar = (varset)omAlloc((hNvar + 1) * sizeof(int));
1122 hpure = (scmon)omAlloc((1 + (hNvar * hNvar)) * sizeof(int));
1123 stcmem = hCreate(hNvar - 1);
1124 for (i = hNvar; i>0; i--)
1125 hvar[i] = i;
1127 if ((hNvar > 2) && (hNstc > 10))
1129 memset(hpure, 0, (hNvar + 1) * sizeof(int));
1130 hPure(hexist, 0, &hNstc, hvar, hNvar, hpure, &hNpure);
1132 if (hEdge!=NULL)
1133 pLmFree(hEdge);
1134 hEdge = pInit();
1135 pWork = pInit();
1137 pSetComp(hEdge,ak);
1138 hKill(stcmem, hNvar - 1);
1139 omFreeSize((ADDRESS)hwork, hNexist * sizeof(scmon));
1140 omFreeSize((ADDRESS)hvar, (hNvar + 1) * sizeof(int));
1141 omFreeSize((ADDRESS)hpure, (1 + (hNvar * hNvar)) * sizeof(int));
1143 pLmFree(pWork);
1144}
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:516
static void hHedgeStep(scmon pure, scfmon stc, int Nstc, varset var, int Nvar, poly hEdge)
Definition: hdegree.cc:1018
STATIC_VAR poly pWork
Definition: hdegree.cc:1004
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:1221
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:861
#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 l = hseries1->length()-1;
904 if (l > 1)
905 hseries2 = hSecondSeries(hseries1);
906 else
907 hseries2 = hseries1;
908 hDegreeSeries(hseries1, hseries2, &co, &mu);
909 if ((l == 1) &&(mu == 0))
910 scPrintDegree((currRing->N)+1, 0);
911 else
912 scPrintDegree(co, mu);
913 if (l>1)
914 delete hseries1;
915 delete hseries2;
916}
void mu(int **points, int sizePoints)
int length() const
Definition: intvec.h:94
void scPrintDegree(int co, int mu)
Definition: hdegree.cc:881
intvec * hSecondSeries(intvec *hseries1)
Definition: hilb.cc:1345
intvec * hFirstSeries(ideal S, intvec *modulweight, ideal Q, intvec *wdegree, ring tailRing)
Definition: hilb.cc:1335
void hDegreeSeries(intvec *s1, intvec *s2, int *co, int *mu)
Definition: hilb.cc:1380

◆ 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);
108 if (hNvar)
109 {
110 memset(hpure, 0, ((currRing->N) + 1) * sizeof(int));
111 hPure(hrad, 0, &hNrad, hvar, hNvar, hpure, &hNpure);
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:80

◆ 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);
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:777
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:511

◆ 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);
322 if (hNvar!=0)
323 {
324 memset(hpure, 0, ((currRing->N) + 1) * sizeof(int));
325 hPure(hrad, 0, &hNrad, hvar, hNvar, hpure, &hNpure);
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 1426 of file hdegree.cc.

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

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

◆ 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}