2081{
2083 WerrorS(
"K-Dim not implemented for rings");
2084 return -2;
2085 }
2086
2088 {
2089 if (_G->m[
i] !=
NULL)
2090 {
2092 {
2093 WerrorS(
"K-Dim not implemented for modules");
2094 return -2;
2095 }
2097 {
2098 WerrorS(
"K-Dim not implemented for bi-modules");
2099 return -2;
2100 }
2101 }
2102 }
2103
2111
2112
2114 {
2115
2117 int ncGenCount =
currRing->LPncGenCount;
2118 if (lV - ncGenCount == 0)
2119 {
2121 return 1;
2122 }
2123 if (lV - ncGenCount == 1)
2124 {
2126 return -1;
2127 }
2128 if (lV - ncGenCount >= 2)
2129 {
2131 return -1;
2132 }
2133 }
2134
2135
2136 long maxDeg = 0;
2138 {
2140
2141
2143 {
2144 WerrorS(
"K-Dim not defined for 0-ring");
2146 return -2;
2147 }
2148 }
2150 Print(
"max deg: %ld\n", maxDeg);
2151
2152
2153
2154
2156 PrintS(
"Computing normal words normally...\n");
2158
2160 Print(
"%ld normal words up to length %ld\n", numberOfNormalWords, maxDeg - 1);
2161
2162
2163 if (maxDeg <= 1)
2164 {
2166 int ncGenCount =
currRing->LPncGenCount;
2168 {
2170 return numberOfNormalWords;
2171 }
2172 if (
IDELEMS(
G) == lV - ncGenCount - 1)
2173 {
2175 return -1;
2176 }
2177 if (
IDELEMS(
G) <= lV - ncGenCount - 2)
2178 {
2180 return -1;
2181 }
2182 }
2183
2185 PrintS(
"Computing Ufnarovski graph...\n");
2186
2187 ideal standardWords;
2190 {
2192 return -2;
2193 }
2195 {
2196 delete UG;
2198 return -2;
2199 }
2200
2202 Print(
"Ufnarovski graph is %dx%d.\n", UG->
rows(), UG->
cols());
2203
2205 PrintS(
"Checking whether Ufnarovski graph is acyclic...\n");
2206
2208 {
2209
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 {
2217 {
2221 }
2222 }
2224 Print(
"Simplified Ufnarovski graph to %dx%d.\n", (
int)vvUG.size(), (
int)vvUG.size());
2225
2226
2227
2229 PrintS(
"Computing normal words via Ufnarovski graph...\n");
2230 std::vector<std::vector<int> > UGpower = vvUG;
2231 long nUGpower = 1;
2233 {
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
2245 {
2246 PrintS(
"Done count graph entries.\n");
2247 Print(
"%ld normal words up to length %ld\n", numberOfNormalWords, maxDeg - 1 + nUGpower);
2248 }
2249
2251 PrintS(
"Start mat mult.\n");
2252 UGpower =
vvMult(UGpower, vvUG);
2254 PrintS(
"Done mat mult.\n");
2255 nUGpower++;
2256 }
2257
2258 delete UG;
2260 return numberOfNormalWords;
2261}
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)