2088{
2090 WerrorS(
"K-Dim not implemented for rings");
2091 return -2;
2092 }
2093
2095 {
2096 if (_G->m[
i] !=
NULL)
2097 {
2099 {
2100 WerrorS(
"K-Dim not implemented for modules");
2101 return -2;
2102 }
2104 {
2105 WerrorS(
"K-Dim not implemented for bi-modules");
2106 return -2;
2107 }
2108 }
2109 }
2110
2118
2119
2121 {
2122
2124 int ncGenCount =
currRing->LPncGenCount;
2125 if (lV - ncGenCount == 0)
2126 {
2128 return 1;
2129 }
2130 if (lV - ncGenCount == 1)
2131 {
2133 return -1;
2134 }
2135 if (lV - ncGenCount >= 2)
2136 {
2138 return -1;
2139 }
2140 }
2141
2142
2143 long maxDeg = 0;
2145 {
2147
2148
2150 {
2151 WerrorS(
"K-Dim not defined for 0-ring");
2153 return -2;
2154 }
2155 }
2157 Print(
"max deg: %ld\n", maxDeg);
2158
2159
2160
2161
2163 PrintS(
"Computing normal words normally...\n");
2165
2167 Print(
"%ld normal words up to length %ld\n", numberOfNormalWords, maxDeg - 1);
2168
2169
2170 if (maxDeg <= 1)
2171 {
2173 int ncGenCount =
currRing->LPncGenCount;
2175 {
2177 return numberOfNormalWords;
2178 }
2179 if (
IDELEMS(
G) == lV - ncGenCount - 1)
2180 {
2182 return -1;
2183 }
2184 if (
IDELEMS(
G) <= lV - ncGenCount - 2)
2185 {
2187 return -1;
2188 }
2189 }
2190
2192 PrintS(
"Computing Ufnarovski graph...\n");
2193
2194 ideal standardWords;
2197 {
2199 return -2;
2200 }
2202 {
2203 delete UG;
2205 return -2;
2206 }
2207
2209 Print(
"Ufnarovski graph is %dx%d.\n", UG->
rows(), UG->
cols());
2210
2212 PrintS(
"Checking whether Ufnarovski graph is acyclic...\n");
2213
2215 {
2216
2217 return -1;
2218 }
2219
2220 std::vector<std::vector<int> > vvUG =
iv2vv(UG);
2221 for (std::vector<std::vector<int> >::size_type
i = 0;
i < vvUG.size();
i++)
2222 {
2224 {
2228 }
2229 }
2231 Print(
"Simplified Ufnarovski graph to %dx%d.\n", (
int)vvUG.size(), (
int)vvUG.size());
2232
2233
2234
2236 PrintS(
"Computing normal words via Ufnarovski graph...\n");
2237 std::vector<std::vector<int> > UGpower = vvUG;
2238 long nUGpower = 1;
2240 {
2242 PrintS(
"Start count graph entries.\n");
2243 for (std::vector<std::vector<int> >::size_type
i = 0;
i < UGpower.size();
i++)
2244 {
2245 for (std::vector<std::vector<int> >::size_type
j = 0;
j < UGpower[
i].size();
j++)
2246 {
2247 numberOfNormalWords += UGpower[
i][
j];
2248 }
2249 }
2250
2252 {
2253 PrintS(
"Done count graph entries.\n");
2254 Print(
"%ld normal words up to length %ld\n", numberOfNormalWords, maxDeg - 1 + nUGpower);
2255 }
2256
2258 PrintS(
"Start mat mult.\n");
2259 UGpower =
vvMult(UGpower, vvUG);
2261 PrintS(
"Done mat mult.\n");
2262 nUGpower++;
2263 }
2264
2265 delete UG;
2267 return numberOfNormalWords;
2268}
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)