My Project
Loading...
Searching...
No Matches
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
 
int scDimIntRing (ideal s, ideal Q=NULL)
 scDimInt for ring-coefficients
 
int scMultInt (ideal s, ideal Q=NULL)
 
long scMult0Int (ideal s, ideal Q=NULL)
 
void scDegree (ideal s, intvec *modulweight, ideal Q=NULL)
 
void scPrintDegree (int co, int mu)
 
ideal scKBase (int deg, ideal s, ideal Q=NULL, intvec *mv=NULL)
 
int lp_gkDim (const ideal G)
 
int lp_kDim (const ideal G)
 
intveclp_ufnarovskiGraph (ideal G, ideal &standardWords)
 

Function Documentation

◆ lp_gkDim()

int lp_gkDim ( const ideal G)

Definition at line 1861 of file hdegree.cc.

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

◆ lp_kDim()

int lp_kDim ( const ideal G)

Definition at line 2111 of file hdegree.cc.

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

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

1101{
1102 id_LmTest(S, currRing);
1103 if (Q!=NULL) id_LmTest(Q, currRing);
1104
1105 int i;
1106 int k = ak;
1107 #ifdef HAVE_RINGS
1108 if (rField_is_Ring(currRing) && (currRing->OrdSgn == -1))
1109 {
1110 //consider just monic generators (over rings with zero-divisors)
1112 for(i=0;i<=idElem(S);i++)
1113 {
1114 if((SS->m[i]!=NULL)
1115 && ((p_IsPurePower(SS->m[i],currRing)==0)
1116 ||(!n_IsUnit(pGetCoeff(SS->m[i]), currRing->cf))))
1117 {
1118 p_Delete(&SS->m[i],currRing);
1119 }
1120 }
1121 S=id_Copy(SS,currRing);
1122 idSkipZeroes(S);
1123 }
1124 #if 0
1125 printf("\nThis is HC:\n");
1126 for(int ii=0;ii<=idElem(S);ii++)
1127 {
1128 pWrite(S->m[ii]);
1129 }
1130 //getchar();
1131 #endif
1132 #endif
1133 if(idElem(S) == 0)
1134 return;
1135 hNvar = (currRing->N);
1136 hexist = hInit(S, Q, &hNexist);
1137 if (k!=0)
1139 else
1140 hNstc = hNexist;
1141 assume(hNexist > 0);
1142 hwork = (scfmon)omAlloc(hNexist * sizeof(scmon));
1143 hvar = (varset)omAlloc((hNvar + 1) * sizeof(int));
1144 hpure = (scmon)omAlloc((1 + (hNvar * hNvar)) * sizeof(int));
1145 stcmem = hCreate(hNvar - 1);
1146 for (i = hNvar; i>0; i--)
1147 hvar[i] = i;
1149 if ((hNvar > 2) && (hNstc > 10))
1151 memset(hpure, 0, (hNvar + 1) * sizeof(int));
1152 hPure(hexist, 0, &hNstc, hvar, hNvar, hpure, &hNpure);
1154 if (hEdge!=NULL)
1155 pLmFree(hEdge);
1156 hEdge = pInit();
1157 pWork = pInit();
1159 pSetComp(hEdge,ak);
1160 hKill(stcmem, hNvar - 1);
1161 omFreeSize((ADDRESS)hwork, hNexist * sizeof(scmon));
1162 omFreeSize((ADDRESS)hvar, (hNvar + 1) * sizeof(int));
1163 omFreeSize((ADDRESS)hpure, (1 + (hNvar * hNvar)) * sizeof(int));
1165 pLmFree(pWork);
1166}
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:512
static void hHedgeStep(scmon pure, scfmon stc, int Nstc, varset var, int Nvar, poly hEdge)
Definition hdegree.cc:1040
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
#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)
#define omAlloc(size)
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:901
#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
static int idElem(const ideal F)
number of non-zero polys in F
#define id_LmTest(A, lR)
#define Q
Definition sirandom.c:26

◆ 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;
934 if (errorreported) return;
935 l = hseries1->length()-1;
936 if (l > 1)
938 else
941 if ((l == 1) &&(mu == 0))
942 scPrintDegree((currRing->N)+1, 0);
943 else
945 if (l>1)
946 delete hseries1;
947 delete hseries2;
948}
int length() const
void scPrintDegree(int co, int mu)
Definition hdegree.cc:912
intvec * hSecondSeries(intvec *hseries1)
Definition hilb.cc:706
intvec * hFirstSeries(ideal A, intvec *module_w, ideal Q, intvec *wdegree)
Definition hilb.cc:2167
void hDegreeSeries(intvec *s1, intvec *s2, int *co, int *mu)
Definition hilb.cc:741
static matrix mu(matrix A, const ring R)
Definition matpol.cc:2025

◆ 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);
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}
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 }
149 int d;
150 if(i == -1)
151 {
152 d = scDimInt(vv, Q);
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);
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 }
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:750
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:509

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

◆ scKBase()

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

Definition at line 1448 of file hdegree.cc.

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

◆ scMult0Int()

long scMult0Int ( ideal s,
ideal Q = NULL )

Definition at line 950 of file hdegree.cc.

951{
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;
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 {
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}