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

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

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

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

1077{
1078 id_LmTest(S, currRing);
1079 if (Q!=NULL) id_LmTest(Q, currRing);
1080
1081 int i;
1082 int k = ak;
1083 #ifdef HAVE_RINGS
1084 if (rField_is_Ring(currRing) && (currRing->OrdSgn == -1))
1085 {
1086 //consider just monic generators (over rings with zero-divisors)
1088 for(i=0;i<=idElem(S);i++)
1089 {
1090 if((SS->m[i]!=NULL)
1091 && ((p_IsPurePower(SS->m[i],currRing)==0)
1092 ||(!n_IsUnit(pGetCoeff(SS->m[i]), currRing->cf))))
1093 {
1094 p_Delete(&SS->m[i],currRing);
1095 }
1096 }
1097 S=id_Copy(SS,currRing);
1098 idSkipZeroes(S);
1099 }
1100 #if 0
1101 printf("\nThis is HC:\n");
1102 for(int ii=0;ii<=idElem(S);ii++)
1103 {
1104 pWrite(S->m[ii]);
1105 }
1106 //getchar();
1107 #endif
1108 #endif
1109 if(idElem(S) == 0)
1110 return;
1111 hNvar = (currRing->N);
1112 hexist = hInit(S, Q, &hNexist);
1113 if (k!=0)
1115 else
1116 hNstc = hNexist;
1117 assume(hNexist > 0);
1118 hwork = (scfmon)omAlloc(hNexist * sizeof(scmon));
1119 hvar = (varset)omAlloc((hNvar + 1) * sizeof(int));
1120 hpure = (scmon)omAlloc((1 + (hNvar * hNvar)) * sizeof(int));
1121 stcmem = hCreate(hNvar - 1);
1122 for (i = hNvar; i>0; i--)
1123 hvar[i] = i;
1125 if ((hNvar > 2) && (hNstc > 10))
1127 memset(hpure, 0, (hNvar + 1) * sizeof(int));
1128 hPure(hexist, 0, &hNstc, hvar, hNvar, hpure, &hNpure);
1130 if (hEdge!=NULL)
1131 pLmFree(hEdge);
1132 hEdge = pInit();
1133 pWork = pInit();
1135 pSetComp(hEdge,ak);
1136 hKill(stcmem, hNvar - 1);
1137 omFreeSize((ADDRESS)hwork, hNexist * sizeof(scmon));
1138 omFreeSize((ADDRESS)hvar, (hNvar + 1) * sizeof(int));
1139 omFreeSize((ADDRESS)hpure, (1 + (hNvar * hNvar)) * sizeof(int));
1141 pLmFree(pWork);
1142}
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:519
static void hHedgeStep(scmon pure, scfmon stc, int Nstc, varset var, int Nvar, poly hEdge)
Definition hdegree.cc:1016
STATIC_VAR poly pWork
Definition hdegree.cc:1003
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: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)
#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:1229
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 2710 of file hilb.cc.

2711{
2712 int co;
2713 int mu=0;
2714#if 0
2715 if (hilb_Qt==NULL) hilb_Qt=makeQt();
2716 poly h1;
2717 if (isModule(S,currRing))
2719 else
2721
2723 int di = (currRing->N)-co;
2724 if (h1==NULL) di=0;
2725 poly p=h2;
2726 while(p!=NULL)
2727 {
2728 mu+=n_Int(pGetCoeff(p),hilb_Qt->cf);
2730 }
2731#else
2733 intvec *hseries1=new intvec(1,h1->cols());
2734 for(int i=0;i<h1->cols();i++)
2735 {
2736 (*hseries1)[i]=n_Int(BIMATELEM(*h1,1,i+1),coeffs_BIGINT);
2737 }
2739 int l = hseries1->length()-1;
2740 if (l > 1)
2742 else
2745 if (l>1)
2746 delete hseries1;
2747 delete hseries2;
2748 if ((l == 1) &&(mu == 0))
2749 scPrintDegree((currRing->N)+1, 0);
2750 else
2751#endif
2753}
#define BIMATELEM(M, I, J)
Definition bigintmat.h:133
int length() const
Matrices of numbers.
Definition bigintmat.h:51
static FORCE_INLINE long n_Int(number &n, const coeffs r)
conversion of n to an int; 0 if not possible in Z/pZ: the representing int lying in (-p/2 ....
Definition coeffs.h:551
void scPrintDegree(int co, int mu)
Definition hdegree.cc:912
poly hFirstSeries0m(ideal A, ideal Q, intvec *wdegree, intvec *shifts, const ring src, const ring Qt)
Definition hilb.cc:2080
poly hFirstSeries0p(ideal A, ideal Q, intvec *wdegree, const ring src, const ring Qt)
Definition hilb.cc:2037
intvec * hSecondSeries(intvec *hseries1)
Definition hilb.cc:707
static BOOLEAN isModule(ideal A, const ring src)
Definition hilb.cc:855
static ring makeQt()
Definition hilb.cc:831
poly hFirst2Second(poly h, const ring Qt, int &co)
Definition hilb.cc:760
bigintmat * hFirstSeries0b(ideal I, ideal Q, intvec *wdegree, intvec *shifts, const ring src, const coeffs biv_cf)
Definition hilb.cc:2672
void hDegreeSeries(intvec *s1, intvec *s2, int *co, int *mu)
Definition hilb.cc:742
STATIC_VAR ring hilb_Qt
Definition hilb.cc:854
VAR coeffs coeffs_BIGINT
Definition ipid.cc:50
static matrix mu(matrix A, const ring R)
Definition matpol.cc:2025
static void p_LmDelete(poly p, const ring r)
Definition p_polys.h:723

◆ 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:757
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:514

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

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

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