My Project
Loading...
Searching...
No Matches
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 1827 of file hdegree.cc.

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

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

◆ lp_ufnarovskiGraph()

intvec * lp_ufnarovskiGraph ( ideal G,
ideal & standardWords )

Definition at line 1766 of file hdegree.cc.

1767{
1768 long l = 0;
1769 for (int i = 0; i < IDELEMS(G); i++)
1770 l = si_max(pTotaldegree(G->m[i]), l);
1771 l--;
1772 if (l <= 0)
1773 {
1774 WerrorS("Ufnarovski graph not implemented for l <= 0");
1775 return NULL;
1776 }
1777 int lV = currRing->isLPring;
1778
1779 standardWords = lp_computeNormalWords(l, G);
1780
1781 int n = IDELEMS(standardWords);
1782 intvec* UG = new intvec(n, n, 0);
1783 for (int i = 0; i < n; i++)
1784 {
1785 for (int j = 0; j < n; j++)
1786 {
1787 poly v = standardWords->m[i];
1788 poly w = standardWords->m[j];
1789
1790 // check whether v*x1 = x2*w (overlap)
1791 bool overlap = true;
1792 for (int k = 1; k <= (l - 1) * lV; k++)
1793 {
1794 if (pGetExp(v, k + lV) != pGetExp(w, k)) {
1795 overlap = false;
1796 break;
1797 }
1798 }
1799
1800 if (overlap)
1801 {
1802 // create the overlap
1803 poly p = pMult(pCopy(v), p_LPVarAt(w, l, currRing));
1804
1805 // check whether the overlap is normal
1806 bool normal = true;
1807 for (int k = 0; k < IDELEMS(G); k++)
1808 {
1809 if (p_LPDivisibleBy(G->m[k], p, currRing))
1810 {
1811 normal = false;
1812 break;
1813 }
1814 }
1815
1816 if (normal)
1817 {
1818 IMATELEM(*UG, i + 1, j + 1) = 1;
1819 }
1820 }
1821 }
1822 }
1823 return UG;
1824}
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:1725
#define IMATELEM(M, I, J)
Definition intvec.h:86
#define pMult(p, q)
Definition polys.h:208
#define pGetExp(p, i)
Exponent.
Definition polys.h:42
#define pCopy(p)
return a copy of the poly
Definition polys.h:186
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 1074 of file hdegree.cc.

1075{
1076 if(idElem(S) == 0)
1077 return;
1078 id_LmTest(S, currRing);
1079 if (Q!=NULL) id_LmTest(Q, currRing);
1080
1081 int i;
1082 int k = ak;
1083 ideal SS=id_Head(S,currRing);
1084 if (rField_is_Ring(currRing) && (currRing->OrdSgn == -1))
1085 {
1086 //consider just monic generators (over rings with zero-divisors)
1087 for(i=0;i<=idElem(S);i++)
1088 {
1089 if((SS->m[i]!=NULL)
1090 && ((p_IsPurePower(SS->m[i],currRing)==0)
1091 ||(!n_IsUnit(pGetCoeff(SS->m[i]), currRing->cf))))
1092 {
1093 p_Delete(&SS->m[i],currRing);
1094 }
1095 }
1096 }
1097 S=SS;
1098 idSkipZeroes(S);
1099 hNvar = (currRing->N);
1100 hexist = hInit(S, Q, &hNexist);
1101 if (hNexist==0) return;
1102 if (k!=0)
1104 else
1105 hNstc = hNexist;
1106 assume(hNexist > 0);
1107 hwork = (scfmon)omAlloc(hNexist * sizeof(scmon));
1108 hvar = (varset)omAlloc((hNvar + 1) * sizeof(int));
1109 hpure = (scmon)omAlloc((1 + (hNvar * hNvar)) * sizeof(int));
1110 stcmem = hCreate(hNvar - 1);
1111 for (i = hNvar; i>0; i--)
1112 hvar[i] = i;
1114 if ((hNvar > 2) && (hNstc > 10))
1116 memset(hpure, 0, (hNvar + 1) * sizeof(int));
1117 hPure(hexist, 0, &hNstc, hvar, hNvar, hpure, &hNpure);
1119 if (hEdge!=NULL)
1120 pLmFree(hEdge);
1121 hEdge = pInit();
1122 pWork = pInit();
1124 pSetComp(hEdge,ak);
1125 hKill(stcmem, hNvar - 1);
1126 omFreeSize((ADDRESS)hwork, hNexist * sizeof(scmon));
1127 omFreeSize((ADDRESS)hvar, (hNvar + 1) * sizeof(int));
1128 omFreeSize((ADDRESS)hpure, (1 + (hNvar * hNvar)) * sizeof(int));
1130 pLmFree(pWork);
1131 idDelete(&S);
1132}
void * ADDRESS
Definition auxiliary.h:120
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:521
static void hHedgeStep(scmon pure, scfmon stc, int Nstc, varset var, int Nvar, poly hEdge)
Definition hdegree.cc:1014
STATIC_VAR poly pWork
Definition hdegree.cc:1001
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
#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:1227
static void p_Delete(poly *p, const ring r)
Definition p_polys.h:903
#define pSetComp(p, v)
Definition polys.h:39
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:71
#define pInit()
allocates a new monomial and initializes everything to 0
Definition polys.h:62
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 2055 of file hilb.cc.

2056{
2057 int co;
2058 int mu=0;
2059#if 0
2060 if (hilb_Qt==NULL) hilb_Qt=makeQt();
2061 poly h1;
2062 if (id_IsModule(S,currRing))
2064 else
2065 h1 = hFirstSeries0m(S,Q,NULL, modulweight,currRing,hilb_Qt);
2066
2067 poly h2=hFirst2Second(h1,hilb_Qt,co);
2068 int di = (currRing->N)-co;
2069 if (h1==NULL) di=0;
2070 poly p=h2;
2071 while(p!=NULL)
2072 {
2073 mu+=n_Int(pGetCoeff(p),hilb_Qt->cf);
2075 }
2076#else
2078 intvec *hseries1=new intvec(1,h1->cols());
2079 for(int i=0;i<h1->cols();i++)
2080 {
2081 (*hseries1)[i]=n_Int(BIMATELEM(*h1,1,i+1),coeffs_BIGINT);
2082 }
2083 delete h1;
2084 intvec *hseries2;
2085 int l = hseries1->length()-1;
2086 if (l > 1)
2087 hseries2 = hSecondSeries(hseries1);
2088 else
2089 hseries2 = hseries1;
2090 hDegreeSeries(hseries1, hseries2, &co, &mu);
2091 if (l>1)
2092 delete hseries1;
2093 delete hseries2;
2094 if ((l == 1) &&(mu == 0))
2095 scPrintDegree((currRing->N)+1, 0);
2096 else
2097#endif
2098 scPrintDegree(co, mu);
2099}
#define BIMATELEM(M, I, J)
Definition bigintmat.h:133
Matrices of numbers.
Definition bigintmat.h:51
int cols() const
Definition bigintmat.h:144
int length() const
Definition intvec.h:95
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:550
void scPrintDegree(int co, int mu)
Definition hdegree.cc:910
poly hFirstSeries0m(ideal A, ideal Q, intvec *wdegree, intvec *shifts, const ring src, const ring Qt)
Definition hilb.cc:1425
poly hFirstSeries0p(ideal A, ideal Q, intvec *wdegree, const ring src, const ring Qt)
Definition hilb.cc:1384
intvec * hSecondSeries(intvec *hseries1)
Definition hilb.cc:71
static ring makeQt()
Definition hilb.cc:196
poly hFirst2Second(poly h, const ring Qt, int &co)
Definition hilb.cc:124
bigintmat * hFirstSeries0b(ideal I, ideal Q, intvec *wdegree, intvec *shifts, const ring src, const coeffs biv_cf)
Definition hilb.cc:2017
void hDegreeSeries(intvec *s1, intvec *s2, int *co, int *mu)
Definition hilb.cc:106
STATIC_VAR ring hilb_Qt
Definition hilb.cc:219
static matrix mu(matrix A, const ring R)
Definition matpol.cc:2028
static void p_LmDelete(poly p, const ring r)
Definition p_polys.h:725
VAR coeffs coeffs_BIGINT
Definition polys.cc:14
BOOLEAN id_IsModule(ideal A, const ring src)

◆ 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:71

◆ scDimIntRing()

int scDimIntRing ( ideal s,
ideal Q = NULL )

scDimInt for ring-coefficients

Definition at line 136 of file hdegree.cc.

137{
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 return scDimInt(vid,Q);
200}
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:747
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:187
static BOOLEAN rField_is_Z(const ring r)
Definition ring.h:520

◆ scIndIntvec()

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

Definition at line 284 of file hdegree.cc.

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

◆ scKBase()

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

Definition at line 1414 of file hdegree.cc.

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

925{
927 if (Q!=NULL) id_LmTest(Q, currRing);
928
929 int mc;
930 hexist = hInit(S, Q, &hNexist);
931 if (!hNexist)
932 {
933 hMu = -1;
934 return -1;
935 }
936 else
937 hMu = 0;
938
939 const ring r = currRing;
940
941 hwork = (scfmon)omAlloc(hNexist * sizeof(scmon));
942 hvar = (varset)omAlloc(((r->N) + 1) * sizeof(int));
943 hpur0 = (scmon)omAlloc((1 + ((r->N) * (r->N))) * sizeof(int));
944 mc = hisModule;
945 if (!mc)
946 {
947 hstc = hexist;
948 hNstc = hNexist;
949 }
950 else
951 hstc = (scfmon)omAlloc(hNexist * sizeof(scmon));
952 stcmem = hCreate((r->N) - 1);
953 loop
954 {
955 if (mc)
956 {
957 hComp(hexist, hNexist, mc, hstc, &hNstc);
958 if (!hNstc)
959 {
960 hMu = -1;
961 break;
962 }
963 }
964 hNvar = (r->N);
965 for (int i = hNvar; i; i--)
966 hvar[i] = i;
969 if ((hNvar == (r->N)) && (hNstc >= (r->N)))
970 {
971 if ((hNvar > 2) && (hNstc > 10))
973 memset(hpur0, 0, ((r->N) + 1) * sizeof(int));
974 hPure(hstc, 0, &hNstc, hvar, hNvar, hpur0, &hNpure);
975 if (hNpure == hNvar)
976 {
979 }
980 else
981 hMu = -1;
982 }
983 else if (hNvar)
984 hMu = -1;
985 mc--;
986 if (mc <= 0 || hMu < 0)
987 break;
988 }
989 hKill(stcmem, (r->N) - 1);
990 omFreeSize((ADDRESS)hpur0, (1 + ((r->N) * (r->N))) * sizeof(int));
991 omFreeSize((ADDRESS)hvar, ((r->N) + 1) * sizeof(int));
992 omFreeSize((ADDRESS)hwork, hNexist * sizeof(scmon));
994 if (hisModule)
995 omFreeSize((ADDRESS)hstc, hNexist * sizeof(scmon));
996 return hMu;
997}
static long hZeroMult(scmon pure, scfmon stc, int Nstc, varset var, int Nvar)
Definition hdegree.cc:619
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 901 of file hdegree.cc.

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

◆ scPrintDegree()

void scPrintDegree ( int co,
int mu )

Definition at line 910 of file hdegree.cc.

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