Changeset b075f5 in git
- Timestamp:
- Sep 8, 2015, 10:28:14 AM (8 years ago)
- Branches:
- (u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
- Children:
- b430ca2b1337f52e1932f689e451e9abb002ec4a
- Parents:
- 53535c6cbef445ffa8464eb62c4971b17a05b3da
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/walk.cc
r53535c rb075f5 16 16 17 17 //#define TEST_OVERFLOW 18 //#define CHECK_IDEAL 19 //#define CHECK_IDEAL_MWALK 18 19 #define CHECK_IDEAL_MWALK //to print intermediate results 20 20 21 21 //#define NEXT_VECTORS_CC 22 //#define PRINT_VECTORS //to print vectors (sigma, tau, omega) 22 #define PRINT_VECTORS //to print weight vectors 23 23 24 24 #define INVEPS_SMALL_IN_FRACTAL //to choose the small invers of epsilon … … 27 27 28 28 #define FIRST_STEP_FRACTAL // to define the first step of the fractal 29 #define MSTDCC_FRACTAL // apply Buchberger alg to compute a red GB, if 30 // tau doesn't stay in the correct cone 29 #define MSTDCC_FRACTAL // apply Buchberger alg to compute a red GB, if tau doesn't stay in the correct cone 31 30 32 31 //#define TIME_TEST // print the used time of each subroutine … … 122 121 ************************************/ 123 122 // unused 124 #if 0 123 /* 125 124 static void initSSpecialCC (ideal F, ideal Q, ideal P,kStrategy strat) 126 125 { … … 270 269 #endif 271 270 } 272 #endif 271 */ 273 272 274 273 /***************** … … 279 278 int j; 280 279 kStrategy strat = new skStrategy; 281 282 // if (TEST_OPT_PROT) 283 // { 284 // writeTime("start InterRed:"); 285 // mflush(); 286 // } 287 //strat->syzComp = 0; 280 /* 281 if (TEST_OPT_PROT) 282 { 283 writeTime("start InterRed:"); 284 mflush(); 285 } 286 strat->syzComp = 0; 287 */ 288 288 strat->kHEdgeFound = (currRing->ppNoether) != NULL; 289 289 strat->kNoether=pCopy((currRing->ppNoether)); … … 348 348 strat->fromQ = NULL; 349 349 } 350 // if (TEST_OPT_PROT) 351 // { 352 // writeTime("end Interred:"); 353 // mflush(); 354 // } 350 /* 351 if (TEST_OPT_PROT) 352 { 353 writeTime("end Interred:"); 354 mflush(); 355 } 356 */ 355 357 ideal shdl=strat->Shdl; 356 358 idSkipZeroes(shdl); … … 360 362 } 361 363 362 //unused 363 #if 0 364 #ifdef TIME_TEST 364 365 static void TimeString(clock_t tinput, clock_t tostd, clock_t tif,clock_t tstd, 365 366 clock_t tlf,clock_t tred, clock_t tnw, int step) … … 399 400 ((((double) xtextra)/1000000)/totm)*100); 400 401 } 401 #endif 402 403 //unused 404 #if 0 402 405 403 static void TimeStringFractal(clock_t tinput, clock_t tostd, clock_t tif,clock_t tstd, 406 404 clock_t textra, clock_t tlf,clock_t tred, clock_t tnw) … … 431 429 #endif 432 430 433 //#ifdef CHECK_IDEAL_MWALK431 #ifdef CHECK_IDEAL_MWALK 434 432 static void idString(ideal L, const char* st) 435 433 { … … 443 441 Print(" %s;", pString(L->m[nL-1])); 444 442 } 445 //#endif446 443 #endif 444 /* 447 445 #if defined(CHECK_IDEAL_MWALK) || defined(ENDWALKS) 448 446 static void headidString(ideal L, char* st) … … 498 496 } 499 497 #endif 500 498 */ 501 499 502 500 static void ivString(intvec* iv, const char* ch) … … 512 510 } 513 511 514 //unused 515 //#if 0 512 #ifdef PRINT_VECTORS 516 513 static void MivString(intvec* iva, intvec* ivb, intvec* ivc) 517 514 { … … 536 533 Print("%d)", (*ivc)[nV]); 537 534 } 538 //#endif535 #endif 539 536 540 537 /******************************************************************** … … 1040 1037 * print the max total degree and the max coefficient of G * 1041 1038 *****************************************************************************/ 1042 #if 0 1039 /* 1043 1040 static void checkComplexity(ideal G, char* cG) 1044 1041 { … … 1081 1078 PrintLn(); 1082 1079 } 1083 #endif 1080 */ 1084 1081 1085 1082 /***************************************************************************** … … 1103 1100 intvec* v_null = new intvec(nV); 1104 1101 1105 1106 1102 // Check that the perturbed degree is valid 1107 1103 if(pdeg > nV || pdeg <= 0) … … 1117 1113 } 1118 1114 mpz_t *pert_vector = (mpz_t*)omAlloc(nV*sizeof(mpz_t)); 1119 //mpz_t *pert_vector1 = (mpz_t*)omAlloc(nV*sizeof(mpz_t));1115 mpz_t *pert_vector1 = (mpz_t*)omAlloc(nV*sizeof(mpz_t)); 1120 1116 1121 1117 for(i=0; i<nV; i++) 1122 1118 { 1123 1119 mpz_init_set_si(pert_vector[i], (*ivtarget)[i]); 1124 //mpz_init_set_si(pert_vector1[i], (*ivtarget)[i]);1120 mpz_init_set_si(pert_vector1[i], (*ivtarget)[i]); 1125 1121 } 1126 1122 // Calculate max1 = Max(A2)+Max(A3)+...+Max(Apdeg), … … 1202 1198 } 1203 1199 } 1200 1201 // 2147483647 is max. integer representation in SINGULAR 1202 mpz_t sing_int; 1203 mpz_init_set_ui(sing_int, 2147483647); 1204 1205 mpz_t check_int; 1206 mpz_init_set_ui(check_int, 100000); 1207 1204 1208 mpz_t ztemp; 1205 1209 mpz_init(ztemp); … … 1221 1225 } 1222 1226 1223 intvec *pert_vector1= new intvec(nV);1224 j = 0;1225 1227 for(i=0; i<nV; i++) 1226 1228 { 1227 (* pert_vector1)[i] = mpz_get_si(pert_vector[i]); 1228 (* pert_vector1)[i] = 0.1*(* pert_vector1)[i]; 1229 (* pert_vector1)[i] = floor((* pert_vector1)[i] + 0.5); 1230 if((* pert_vector1)[i] == 0) 1231 { 1232 j++; 1233 } 1234 } 1235 if(j > nV - 1) 1236 { 1237 // Print("\n// MPertVectors: geaenderter vector gleich Null! \n"); 1238 delete pert_vector1; 1239 goto CHECK_OVERFLOW; 1240 } 1241 1242 // check that the perturbed weight vector lies in the Groebner cone 1243 if(test_w_in_ConeCC(G,pert_vector1) != 0) 1244 { 1245 // Print("\n// MPertVectors: geaenderter vector liegt in Groebnerkegel! \n"); 1229 if(mpz_cmp(pert_vector[i], check_int)>=0) 1230 { 1231 for(j=0; j<nV; j++) 1232 { 1233 mpz_fdiv_q_ui(pert_vector1[j], pert_vector[j], 100); 1234 } 1235 } 1236 } 1237 1238 intvec* result = new intvec(nV); 1239 1240 int ntrue=0; 1241 1242 for(i=0; i<nV; i++) 1243 { 1244 (*result)[i] = mpz_get_si(pert_vector1[i]); 1245 if(mpz_cmp(pert_vector1[i], sing_int)>=0) 1246 { 1247 ntrue++; 1248 } 1249 } 1250 if(ntrue > 0 || test_w_in_ConeCC(G,result)==0) 1251 { 1252 ntrue=0; 1246 1253 for(i=0; i<nV; i++) 1247 1254 { 1248 mpz_set_si(pert_vector[i], (*pert_vector1)[i]); 1249 } 1250 } 1251 else 1252 { 1253 //Print("\n// MpertVectors: geaenderter vector liegt nicht in Groebnerkegel! \n"); 1254 } 1255 delete pert_vector1; 1256 1257 CHECK_OVERFLOW: 1258 intvec* result = new intvec(nV); 1259 1260 /* 2147483647 is max. integer representation in SINGULAR */ 1261 mpz_t sing_int; 1262 mpz_init_set_ui(sing_int, 2147483647); 1263 1264 int ntrue=0; 1265 for(i=0; i<nV; i++) 1266 { 1267 (*result)[i] = mpz_get_si(pert_vector[i]); 1268 if(mpz_cmp(pert_vector[i], sing_int)>=0) 1269 { 1270 ntrue++; 1271 if(Overflow_Error == FALSE) 1272 { 1273 Overflow_Error = TRUE; 1274 PrintS("\n// ** OVERFLOW in \"MPertvectors\": "); 1275 mpz_out_str( stdout, 10, pert_vector[i]); 1276 PrintS(" is greater than 2147483647 (max. integer representation)"); 1277 Print("\n// So vector[%d] := %d is wrong!!", i+1, (*result)[i]); 1278 } 1279 } 1280 } 1281 1282 if(Overflow_Error == TRUE) 1283 { 1284 ivString(result, "pert_vector"); 1285 Print("\n// %d element(s) of it is overflow!!", ntrue); 1255 (*result)[i] = mpz_get_si(pert_vector[i]); 1256 if(mpz_cmp(pert_vector[i], sing_int)>=0) 1257 { 1258 ntrue++; 1259 if(Overflow_Error == FALSE) 1260 { 1261 Overflow_Error = TRUE; 1262 PrintS("\n// ** OVERFLOW in \"MPertvectors\": "); 1263 mpz_out_str( stdout, 10, pert_vector[i]); 1264 PrintS(" is greater than 2147483647 (max. integer representation)"); 1265 Print("\n// So vector[%d] := %d is wrong!!", i+1, (*result)[i]); 1266 } 1267 } 1268 } 1269 1270 if(Overflow_Error == TRUE) 1271 { 1272 ivString(result, "pert_vector"); 1273 Print("\n// %d element(s) of it is overflow!!", ntrue); 1274 } 1286 1275 } 1287 1276 1288 1277 mpz_clear(ztemp); 1289 1278 mpz_clear(sing_int); 1279 mpz_clear(check_int); 1290 1280 omFree(pert_vector); 1291 //omFree(pert_vector1);1281 omFree(pert_vector1); 1292 1282 mpz_clear(tot_deg); 1293 1283 mpz_clear(maxdeg); … … 1491 1481 1492 1482 //unused 1493 #if 0 1483 /* 1494 1484 static intvec* MatrixOrderdp(int nV) 1495 1485 { … … 1507 1497 return(ivM); 1508 1498 } 1509 #endif 1499 */ 1510 1500 1511 1501 intvec* MivUnit(int nV) … … 1584 1574 mpz_cdiv_q_ui(inveps, inveps, nV); 1585 1575 } 1586 // PrintS("\n// choose the \"small\" inverse epsilon!");1576 // choose the small inverse epsilon 1587 1577 #endif 1588 1578 … … 1618 1608 1619 1609 for(j=0; j<nV; j++) 1620 1610 { 1621 1611 mpz_init_set(pert_vector[i*nV+j],ivtemp[j]); 1622 1623 } 1624 1625 / * 2147483647 is max. integer representation in SINGULAR */1612 } 1613 } 1614 1615 // 2147483647 is max. integer representation in SINGULAR 1626 1616 mpz_t sing_int; 1627 1617 mpz_init_set_ui(sing_int, 2147483647); … … 1647 1637 (* result)[i] = mpz_get_si(pert_vector[i]); 1648 1638 } 1649 /* 1650 j = 0; 1651 for(i=0; i<niv; i++) 1652 { 1653 (* result1)[i] = mpz_get_si(pert_vector[i]); 1654 (* result1)[i] = 0.1*(* result1)[i]; 1655 (* result1)[i] = floor((* result1)[i] + 0.5); 1656 if((* result1)[i] == 0) 1657 { 1658 j++; 1659 } 1660 } 1661 if(j > niv - 1) 1662 { 1663 // Print("\n// MfPertwalk: geaenderter vector gleich Null! \n"); 1664 delete result1; 1665 goto CHECK_OVERFLOW; 1666 } 1667 /* 1668 // check that the perturbed weight vector lies in the Groebner cone 1669 Print("\n========================================\n//** MfPertvector: test in Cone.\n"); 1670 if(test_w_in_ConeCC(G,result1) != 0) 1671 { 1672 // Print("\n// MfPertwalk: geaenderter vector liegt in Groebnerkegel! \n"); 1673 delete result; 1674 result = result1; 1675 for(i=0; i<nV; i++) 1676 { 1677 mpz_set_si(pert_vector[i], (*result1)[i]); 1678 } 1679 } 1680 else 1681 { 1682 delete result1; 1683 // Print("\n// Mfpertwalk: geaenderter vector liegt nicht in Groebnerkegel! \n"); 1684 } 1685 Print("\n ========================================\n");*/ 1639 1686 1640 CHECK_OVERFLOW: 1687 1641 … … 1721 1675 while(p!=NULL) 1722 1676 { 1723 p_Setm(p,currRing); pIter(p); 1677 p_Setm(p,currRing); 1678 pIter(p); 1724 1679 } 1725 1680 } … … 1804 1759 1805 1760 //unused 1806 #if 0 1761 /* 1807 1762 static void checkidealCC(ideal G, char* Ch) 1808 1763 { … … 1830 1785 PrintLn(); 1831 1786 } 1832 #endif 1787 */ 1833 1788 1834 1789 //unused 1835 #if 0 1790 /* 1836 1791 static void HeadidString(ideal L, char* st) 1837 1792 { … … 1845 1800 Print(" %s;\n", pString(pHead(L->m[nL]))); 1846 1801 } 1847 #endif 1848 1802 1803 */ 1849 1804 static inline int MivComp(intvec* iva, intvec* ivb) 1850 1805 { … … 1919 1874 * with respect to an ideal <G>. * 1920 1875 **********************************************************************/ 1876 /* 1921 1877 static intvec* MwalkNextWeightCC(intvec* curr_weight, intvec* target_weight, 1922 1878 ideal G) … … 2040 1996 if(mpz_cmp(t_nenner, t_null) == 0) 2041 1997 { 2042 2043 Print("\n//MwalkNextWeightCC: t_nenner ist Null!");2044 1998 #ifndef SING_NDEBUG 1999 Print("\n//MwalkNextWeightCC: t_nenner=0\n"); 2000 #endif 2045 2001 delete diff_weight; 2046 2002 diff_weight = ivCopy(curr_weight);//take memory … … 2171 2127 2172 2128 for(j=0; j<nRing; j++) 2173 2129 { 2174 2130 if(mpz_cmp(vec[j], sing_int_half) >= 0) 2175 2131 { 2176 2132 goto REDUCTION; 2177 2178 2133 } 2134 } 2179 2135 checkRed = 1; 2180 2136 for (j=0; j<nRing; j++) … … 2271 2227 return diff_weight; 2272 2228 } 2229 */ 2230 /********************************************************************** 2231 * Compute a next weight vector between curr_weight and target_weight * 2232 * with respect to an ideal <G>. * 2233 **********************************************************************/ 2234 static intvec* MwalkNextWeightCC(intvec* curr_weight, intvec* target_weight, 2235 ideal G) 2236 { 2237 BOOLEAN nError = Overflow_Error; 2238 Overflow_Error = FALSE; 2239 2240 assume(currRing != NULL && curr_weight != NULL && 2241 target_weight != NULL && G != NULL); 2242 2243 int nRing = currRing->N; 2244 int checkRed, j, nG = IDELEMS(G); 2245 intvec* ivtemp; 2246 2247 mpz_t t_zaehler, t_nenner; 2248 mpz_init(t_zaehler); 2249 mpz_init(t_nenner); 2250 2251 mpz_t s_zaehler, s_nenner, temp, MwWd; 2252 mpz_init(s_zaehler); 2253 mpz_init(s_nenner); 2254 mpz_init(temp); 2255 mpz_init(MwWd); 2256 2257 mpz_t sing_int; 2258 mpz_init(sing_int); 2259 mpz_set_si(sing_int, 2147483647); 2260 2261 mpz_t sing_int_half; 2262 mpz_init(sing_int_half); 2263 mpz_set_si(sing_int_half, 3*(1073741824/2)); 2264 2265 mpz_t deg_w0_p1, deg_d0_p1; 2266 mpz_init(deg_w0_p1); 2267 mpz_init(deg_d0_p1); 2268 2269 mpz_t sztn, sntz; 2270 mpz_init(sztn); 2271 mpz_init(sntz); 2272 2273 mpz_t t_null; 2274 mpz_init(t_null); 2275 2276 mpz_t ggt; 2277 mpz_init(ggt); 2278 2279 mpz_t dcw; 2280 mpz_init(dcw); 2281 2282 int gcd_tmp; 2283 //intvec* diff_weight = MivSub(target_weight, curr_weight); 2284 2285 intvec* diff_weight1 = new intvec(nRing); //MivSub(target_weight, curr_weight); 2286 poly g; 2287 2288 // reduce the size of the entries of the current weight vector 2289 if(TEST_OPT_REDSB) 2290 { 2291 for (j=0; j<nRing; j++) 2292 { 2293 (*diff_weight1)[j] = (*curr_weight)[j]; 2294 } 2295 while(MivAbsMax(diff_weight1)>10000 && test_w_in_ConeCC(G,diff_weight1)==1) 2296 { 2297 for(j=0; j<nRing; j++) 2298 { 2299 (*curr_weight)[j] = (*diff_weight1)[j]; 2300 } 2301 for(j=0; j<nRing; j++) 2302 { 2303 (*diff_weight1)[j] = floor(0.1*(*diff_weight1)[j] + 0.5); 2304 } 2305 } 2306 2307 if(MivAbsMax(curr_weight)>100000) 2308 { 2309 for(j=0; j<nRing; j++) 2310 { 2311 (*diff_weight1)[j] = (*curr_weight)[j]; 2312 } 2313 j = 0; 2314 while(test_w_in_ConeCC(G,diff_weight1)==1 && MivAbsMax(diff_weight1)>1000) 2315 { 2316 (*curr_weight)[j] = (*diff_weight1)[j]; 2317 j = MivAbsMaxArg(diff_weight1); 2318 (*diff_weight1)[j] = floor(0.1*(*diff_weight1)[j] + 0.5); 2319 } 2320 } 2321 2322 } 2323 intvec* diff_weight = MivSub(target_weight, curr_weight); 2324 2325 // compute a suitable next weight vector 2326 for (j=0; j<nG; j++) 2327 { 2328 g = G->m[j]; 2329 if (g != NULL) 2330 { 2331 ivtemp = MExpPol(g); 2332 mpz_set_si(deg_w0_p1, MivDotProduct(ivtemp, curr_weight)); 2333 mpz_set_si(deg_d0_p1, MivDotProduct(ivtemp, diff_weight)); 2334 delete ivtemp; 2335 2336 pIter(g); 2337 while (g != NULL) 2338 { 2339 ivtemp = MExpPol(g); 2340 mpz_set_si(MwWd, MivDotProduct(ivtemp, curr_weight)); 2341 mpz_sub(s_zaehler, deg_w0_p1, MwWd); 2342 if(mpz_cmp(s_zaehler, t_null) != 0) 2343 { 2344 mpz_set_si(MwWd, MivDotProduct(ivtemp, diff_weight)); 2345 mpz_sub(s_nenner, MwWd, deg_d0_p1); 2346 // check for 0 < s <= 1 2347 if( (mpz_cmp(s_zaehler,t_null) > 0 && 2348 mpz_cmp(s_nenner, s_zaehler)>=0) || 2349 (mpz_cmp(s_zaehler, t_null) < 0 && 2350 mpz_cmp(s_nenner, s_zaehler)<=0)) 2351 { 2352 // make both positive 2353 if (mpz_cmp(s_zaehler, t_null) < 0) 2354 { 2355 mpz_neg(s_zaehler, s_zaehler); 2356 mpz_neg(s_nenner, s_nenner); 2357 } 2358 2359 //compute a simple fraction of s 2360 cancel(s_zaehler, s_nenner); 2361 2362 if(mpz_cmp(t_nenner, t_null) != 0) 2363 { 2364 mpz_mul(sztn, s_zaehler, t_nenner); 2365 mpz_mul(sntz, s_nenner, t_zaehler); 2366 2367 if(mpz_cmp(sztn,sntz) < 0) 2368 { 2369 mpz_add(t_nenner, t_null, s_nenner); 2370 mpz_add(t_zaehler,t_null, s_zaehler); 2371 } 2372 } 2373 else 2374 { 2375 mpz_add(t_nenner, t_null, s_nenner); 2376 mpz_add(t_zaehler,t_null, s_zaehler); 2377 } 2378 } 2379 } 2380 pIter(g); 2381 delete ivtemp; 2382 } 2383 } 2384 } 2385 //Print("\n// Alloc Size = %d \n", nRing*sizeof(mpz_t)); 2386 mpz_t *vec=(mpz_t*)omAlloc(nRing*sizeof(mpz_t)); 2387 2388 2389 // there is no 0<t<1 and define the next weight vector that is equal 2390 // to the current weight vector 2391 if(mpz_cmp(t_nenner, t_null) == 0) 2392 { 2393 #ifndef SING_NDEBUG 2394 Print("\n//MwalkNextWeightCC: t_nenner=0\n"); 2395 #endif 2396 delete diff_weight; 2397 diff_weight = ivCopy(curr_weight);//take memory 2398 goto FINISH; 2399 } 2400 2401 // define the target vector as the next weight vector, if t = 1 2402 if(mpz_cmp_si(t_nenner, 1)==0 && mpz_cmp_si(t_zaehler,1)==0) 2403 { 2404 delete diff_weight; 2405 diff_weight = ivCopy(target_weight); //this takes memory 2406 goto FINISH; 2407 } 2408 2409 //checkRed = 0; 2410 2411 SIMPLIFY_GCD: 2412 2413 // simplify the vectors curr_weight and diff_weight (C-int) 2414 gcd_tmp = (*curr_weight)[0]; 2415 2416 for (j=1; j<nRing; j++) 2417 { 2418 gcd_tmp = gcd(gcd_tmp, (*curr_weight)[j]); 2419 if(gcd_tmp == 1) 2420 { 2421 break; 2422 } 2423 } 2424 if(gcd_tmp != 1) 2425 { 2426 for (j=0; j<nRing; j++) 2427 { 2428 gcd_tmp = gcd(gcd_tmp, (*diff_weight)[j]); 2429 if(gcd_tmp == 1) 2430 { 2431 break; 2432 } 2433 } 2434 } 2435 if(gcd_tmp != 1) 2436 { 2437 for (j=0; j<nRing; j++) 2438 { 2439 (*curr_weight)[j] = (*curr_weight)[j]/gcd_tmp; 2440 (*diff_weight)[j] = (*diff_weight)[j]/gcd_tmp; 2441 } 2442 } 2443 if(checkRed > 0) 2444 { 2445 for (j=0; j<nRing; j++) 2446 { 2447 mpz_set_si(vec[j], (*diff_weight)[j]); 2448 } 2449 goto TEST_OVERFLOW; 2450 } 2451 2452 #ifdef NEXT_VECTORS_CC 2453 Print("\n// gcd of the weight vectors (current and target) = %d", gcd_tmp); 2454 ivString(curr_weight, "new cw"); 2455 ivString(diff_weight, "new dw"); 2456 2457 PrintS("\n// t_zaehler: "); mpz_out_str( stdout, 10, t_zaehler); 2458 PrintS(", t_nenner: "); mpz_out_str( stdout, 10, t_nenner); 2459 #endif 2460 2461 // construct a new weight vector and check whether vec[j] is overflow, i.e. vec[j] > 2^31. 2462 // If vec[j] doesn't overflow, define a weight vector. Otherwise, report that overflow 2463 // appears. In the second case, test whether the the correctness of the new vector plays 2464 // an important role 2465 2466 for (j=0; j<nRing; j++) 2467 { 2468 mpz_set_si(dcw, (*curr_weight)[j]); 2469 mpz_mul(s_nenner, t_nenner, dcw); 2470 2471 if( (*diff_weight)[j]>0) 2472 { 2473 mpz_mul_ui(s_zaehler, t_zaehler, (*diff_weight)[j]); 2474 } 2475 else 2476 { 2477 mpz_mul_ui(s_zaehler, t_zaehler, -(*diff_weight)[j]); 2478 mpz_neg(s_zaehler, s_zaehler); 2479 } 2480 mpz_add(sntz, s_nenner, s_zaehler); 2481 mpz_init_set(vec[j], sntz); 2482 2483 #ifdef NEXT_VECTORS_CC 2484 Print("\n// j = %d ==> ", j); 2485 PrintS("("); 2486 mpz_out_str( stdout, 10, t_nenner); 2487 Print(" * %d)", (*curr_weight)[j]); 2488 Print(" + ("); mpz_out_str( stdout, 10, t_zaehler); 2489 Print(" * %d) = ", (*diff_weight)[j]); 2490 mpz_out_str( stdout, 10, s_nenner); 2491 PrintS(" + "); 2492 mpz_out_str( stdout, 10, s_zaehler); 2493 PrintS(" = "); mpz_out_str( stdout, 10, sntz); 2494 Print(" ==> vector[%d]: ", j); mpz_out_str(stdout, 10, vec[j]); 2495 #endif 2496 2497 if(j==0) 2498 { 2499 mpz_set(ggt, sntz); 2500 } 2501 else 2502 { 2503 if(mpz_cmp_si(ggt,1) != 0) 2504 { 2505 mpz_gcd(ggt, ggt, sntz); 2506 } 2507 } 2508 } 2509 // reduce the vector with the gcd 2510 if(mpz_cmp_si(ggt,1) != 0) 2511 { 2512 for (j=0; j<nRing; j++) 2513 { 2514 mpz_divexact(vec[j], vec[j], ggt); 2515 } 2516 } 2517 #ifdef NEXT_VECTORS_CC 2518 PrintS("\n// gcd of elements of the vector: "); 2519 mpz_out_str( stdout, 10, ggt); 2520 #endif 2521 2522 for (j=0; j<nRing; j++) 2523 { 2524 (*diff_weight)[j] = mpz_get_si(vec[j]); 2525 } 2526 2527 TEST_OVERFLOW: 2528 2529 for (j=0; j<nRing; j++) 2530 { 2531 if(mpz_cmp(vec[j], sing_int)>=0) 2532 { 2533 if(Overflow_Error == FALSE) 2534 { 2535 Overflow_Error = TRUE; 2536 PrintS("\n// ** OVERFLOW in \"MwalkNextWeightCC\": "); 2537 mpz_out_str( stdout, 10, vec[j]); 2538 PrintS(" is greater than 2147483647 (max. integer representation)\n"); 2539 Print("// So vector[%d] := %d is wrong!!\n",j+1, vec[j]);// vec[j] is mpz_t 2540 } 2541 } 2542 } 2543 2544 FINISH: 2545 delete diff_weight1; 2546 mpz_clear(t_zaehler); 2547 mpz_clear(t_nenner); 2548 mpz_clear(s_zaehler); 2549 mpz_clear(s_nenner); 2550 mpz_clear(sntz); 2551 mpz_clear(sztn); 2552 mpz_clear(temp); 2553 mpz_clear(MwWd); 2554 mpz_clear(deg_w0_p1); 2555 mpz_clear(deg_d0_p1); 2556 mpz_clear(ggt); 2557 omFree(vec); 2558 mpz_clear(sing_int_half); 2559 mpz_clear(sing_int); 2560 mpz_clear(dcw); 2561 mpz_clear(t_null); 2562 2563 if(Overflow_Error == FALSE) 2564 { 2565 Overflow_Error = nError; 2566 } 2567 rComplete(currRing); 2568 for(j=0; j<IDELEMS(G); j++) 2569 { 2570 poly p=G->m[j]; 2571 while(p!=NULL) 2572 { 2573 p_Setm(p,currRing); 2574 pIter(p); 2575 } 2576 } 2577 return diff_weight; 2578 } 2579 2273 2580 2274 2581 /********************************************************************** … … 2956 3263 int i,j,N = IDELEMS(Gomega); 2957 3264 poly p,lm,factor1,factor2; 2958 //PrintS("\n//** idCopy\n"); 3265 2959 3266 ideal Go = idCopy(G); 2960 3267 2961 //PrintS("\n//** jetzt for-Loop!\n");2962 2963 3268 // check whether leading monomials of G and Gomega coincide 2964 3269 // and return NULL if not 2965 3270 for(i=0; i<N; i++) 2966 3271 { 2967 p = pCopy(Gomega->m[i]); 2968 lm = pCopy(pHead(G->m[i])); 2969 if(!pIsConstant(pSub(p,lm))) 2970 { 2971 //pDelete(&p); 2972 //pDelete(&lm); 3272 if(!pIsConstant(pSub(pCopy(Gomega->m[i]),pCopy(pHead(G->m[i]))))) 3273 { 2973 3274 idDelete(&Go); 2974 3275 return NULL; 2975 3276 } 2976 //pDelete(&p);2977 //pDelete(&lm);2978 3277 } 2979 3278 for(i=0; i<N; i++) … … 3007 3306 } 3008 3307 } 3009 3010 //PrintS("\n//** jetzt Delete!\n"); 3011 //pDelete(&p); 3012 //pDelete(&factor); 3013 //pDelete(&lm); 3308 3014 3309 if(middle == TRUE) 3015 3310 { 3016 //PrintS("\n//** middle TRUE!\n");3017 3311 return Go; 3018 3312 } 3019 //PrintS("\n//** middle FALSE!\n");3020 3313 idDelete(&Go); 3021 3314 return NULL; … … 3151 3444 { 3152 3445 Print("\n// ring r%d_%d = %s;\n", tp_deg, nwalk, rString(currRing)); 3446 /* 3153 3447 idElements(Gomega, "Gw"); 3154 3448 headidString(Gomega, "Gw"); 3449 */ 3155 3450 } 3156 3451 #endif … … 3309 3604 for(i=IDELEMS(G)-1; i>=0; i--) 3310 3605 { 3311 #if 03312 if(pLength(G->m[i])>2)3313 {3314 return 1;3315 }3316 #else3317 3606 if((G->m[i]!=NULL) /* len >=0 */ 3318 3607 && (G->m[i]->next!=NULL) /* len >=1 */ 3319 3608 && (G->m[i]->next->next!=NULL) /* len >=2 */ 3320 && (G->m[i]->next->next->next!=NULL) /* len >=3 */ 3321 //&& (G->m[i]->next->next->next->next!=NULL) /* len >=4 */ 3322 ) 3323 { 3324 return 1; 3325 } 3326 #endif 3609 && (G->m[i]->next->next->next!=NULL) /* len >=3 */) 3610 { 3611 return 1; 3612 } 3327 3613 } 3328 3614 return 0; … … 3414 3700 for(i=nG-1; i>=0; i--) 3415 3701 { 3416 #if 0 3702 /* 3417 3703 poly t; 3418 3704 if((t=pSub(pCopy(H0->m[i]), pCopy(H1->m[i]))) != NULL) … … 3422 3708 } 3423 3709 pDelete(&t); 3424 #else 3710 */ 3425 3711 if(!pEqualPolys(H0->m[i],H1->m[i])) 3426 3712 { 3427 3713 return 0; 3428 3714 } 3429 #endif3430 3715 } 3431 3716 return 1; … … 3436 3721 * find the maximal total degree of polynomials in G * 3437 3722 *****************************************************/ 3438 #if 0 3723 /* 3439 3724 static int Trandegreebound(ideal G) 3440 3725 { … … 3457 3742 return result; 3458 3743 } 3459 #endif 3744 */ 3460 3745 3461 3746 //unused … … 3804 4089 * basis or n times, where n is the numbers of variables. * 3805 4090 *****************************************************************************/ 3806 3807 //unused3808 #if 03809 static int testnegintvec(intvec* v)3810 {3811 int n = v->length();3812 int i;3813 for(i=0; i<n; i++)3814 {3815 if((*v)[i]<0)3816 {3817 return(1);3818 }3819 }3820 return(0);3821 }3822 #endif3823 4091 3824 4092 // npwinc = 0, if curr_weight doesn't stay in the correct Groebner cone … … 4032 4300 //nOverflow_Error = Overflow_Error; 4033 4301 tproc=tproc+clock()-tinput; 4034 /*4035 4036 4037 */4302 4303 Print("\n// takes %d steps and calls \"Rec_LastGB\" (%d):", 4304 nwalk, tp_deg+1); 4305 4038 4306 G = Rec_LastGB(G,curr_weight, orig_target_weight, tp_deg+1,nnwinC); 4039 4307 newRing = currRing; … … 4069 4337 { 4070 4338 // nOverflow_Error = Overflow_Error; 4071 //Print("\n// takes %d steps and calls \"Rec_LastGB (%d):", tp_deg+1);4339 Print("\n// takes %d steps and calls \"Rec_LastGB (%d):", tp_deg+1); 4072 4340 tproc=tproc+clock()-tinput; 4073 4341 F1 = Rec_LastGB(F1,curr_weight, orig_target_weight, tp_deg+1,nnwinC); … … 4123 4391 Overflow_Error=nError; 4124 4392 } 4125 // Print("\n// \"Rec_LastGB\" (%d) took %d steps and %.2f sec.Overflow_Error (%d)", tp_deg, nwalk, ((double) tproc)/1000000, nOverflow_Error); 4393 #ifdef TIME_TEST 4394 Print("\n// \"Rec_LastGB\" (%d) took %d steps and %.2f sec.Overflow_Error (%d)", tp_deg, nwalk, ((double) tproc)/1000000, nOverflow_Error); 4395 #endif 4126 4396 return(result); 4127 4397 } … … 4145 4415 //BOOLEAN nOverflow_Error = FALSE; 4146 4416 //Print("// pSetm_Error = (%d)", ErrorCheck()); 4147 4417 #ifdef TIME_TEST 4148 4418 xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0; xtextra=0; 4149 4419 xftinput = clock(); 4150 4420 clock_t tostd, tproc; 4151 4421 #endif 4152 4422 nstep = 0; 4153 4423 int i, nV = currRing->N; … … 4160 4430 intvec* ivNull = new intvec(nV); 4161 4431 intvec* next_weight; 4162 #if 0 4163 intvec* extra_curr_weight = new intvec(nV); 4164 #endif 4432 //intvec* extra_curr_weight = new intvec(nV); 4165 4433 //intvec* hilb_func; 4166 4434 intvec* exivlp = Mivlp(nV); 4167 4168 4435 ring XXRing = currRing; 4169 4436 4170 4437 //Print("\n// ring r_input = %s;", rString(currRing)); 4438 #ifdef TIME_TEST 4171 4439 to = clock(); 4440 #endif 4172 4441 /* compute the reduced Groebner basis of the given ideal w.r.t. 4173 4442 a "fast" monomial order, e.g. degree reverse lex. order (dp) */ 4174 4443 G = MstdCC(Go); 4444 #ifdef TIME_TEST 4175 4445 tostd=clock()-to; 4176 4446 4177 /*4178 4447 Print("\n// Computation of the first std took = %.2f sec", 4179 4448 ((double) tostd)/1000000); 4180 */ 4449 #endif 4181 4450 if(currRing->order[0] == ringorder_a) 4182 4451 { … … 4187 4456 nwalk ++; 4188 4457 nstep ++; 4458 #ifdef TIME_TEST 4189 4459 to = clock(); 4460 #endif 4190 4461 /* compute an initial form ideal of <G> w.r.t. "curr_vector" */ 4191 4462 Gomega = MwalkInitialForm(G, curr_weight); 4463 #ifdef TIME_TEST 4192 4464 xtif=xtif+clock()-to; 4193 #if 0 4465 #endif 4466 /* 4194 4467 if(Overflow_Error == TRUE) 4195 4468 { … … 4199 4472 goto LAST_GB_ALT2; 4200 4473 } 4201 #endif 4474 */ 4202 4475 oldRing = currRing; 4203 4476 … … 4213 4486 newRing = currRing; 4214 4487 Gomega1 = idrMoveR(Gomega, oldRing,currRing); 4488 #ifdef TIME_TEST 4215 4489 to = clock(); 4490 #endif 4216 4491 /* compute a reduced Groebner basis of <Gomega> w.r.t. "newRing" */ 4217 4492 M = MstdhomCC(Gomega1); 4493 #ifdef TIME_TEST 4218 4494 xtstd=xtstd+clock()-to; 4495 #endif 4219 4496 /* change the ring to oldRing */ 4220 4497 rChangeCurrRing(oldRing); 4221 4498 M1 = idrMoveR(M, newRing,currRing); 4222 4499 Gomega2 = idrMoveR(Gomega1, newRing,currRing); 4223 4500 #ifdef TIME_TEST 4224 4501 to = clock(); 4502 #endif 4225 4503 /* compute the reduced Groebner basis of <G> w.r.t. "newRing" 4226 4504 by the liftig process */ 4227 4505 F = MLifttwoIdeal(Gomega2, M1, G); 4506 #ifdef TIME_TEST 4228 4507 xtlift=xtlift+clock()-to; 4508 #endif 4229 4509 idDelete(&M1); 4230 4510 idDelete(&Gomega2); … … 4234 4514 rChangeCurrRing(newRing); 4235 4515 F1 = idrMoveR(F, oldRing,currRing); 4236 4516 #ifdef TIME_TEST 4237 4517 to = clock(); 4518 #endif 4238 4519 /* reduce the Groebner basis <G> w.r.t. newRing */ 4239 4520 G = kInterRedCC(F1, NULL); 4521 #ifdef TIME_TEST 4240 4522 xtred=xtred+clock()-to; 4523 #endif 4241 4524 idDelete(&F1); 4242 4525 … … 4245 4528 4246 4529 NEXT_VECTOR: 4530 #ifdef TIME_TEST 4247 4531 to = clock(); 4532 #endif 4248 4533 /* compute a next weight vector */ 4249 4534 next_weight = MkInterRedNextWeight(curr_weight,target_weight, G); 4535 #ifdef TIME_TEST 4250 4536 xtnw=xtnw+clock()-to; 4537 #endif 4251 4538 #ifdef PRINT_VECTORS 4252 4539 MivString(curr_weight, target_weight, next_weight); … … 4292 4579 // LAST_GB_ALT2: 4293 4580 //nOverflow_Error = Overflow_Error; 4581 #ifdef TIME_TEST 4294 4582 tproc = clock()-xftinput; 4583 #endif 4295 4584 //Print("\n// takes %d steps and calls the recursion of level 2:", nwalk); 4296 4585 /* call the changed perturbation walk algorithm with degree 2 */ … … 4319 4608 4320 4609 #ifdef TIME_TEST 4321 // Print("\n// \"Main procedure\" took %d steps dnd %.2f sec. Overflow_Error (%d)", nwalk, ((double) tproc)/1000000, nOverflow_Error); 4610 Print("\n// \"Main procedure\" took %d steps dnd %.2f sec. Overflow_Error (%d)", 4611 nwalk, ((double) tproc)/1000000, nOverflow_Error); 4322 4612 4323 4613 TimeStringFractal(xftinput, tostd, xtif, xtstd, xtextra,xtlift, xtred,xtnw); … … 4355 4645 * compute a next weight vector * 4356 4646 ********************************/ 4357 static intvec* MWalkRandomNextWeight(ideal G, intvec* curr_weight,4358 intvec* target_weight,int weight_rad, int pert_deg)4647 static intvec* MWalkRandomNextWeight(ideal G, intvec* orig_M, intvec* target_weight, 4648 int weight_rad, int pert_deg) 4359 4649 { 4360 assume(currRing != NULL && curr_weight!= NULL &&4650 assume(currRing != NULL && orig_M != NULL && 4361 4651 target_weight != NULL && G->m[0] != NULL); 4362 4652 4363 int i,weight_norm,nV = currRing->N; 4364 intvec* next_weight2; 4653 //BOOLEAN nError = Overflow_Error; 4654 Overflow_Error = FALSE; 4655 4656 BOOLEAN found_random_weight = FALSE; 4657 int i,nV = currRing->N; 4658 intvec* curr_weight = new intvec(nV); 4659 4660 for(i=0; i<nV; i++) 4661 { 4662 (*curr_weight)[i] = (*orig_M)[i]; 4663 } 4664 4665 int k=0,weight_norm; 4666 intvec* next_weight; 4667 intvec* next_weight1 = MkInterRedNextWeight(curr_weight,target_weight,G); 4668 intvec* next_weight2 = new intvec(nV); 4365 4669 intvec* next_weight22 = new intvec(nV); 4366 4670 intvec* result = new intvec(nV); 4367 4368 intvec* next_weight1 =MkInterRedNextWeight(curr_weight,target_weight,G); 4369 //compute a random next weight vector "next_weight2" 4370 while(1) 4671 intvec* curr_weight1; 4672 ideal G_test, G_test1, G_test2; 4673 4674 //try to find a random next weight vector "next_weight2" 4675 if(weight_rad > 0){ while(k<10) 4371 4676 { 4372 4677 weight_norm = 0; … … 4376 4681 for(i=0; i<nV; i++) 4377 4682 { 4378 (*next_weight2 2)[i] = rand() % 60000 - 30000;4379 weight_norm = weight_norm + (*next_weight2 2)[i]*(*next_weight22)[i];4683 (*next_weight2)[i] = rand() % 60000 - 30000; 4684 weight_norm = weight_norm + (*next_weight2)[i]*(*next_weight2)[i]; 4380 4685 } 4381 4686 weight_norm = 1 + floor(sqrt(weight_norm)); … … 4384 4689 for(i=0; i<nV; i++) 4385 4690 { 4386 if((*next_weight2 2)[i] < 0)4387 { 4388 (*next_weight2 2)[i] = 1 + (*curr_weight)[i] + floor(weight_rad*(*next_weight22)[i]/weight_norm);4691 if((*next_weight2)[i] < 0) 4692 { 4693 (*next_weight2)[i] = 1 + (*curr_weight)[i] + floor(weight_rad*(*next_weight2)[i]/weight_norm); 4389 4694 } 4390 4695 else 4391 4696 { 4392 (*next_weight22)[i] = (*curr_weight)[i] + floor(weight_rad*(*next_weight22)[i]/weight_norm); 4393 } 4394 } 4395 4396 if(test_w_in_ConeCC(G, next_weight22) == 1) 4397 { 4398 next_weight2 = MkInterRedNextWeight(next_weight22,target_weight,G); 4697 (*next_weight2)[i] = (*curr_weight)[i] + floor(weight_rad*(*next_weight2)[i]/weight_norm); 4698 } 4699 } 4700 4701 if(test_w_in_ConeCC(G,next_weight2) == 1) 4702 { 4703 if(maxlengthpoly(MwalkInitialForm(G,next_weight2))<2) 4704 { 4705 next_weight2 = MkInterRedNextWeight(next_weight2,target_weight,G); 4706 } 4707 /* 4399 4708 if(MivAbsMax(next_weight2)>1147483647) 4400 4709 { … … 4404 4713 } 4405 4714 i = 0; 4406 / * reduce the size of the maximal entry of the vector*/4407 while(test_w_in_ConeCC(G,next_weight22) )4715 // reduce the size of the maximal entry of the vector 4716 while(test_w_in_ConeCC(G,next_weight22) == 1) 4408 4717 { 4409 4718 (*next_weight2)[i] = (*next_weight22)[i]; … … 4411 4720 (*next_weight22)[i] = floor(0.1*(*next_weight22)[i] + 0.5); 4412 4721 } 4413 } 4414 delete next_weight22; 4722 delete next_weight22; 4723 } 4724 */ 4725 G_test2 = MwalkInitialForm(G, next_weight2); 4726 found_random_weight = TRUE; 4415 4727 break; 4416 4728 } 4417 } 4418 4419 // compute "usual" next weight vector 4420 intvec* next_weight = MwalkNextWeightCC(curr_weight,target_weight, G); 4421 ideal G_test = MwalkInitialForm(G, next_weight); 4422 ideal G_test2 = MwalkInitialForm(G, next_weight2); 4423 4729 k++; 4730 }} 4731 Print("\n MWalkRandomNextWeight: compute perurbation...\n"); 4732 // compute "perturbed" next weight vector 4733 if(pert_deg > 1) 4734 { 4735 curr_weight1 = MPertVectors(G,orig_M,pert_deg); 4736 next_weight = MkInterRedNextWeight(curr_weight1,target_weight,G); 4737 delete curr_weight1; 4738 } 4739 else 4740 { 4741 next_weight = MkInterRedNextWeight(curr_weight,target_weight,G); 4742 } 4743 if(MivSame(curr_weight,next_weight)==1 || Overflow_Error == TRUE) 4744 { 4745 Overflow_Error = FALSE; 4746 delete next_weight; 4747 next_weight = MkInterRedNextWeight(curr_weight,target_weight,G); 4748 } 4749 G_test=MwalkInitialForm(G,next_weight); 4750 G_test1=MwalkInitialForm(G,next_weight1); 4751 Print("\n MWalkRandomNextWeight: finished...\n"); 4424 4752 // compare next weights 4425 4753 if(Overflow_Error == FALSE) 4426 4754 { 4427 i deal G_test1 = MwalkInitialForm(G, next_weight1);4428 if(G_test1->m[0] != NULL && maxlengthpoly(G_test1) < maxlengthpoly(G_test))//if(IDELEMS(G_test1) < IDELEMS(G_test))4429 {4430 if(G_test 2->m[0] != NULL && maxlengthpoly(G_test2) < maxlengthpoly(G_test1))//if(IDELEMS(G_test2) < IDELEMS(G_test1))4431 { 4432 for(i=0; i<nV; i++)4755 if(found_random_weight == TRUE) 4756 { 4757 // random next weight vector found 4758 if(G_test1->m[0] != NULL && maxlengthpoly(G_test1) < maxlengthpoly(G_test)) 4759 { 4760 if(G_test2->m[0] != NULL && maxlengthpoly(G_test2) < maxlengthpoly(G_test1)) 4433 4761 { 4434 (*result)[i] = (*next_weight2)[i]; 4762 for(i=0; i<nV; i++) 4763 { 4764 (*result)[i] = (*next_weight2)[i]; 4765 } 4435 4766 } 4767 else 4768 { 4769 for(i=0; i<nV; i++) 4770 { 4771 (*result)[i] = (*next_weight1)[i]; 4772 } 4773 } 4436 4774 } 4437 4775 else 4438 4776 { 4439 for(i=0; i<nV; i++) 4777 if(G_test2->m[0] != NULL && maxlengthpoly(G_test2) < maxlengthpoly(G_test)) 4778 { 4779 for(i=0; i<nV; i++) 4780 { 4781 (*result)[i] = (*next_weight2)[i]; 4782 } 4783 } 4784 else 4785 { 4786 for(i=0; i<nV; i++) 4787 { 4788 (*result)[i] = (*next_weight)[i]; 4789 } 4790 } 4791 } 4792 } 4793 else 4794 { 4795 // no random next weight vector found 4796 if(G_test1->m[0] != NULL && maxlengthpoly(G_test1) < maxlengthpoly(G_test)) 4797 { 4798 for(i=0; i<nV; i++) 4440 4799 { 4441 4800 (*result)[i] = (*next_weight1)[i]; 4442 }4443 }4444 }4445 else4446 {4447 if(G_test2->m[0] != NULL && maxlengthpoly(G_test2) < maxlengthpoly(G_test))//if(IDELEMS(G_test2) < IDELEMS(G_test)) // |G_test2| < |G_test| <= |G_test1|4448 {4449 for(i=0; i<nV; i++)4450 {4451 (*result)[i] = (*next_weight2)[i];4452 4801 } 4453 4802 } … … 4460 4809 } 4461 4810 } 4462 idDelete(&G_test1);4463 4811 } 4464 4812 else 4465 4813 { 4466 4814 Overflow_Error = FALSE; 4467 if(G_test2->m[0] != NULL && maxlengthpoly(G_test2) < maxlengthpoly(G_test))//if(IDELEMS(G_test2) < IDELEMS(G_test)) 4468 { 4469 for(i=1; i<nV; i++) 4470 { 4471 (*result)[i] = (*next_weight2)[i]; 4815 if(found_random_weight == TRUE) 4816 { 4817 if(G_test2->m[0] != NULL && maxlengthpoly(G_test2) < maxlengthpoly(G_test)) 4818 { 4819 for(i=1; i<nV; i++) 4820 { 4821 (*result)[i] = (*next_weight2)[i]; 4822 } 4823 } 4824 else 4825 { 4826 for(i=0; i<nV; i++) 4827 { 4828 (*result)[i] = (*next_weight)[i]; 4829 } 4472 4830 } 4473 4831 } … … 4480 4838 } 4481 4839 } 4482 //PrintS("\n MWalkRandomNextWeight: Ende ok!\n"); 4840 // delete curr_weight1; 4841 delete next_weight; 4842 delete next_weight2; 4483 4843 idDelete(&G_test); 4484 idDelete(&G_test2); 4485 if(test_w_in_ConeCC(G, result) == 1) 4486 { 4487 delete next_weight2; 4488 delete next_weight; 4844 idDelete(&G_test1); 4845 if(found_random_weight == TRUE) 4846 { 4847 idDelete(&G_test2); 4848 } 4849 if(test_w_in_ConeCC(G, result) == 1 && MivSame(curr_weight,result)==0) 4850 { 4851 delete curr_weight; 4489 4852 delete next_weight1; 4490 4853 return result; … … 4492 4855 else 4493 4856 { 4857 delete curr_weight; 4494 4858 delete result; 4495 delete next_weight2; 4496 delete next_weight1; 4497 return next_weight; 4859 return next_weight1; 4498 4860 } 4499 4861 } … … 4503 4865 * The procedur REC_GB_Mwalk computes a GB for <G> w.r.t. the weight order * 4504 4866 * otw, where G is a reduced GB w.r.t. the weight order cw. * 4505 * The new procedur Mwalk calls REC_GB.*4867 * The new procedure Mwalk calls REC_GB. * 4506 4868 ***************************************************************************/ 4507 4869 static ideal REC_GB_Mwalk(ideal G, intvec* curr_weight, intvec* orig_target_weight, … … 4806 5168 4807 5169 ideal Gomega, M, F, Gomega1, Gomega2, M1, F1, G; 4808 //ideal G1; 4809 //ring endRing; 5170 4810 5171 ring newRing, oldRing; 4811 5172 intvec* ivNull = new intvec(nV); … … 4849 5210 the recursive changed perturbation walk alg. */ 4850 5211 tim = clock(); 4851 /* 5212 #ifdef CHECK_IDEAL_MWALK 4852 5213 Print("\n// **** Groebnerwalk took %d steps and ", nwalk); 4853 5214 PrintS("\n// **** call the rec. Pert. Walk to compute a red GB of:"); 4854 id Elements(Gomega, "G_omega");4855 */ 5215 idString(Gomega, "Gomega"); 5216 #endif 4856 5217 4857 5218 if(MivSame(exivlp, target_weight)==1) … … 4859 5220 else 4860 5221 goto NORMAL_GW; 4861 /* 5222 #ifdef TIME_TEST 4862 5223 Print("\n// time for the last std(Gw) = %.2f sec", 4863 5224 ((double) (clock()-tim)/1000000)); 4864 PrintS("\n// ***************************************************\n"); 4865 */ 5225 #endif 5226 /* 4866 5227 #ifdef CHECK_IDEAL_MWALK 4867 5228 idElements(Gomega, "G_omega"); … … 4870 5231 //headidString(M, "M"); 4871 5232 #endif 5233 */ 4872 5234 to = clock(); 4873 5235 F = MLifttwoIdeal(Gomega, M, G); … … 5029 5391 } 5030 5392 5031 5032 5393 /******************************* 5033 5394 * THE GROEBNER WALK ALGORITHM * … … 5087 5448 #endif 5088 5449 rComplete(currRing); 5089 //#ifdef CHECK_IDEAL_MWALK5450 #ifdef CHECK_IDEAL_MWALK 5090 5451 if(printout > 2) 5091 5452 { 5092 5453 idString(Go,"//** Mwalk: Go"); 5093 5454 } 5094 //#endif5455 #endif 5095 5456 5096 5457 if(target_M->length() == nV) … … 5117 5478 to = clock(); 5118 5479 #endif 5119 5120 5480 ideal G = MstdCC(idrMoveR(Go,baseRing,currRing)); 5121 5122 5481 #ifdef TIME_TEST 5123 5482 tostd = clock()-to; … … 5131 5490 nwalk ++; 5132 5491 nstep ++; 5133 5492 //compute an initial form ideal of <G> w.r.t. "curr_vector" 5134 5493 #ifdef TIME_TEST 5135 5494 to = clock(); 5136 5495 #endif 5137 // compute an initial form ideal of <G> w.r.t. "curr_vector"5138 5496 Gomega = MwalkInitialForm(G, curr_weight); 5139 5497 #ifdef TIME_TEST … … 5141 5499 #endif 5142 5500 5143 //#ifdef CHECK_IDEAL_MWALK5501 #ifdef CHECK_IDEAL_MWALK 5144 5502 if(printout > 1) 5145 5503 { 5146 5504 idString(Gomega,"//** Mwalk: Gomega"); 5147 5505 } 5148 //#endif5506 #endif 5149 5507 5150 5508 if(reduction == 0) 5151 5509 { 5152 5510 FF = middleOfCone(G,Gomega); 5153 if( 5511 if(FF != NULL) 5154 5512 { 5155 5513 idDelete(&G); … … 5213 5571 #endif 5214 5572 idSkipZeroes(M); 5215 //#ifdef CHECK_IDEAL_MWALK5573 #ifdef CHECK_IDEAL_MWALK 5216 5574 if(printout > 2) 5217 5575 { 5218 5576 idString(M, "//** Mwalk: M"); 5219 5577 } 5220 //#endif5578 #endif 5221 5579 //change the ring to baseRing 5222 5580 rChangeCurrRing(baseRing); … … 5231 5589 // where Gomega is a reduced Groebner basis w.r.t. the current ring 5232 5590 F = MLifttwoIdeal(Gomega2, M1, G); 5233 5234 5591 #ifdef TIME_TEST 5235 5592 tlift = tlift + clock() - to; 5236 5593 #endif 5237 //#ifdef CHECK_IDEAL_MWALK5594 #ifdef CHECK_IDEAL_MWALK 5238 5595 if(printout > 2) 5239 5596 { 5240 5597 idString(F, "//** Mwalk: F"); 5241 5598 } 5242 //#endif5599 #endif 5243 5600 idDelete(&Gomega2); 5244 5601 idDelete(&M1); … … 5249 5606 idSkipZeroes(G); 5250 5607 5251 //#ifdef CHECK_IDEAL_MWALK5608 #ifdef CHECK_IDEAL_MWALK 5252 5609 if(printout > 2) 5253 5610 { 5254 5611 idString(G, "//** Mwalk: G"); 5255 5612 } 5256 //#endif5613 #endif 5257 5614 5258 5615 rChangeCurrRing(targetRing); … … 5270 5627 baseRing = currRing; 5271 5628 5629 NEXT_VECTOR: 5630 #ifdef TIME_TEST 5631 to = clock(); 5632 #endif 5633 intvec* next_weight = MwalkNextWeightCC(curr_weight,target_weight,G); 5634 #ifdef TIME_TEST 5635 tnw = tnw + clock() - to; 5636 #endif 5637 #ifdef PRINT_VECTORS 5638 if(printout > 0) 5639 { 5640 MivString(curr_weight, target_weight, next_weight); 5641 } 5642 #endif 5643 if(MivComp(target_weight,curr_weight) == 1)// || endwalks == TRUE) 5644 { 5272 5645 /* 5273 #ifdef TIME_TEST 5274 to = clock(); 5275 #endif 5276 5277 #ifdef TIME_TEST 5278 tstd = tstd + clock() - to; 5279 #endif 5280 */ 5281 5282 5283 #ifdef TIME_TEST 5284 to = clock(); 5285 #endif 5286 NEXT_VECTOR: 5287 intvec* next_weight = MwalkNextWeightCC(curr_weight,target_weight,G); 5288 #ifdef TIME_TEST 5289 tnw = tnw + clock() - to; 5290 #endif 5291 //#ifdef PRINT_VECTORS 5292 if(printout > 0) 5293 { 5294 MivString(curr_weight, target_weight, next_weight); 5295 } 5296 //#endif 5297 if(MivComp(target_weight,curr_weight) == 1)// || endwalks == TRUE) 5298 {/* 5299 //#ifdef CHECK_IDEAL_MWALK 5646 #ifdef CHECK_IDEAL_MWALK 5300 5647 if(printout > 0) 5301 5648 { 5302 5649 PrintS("\n//** Mwalk: entering last cone.\n"); 5303 5650 } 5304 //#endif5651 #endif 5305 5652 5306 5653 Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector" … … 5316 5663 Gomega1 = idrMoveR(Gomega, baseRing,currRing); 5317 5664 idDelete(&Gomega); 5318 //#ifdef CHECK_IDEAL_MWALK5665 #ifdef CHECK_IDEAL_MWALK 5319 5666 if(printout > 1) 5320 5667 { … … 5322 5669 } 5323 5670 PrintS("\n //** Mwalk: kStd(Gomega)"); 5324 //#endif5671 #endif 5325 5672 M = kStd(Gomega1,NULL,testHomog,NULL,NULL,0,0,NULL); 5326 //#ifdef CHECK_IDEAL_MWALK5673 #ifdef CHECK_IDEAL_MWALK 5327 5674 if(printout > 1) 5328 5675 { 5329 5676 idString(M,"//** Mwalk: M"); 5330 5677 } 5331 //#endif5678 #endif 5332 5679 rChangeCurrRing(baseRing); 5333 5680 M1 = idrMoveR(M, newRing,currRing); … … 5337 5684 //PrintS("\n //** Mwalk: MLifttwoIdeal"); 5338 5685 F = MLifttwoIdeal(Gomega2, M1, G); 5339 //#ifdef CHECK_IDEAL_MWALK5686 #ifdef CHECK_IDEAL_MWALK 5340 5687 if(printout > 2) 5341 5688 { 5342 5689 idString(F,"//** Mwalk: F"); 5343 5690 } 5344 //#endif5691 #endif 5345 5692 idDelete(&Gomega2); 5346 5693 idDelete(&M1); … … 5349 5696 idDelete(&F); 5350 5697 baseRing = currRing; 5351 si_opt_1 = save1; //set original options, e. g. option(RedSB)5352 5698 idSkipZeroes(G); 5353 5699 #ifdef TIME_TEST … … 5361 5707 #endif 5362 5708 idSkipZeroes(G); 5363 delete next_weight; */ 5709 delete next_weight; 5710 */ 5364 5711 break; 5365 5712 } … … 5388 5735 #endif 5389 5736 Print("\n//** Mwalk: Groebner Walk took %d steps.\n", nstep); 5737 si_opt_1 = save1; //set original options 5390 5738 return(result); 5391 5739 } … … 5401 5749 si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions 5402 5750 } 5751 5403 5752 Set_Error(FALSE); 5404 5753 Overflow_Error = FALSE; 5405 //BOOLEAN endwalks = FALSE;5754 BOOLEAN endwalks = FALSE; 5406 5755 #ifdef TIME_TEST 5407 5756 clock_t tinput, tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0; … … 5411 5760 #endif 5412 5761 nstep=0; 5413 int i, polylength,nwalk;5762 int i,nwalk;//polylength; 5414 5763 int nV = currRing->N; 5764 5765 //check that weight radius is valid 5766 if(weight_rad < 0) 5767 { 5768 Werror("Invalid radius.\n"); 5769 return NULL; 5770 } 5771 5772 //check that perturbation degree is valid 5773 if(pert_deg > nV || pert_deg < 1) 5774 { 5775 Werror("Invalid perturbation degree.\n"); 5776 return NULL; 5777 } 5415 5778 5416 5779 ideal Gomega, M, F,FF, Gomega1, Gomega2, M1; … … 5419 5782 ring baseRing = currRing; 5420 5783 ring XXRing = currRing; 5784 intvec* iv_M; 5421 5785 intvec* ivNull = new intvec(nV); 5422 5786 intvec* curr_weight = new intvec(nV); 5423 5787 intvec* target_weight = new intvec(nV); 5424 intvec* exivlp = Mivlp(nV);5425 5788 intvec* next_weight= new intvec(nV); 5426 /* 5427 intvec* tmp_weight = new intvec(nV); 5428 for(i=0; i<nV; i++) 5429 { 5430 (*tmp_weight)[i] = (*target_M)[i]; 5431 } 5432 */ 5789 5433 5790 for(i=0; i<nV; i++) 5434 5791 { … … 5436 5793 (*target_weight)[i] = (*target_M)[i]; 5437 5794 } 5795 5438 5796 #ifndef BUCHBERGER_ALG 5439 5797 intvec* hilb_func; … … 5447 5805 #endif 5448 5806 rComplete(currRing); 5807 5808 if(target_M->length() == nV) 5809 { 5810 targetRing = VMrDefault(target_weight); // define the target ring 5811 } 5812 else 5813 { 5814 targetRing = VMatrDefault(target_M); 5815 } 5816 if(orig_M->length() == nV) 5817 { 5818 newRing = VMrDefault(curr_weight); // define a new ring with ordering "(a(curr_weight),lp) 5819 } 5820 else 5821 { 5822 newRing = VMatrDefault(orig_M); 5823 } 5824 rChangeCurrRing(newRing); 5449 5825 #ifdef TIME_TEST 5450 5826 to = clock(); 5451 5827 #endif 5452 5453 if(target_M->length() == nV)5454 {5455 // define the target ring5456 targetRing = VMrDefault(target_weight);5457 }5458 else5459 {5460 targetRing = VMatrDefault(target_M);5461 }5462 if(orig_M->length() == nV)5463 {5464 newRing = VMrDefault(curr_weight); // define a new ring with ordering "(a(curr_weight),lp)5465 }5466 else5467 {5468 newRing = VMatrDefault(orig_M);5469 }5470 rChangeCurrRing(newRing);5471 5828 ideal G = MstdCC(idrMoveR(Go,baseRing,currRing)); 5829 #ifdef TIME_TEST 5830 tostd = clock()-to; 5831 #endif 5472 5832 baseRing = currRing; 5473 #ifdef TIME_TEST5474 tostd = clock()-to;5475 #endif5476 5477 5833 nwalk = 0; 5834 5835 #ifdef TIME_TEST 5836 to = clock(); 5837 #endif 5838 Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector" 5839 #ifdef TIME_TEST 5840 tif = tif + clock()-to; //time for computing initial form ideal 5841 #endif 5842 5478 5843 while(1) 5479 5844 { 5480 5845 nwalk ++; 5481 5846 nstep ++; 5482 #ifdef TIME_TEST 5483 to = clock(); 5484 #endif 5485 5486 Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector" 5487 //polylength = 1 if there is a polynomial in Gomega with at least 3 monomials and 0 otherwise 5488 polylength = lengthpoly(Gomega); 5489 #ifdef TIME_TEST 5490 tif = tif + clock()-to; //time for computing initial form ideal 5491 #endif 5492 //#ifdef CHECK_IDEAL_MWALK 5847 #ifdef CHECK_IDEAL_MWALK 5493 5848 if(printout > 1) 5494 5849 { 5495 5850 idString(Gomega,"//** Mrwalk: Gomega"); 5496 5851 } 5497 //#endif 5498 // test whether target cone is reached 5499 /* if(test_w_in_ConeCC(G,target_weight) == 1) 5500 { 5501 endwalks = TRUE; 5502 }*/ 5852 #endif 5503 5853 if(reduction == 0) 5504 5854 { 5505 5506 5855 FF = middleOfCone(G,Gomega); 5507 5508 5856 if(FF != NULL) 5509 5857 { … … 5511 5859 G = idCopy(FF); 5512 5860 idDelete(&FF); 5513 5514 5861 goto NEXT_VECTOR; 5515 5862 } … … 5541 5888 { 5542 5889 newRing = VMrDefault(curr_weight); // define a new ring with ordering "(a(curr_weight),lp) 5543 //newRing = VMrRefine(curr_weight,target_weight); //define a new ring with ordering "(a(curr_weight),Wp(target_weight))"5544 5890 } 5545 5891 else … … 5555 5901 to = clock(); 5556 5902 #endif 5557 #ifndef 5903 #ifndef BUCHBERGER_ALG 5558 5904 M=kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight); 5559 5905 delete hilb_func; … … 5565 5911 #endif 5566 5912 idSkipZeroes(M); 5567 //#ifdef CHECK_IDEAL_MWALK5913 #ifdef CHECK_IDEAL_MWALK 5568 5914 if(printout > 2) 5569 5915 { 5570 5916 idString(M, "//** Mrwalk: M"); 5571 5917 } 5572 //#endif5918 #endif 5573 5919 //change the ring to baseRing 5574 5920 rChangeCurrRing(baseRing); … … 5586 5932 tlift = tlift + clock() - to; 5587 5933 #endif 5588 //#ifdef CHECK_IDEAL_MWALK5934 #ifdef CHECK_IDEAL_MWALK 5589 5935 if(printout > 2) 5590 5936 { 5591 idString(F, 5592 } 5593 //#endif5937 idString(F,"//** Mrwalk: F"); 5938 } 5939 #endif 5594 5940 idDelete(&Gomega2); 5595 5941 idDelete(&M1); … … 5603 5949 #endif 5604 5950 idSkipZeroes(G); 5605 //#ifdef CHECK_IDEAL_MWALK5951 #ifdef CHECK_IDEAL_MWALK 5606 5952 if(printout > 2) 5607 5953 { 5608 idString(G, 5609 } 5610 //#endif5954 idString(G,"//** Mrwalk: G"); 5955 } 5956 #endif 5611 5957 5612 5958 rChangeCurrRing(targetRing); 5613 5959 G = idrMoveR(G,newRing,currRing); 5960 5614 5961 // test whether target cone is reached 5615 5962 if(reduction !=0 && test_w_in_ConeCC(G,curr_weight) == 1) … … 5623 5970 baseRing = currRing; 5624 5971 5625 5626 5972 NEXT_VECTOR: 5627 5973 #ifdef TIME_TEST … … 5629 5975 #endif 5630 5976 next_weight = MwalkNextWeightCC(curr_weight,target_weight,G); 5631 if(polylength > 0) 5977 #ifdef TIME_TEST 5978 tnw = tnw + clock() - to; 5979 #endif 5980 5981 #ifdef TIME_TEST 5982 to = clock(); 5983 #endif 5984 Gomega = MwalkInitialForm(G, next_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector" 5985 #ifdef TIME_TEST 5986 tif = tif + clock()-to; //time for computing initial form ideal 5987 #endif 5988 5989 //lengthpoly(Gomega) = 1 if there is a polynomial in Gomega with at least 3 monomials and 0 otherwise 5990 //polylength = lengthpoly(Gomega); 5991 if(lengthpoly(Gomega) > 0) 5632 5992 { 5633 5993 //there is a polynomial in Gomega with at least 3 monomials, 5634 5994 //low-dimensional facet of the cone 5635 5995 delete next_weight; 5636 next_weight = MWalkRandomNextWeight(G, curr_weight, target_weight, weight_rad, pert_deg); 5637 } 5638 #ifdef TIME_TEST 5639 tnw = tnw + clock() - to; 5640 #endif 5641 //#ifdef PRINT_VECTORS 5996 if(target_M->length() == nV) 5997 { 5998 iv_M = MivMatrixOrder(curr_weight); 5999 } 6000 else 6001 { 6002 iv_M = MivMatrixOrderRefine(curr_weight,target_M); 6003 } 6004 #ifdef TIME_TEST 6005 to = clock(); 6006 #endif 6007 next_weight = MWalkRandomNextWeight(G, iv_M, target_weight, weight_rad, pert_deg); 6008 #ifdef TIME_TEST 6009 tnw = tnw + clock() - to; 6010 #endif 6011 idDelete(&Gomega); 6012 #ifdef TIME_TEST 6013 to = clock(); 6014 #endif 6015 Gomega = MwalkInitialForm(G, next_weight); 6016 #ifdef TIME_TEST 6017 tif = tif + clock()-to; //time for computing initial form ideal 6018 #endif 6019 delete iv_M; 6020 } 6021 6022 // test whether target weight vector is reached 6023 if(MivComp(next_weight, ivNull) == 1 || MivComp(target_weight,curr_weight) == 1) 6024 { 6025 baseRing = currRing; 6026 delete next_weight; 6027 break; 6028 } 6029 6030 #ifdef PRINT_VECTORS 5642 6031 if(printout > 0) 5643 6032 { 5644 6033 MivString(curr_weight, target_weight, next_weight); 5645 6034 } 5646 //#endif 5647 if(MivComp(next_weight, ivNull) == 1 || MivComp(target_weight,curr_weight) == 1)// || endwalks == TRUE) 5648 {/* 5649 //#ifdef CHECK_IDEAL_MWALK 5650 if(printout > 0) 5651 { 5652 PrintS("\n//** Mrwalk: entering last cone.\n"); 5653 } 5654 //#endif 5655 5656 Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector" 5657 if(target_M->length() == nV) 5658 { 5659 newRing = VMrDefault(target_weight); // define a new ring with ordering "(a(curr_weight),lp) 5660 } 5661 else 5662 { 5663 newRing = VMatrDefault(target_M); 5664 } 5665 rChangeCurrRing(newRing); 5666 Gomega1 = idrMoveR(Gomega, baseRing,currRing); 5667 idDelete(&Gomega); 5668 //#ifdef CHECK_IDEAL_MWALK 5669 if(printout > 1) 5670 { 5671 idString(Gomega1, "//** Mrwalk: Gomega"); 5672 } 5673 PrintS("\n //** Mrwalk: kStd(Gomega)"); 5674 //#endif 5675 M = kStd(Gomega1,NULL,testHomog,NULL,NULL,0,0,NULL); 5676 //#ifdef CHECK_IDEAL_MWALK 5677 if(printout > 1) 5678 { 5679 idString(M,"//** Mrwalk: M"); 5680 } 5681 //#endif 5682 rChangeCurrRing(baseRing); 5683 M1 = idrMoveR(M, newRing,currRing); 5684 idDelete(&M); 5685 Gomega2 = idrMoveR(Gomega1, newRing,currRing); 5686 idDelete(&Gomega1); 5687 //PrintS("\n //** Mrwalk: MLifttwoIdeal"); 5688 F = MLifttwoIdeal(Gomega2, M1, G); 5689 //#ifdef CHECK_IDEAL_MWALK 5690 if(printout > 2) 5691 { 5692 idString(F,"//** Mrwalk: F"); 5693 } 5694 //#endif 5695 idDelete(&Gomega2); 5696 idDelete(&M1); 5697 rChangeCurrRing(newRing); // change the ring to newRing 5698 G = idrMoveR(F,baseRing,currRing); 5699 idDelete(&F); 5700 baseRing = currRing; 5701 si_opt_1 = save1; //set original options, e. g. option(RedSB) 5702 idSkipZeroes(G); 5703 #ifdef TIME_TEST 5704 to = clock(); 5705 #endif 5706 //PrintS("\n //**Mrwalk: Interreduce"); 5707 //interreduce the Groebner basis <G> w.r.t. currRing 5708 //G = kInterRedCC(G,NULL); 5709 #ifdef TIME_TEST 5710 tred = tred + clock() - to; 5711 #endif 5712 idSkipZeroes(G); 5713 delete next_weight;*/ 5714 break; 5715 } 6035 #endif 5716 6036 5717 6037 for(i=nV-1; i>=0; i--) 5718 6038 { 5719 //(*tmp_weight)[i] = (*curr_weight)[i];5720 6039 (*curr_weight)[i] = (*next_weight)[i]; 5721 6040 } … … 5726 6045 ideal result = idrMoveR(G,baseRing,currRing); 5727 6046 idDelete(&G); 5728 si_opt_1 = save1; //set original options, e. g. option(RedSB)5729 //delete tmp_weight;5730 6047 delete ivNull; 5731 delete exivlp;5732 6048 #ifndef BUCHBERGER_ALG 5733 6049 delete last_omega; … … 5739 6055 //Print("\n// Overflow_Error? (%d)\n", Overflow_Error); 5740 6056 #endif 6057 si_opt_1 = save1; //set original options 5741 6058 return(result); 5742 6059 } 5743 5744 //unused5745 #if 05746 ideal Mwalk_tst(ideal Go, intvec* curr_weight, intvec* target_weight)5747 {5748 //clock_t tinput=clock();5749 //idString(Go,"Ginp");5750 int i, nV = currRing->N;5751 int nwalk=0, endwalks=0;5752 5753 ideal Gomega, M, F, Gomega1, Gomega2, M1, F1, G;5754 // ideal G1; ring endRing;5755 ring newRing, oldRing;5756 intvec* ivNull = new intvec(nV);5757 ring XXRing = currRing;5758 5759 intvec* tmp_weight = new intvec(nV);5760 for(i=nV-1; i>=0; i--)5761 {5762 (*tmp_weight)[i] = (*curr_weight)[i];5763 }5764 /* the monomial ordering of this current ring would be "dp" */5765 G = MstdCC(Go);5766 #ifndef BUCHBERGER_ALG5767 intvec* hilb_func;5768 #endif5769 /* to avoid (1,0,...,0) as the target vector */5770 intvec* last_omega = new intvec(nV);5771 for(i=nV-1; i>0; i--)5772 (*last_omega)[i] = 1;5773 (*last_omega)[0] = 10000;5774 5775 while(1)5776 {5777 nwalk ++;5778 //Print("\n// Entering the %d-th step:", nwalk);5779 //Print("\n// ring r[%d] = %s;", nwalk, rString(currRing));5780 idString(G,"G");5781 /* compute an initial form ideal of <G> w.r.t. "curr_vector" */5782 Gomega = MwalkInitialForm(G, curr_weight);5783 //ivString(curr_weight, "omega");5784 idString(Gomega,"Gw");5785 5786 #ifndef BUCHBERGER_ALG5787 if(isNolVector(curr_weight) == 0)5788 hilb_func = hFirstSeries(Gomega,NULL,NULL,curr_weight,currRing);5789 else5790 hilb_func = hFirstSeries(Gomega,NULL,NULL,last_omega,currRing);5791 #endif // BUCHBERGER_ALG5792 5793 5794 oldRing = currRing;5795 5796 /* define a new ring that its ordering is "(a(curr_weight),lp) */5797 VMrDefault(curr_weight);5798 newRing = currRing;5799 5800 Gomega1 = idrMoveR(Gomega, oldRing,currRing);5801 5802 /* compute a reduced Groebner basis of <Gomega> w.r.t. "newRing" */5803 #ifdef BUCHBERGER_ALG5804 M = MstdhomCC(Gomega1);5805 #else5806 M=kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight);5807 delete hilb_func;5808 #endif // BUCHBERGER_ALG5809 5810 idString(M,"M");5811 5812 /* change the ring to oldRing */5813 rChangeCurrRing(oldRing);5814 M1 = idrMoveR(M, newRing,currRing);5815 Gomega2 = idrMoveR(Gomega1, newRing,currRing);5816 5817 /* compute a representation of the generators of submod (M)5818 with respect to those of mod (Gomega).5819 Gomega is a reduced Groebner basis w.r.t. the current ring */5820 F = MLifttwoIdeal(Gomega2, M1, G);5821 idDelete(&M1);5822 idDelete(&Gomega2);5823 idDelete(&G);5824 idString(F,"F");5825 5826 /* change the ring to newRing */5827 rChangeCurrRing(newRing);5828 F1 = idrMoveR(F, oldRing,currRing);5829 5830 /* reduce the Groebner basis <G> w.r.t. new ring */5831 G = kInterRedCC(F1, NULL);5832 //idSkipZeroes(G);//done by kInterRed5833 idDelete(&F1);5834 idString(G,"G");5835 if(endwalks == 1)5836 break;5837 5838 /* compute a next weight vector */5839 intvec* next_weight = MkInterRedNextWeight(curr_weight,target_weight,G);5840 #ifdef PRINT_VECTORS5841 MivString(curr_weight, target_weight, next_weight);5842 #endif5843 5844 if(MivComp(next_weight, ivNull) == 1)5845 {5846 delete next_weight;5847 break;5848 }5849 if(MivComp(next_weight, target_weight) == 1)5850 endwalks = 1;5851 5852 for(i=nV-1; i>=0; i--)5853 (*tmp_weight)[i] = (*curr_weight)[i];5854 5855 /* 06.11.01 to free the memory: NOT Changed!!*/5856 for(i=nV-1; i>=0; i--)5857 (*curr_weight)[i] = (*next_weight)[i];5858 delete next_weight;5859 }5860 rChangeCurrRing(XXRing);5861 G = idrMoveR(G, newRing,currRing);5862 5863 delete tmp_weight;5864 delete ivNull;5865 PrintLn();5866 return(G);5867 }5868 #endif5869 6060 5870 6061 /**************************************************************/ … … 5880 6071 2) the changed perturbation walk algorithm with a decreased degree. 5881 6072 */ 5882 // use kStd, if nP = 0, else call LastGB6073 // if nP = 0 use kStd, else call LastGB 5883 6074 ideal Mpwalk(ideal Go, int op_deg, int tp_deg,intvec* curr_weight, 5884 6075 intvec* target_weight, int nP, int reduction, int printout) … … 5888 6079 { 5889 6080 si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis 5890 //si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions 5891 //si_opt_1|=(Sy_bit(OPT_REDTAIL)|Sy_bit(OPT_REDSB)); 6081 si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions 5892 6082 } 5893 6083 Set_Error(FALSE ); 5894 6084 Overflow_Error = FALSE; 5895 6085 //Print("// pSetm_Error = (%d)", ErrorCheck()); 5896 6086 #ifdef TIME_TEST 5897 6087 clock_t tinput, tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0; 5898 6088 xtextra=0; … … 5901 6091 5902 6092 clock_t tim; 5903 6093 #endif 5904 6094 nstep = 0; 5905 6095 int i, ntwC=1, ntestw=1, nV = currRing->N; 6096 6097 //check that perturbation degree is valid 6098 if(op_deg < 1 || tp_deg < 1 || op_deg > nV || tp_deg > nV) 6099 { 6100 Werror("Invalid perturbation degree.\n"); 6101 return NULL; 6102 } 6103 5906 6104 BOOLEAN endwalks = FALSE; 5907 5908 6105 ideal Gomega, M, F, FF, G, Gomega1, Gomega2, M1,F1,Eresult,ssG; 5909 6106 ring newRing, oldRing, TargetRing; … … 5927 6124 5928 6125 ring XXRing = currRing; 5929 6126 #ifdef TIME_TEST 5930 6127 to = clock(); 6128 #endif 5931 6129 // perturbs the original vector 5932 6130 if(MivComp(curr_weight, iv_dp) == 1) //rOrdStr(currRing) := "dp" 5933 6131 { 5934 6132 G = MstdCC(Go); 6133 #ifdef TIME_TEST 5935 6134 tostd = clock()-to; 6135 #endif 5936 6136 if(op_deg != 1){ 5937 6137 iv_M_dp = MivMatrixOrderdp(nV); … … 5950 6150 G = idrMoveR(Go, XXRing,currRing); 5951 6151 G = MstdCC(G); 6152 #ifdef TIME_TEST 5952 6153 tostd = clock()-to; 6154 #endif 5953 6155 if(op_deg != 1){ 5954 6156 iv_M_dp = MivMatrixOrder(curr_weight); … … 5986 6188 G = idrMoveR(ssG, TargetRing,currRing); 5987 6189 } 5988 if(printout > 0) 5989 { 5990 Print("\n//** Mpwalk: Perturbation Walk of degree (%d,%d):",op_deg,tp_deg); 5991 ivString(curr_weight, "//** Mpwalk: new current weight"); 5992 ivString(target_weight, "//** Mpwalk: new target weight"); 5993 } 6190 if(printout > 0) 6191 { 6192 Print("\n//** Mpwalk: Perturbation Walk of degree (%d,%d):",op_deg,tp_deg); 6193 #ifdef PRINT_VECTORS 6194 ivString(curr_weight, "//** Mpwalk: new current weight"); 6195 ivString(target_weight, "//** Mpwalk: new target weight"); 6196 #endif 6197 } 5994 6198 while(1) 5995 6199 { 5996 6200 nstep ++; 6201 #ifdef TIME_TEST 5997 6202 to = clock(); 6203 #endif 5998 6204 // compute an initial form ideal of <G> w.r.t. the weight vector 5999 6205 // "curr_weight" 6000 6206 Gomega = MwalkInitialForm(G, curr_weight); 6001 //#ifdef CHECK_IDEAL_MWALK 6207 #ifdef TIME_TEST 6208 tif = tif + clock()-to; 6209 #endif 6210 #ifdef CHECK_IDEAL_MWALK 6002 6211 if(printout > 1) 6003 6212 { 6004 6213 idString(Gomega,"//** Mpwalk: Gomega"); 6005 6214 } 6006 //#endif6215 #endif 6007 6216 if(reduction == 0 && nstep > 1) 6008 6217 { 6218 /* 6009 6219 // check whether weight vector is in the interior of the cone 6010 6220 while(1) … … 6017 6227 idDelete(&FF); 6018 6228 next_weight = MwalkNextWeightCC(curr_weight,target_weight,G); 6229 #ifdef PRINT_VECTORS 6019 6230 if(printout > 0) 6020 6231 { 6021 6232 MivString(curr_weight, target_weight, next_weight); 6022 6233 } 6234 #endif 6023 6235 } 6024 6236 else … … 6031 6243 } 6032 6244 Gomega = MwalkInitialForm(G, curr_weight); 6245 #ifdef CHECK_IDEAL_MWALK 6033 6246 if(printout > 1) 6034 6247 { 6035 6248 idString(Gomega,"//** Mpwalk: Gomega"); 6036 6249 } 6250 #endif 6251 } 6252 */ 6253 FF = middleOfCone(G,Gomega); 6254 if(FF != NULL) 6255 { 6256 idDelete(&G); 6257 G = idCopy(FF); 6258 idDelete(&FF); 6259 goto NEXT_VECTOR; 6037 6260 } 6038 6261 } … … 6042 6265 { 6043 6266 Print("\n// ring r%d = %s;\n", nstep, rString(currRing)); 6267 /* 6044 6268 idElements(G, "G"); 6045 6269 headidString(G, "G"); 6046 } 6047 #endif 6048 6049 tif = tif + clock()-to; 6270 */ 6271 } 6272 #endif 6050 6273 6051 6274 #ifndef BUCHBERGER_ALG … … 6071 6294 { 6072 6295 Print("\n// ring r%d = %s;\n", nstep, rString(currRing)); 6296 /* 6073 6297 idElements(Gomega1, "Gw"); 6074 6298 headidString(Gomega1, "headGw"); 6299 */ 6075 6300 PrintS("\n// compute a rGB of Gw:\n"); 6076 6077 6301 #ifndef BUCHBERGER_ALG 6078 6302 ivString(hilb_func, "w"); … … 6080 6304 } 6081 6305 #endif 6082 6306 #ifdef TIME_TEST 6083 6307 tim = clock(); 6084 6308 to = clock(); 6309 #endif 6085 6310 // compute a reduced Groebner basis of <Gomega> w.r.t. "newRing" 6086 6311 #ifdef BUCHBERGER_ALG … … 6090 6315 delete hilb_func; 6091 6316 #endif 6092 //#ifdef CHECK_IDEAL_MWALK 6093 if(printout > 2) 6094 { 6095 idString(M,"//** Mpwalk: M"); 6096 } 6097 //#endif 6098 6099 if(endwalks == TRUE){ 6317 6318 if(endwalks == TRUE) 6319 { 6320 #ifdef TIME_TEST 6100 6321 xtstd = xtstd+clock()-to; 6322 #endif 6101 6323 #ifdef ENDWALKS 6102 6324 Print("\n// time for the last std(Gw) = %.2f sec\n", … … 6105 6327 } 6106 6328 else 6329 { 6330 #ifdef TIME_TEST 6107 6331 tstd=tstd+clock()-to; 6108 6332 #endif 6333 } 6334 #ifdef CHECK_IDEAL_MWALK 6335 if(printout > 2) 6336 { 6337 idString(M,"//** Mpwalk: M"); 6338 } 6339 #endif 6109 6340 // change the ring to oldRing 6110 6341 rChangeCurrRing(oldRing); 6111 6342 M1 = idrMoveR(M, newRing,currRing); 6112 6343 Gomega2 = idrMoveR(Gomega1, newRing,currRing); 6113 6344 #ifdef TIME_TEST 6114 6345 to=clock(); 6346 #endif 6115 6347 /* compute a representation of the generators of submod (M) 6116 6348 with respect to those of mod (Gomega). 6117 6349 Gomega is a reduced Groebner basis w.r.t. the current ring */ 6118 6350 F = MLifttwoIdeal(Gomega2, M1, G); 6351 #ifdef TIME_TEST 6119 6352 if(endwalks == FALSE) 6120 6353 tlift = tlift+clock()-to; 6121 6354 else 6122 6355 xtlift=clock()-to; 6123 6124 //#ifdef CHECK_IDEAL_MWALK6356 #endif 6357 #ifdef CHECK_IDEAL_MWALK 6125 6358 if(printout > 2) 6126 6359 { 6127 6360 idString(F,"//** Mpwalk: F"); 6128 6361 } 6129 //#endif6362 #endif 6130 6363 6131 6364 idDelete(&M1); … … 6146 6379 PrintS("\n //** Mpwalk: reduce the Groebner basis.\n"); 6147 6380 } 6381 #ifdef TIME_TEST 6148 6382 to=clock(); 6383 #endif 6149 6384 G = kInterRedCC(F1, NULL); 6385 #ifdef TIME_TEST 6150 6386 if(endwalks == FALSE) 6151 6387 tred = tred+clock()-to; 6152 6388 else 6153 6389 xtred=clock()-to; 6390 #endif 6154 6391 idDelete(&F1); 6155 6392 } … … 6157 6394 break; 6158 6395 6396 NEXT_VECTOR: 6397 #ifdef TIME_TEST 6159 6398 to=clock(); 6399 #endif 6160 6400 // compute a next weight vector 6161 6401 next_weight = MkInterRedNextWeight(curr_weight,target_weight, G); 6402 #ifdef TIME_TEST 6162 6403 tnw=tnw+clock()-to; 6163 //#ifdef PRINT_VECTORS 6404 #endif 6405 #ifdef PRINT_VECTORS 6164 6406 if(printout > 0) 6165 6407 { 6166 6408 MivString(curr_weight, target_weight, next_weight); 6167 6409 } 6168 //#endif6410 #endif 6169 6411 6170 6412 if(Overflow_Error == TRUE) … … 6208 6450 TargetRing=currRing; 6209 6451 F1 = idrMoveR(G, newRing,currRing); 6210 #ifdef CHECK_IDEAL 6452 /* 6453 #ifdef CHECK_IDEAL_MWALK 6211 6454 headidString(G, "G"); 6212 6455 #endif 6213 6456 */ 6214 6457 6215 6458 // check whether the pertubed target vector stays in the correct cone … … 6289 6532 { 6290 6533 si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis 6291 //si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions 6292 //si_opt_1|=(Sy_bit(OPT_REDTAIL)|Sy_bit(OPT_REDSB)); 6534 si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions 6293 6535 } 6294 6536 Set_Error(FALSE); 6295 6537 Overflow_Error = FALSE; 6296 6538 //Print("// pSetm_Error = (%d)", ErrorCheck()); 6297 6539 #ifdef TIME_TEST 6298 6540 clock_t tinput, tostd, tif=0, tstd=0, tlift=0, tred=0, tnw=0; 6299 6541 xtextra=0; … … 6302 6544 6303 6545 clock_t tim; 6304 6546 #endif 6305 6547 nstep = 0; 6306 int i, ntwC=1, ntestw=1, polylength, nV = currRing->N; 6548 int i, ntwC=1, ntestw=1, nV = currRing->N; //polylength 6549 6550 //check that weight radius is valid 6551 if(weight_rad < 0) 6552 { 6553 Werror("Invalid radius.\n"); 6554 return NULL; 6555 } 6556 6557 //check that perturbation degree is valid 6558 if(op_deg < 1 || tp_deg < 1 || op_deg > nV || tp_deg > nV) 6559 { 6560 Werror("Invalid perturbation degree.\n"); 6561 return NULL; 6562 } 6563 6307 6564 BOOLEAN endwalks = FALSE; 6308 6565 6309 6566 ideal Gomega, M, F, FF, G, Gomega1, Gomega2, M1,F1,Eresult,ssG; 6310 6567 ring newRing, oldRing, TargetRing; 6568 intvec* iv_M; 6311 6569 intvec* iv_M_dp; 6312 6570 intvec* iv_M_lp; … … 6336 6594 ring XXRing = currRing; 6337 6595 6338 to = clock();6339 6596 // perturbs the original vector 6340 6597 if(orig_M->length() == nV) … … 6342 6599 if(MivComp(curr_weight, iv_dp) == 1) //rOrdStr(currRing) := "dp" 6343 6600 { 6601 #ifdef TIME_TEST 6602 to = clock(); 6603 #endif 6344 6604 G = MstdCC(Go); 6605 #ifdef TIME_TEST 6345 6606 tostd = clock()-to; 6607 #endif 6346 6608 if(op_deg != 1) 6347 6609 { … … 6359 6621 6360 6622 G = idrMoveR(Go, XXRing,currRing); 6623 #ifdef TIME_TEST 6624 to = clock(); 6625 #endif 6361 6626 G = MstdCC(G); 6627 #ifdef TIME_TEST 6362 6628 tostd = clock()-to; 6629 #endif 6363 6630 if(op_deg != 1) 6364 6631 { … … 6372 6639 rChangeCurrRing(VMatrDefault(orig_M)); 6373 6640 G = idrMoveR(Go, XXRing,currRing); 6641 #ifdef TIME_TEST 6642 to = clock(); 6643 #endif 6374 6644 G = MstdCC(G); 6645 #ifdef TIME_TEST 6375 6646 tostd = clock()-to; 6647 #endif 6376 6648 if(op_deg != 1) 6377 6649 { … … 6429 6701 ivString(target_weight, "//** Mprwalk: new target weight"); 6430 6702 } 6703 6704 #ifdef TIME_TEST 6705 to = clock(); 6706 #endif 6707 Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector" 6708 #ifdef TIME_TEST 6709 tif = tif + clock()-to; //time for computing initial form ideal 6710 #endif 6711 6431 6712 while(1) 6432 6713 { 6433 6714 nstep ++; 6434 to = clock(); 6435 // compute an initial form ideal of <G> w.r.t. the weight vector 6436 // "curr_weight" 6437 Gomega = MwalkInitialForm(G, curr_weight); 6438 polylength = lengthpoly(Gomega); 6439 //#ifdef CHECK_IDEAL_MWALK 6715 #ifdef CHECK_IDEAL_MWALK 6440 6716 if(printout > 1) 6441 6717 { 6442 6718 idString(Gomega,"//** Mprwalk: Gomega"); 6443 6719 } 6444 //#endif6720 #endif 6445 6721 6446 6722 if(reduction == 0 && nstep > 1) 6447 6723 { 6724 /* 6448 6725 // check whether weight vector is in the interior of the cone 6449 6726 while(1) … … 6456 6733 idDelete(&FF); 6457 6734 next_weight = MwalkNextWeightCC(curr_weight,target_weight,G); 6735 #ifdef PRINT_VECTORS 6458 6736 if(printout > 0) 6459 6737 { 6460 6738 MivString(curr_weight, target_weight, next_weight); 6461 6739 } 6740 #endif 6462 6741 } 6463 6742 else … … 6470 6749 } 6471 6750 Gomega = MwalkInitialForm(G, curr_weight); 6751 #ifdef CHECK_IDEAL_MWALK 6472 6752 if(printout > 1) 6473 6753 { 6474 6754 idString(Gomega,"//** Mprwalk: Gomega"); 6475 6755 } 6476 } 6756 #endif 6757 } 6758 */ 6759 FF = middleOfCone(G,Gomega); 6760 if(FF != NULL) 6761 { 6762 idDelete(&G); 6763 G = idCopy(FF); 6764 idDelete(&FF); 6765 goto NEXT_VECTOR; 6766 } 6477 6767 } 6478 6768 … … 6481 6771 { 6482 6772 Print("\n// ring r%d = %s;\n", nstep, rString(currRing)); 6773 /* 6483 6774 idElements(G, "G"); 6484 6775 headidString(G, "G"); 6485 } 6486 #endif 6487 6488 tif = tif + clock()-to; 6776 */ 6777 } 6778 #endif 6489 6779 6490 6780 #ifndef BUCHBERGER_ALG … … 6515 6805 { 6516 6806 Print("\n// ring r%d = %s;\n", nstep, rString(currRing)); 6807 /* 6517 6808 idElements(Gomega1, "Gw"); 6518 6809 headidString(Gomega1, "headGw"); 6810 */ 6519 6811 PrintS("\n// compute a rGB of Gw:\n"); 6520 6812 … … 6524 6816 } 6525 6817 #endif 6526 6818 #ifdef TIME_TEST 6527 6819 tim = clock(); 6528 6820 to = clock(); 6821 #endif 6529 6822 // compute a reduced Groebner basis of <Gomega> w.r.t. "newRing" 6530 6823 #ifdef BUCHBERGER_ALG … … 6534 6827 delete hilb_func; 6535 6828 #endif 6536 //#ifdef CHECK_IDEAL_MWALK6829 #ifdef CHECK_IDEAL_MWALK 6537 6830 if(printout > 2) 6538 6831 { 6539 6832 idString(M,"//** Mprwalk: M"); 6540 6833 } 6541 //#endif6542 6834 #endif 6835 #ifdef TIME_TEST 6543 6836 if(endwalks == TRUE) 6544 6837 { … … 6551 6844 else 6552 6845 tstd=tstd+clock()-to; 6553 6846 #endif 6554 6847 /* change the ring to oldRing */ 6555 6848 rChangeCurrRing(oldRing); 6556 6849 M1 = idrMoveR(M, newRing,currRing); 6557 6850 Gomega2 = idrMoveR(Gomega1, newRing,currRing); 6558 6851 #ifdef TIME_TEST 6559 6852 to=clock(); 6853 #endif 6560 6854 /* compute a representation of the generators of submod (M) 6561 6855 with respect to those of mod (Gomega). 6562 6856 Gomega is a reduced Groebner basis w.r.t. the current ring */ 6563 6857 F = MLifttwoIdeal(Gomega2, M1, G); 6858 #ifdef TIME_TEST 6564 6859 if(endwalks == FALSE) 6565 6860 tlift = tlift+clock()-to; 6566 6861 else 6567 6862 xtlift=clock()-to; 6568 6569 //#ifdef CHECK_IDEAL_MWALK6863 #endif 6864 #ifdef CHECK_IDEAL_MWALK 6570 6865 if(printout > 2) 6571 6866 { 6572 6867 idString(F,"//** Mprwalk: F"); 6573 6868 } 6574 //#endif6869 #endif 6575 6870 6576 6871 idDelete(&M1); … … 6591 6886 PrintS("\n //** Mprwalk: reduce the Groebner basis.\n"); 6592 6887 } 6888 #ifdef TIME_TEST 6593 6889 to=clock(); 6890 #endif 6594 6891 G = kInterRedCC(F1, NULL); 6892 #ifdef TIME_TEST 6595 6893 if(endwalks == FALSE) 6596 6894 tred = tred+clock()-to; 6597 6895 else 6598 6896 xtred=clock()-to; 6897 #endif 6599 6898 idDelete(&F1); 6600 6899 } … … 6603 6902 break; 6604 6903 6904 NEXT_VECTOR: 6905 #ifdef TIME_TEST 6906 to = clock(); 6907 #endif 6908 next_weight = next_weight = MkInterRedNextWeight(curr_weight,target_weight, G); 6909 #ifdef TIME_TEST 6910 tnw = tnw + clock() - to; 6911 #endif 6912 6913 #ifdef TIME_TEST 6914 to = clock(); 6915 #endif 6916 // compute an initial form ideal of <G> w.r.t. "next_vector" 6917 Gomega = MwalkInitialForm(G, next_weight); 6918 #ifdef TIME_TEST 6919 tif = tif + clock()-to; //time for computing initial form ideal 6920 #endif 6921 6922 //lengthpoly(Gomega) = 1 if there is a polynomial in Gomega with at least 3 monomials and 0 otherwise 6923 if(lengthpoly(Gomega) > 0) 6924 { 6925 Print("\n there is a polynomial in Gomega with at least 3 monomials,\n"); 6926 // low-dimensional facet of the cone 6927 delete next_weight; 6928 if(target_M->length() == nV) 6929 { 6930 iv_M = MivMatrixOrder(curr_weight); 6931 } 6932 else 6933 { 6934 iv_M = MivMatrixOrderRefine(curr_weight,target_M); 6935 } 6936 #ifdef TIME_TEST 6937 to = clock(); 6938 #endif 6939 next_weight = MWalkRandomNextWeight(G, iv_M, target_weight, weight_rad, op_deg); 6940 #ifdef TIME_TEST 6941 tnw = tnw + clock() - to; 6942 #endif 6943 idDelete(&Gomega); 6944 #ifdef TIME_TEST 6945 to = clock(); 6946 #endif 6947 Gomega = MwalkInitialForm(G, next_weight); 6948 #ifdef TIME_TEST 6949 tif = tif + clock()-to; //time for computing initial form ideal 6950 #endif 6951 Print("delete\n"); 6952 delete iv_M; 6953 } 6954 6955 /* 6605 6956 to=clock(); 6606 6607 6957 next_weight = MkInterRedNextWeight(curr_weight,target_weight, G); 6608 6958 if(polylength > 0) … … 6616 6966 } 6617 6967 tnw=tnw+clock()-to; 6618 //#ifdef PRINT_VECTORS 6968 */ 6969 #ifdef PRINT_VECTORS 6619 6970 if(printout > 0) 6620 6971 { 6621 6972 MivString(curr_weight, target_weight, next_weight); 6622 6973 } 6623 //#endif6974 #endif 6624 6975 6625 6976 if(Overflow_Error == TRUE) 6626 6977 { 6627 6978 ntwC = 0; 6628 //ntestomega = 1;6629 6979 //Print("\n// ring r%d = %s;\n", nstep, rString(currRing)); 6630 6980 //idElements(G, "G"); … … 6645 6995 6646 6996 delete next_weight; 6647 }// while6997 }// end of while-loop 6648 6998 6649 6999 if(tp_deg != 1) … … 6669 7019 TargetRing=currRing; 6670 7020 F1 = idrMoveR(G, newRing,currRing); 6671 #ifdef CHECK_IDEAL6672 headidString(G, "G");6673 #endif6674 7021 6675 7022 // check whether the pertubed target vector stays in the correct cone … … 6682 7029 if(ntestw != 1 && printout > 2) 6683 7030 { 7031 #ifdef PRINT_VECTORS 6684 7032 ivString(pert_target_vector, "tau"); 7033 #endif 6685 7034 PrintS("\n// **Mprwalk: perturbed target vector doesn't stay in cone."); 6686 7035 Print("\n// ring r%d = %s;\n", nstep, rString(currRing)); … … 6688 7037 } 6689 7038 // LastGB is "better" than the kStd subroutine 7039 #ifdef TIME_TEST 6690 7040 to=clock(); 7041 #endif 6691 7042 ideal eF1; 6692 7043 if(nP == 0 || tp_deg == 1 || MivSame(orig_target, exivlp) != 1 || target_M->length() != nV) … … 6710 7061 F2=NULL; 6711 7062 } 7063 #ifdef TIME_TEST 6712 7064 xtextra=clock()-to; 7065 #endif 6713 7066 ring exTargetRing = currRing; 6714 7067 … … 6716 7069 Eresult = idrMoveR(eF1, exTargetRing,currRing); 6717 7070 } 6718 else{ 7071 else 7072 { 6719 7073 rChangeCurrRing(XXRing); 6720 7074 Eresult = idrMoveR(F1, TargetRing,currRing); 6721 7075 } 6722 7076 } 6723 else { 7077 else 7078 { 6724 7079 rChangeCurrRing(XXRing); 6725 7080 Eresult = idrMoveR(G, newRing,currRing); … … 6786 7141 intvec* hilb_func; 6787 7142 #endif 6788 //intvec* extXtau;7143 //intvec* extXtau; 6789 7144 intvec* next_vect; 6790 7145 intvec* omega2 = new intvec(nV); … … 6835 7190 nwalks ++; 6836 7191 NEXT_VECTOR_FRACTAL: 7192 #ifdef TIME_TEST 6837 7193 to=clock(); 7194 #endif 6838 7195 // determine the next border 6839 7196 next_vect = MkInterRedNextWeight(omega,omega2,G); 7197 #ifdef TIME_TEST 6840 7198 xtnw=xtnw+clock()-to; 6841 7199 #endif 6842 7200 oRing = currRing; 6843 7201 … … 6897 7255 6898 7256 delete next_vect; 7257 #ifdef TIME_TEST 6899 7258 to=clock(); 6900 7259 #endif 6901 7260 // to avoid the value of Overflow_Error that occur in Mfpertvector 6902 7261 Overflow_Error = FALSE; 6903 7262 next_vect = MkInterRedNextWeight(omega,omega2,G); 7263 #ifdef TIME_TEST 6904 7264 xtnw=xtnw+clock()-to; 7265 #endif 6905 7266 }// end of (if MivComp(next_vect, omega2) == 1) 6906 7267 6907 //#ifdef PRINT_VECTORS7268 #ifdef PRINT_VECTORS 6908 7269 if(printout > 0) 6909 7270 { 6910 7271 MivString(omega, omega2, next_vect); 6911 7272 } 6912 //#endif7273 #endif 6913 7274 6914 7275 // check whether the the computed vector is in the correct cone. … … 6938 7299 rString(currRing)); 6939 7300 } 7301 #ifdef TIME_TEST 6940 7302 to=clock(); 7303 #endif 6941 7304 Gt = idrMoveR(G, oRing,currRing); 6942 7305 G1 = MstdCC(Gt); 7306 #ifdef TIME_TEST 6943 7307 xtextra=xtextra+clock()-to; 7308 #endif 6944 7309 Gt = NULL; 6945 7310 … … 6957 7322 return (G1); 6958 7323 } 6959 6960 7324 6961 7325 /* If the perturbed target vector stays in the correct cone, … … 7045 7409 rString(currRing)); 7046 7410 } 7411 #ifdef TIME_TEST 7047 7412 to=clock(); 7413 #endif 7048 7414 G = MstdCC(Gt); 7415 #ifdef TIME_TEST 7049 7416 xtextra=xtextra+clock()-to; 7050 7417 #endif 7051 7418 oRing = currRing; 7052 7419 … … 7109 7476 } 7110 7477 delete next_vect; 7111 7478 #ifdef TIME_TEST 7112 7479 to=clock(); 7480 #endif 7113 7481 // Take the initial form of <G> w.r.t. omega 7114 7482 Gomega = MwalkInitialForm(G, omega); 7483 #ifdef TIME_TEST 7115 7484 xtif=xtif+clock()-to; 7485 #endif 7486 #ifdef CHECK_IDEAL_MWALK 7116 7487 if(printout > 1) 7117 7488 { 7118 7489 idString(Gomega,"//** rec_fractal_call: Gomega"); 7119 7490 } 7120 7491 #endif 7121 7492 if(reduction == 0) 7122 7493 { … … 7163 7534 Print("\n//** rec_fractal_call: Maximal recursion depth.\n"); 7164 7535 } 7165 7536 #ifdef TIME_TEST 7166 7537 to=clock(); 7538 #endif 7167 7539 #ifdef BUCHBERGER_ALG 7168 7540 Gresult = MstdhomCC(Gomega1); … … 7171 7543 delete hilb_func; 7172 7544 #endif 7545 #ifdef TIME_TEST 7173 7546 xtstd=xtstd+clock()-to; 7547 #endif 7174 7548 } 7175 7549 else … … 7179 7553 Gresult = rec_fractal_call(idCopy(Gomega1),nlev+1,omega,reduction,printout); 7180 7554 } 7555 #ifdef CHECK_IDEAL_MWALK 7181 7556 if(printout > 2) 7182 7557 { 7183 7558 idString(Gresult,"//** rec_fractal_call: M"); 7184 7559 } 7560 #endif 7185 7561 //convert a Groebner basis from a ring to another ring 7186 7562 new_ring = currRing; … … 7189 7565 Gresult1 = idrMoveR(Gresult, new_ring,currRing); 7190 7566 Gomega2 = idrMoveR(Gomega1, new_ring,currRing); 7191 7567 #ifdef TIME_TEST 7192 7568 to=clock(); 7569 #endif 7193 7570 // Lifting process 7194 7571 F = MLifttwoIdeal(Gomega2, Gresult1, G); 7572 #ifdef TIME_TEST 7195 7573 xtlift=xtlift+clock()-to; 7574 #endif 7575 #ifdef CHECK_IDEAL_MWALK 7196 7576 if(printout > 2) 7197 7577 { 7198 7578 idString(F,"//** rec_fractal_call: F"); 7199 7579 } 7580 #endif 7200 7581 idDelete(&Gresult1); 7201 7582 idDelete(&Gomega2); … … 7203 7584 7204 7585 rChangeCurrRing(new_ring); 7205 //F1 = idrMoveR(F, oRing,currRing);7206 7586 G = idrMoveR(F,oRing,currRing); 7587 /* 7588 F1 = idrMoveR(F, oRing,currRing); 7589 #ifdef TIME_TEST 7207 7590 to=clock(); 7591 #endif 7208 7592 // Interreduce G 7209 // G = kInterRedCC(F1, NULL); 7593 G = kInterRedCC(F1, NULL); 7594 #ifdef TIME_TEST 7210 7595 xtred=xtred+clock()-to; 7211 //idDelete(&F1); 7596 #endif 7597 idDelete(&F1); 7598 */ 7212 7599 } 7213 7600 } … … 7222 7609 //Print("\n\n// Entering the %d-th recursion:", nlev); 7223 7610 7224 int i, polylength, nV = currRing->N;7611 int nwalks = 0,i,nV=currRing->N;//polylength 7225 7612 ring new_ring, testring; 7226 7613 //ring extoRing; 7227 7614 ideal Gomega, Gomega1, Gomega2, F, FF, F1, Gresult, Gresult1, G1, Gt; 7228 int nwalks = 0;7229 7615 intvec* Mwlp; 7230 7616 #ifndef BUCHBERGER_ALG … … 7233 7619 // intvec* extXtau; 7234 7620 intvec* next_vect; 7621 intvec* iv_M; 7235 7622 intvec* omega2 = new intvec(nV); 7236 7623 intvec* omtmp = new intvec(nV); … … 7282 7669 nwalks ++; 7283 7670 NEXT_VECTOR_FRACTAL: 7671 #ifdef TIME_TEST 7284 7672 to=clock(); 7673 #endif 7285 7674 /* determine the next border */ 7286 7675 next_vect = MkInterRedNextWeight(omega,omega2,G); 7287 if(polylength > 0 && G->m[0] != NULL) 7288 { 7289 7290 PrintS("\n**// rec_r_fractal_call: there is a polynomial in Gomega with at least 3 monomials, low-dimensional facet of the cone.\n"); 7291 7676 #ifdef TIME_TEST 7677 xtnw=xtnw+clock()-to; 7678 #endif 7679 if(lengthpoly(MwalkInitialForm(G, next_vect)) > 0 && G->m[0] != NULL) 7680 { 7681 if(printout > 0) 7682 { 7683 PrintS("\n**// rec_r_fractal_call: there is a polynomial in Gomega with at least 3 monomials.\n"); 7684 } 7292 7685 delete next_vect; 7293 next_vect = MWalkRandomNextWeight(G,omega,omega2,weight_rad,nlev); 7294 if(isNegNolVector(next_vect)==1) 7686 iv_M = MivMatrixOrder(omega); 7687 #ifdef TIME_TEST 7688 to=clock(); 7689 #endif 7690 next_vect = MWalkRandomNextWeight(G,iv_M,omega2,weight_rad,nlev); 7691 #ifdef TIME_TEST 7692 xtnw=xtnw+clock()-to; 7693 #endif 7694 if(isNegNolVector(next_vect) == 1) 7295 7695 { 7296 7696 delete next_vect; 7697 #ifdef TIME_TEST 7698 to=clock(); 7699 #endif 7297 7700 next_vect = MkInterRedNextWeight(omega,omega2,G); 7298 } 7299 } 7300 xtnw=xtnw+clock()-to; 7301 7701 #ifdef TIME_TEST 7702 xtnw=xtnw+clock()-to; 7703 #endif 7704 } 7705 } 7302 7706 oRing = currRing; 7303 7707 … … 7354 7758 delete Mwlp; 7355 7759 7356 for(i=nV-1; i>=0; i--) { 7760 for(i=nV-1; i>=0; i--) 7761 { 7357 7762 (*omega2)[i] = (*Xtau)[nV+i]; 7358 7763 (*omega)[i] = (*Xsigma)[nV+i]; … … 7360 7765 7361 7766 delete next_vect; 7767 7768 //to avoid the value of Overflow_Error that occur in Mfpertvector 7769 Overflow_Error = FALSE; 7770 #ifdef TIME_TEST 7362 7771 to=clock(); 7363 7364 /* 7365 to avoid the value of Overflow_Error that occur in 7366 Mfpertvector 7367 */ 7368 Overflow_Error = FALSE; 7369 7772 #endif 7370 7773 next_vect = MkInterRedNextWeight(omega,omega2,G); 7371 if(G->m[0] != NULL && polylength > 0) 7774 #ifdef TIME_TEST 7775 xtnw=xtnw+clock()-to; 7776 #endif 7777 if(lengthpoly(MwalkInitialForm(G, next_vect)) > 0 && G->m[0] != NULL) 7372 7778 { 7373 7374 PrintS("//** rec_r_fractal_call: there is a polynomial in Gomega with at least 3 monomials, low-dimensional facet of the cone"); 7375 7779 // there is a polynomial in Gomega with at least 3 monomials 7780 iv_M = MivMatrixOrder(omega); 7376 7781 delete next_vect; 7377 next_vect = MWalkRandomNextWeight(G,omega,omega2,weight_rad,nlev); 7378 if(isNegNolVector(next_vect)==1) 7782 #ifdef TIME_TEST 7783 to=clock(); 7784 #endif 7785 next_vect = MWalkRandomNextWeight(G,iv_M,omega2,weight_rad,nlev); 7786 #ifdef TIME_TEST 7787 xtnw=xtnw+clock()-to; 7788 #endif 7789 delete iv_M; 7790 if(isNegNolVector(next_vect) == 1) 7379 7791 { 7380 7792 delete next_vect; 7793 #ifdef TIME_TEST 7794 to=clock(); 7795 #endif 7381 7796 next_vect = MkInterRedNextWeight(omega,omega2,G); 7797 #ifdef TIME_TEST 7798 xtnw=xtnw+clock()-to; 7799 #endif 7382 7800 } 7383 7801 } 7384 xtnw=xtnw+clock()-to; 7385 } 7386 //#ifdef PRINT_VECTORS 7802 } 7803 #ifdef PRINT_VECTORS 7387 7804 if(printout > 0) 7388 7805 { 7389 7806 MivString(omega, omega2, next_vect); 7390 7807 } 7391 //#endif7392 7393 /*check whether the the computed vector is in the correct cone7808 #endif 7809 7810 /* check whether the the computed vector is in the correct cone 7394 7811 If no, the reduced GB of an omega-homogeneous ideal will be 7395 computed by Buchberger algorithm and stop this recursion step */7396 //if(test_w_in_ConeCC(G, next_vect) != 1) //e.g. Example s7, cyc6 7397 if(Overflow_Error == TRUE || test_w_in_ConeCC(G,next_vect) != 1) 7812 computed by Buchberger algorithm and stop this recursion step 7813 */ 7814 if(Overflow_Error == TRUE || test_w_in_ConeCC(G,next_vect) != 1)//e.g. Example s7, cyc6 7398 7815 { 7399 7816 delete next_vect; … … 7423 7840 rString(currRing)); 7424 7841 } 7842 Gt = idrMoveR(G, oRing,currRing); 7843 #ifdef TIME_TEST 7425 7844 to=clock(); 7426 Gt = idrMoveR(G, oRing,currRing); 7845 #endif 7427 7846 G1 = MstdCC(Gt); 7847 #ifdef TIME_TEST 7428 7848 xtextra=xtextra+clock()-to; 7849 #endif 7429 7850 Gt = NULL; 7430 7851 … … 7487 7908 7488 7909 #ifndef MSTDCC_FRACTAL 7489 //ivString(Xtau, "old Xtau"); 7910 #ifdef PRINT_VECTORS 7911 if(printout > 0) 7912 { 7913 ivString(Xtau, "old Xtau"); 7914 } 7915 #endif 7490 7916 intvec* Xtautmp; 7491 7917 if(ivtarget->length() == nV) … … 7511 7937 Xtau = Xtautmp; 7512 7938 Xtautmp = NULL; 7513 //ivString(Xtau, "new Xtau"); 7939 #ifdef PRINT_VECTORS 7940 if(printout > 0) 7941 { 7942 ivString(Xtau, "new Xtau"); 7943 } 7944 #endif 7514 7945 7515 7946 for(i=nV-1; i>=0; i--) … … 7529 7960 rString(currRing)); 7530 7961 } 7962 #ifdef TIME_TEST 7531 7963 to=clock(); 7964 #endif 7532 7965 G = MstdCC(Gt); 7966 #ifdef TIME_TEST 7533 7967 xtextra=xtextra+clock()-to; 7534 7968 #endif 7535 7969 oRing = currRing; 7536 7970 … … 7594 8028 } 7595 8029 delete next_vect; 7596 8030 #ifdef TIME_TEST 7597 8031 to=clock(); 8032 #endif 7598 8033 // Take the initial form of <G> w.r.t. omega 7599 8034 Gomega = MwalkInitialForm(G, omega); 8035 #ifdef TIME_TEST 7600 8036 xtif=xtif+clock()-to; 8037 #endif 7601 8038 //polylength = 1 if there is a polynomial in Gomega with at least 3 monomials and 0 otherwise 7602 polylength = lengthpoly(Gomega); 8039 //polylength = lengthpoly(Gomega); 8040 #ifdef CHECK_IDEAL_MWALK 7603 8041 if(printout > 1) 7604 8042 { 7605 8043 idString(Gomega,"//** rec_r_fractal_call: Gomega"); 7606 8044 } 7607 8045 #endif 7608 8046 if(reduction == 0) 7609 8047 { … … 7645 8083 if(nlev == Xnlev || lengthpoly(Gomega1) == 0) 7646 8084 { 8085 #ifdef TIME_TEST 7647 8086 to=clock(); 8087 #endif 7648 8088 #ifdef BUCHBERGER_ALG 7649 8089 Gresult = MstdhomCC(Gomega1); … … 7652 8092 delete hilb_func; 7653 8093 #endif 8094 #ifdef TIME_TEST 7654 8095 xtstd=xtstd+clock()-to; 8096 #endif 7655 8097 } 7656 8098 else … … 7660 8102 Gresult = rec_r_fractal_call(idCopy(Gomega1),nlev+1,omega,weight_rad,reduction,printout); 7661 8103 } 8104 #ifdef CHECK_IDEAL_MWALK 7662 8105 if(printout > 2) 7663 8106 { 7664 8107 idString(Gresult,"//** rec_r_fractal_call: M"); 7665 8108 } 8109 #endif 7666 8110 //convert a Groebner basis from a ring to another ring 7667 8111 new_ring = currRing; … … 7670 8114 Gresult1 = idrMoveR(Gresult, new_ring,currRing); 7671 8115 Gomega2 = idrMoveR(Gomega1, new_ring,currRing); 7672 8116 #ifdef TIME_TEST 7673 8117 to=clock(); 8118 #endif 7674 8119 // Lifting process 7675 8120 F = MLifttwoIdeal(Gomega2, Gresult1, G); 8121 #ifdef TIME_TEST 7676 8122 xtlift=xtlift+clock()-to; 7677 8123 #endif 8124 #ifdef CHECK_IDEAL_MWALK 7678 8125 if(printout > 2) 7679 8126 { 7680 8127 idString(F,"//** rec_r_fractal_call: F"); 7681 8128 } 7682 8129 #endif 7683 8130 idDelete(&Gresult1); 7684 8131 idDelete(&Gomega2); … … 7688 8135 //F1 = idrMoveR(F, oRing,currRing); 7689 8136 G = idrMoveR(F,oRing,currRing); 8137 /* 8138 #ifdef TIME_TEST 7690 8139 to=clock(); 8140 #endif 7691 8141 // Interreduce G 7692 //G = kInterRedCC(F1, NULL); 8142 G = kInterRedCC(F1, NULL); 8143 #ifdef TIME_TEST 7693 8144 xtred=xtred+clock()-to; 7694 //idDelete(&F1); 8145 #endif 8146 idDelete(&F1); 8147 */ 7695 8148 } 7696 8149 } … … 7723 8176 Xngleich = 0; 7724 8177 Xcall = 0; 8178 #ifdef TIME_TEST 7725 8179 xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0; xtextra=0; 7726 8180 xftinput = clock(); 7727 8181 #endif 7728 8182 ring oldRing = currRing; 7729 8183 int i, nV = currRing->N; … … 7731 8185 Xivinput = ivtarget; 7732 8186 ngleich = 0; 8187 #ifdef TIME_TEST 7733 8188 to=clock(); 8189 #endif 7734 8190 ideal I = MstdCC(G); 7735 8191 G = NULL; 8192 #ifdef TIME_TEST 7736 8193 xftostd=clock()-to; 8194 #endif 7737 8195 Xsigma = ivstart; 7738 8196 … … 7829 8287 7830 8288 I = idrMoveR(I1,tRing,currRing); 8289 #ifdef TIME_TEST 7831 8290 to=clock(); 8291 #endif 7832 8292 ideal J = MstdCC(I); 7833 8293 idDelete(&I); 8294 #ifdef TIME_TEST 7834 8295 xftostd=xftostd+clock()-to; 7835 8296 #endif 7836 8297 ideal resF; 7837 8298 ring helpRing = currRing; … … 7875 8336 { 7876 8337 BITSET save1 = si_opt_1; // save current options 8338 //check that weight radius is valid 8339 if(weight_rad < 0) 8340 { 8341 Werror("Invalid radius.\n"); 8342 return NULL; 8343 } 7877 8344 if(reduction == 0) 7878 8345 { 7879 8346 si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis 7880 //si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions8347 si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions 7881 8348 } 7882 8349 Set_Error(FALSE); … … 7888 8355 Xngleich = 0; 7889 8356 Xcall = 0; 8357 #ifdef TIME_TEST 7890 8358 xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0; xtextra=0; 7891 8359 xftinput = clock(); 7892 8360 #endif 7893 8361 ring oldRing = currRing; 7894 8362 int i, nV = currRing->N; … … 7896 8364 Xivinput = ivtarget; 7897 8365 ngleich = 0; 8366 #ifdef TIME_TEST 7898 8367 to=clock(); 8368 #endif 7899 8369 ideal I = MstdCC(G); 7900 8370 G = NULL; 8371 #ifdef TIME_TEST 7901 8372 xftostd=clock()-to; 8373 #endif 7902 8374 Xsigma = ivstart; 7903 8375 … … 7994 8466 7995 8467 I = idrMoveR(I1,tRing,currRing); 8468 #ifdef TIME_TEST 7996 8469 to=clock(); 8470 #endif 7997 8471 ideal J = MstdCC(I); 7998 8472 idDelete(&I); 8473 #ifdef TIME_TEST 7999 8474 xftostd=xftostd+clock()-to; 8000 8475 #endif 8001 8476 ideal resF; 8002 8477 ring helpRing = currRing; … … 8219 8694 goto BE_FINISH; 8220 8695 #endif 8221 8696 /* 8222 8697 #ifdef CHECK_IDEAL_MWALK 8223 8698 idElements(G, "G"); 8224 8699 //headidString(G, "G"); 8225 8700 #endif 8226 8701 */ 8227 8702 if(MivSame(target_tmp, iv_lp) == 1) 8228 8703 if (rParameter(currRing) != NULL) … … 8958 9433 clock_t tinput=clock(); 8959 9434 int i, nV = currRing->N; 9435 9436 //check that perturbation degree is valid 9437 if(tp_deg < 1 || tp_deg > nV) 9438 { 9439 Werror("Invalid perturbation degree.\n"); 9440 return NULL; 9441 } 9442 8960 9443 int nwalk=0, endwalks=0, ntestwinC=1; 8961 9444 int tp_deg_tmp = tp_deg; … … 9067 9550 { 9068 9551 Print("\n// it is %d-th step!!", nwalk); 9069 id Elements(Gomega1, "Gw");9552 idString(Gomega1, "Gw"); 9070 9553 PrintS("\n// compute a rGB of Gw:"); 9071 9554 }
Note: See TracChangeset
for help on using the changeset viewer.