2082{
2084 WerrorS(
"K-Dim not implemented for rings");
2085 return -2;
2086 }
2087
2089 {
2090 if (_G->m[
i] !=
NULL)
2091 {
2093 {
2094 WerrorS(
"K-Dim not implemented for modules");
2095 return -2;
2096 }
2098 {
2099 WerrorS(
"K-Dim not implemented for bi-modules");
2100 return -2;
2101 }
2102 }
2103 }
2104
2112
2113
2115 {
2116
2118 int ncGenCount =
currRing->LPncGenCount;
2119 if (lV - ncGenCount == 0)
2120 {
2122 return 1;
2123 }
2124 if (lV - ncGenCount == 1)
2125 {
2127 return -1;
2128 }
2129 if (lV - ncGenCount >= 2)
2130 {
2132 return -1;
2133 }
2134 }
2135
2136
2137 long maxDeg = 0;
2139 {
2141
2142
2144 {
2145 WerrorS(
"K-Dim not defined for 0-ring");
2147 return -2;
2148 }
2149 }
2151 Print(
"max deg: %ld\n", maxDeg);
2152
2153
2154
2155
2157 PrintS(
"Computing normal words normally...\n");
2159
2161 Print(
"%ld normal words up to length %ld\n", numberOfNormalWords, maxDeg - 1);
2162
2163
2164 if (maxDeg <= 1)
2165 {
2167 int ncGenCount =
currRing->LPncGenCount;
2169 {
2171 return numberOfNormalWords;
2172 }
2173 if (
IDELEMS(
G) == lV - ncGenCount - 1)
2174 {
2176 return -1;
2177 }
2178 if (
IDELEMS(
G) <= lV - ncGenCount - 2)
2179 {
2181 return -1;
2182 }
2183 }
2184
2186 PrintS(
"Computing Ufnarovski graph...\n");
2187
2188 ideal standardWords;
2191 {
2193 return -2;
2194 }
2196 {
2197 delete UG;
2199 return -2;
2200 }
2201
2203 Print(
"Ufnarovski graph is %dx%d.\n", UG->
rows(), UG->
cols());
2204
2206 PrintS(
"Checking whether Ufnarovski graph is acyclic...\n");
2207
2209 {
2210
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 {
2218 {
2222 }
2223 }
2225 Print(
"Simplified Ufnarovski graph to %dx%d.\n", (
int)vvUG.size(), (
int)vvUG.size());
2226
2227
2228
2230 PrintS(
"Computing normal words via Ufnarovski graph...\n");
2231 std::vector<std::vector<int> > UGpower = vvUG;
2232 long nUGpower = 1;
2234 {
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
2246 {
2247 PrintS(
"Done count graph entries.\n");
2248 Print(
"%ld normal words up to length %ld\n", numberOfNormalWords, maxDeg - 1 + nUGpower);
2249 }
2250
2252 PrintS(
"Start mat mult.\n");
2253 UGpower =
vvMult(UGpower, vvUG);
2255 PrintS(
"Done mat mult.\n");
2256 nUGpower++;
2257 }
2258
2259 delete UG;
2261 return numberOfNormalWords;
2262}
static std::vector< std::vector< int > > vvMult(const std::vector< std::vector< int > > &a, const std::vector< std::vector< int > > &b)
static void vvDeleteRow(std::vector< std::vector< int > > &mat, int row)
static BOOLEAN vvIsColumnZero(const std::vector< std::vector< int > > &mat, int col)
static void vvDeleteColumn(std::vector< std::vector< int > > &mat, int col)
static std::vector< std::vector< int > > iv2vv(intvec *M)
static int lp_countNormalWords(int upToLength, ideal M)
static BOOLEAN isAcyclic(const intvec *G)
static BOOLEAN vvIsZero(const std::vector< std::vector< int > > &mat)
static BOOLEAN vvIsRowZero(const std::vector< std::vector< int > > &mat, int row)
void PrintS(const char *s)