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

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

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

◆ lp_ufnarovskiGraph()

intvec * lp_ufnarovskiGraph ( ideal G,
ideal & standardWords )

Definition at line 1765 of file hdegree.cc.

1766{
1767 long l = 0;
1768 for (int i = 0; i < IDELEMS(G); i++)
1769 l = si_max(pTotaldegree(G->m[i]), l);
1770 l--;
1771 if (l <= 0)
1772 {
1773 WerrorS("Ufnarovski graph not implemented for l <= 0");
1774 return NULL;
1775 }
1776 int lV = currRing->isLPring;
1777
1778 standardWords = lp_computeNormalWords(l, G);
1779
1780 int n = IDELEMS(standardWords);
1781 intvec* UG = new intvec(n, n, 0);
1782 for (int i = 0; i < n; i++)
1783 {
1784 for (int j = 0; j < n; j++)
1785 {
1786 poly v = standardWords->m[i];
1787 poly w = standardWords->m[j];
1788
1789 // check whether v*x1 = x2*w (overlap)
1790 bool overlap = true;
1791 for (int k = 1; k <= (l - 1) * lV; k++)
1792 {
1793 if (pGetExp(v, k + lV) != pGetExp(w, k)) {
1794 overlap = false;
1795 break;
1796 }
1797 }
1798
1799 if (overlap)
1800 {
1801 // create the overlap
1802 poly p = pMult(pCopy(v), p_LPVarAt(w, l, currRing));
1803
1804 // check whether the overlap is normal
1805 bool normal = true;
1806 for (int k = 0; k < IDELEMS(G); k++)
1807 {
1808 if (p_LPDivisibleBy(G->m[k], p, currRing))
1809 {
1810 normal = false;
1811 break;
1812 }
1813 }
1814
1815 if (normal)
1816 {
1817 IMATELEM(*UG, i + 1, j + 1) = 1;
1818 }
1819 }
1820 }
1821 }
1822 return UG;
1823}
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:1724
#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 if (rField_is_Ring(currRing) && (currRing->OrdSgn == -1))
1084 {
1085 //consider just monic generators (over rings with zero-divisors)
1086 ideal SS=id_Head(S,currRing);
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 S=id_Copy(SS,currRing);
1097 idSkipZeroes(S);
1098 }
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}
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:519
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
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: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 2693 of file hilb.cc.

2694{
2695 int co;
2696 int mu=0;
2697#if 0
2698 if (hilb_Qt==NULL) hilb_Qt=makeQt();
2699 poly h1;
2700 if (id_IsModule(S,currRing))
2702 else
2703 h1 = hFirstSeries0m(S,Q,NULL, modulweight,currRing,hilb_Qt);
2704
2705 poly h2=hFirst2Second(h1,hilb_Qt,co);
2706 int di = (currRing->N)-co;
2707 if (h1==NULL) di=0;
2708 poly p=h2;
2709 while(p!=NULL)
2710 {
2711 mu+=n_Int(pGetCoeff(p),hilb_Qt->cf);
2713 }
2714#else
2716 intvec *hseries1=new intvec(1,h1->cols());
2717 for(int i=0;i<h1->cols();i++)
2718 {
2719 (*hseries1)[i]=n_Int(BIMATELEM(*h1,1,i+1),coeffs_BIGINT);
2720 }
2721 delete h1;
2722 intvec *hseries2;
2723 int l = hseries1->length()-1;
2724 if (l > 1)
2725 hseries2 = hSecondSeries(hseries1);
2726 else
2727 hseries2 = hseries1;
2728 hDegreeSeries(hseries1, hseries2, &co, &mu);
2729 if (l>1)
2730 delete hseries1;
2731 delete hseries2;
2732 if ((l == 1) &&(mu == 0))
2733 scPrintDegree((currRing->N)+1, 0);
2734 else
2735#endif
2736 scPrintDegree(co, mu);
2737}
#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:548
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:2063
poly hFirstSeries0p(ideal A, ideal Q, intvec *wdegree, const ring src, const ring Qt)
Definition hilb.cc:2020
intvec * hSecondSeries(intvec *hseries1)
Definition hilb.cc:707
static ring makeQt()
Definition hilb.cc:832
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:2655
void hDegreeSeries(intvec *s1, intvec *s2, int *co, int *mu)
Definition hilb.cc:742
STATIC_VAR ring hilb_Qt
Definition hilb.cc:855
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:748
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:515

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

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