Changeset 1b0fdf in git for Singular/walk.cc
- Timestamp:
- May 6, 2015, 3:45:32 PM (9 years ago)
- Branches:
- (u'spielwiese', '2a584933abf2a2d3082034c7586d38bb6de1a30a')
- Children:
- 20357b2d3e79a043b31e25be30cdcf08dbc6b37e
- Parents:
- 07f91e61990361e7f50ab5976d0c92e77fbaf4ae
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/walk.cc
r07f91e r1b0fdf 512 512 } 513 513 514 //unused 515 //#if 0 514 516 static void MivString(intvec* iva, intvec* ivb, intvec* ivc) 515 517 { … … 534 536 Print("%d)", (*ivc)[nV]); 535 537 } 538 //#endif 536 539 537 540 /******************************************************************** … … 1103 1106 if(pdeg > nV || pdeg <= 0) 1104 1107 { 1105 WerrorS("//** MPertVectors:The perturbed degree is wrong!!");1108 WerrorS("//** The perturbed degree is wrong!!"); 1106 1109 return v_null; 1107 1110 } … … 1113 1116 } 1114 1117 mpz_t *pert_vector = (mpz_t*)omAlloc(nV*sizeof(mpz_t)); 1118 //mpz_t *pert_vector1 = (mpz_t*)omAlloc(nV*sizeof(mpz_t)); 1115 1119 1116 1120 for(i=0; i<nV; i++) … … 1119 1123 // mpz_init_set_si(pert_vector1[i], (*ivtarget)[i]); 1120 1124 } 1121 // C ompute max1 = Max(A2)+Max(A3)+...+Max(Apdeg),1125 // Calculate max1 = Max(A2)+Max(A3)+...+Max(Apdeg), 1122 1126 // where the Ai are the i-te rows of the matrix target_ord. 1123 1127 int ntemp, maxAi, maxA=0; … … 1144 1148 } 1145 1149 1146 // C ompute inveps = 1/eps, where 1/eps > totaldeg(p)*max1 for all p in G.1150 // Calculate inveps = 1/eps, where 1/eps > totaldeg(p)*max1 for all p in G. 1147 1151 1148 1152 intvec* ivUnit = Mivdp(nV); … … 1176 1180 } 1177 1181 #else 1178 PrintS("\n //**MPertVectors: the \"big\" inverse epsilon:");1182 // PrintS("\n// the \"big\" inverse epsilon: "); 1179 1183 mpz_out_str(stdout, 10, inveps); 1180 1184 #endif … … 1230 1234 if(j > nV - 1) 1231 1235 { 1232 // perturbed vector equals zero1236 // Print("\n// MPertVectors: geaenderter vector gleich Null! \n"); 1233 1237 delete pert_vector1; 1234 1238 goto CHECK_OVERFLOW; 1235 1239 } 1236 1240 1237 1241 // check that the perturbed weight vector lies in the Groebner cone 1238 1242 if(test_w_in_ConeCC(G,pert_vector1) != 0) 1239 1243 { 1244 // Print("\n// MPertVectors: geaenderter vector liegt in Groebnerkegel! \n"); 1240 1245 for(i=0; i<nV; i++) 1241 1246 { … … 1243 1248 } 1244 1249 } 1245 1250 else 1251 { 1252 //Print("\n// MpertVectors: geaenderter vector liegt nicht in Groebnerkegel! \n"); 1253 } 1246 1254 delete pert_vector1; 1247 1255 … … 1249 1257 intvec* result = new intvec(nV); 1250 1258 1251 / / 2147483647 is max. integer representation in SINGULAR1259 /* 2147483647 is max. integer representation in SINGULAR */ 1252 1260 mpz_t sing_int; 1253 1261 mpz_init_set_ui(sing_int, 2147483647); … … 1636 1644 { 1637 1645 mpz_divexact(pert_vector[i], pert_vector[i], ztmp); 1646 (* result)[i] = mpz_get_si(pert_vector[i]); 1647 } 1648 1649 j = 0; 1650 for(i=0; i<nV; i++) 1651 { 1638 1652 (* result1)[i] = mpz_get_si(pert_vector[i]); 1639 } 1640 j = 0; 1641 while(test_w_in_ConeCC(G,result1) && j<nV) 1642 { 1643 j = 0; 1653 (* result1)[i] = 0.1*(* result1)[i]; 1654 (* result1)[i] = floor((* result1)[i] + 0.5); 1655 if((* result1)[i] == 0) 1656 { 1657 j++; 1658 } 1659 } 1660 if(j > nV - 1) 1661 { 1662 // Print("\n// MfPertwalk: geaenderter vector gleich Null! \n"); 1663 delete result1; 1664 goto CHECK_OVERFLOW; 1665 } 1666 1667 // check that the perturbed weight vector lies in the Groebner cone 1668 if(test_w_in_ConeCC(G,result1) != 0) 1669 { 1670 // Print("\n// MfPertwalk: geaenderter vector liegt in Groebnerkegel! \n"); 1671 delete result; 1672 result = result1; 1644 1673 for(i=0; i<nV; i++) 1645 1674 { 1646 (* result)[i] = (* result1)[i];1647 1675 mpz_set_si(pert_vector[i], (*result1)[i]); 1648 (* result1)[i] = floor(0.1*(mpz_get_si(pert_vector[i])) + 0.5); 1649 if((* result1)[i] == 0) 1650 { 1651 j++; 1652 } 1653 } 1654 } 1655 delete result1; 1676 } 1677 } 1678 else 1679 { 1680 delete result1; 1681 // Print("\n// Mfpertwalk: geaenderter vector liegt nicht in Groebnerkegel! \n"); 1682 } 1656 1683 1657 1684 CHECK_OVERFLOW: … … 1960 1987 mpz_set_si(MwWd, MivDotProduct(ivtemp, curr_weight)); 1961 1988 mpz_sub(s_zaehler, deg_w0_p1, MwWd); 1962 1963 1989 if(mpz_cmp(s_zaehler, t_null) != 0) 1964 1990 { 1965 1991 mpz_set_si(MwWd, MivDotProduct(ivtemp, diff_weight)); 1966 1992 mpz_sub(s_nenner, MwWd, deg_d0_p1); 1967 1968 1993 // check for 0 < s <= 1 1969 1994 if( (mpz_cmp(s_zaehler,t_null) > 0 && … … 2278 2303 * define and execute a new ring which order is (a(vb),a(va),lp,C) * 2279 2304 * ******************************************************************/ 2280 #if 02281 // unused2282 2305 static void VMrHomogeneous(intvec* va, intvec* vb) 2283 2306 { … … 2357 2380 rChangeCurrRing(r); 2358 2381 } 2359 #endif 2382 2360 2383 2361 2384 /************************************************************** … … 2931 2954 int i,j,N = IDELEMS(Gomega); 2932 2955 poly p,lm,factor1,factor2; 2933 PrintS("\n//** idCopy\n");2956 //PrintS("\n//** idCopy\n"); 2934 2957 ideal Go = idCopy(G); 2935 2958 2936 PrintS("\n//** jetzt for-Loop!\n");2959 //PrintS("\n//** jetzt for-Loop!\n"); 2937 2960 for(i=0; i<N; i++) 2938 2961 { … … 2972 2995 if(middle == TRUE) 2973 2996 { 2974 PrintS("\n//** middle TRUE!\n");2997 //PrintS("\n//** middle TRUE!\n"); 2975 2998 return Go; 2976 2999 } 2977 PrintS("\n//** middle FALSE!\n");3000 //PrintS("\n//** middle FALSE!\n"); 2978 3001 idDelete(&Go); 2979 3002 return NULL; … … 4318 4341 assume(currRing != NULL && curr_weight != NULL && 4319 4342 target_weight != NULL && G->m[0] != NULL); 4320 //PrintS("\n //**MWalkRandomNextWeight: Anfang ok!\n"); 4321 int i,k,nV = currRing->N; 4322 long weight_norm; 4343 4344 int i,weight_norm,nV = currRing->N; 4323 4345 intvec* next_weight2; 4324 //intvec* next_weight22 = new intvec(nV);4346 intvec* next_weight22 = new intvec(nV); 4325 4347 intvec* result = new intvec(nV); 4326 ideal G_test;4327 ideal G_test2;4328 BOOLEAN random = FALSE;4329 4348 4330 4349 intvec* next_weight1 =MkInterRedNextWeight(curr_weight,target_weight,G); 4331 4350 //compute a random next weight vector "next_weight2" 4332 k = 1; 4333 while(k<4) 4334 { 4335 k++; 4351 while(1) 4352 { 4336 4353 weight_norm = 0; 4337 intvec* next_weight22 = new intvec(nV);4338 4354 while(weight_norm == 0) 4339 4355 { 4340 //PrintS("\nWhile WeightNorm\n"); 4356 4341 4357 for(i=0; i<nV; i++) 4342 4358 { 4343 (*next_weight22)[i] = rand() % 60000 ;4359 (*next_weight22)[i] = rand() % 60000 - 30000; 4344 4360 weight_norm = weight_norm + (*next_weight22)[i]*(*next_weight22)[i]; 4345 4361 } 4346 //Print("\n// weight_norm vor Wurzel = %d\n", weight_norm);4347 4362 weight_norm = 1 + floor(sqrt(weight_norm)); 4348 4349 } 4350 //Print("\n// weight_norm nach Wurzel = %d\n", weight_norm); 4363 } 4364 4351 4365 for(i=0; i<nV; i++) 4352 4366 { 4353 4367 if((*next_weight22)[i] < 0) 4354 4368 { 4355 (*next_weight22)[i] = 1 + (*curr_weight)[i] + floor( (weight_rad)*(*next_weight22)[i]/weight_norm);4369 (*next_weight22)[i] = 1 + (*curr_weight)[i] + floor(weight_rad*(*next_weight22)[i]/weight_norm); 4356 4370 } 4357 4371 else 4358 4372 { 4359 (*next_weight22)[i] = (*curr_weight)[i] + floor( (weight_rad)*(*next_weight22)[i]/weight_norm);4373 (*next_weight22)[i] = (*curr_weight)[i] + floor(weight_rad*(*next_weight22)[i]/weight_norm); 4360 4374 } 4361 4375 } … … 4363 4377 if(test_w_in_ConeCC(G, next_weight22) == 1) 4364 4378 { 4365 //PrintS("\n //** MWalkRandomNextWeight: test ob in Kegel.\n");4366 4379 next_weight2 = MkInterRedNextWeight(next_weight22,target_weight,G); 4367 4380 if(MivAbsMax(next_weight2)>1147483647) … … 4380 4393 } 4381 4394 } 4382 random = TRUE;4395 delete next_weight22; 4383 4396 break; 4384 4397 } 4385 delete next_weight22; 4386 } 4387 //PrintS("\n //**MWalkRandomNextWeight: Ende while-Schleife!\n"); 4388 4398 } 4399 4389 4400 // compute "usual" next weight vector 4390 4401 intvec* next_weight = MwalkNextWeightCC(curr_weight,target_weight, G); 4391 G_test = MwalkInitialForm(G, next_weight); 4392 if(random == TRUE) 4393 { 4394 G_test2 = MwalkInitialForm(G, next_weight2); 4395 } 4402 ideal G_test = MwalkInitialForm(G, next_weight); 4403 ideal G_test2 = MwalkInitialForm(G, next_weight2); 4404 4396 4405 // compare next weights 4397 4406 if(Overflow_Error == FALSE) 4398 4407 { 4399 4408 ideal G_test1 = MwalkInitialForm(G, next_weight1); 4400 if(G_test1->m[0] != NULL && maxlengthpoly(G_test1) < maxlengthpoly(G_test)) 4401 { 4402 if(random == TRUE && 4403 G_test2->m[0] != NULL && 4404 maxlengthpoly(G_test2) < maxlengthpoly(G_test1)) 4405 { 4409 if(G_test1->m[0] != NULL && maxlengthpoly(G_test1) < maxlengthpoly(G_test))//if(IDELEMS(G_test1) < IDELEMS(G_test)) 4410 { 4411 if(G_test2->m[0] != NULL && maxlengthpoly(G_test2) < maxlengthpoly(G_test1)) //if(IDELEMS(G_test2) < IDELEMS(G_test1)) 4412 { 4413 // |G_test2| < |G_test1| < |G_test| 4406 4414 for(i=0; i<nV; i++) 4407 4415 { … … 4411 4419 else 4412 4420 { 4421 // |G_test1| < |G_test|, |G_test1| <= |G_test2| 4413 4422 for(i=0; i<nV; i++) 4414 4423 { … … 4419 4428 else 4420 4429 { 4421 if(random == TRUE && 4422 G_test2->m[0] != NULL && 4423 maxlengthpoly(G_test2) < maxlengthpoly(G_test)) 4430 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| 4424 4431 { 4425 4432 for(i=0; i<nV; i++) … … 4430 4437 else 4431 4438 { 4439 // |G_test| < |G_test1|, |G_test| <= |G_test2| 4432 4440 for(i=0; i<nV; i++) 4433 4441 { … … 4441 4449 { 4442 4450 Overflow_Error = FALSE; 4443 if(random == TRUE && 4444 G_test2->m[0] != NULL && 4445 maxlengthpoly(G_test2) < maxlengthpoly(G_test)) 4451 if(G_test2->m[0] != NULL && maxlengthpoly(G_test2) < maxlengthpoly(G_test))//if(IDELEMS(G_test2) < IDELEMS(G_test)) 4446 4452 { 4447 4453 for(i=1; i<nV; i++) … … 4458 4464 } 4459 4465 } 4460 //PrintS("\n MWalkRandomNextWeight: Ende ok!\n");4466 PrintS("\n MWalkRandomNextWeight: Ende ok!\n"); 4461 4467 idDelete(&G_test); 4462 if(random == TRUE) 4463 { 4464 idDelete(&G_test2); 4465 } 4468 idDelete(&G_test2); 4466 4469 if(test_w_in_ConeCC(G, result) == 1) 4467 4470 { 4468 if(random == TRUE) 4469 { 4470 delete next_weight2; 4471 } 4471 delete next_weight2; 4472 4472 delete next_weight; 4473 4473 delete next_weight1; … … 4477 4477 { 4478 4478 delete result; 4479 if(random == TRUE) 4480 { 4481 delete next_weight2; 4482 } 4479 delete next_weight2; 4483 4480 delete next_weight1; 4484 4481 return next_weight; … … 5124 5121 } 5125 5122 //#endif 5126 5127 5128 5123 if(reduction == 0) 5129 5124 { … … 5140 5135 } 5141 5136 } 5142 5143 5137 #ifndef BUCHBERGER_ALG 5144 5138 if(isNolVector(curr_weight) == 0) … … 5262 5256 PrintS("\n//** Mwalk: entering last cone.\n"); 5263 5257 } 5258 if(reduction == 0) 5259 { 5260 if(MivComp(next_weight, ivNull) == 1 || MivComp(target_weight,curr_weight) == 1) 5261 { 5262 delete next_weight; 5263 baseRing = currRing; 5264 si_opt_1 = save1; //set original options, e. g. option(RedSB) 5265 break; 5266 } 5267 } 5268 else 5269 { 5264 5270 //#endif 5265 Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector"5266 if(target_M->length() == nV)5267 {5268 newRing = VMrDefault(target_weight); // define a new ring with ordering "(a(curr_weight),lp)5269 }5270 else5271 {5272 newRing = VMatrDefault(target_M);5273 }5274 rChangeCurrRing(newRing);5275 Gomega1 = idrMoveR(Gomega, baseRing,currRing);5276 idDelete(&Gomega);5271 Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector" 5272 if(target_M->length() == nV) 5273 { 5274 newRing = VMrDefault(target_weight); // define a new ring with ordering "(a(curr_weight),lp) 5275 } 5276 else 5277 { 5278 newRing = VMatrDefault(target_M); 5279 } 5280 rChangeCurrRing(newRing); 5281 Gomega1 = idrMoveR(Gomega, baseRing,currRing); 5282 idDelete(&Gomega); 5277 5283 //#ifdef CHECK_IDEAL_MWALK 5278 if(printout > 1)5279 {5280 idString(Gomega1, "//** Mwalk: Gomega");5281 }5282 PrintS("\n //** Mwalk: kStd(Gomega)");5284 if(printout > 1) 5285 { 5286 idString(Gomega1, "//** Mwalk: Gomega"); 5287 } 5288 PrintS("\n //** Mwalk: kStd(Gomega)"); 5283 5289 //#endif 5284 M = kStd(Gomega1,NULL,testHomog,NULL,NULL,0,0,NULL);5290 M = kStd(Gomega1,NULL,testHomog,NULL,NULL,0,0,NULL); 5285 5291 //#ifdef CHECK_IDEAL_MWALK 5286 if(printout > 1)5287 {5288 idString(M,"//** Mwalk: M");5289 }5292 if(printout > 1) 5293 { 5294 idString(M,"//** Mwalk: M"); 5295 } 5290 5296 //#endif 5291 rChangeCurrRing(baseRing);5292 M1 = idrMoveR(M, newRing,currRing);5293 idDelete(&M);5294 Gomega2 = idrMoveR(Gomega1, newRing,currRing);5295 idDelete(&Gomega1);5296 PrintS("\n //** Mwalk: MLifttwoIdeal");5297 F = MLifttwoIdeal(Gomega2, M1, G);5297 rChangeCurrRing(baseRing); 5298 M1 = idrMoveR(M, newRing,currRing); 5299 idDelete(&M); 5300 Gomega2 = idrMoveR(Gomega1, newRing,currRing); 5301 idDelete(&Gomega1); 5302 PrintS("\n //** Mwalk: MLifttwoIdeal"); 5303 F = MLifttwoIdeal(Gomega2, M1, G); 5298 5304 //#ifdef CHECK_IDEAL_MWALK 5299 if(printout > 2)5300 {5301 idString(F,"//** Mwalk: F");5302 }5305 if(printout > 2) 5306 { 5307 idString(F,"//** Mwalk: F"); 5308 } 5303 5309 //#endif 5304 idDelete(&Gomega2);5305 idDelete(&M1);5306 rChangeCurrRing(newRing); // change the ring to newRing5307 G = idrMoveR(F,baseRing,currRing);5308 idDelete(&F);5309 baseRing = currRing;5310 si_opt_1 = save1; //set original options, e. g. option(RedSB)5311 idSkipZeroes(G);5310 idDelete(&Gomega2); 5311 idDelete(&M1); 5312 rChangeCurrRing(newRing); // change the ring to newRing 5313 G = idrMoveR(F,baseRing,currRing); 5314 idDelete(&F); 5315 baseRing = currRing; 5316 si_opt_1 = save1; //set original options, e. g. option(RedSB) 5317 idSkipZeroes(G); 5312 5318 #ifdef TIME_TEST 5313 to = clock();5314 #endif 5315 //PrintS("\n //**Mwalk: Interreduce");5316 //interreduce the Groebner basis <G> w.r.t. currRing5317 //G = kInterRedCC(G,NULL);5319 to = clock(); 5320 #endif 5321 //PrintS("\n //**Mwalk: Interreduce"); 5322 //interreduce the Groebner basis <G> w.r.t. currRing 5323 //G = kInterRedCC(G,NULL); 5318 5324 #ifdef TIME_TEST 5319 tred = tred + clock() - to; 5320 #endif 5321 idSkipZeroes(G); 5322 delete next_weight; 5323 break; 5325 tred = tred + clock() - to; 5326 #endif 5327 idSkipZeroes(G); 5328 delete next_weight; 5329 break; 5330 } 5324 5331 } 5325 5332 for(i=nV-1; i>=0; i--) … … 5371 5378 int nV = currRing->N; 5372 5379 5373 ideal Gomega, M, F, Gomega1, Gomega2, M1; //, F1;5380 ideal Gomega, M, F,FF, Gomega1, Gomega2, M1; //, F1; 5374 5381 ring newRing; 5375 5382 ring baseRing = currRing; … … 5446 5453 } 5447 5454 //#endif 5455 if(reduction == 0) 5456 { 5457 PrintS("\n//** Mrwalk: test middle of cone!\n"); 5458 FF = middleOfCone(G,Gomega); 5459 PrintS("\n//** Mrwalk: Test F!\n"); 5460 if( FF != NULL) 5461 { 5462 idDelete(&G); 5463 G = idCopy(FF); 5464 idDelete(&FF); 5465 PrintS("\n//** Mrwalk: FF nicht NULL! Compue next vector.\n"); 5466 goto NEXT_VECTOR; 5467 } 5468 } 5448 5469 #ifndef BUCHBERGER_ALG 5449 5470 if(isNolVector(curr_weight) == 0) … … 5539 5560 } 5540 5561 //#endif 5562 NEXT_VECTOR: 5541 5563 #ifdef TIME_TEST 5542 5564 to = clock(); … … 5559 5581 } 5560 5582 //#endif 5561 if(MivComp(next_weight, ivNull) == 1 || MivComp(target_weight,curr_weight) == 1 || test_w_in_ConeCC(G, target_weight) == 1) // || MivComp(next_weight,curr_weight) == 1) 5562 { 5563 #ifdef CHECK_IDEAL_MWALK 5564 PrintS("\n//** Mwalk: entering last cone.\n"); 5565 #endif 5566 Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector" 5583 if(MivComp(next_weight, ivNull) == 1 || MivComp(target_weight,curr_weight) == 1 || test_w_in_ConeCC(G, target_weight) == 1) 5584 { 5567 5585 //#ifdef CHECK_IDEAL_MWALK 5568 if(printout > 1) 5569 { 5570 idString(Gomega, "//** Mrwalk: Gomega"); 5571 } 5586 if(printout > 0) 5587 { 5588 PrintS("\n//** Mrwalk: entering last cone.\n"); 5589 } 5590 if(reduction == 0) 5591 { 5592 if(MivComp(next_weight, ivNull) == 1 || MivComp(target_weight,curr_weight) == 1) 5593 { 5594 delete next_weight; 5595 baseRing = currRing; 5596 si_opt_1 = save1; //set original options, e. g. option(RedSB) 5597 break; 5598 } 5599 } 5600 else 5601 { 5572 5602 //#endif 5573 if(target_M->length() == nV)5574 {5575 newRing = VMrDefault(target_weight); // define a new ring with ordering "(a(curr_weight),lp)5576 }5577 else5578 {5579 newRing = VMatrDefault(target_M);5580 }5581 rChangeCurrRing(newRing);5582 Gomega1 = idrMoveR(Gomega, baseRing,currRing);5583 idDelete(&Gomega);5584 M = kStd(Gomega1,NULL,testHomog,NULL,NULL,0,0,NULL);5603 Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector" 5604 if(target_M->length() == nV) 5605 { 5606 newRing = VMrDefault(target_weight); // define a new ring with ordering "(a(curr_weight),lp) 5607 } 5608 else 5609 { 5610 newRing = VMatrDefault(target_M); 5611 } 5612 rChangeCurrRing(newRing); 5613 Gomega1 = idrMoveR(Gomega, baseRing,currRing); 5614 idDelete(&Gomega); 5585 5615 //#ifdef CHECK_IDEAL_MWALK 5586 if(printout > 2) 5587 { 5588 idString(M,"//** Mrwalk: M"); 5589 } 5616 if(printout > 1) 5617 { 5618 idString(Gomega1, "//** Mrwalk: Gomega"); 5619 } 5620 PrintS("\n //** Mrwalk: kStd(Gomega)"); 5590 5621 //#endif 5591 rChangeCurrRing(baseRing); 5592 M1 = idrMoveR(M, newRing,currRing); 5593 idDelete(&M); 5594 Gomega2 = idrMoveR(Gomega1, newRing,currRing); 5595 idDelete(&Gomega1); 5596 F = MLifttwoIdeal(Gomega2, M1, G); 5597 idDelete(&Gomega2); 5598 idDelete(&M1); 5599 rChangeCurrRing(newRing); // change the ring to newRing 5600 G = idrMoveR(F,baseRing,currRing); 5601 idDelete(&F); 5602 baseRing = currRing; 5603 idSkipZeroes(G); 5622 M = kStd(Gomega1,NULL,testHomog,NULL,NULL,0,0,NULL); 5623 //#ifdef CHECK_IDEAL_MWALK 5624 if(printout > 1) 5625 { 5626 idString(M,"//** Mrwalk: M"); 5627 } 5628 //#endif 5629 rChangeCurrRing(baseRing); 5630 M1 = idrMoveR(M, newRing,currRing); 5631 idDelete(&M); 5632 Gomega2 = idrMoveR(Gomega1, newRing,currRing); 5633 idDelete(&Gomega1); 5634 PrintS("\n //** Mrwalk: MLifttwoIdeal"); 5635 F = MLifttwoIdeal(Gomega2, M1, G); 5636 //#ifdef CHECK_IDEAL_MWALK 5637 if(printout > 2) 5638 { 5639 idString(F,"//** Mrwalk: F"); 5640 } 5641 //#endif 5642 idDelete(&Gomega2); 5643 idDelete(&M1); 5644 rChangeCurrRing(newRing); // change the ring to newRing 5645 G = idrMoveR(F,baseRing,currRing); 5646 idDelete(&F); 5647 baseRing = currRing; 5648 si_opt_1 = save1; //set original options, e. g. option(RedSB) 5649 idSkipZeroes(G); 5604 5650 #ifdef TIME_TEST 5605 to = clock(); 5606 #endif 5607 //#ifdef CHECK_IDEAL_MWALK 5608 if(printout > 2) 5609 { 5610 idString(G,"//** Mrwalk: G"); 5611 } 5612 ///#endif 5613 if(si_opt_1 == (Sy_bit(OPT_REDSB))) 5614 { 5615 //G = kInterRedCC(G,NULL); //interreduce the Groebner basis <G> w.r.t. currRing 5616 } 5651 to = clock(); 5652 #endif 5653 //PrintS("\n //**Mrwalk: Interreduce"); 5654 //interreduce the Groebner basis <G> w.r.t. currRing 5655 //G = kInterRedCC(G,NULL); 5617 5656 #ifdef TIME_TEST 5618 tred = tred + clock() - to; 5619 #endif 5620 idSkipZeroes(G); 5621 delete next_weight; 5622 break; 5657 tred = tred + clock() - to; 5658 #endif 5659 idSkipZeroes(G); 5660 delete next_weight; 5661 break; 5662 } 5623 5663 } 5624 5664 for(i=nV-1; i>=0; i--) … … 5813 5853 int endwalks=0; 5814 5854 5815 ideal Gomega, M, F, G, Gomega1, Gomega2, M1,F1,Eresult,ssG;5855 ideal Gomega, M, F, FF, G, Gomega1, Gomega2, M1,F1,Eresult,ssG; 5816 5856 ring newRing, oldRing, TargetRing; 5817 5857 intvec* iv_M_dp; … … 5881 5921 { 5882 5922 iv_M_lp = MivMatrixOrderlp(nV); 5883 //ivString(iv_M_lp, "iv_M_lp");5884 //target_weight = MPertVectorslp(ssG, iv_M_lp, tp_deg);5885 5923 target_weight = MPertVectors(ssG, iv_M_lp, tp_deg); 5886 5924 } … … 5888 5926 { 5889 5927 iv_M_lp = MivMatrixOrder(target_weight); 5890 //target_weight = MPertVectorslp(ssG, iv_M_lp, tp_deg);5891 5928 target_weight = MPertVectors(ssG, iv_M_lp, tp_deg); 5892 5929 } … … 5915 5952 } 5916 5953 //#endif 5954 if(reduction == 0 && nstep > 1) 5955 { 5956 // check whether weight vector is in the interior of the cone 5957 while(1) 5958 { 5959 FF = middleOfCone(G,Gomega); 5960 if(FF != NULL) 5961 { 5962 idDelete(&G); 5963 G = idCopy(FF); 5964 idDelete(&FF); 5965 next_weight = MwalkNextWeightCC(curr_weight,target_weight,G); 5966 if(printout > 0) 5967 { 5968 MivString(curr_weight, target_weight, next_weight); 5969 } 5970 } 5971 else 5972 { 5973 break; 5974 } 5975 for(i=nV-1; i>=0; i--) 5976 { 5977 (*curr_weight)[i] = (*next_weight)[i]; 5978 } 5979 Gomega = MwalkInitialForm(G, curr_weight); 5980 if(printout > 1) 5981 { 5982 idString(Gomega,"//** Mpwalk: Gomega"); 5983 } 5984 } 5985 } 5917 5986 5918 5987 #ifdef ENDWALKS … … 5996 6065 F = MLifttwoIdeal(Gomega2, M1, G); 5997 6066 if(endwalks != 1) 5998 {5999 6067 tlift = tlift+clock()-to; 6000 }6001 6068 else 6002 {6003 6069 xtlift=clock()-to; 6004 } 6070 6071 //#ifdef CHECK_IDEAL_MWALK 6005 6072 if(printout > 2) 6006 6073 { 6007 6074 idString(F,"//** Mpwalk: F"); 6008 6075 } 6076 //#endif 6009 6077 6010 6078 idDelete(&M1); … … 6014 6082 // change the ring to newRing 6015 6083 rChangeCurrRing(newRing); 6016 F1 = idrMoveR(F, oldRing,currRing); 6017 to=clock(); 6018 if(printout > 0) 6019 { 6020 PrintS("\n //** Mpwalk: reduce the Groebner basis.\n"); 6021 } 6022 G = kInterRedCC(F1, NULL); 6023 if(endwalks != 1) 6024 { 6025 tred = tred+clock()-to; 6084 if(reduction == 0) 6085 { 6086 G = idrMoveR(F,oldRing,currRing); 6026 6087 } 6027 6088 else 6028 6089 { 6029 xtred=clock()-to; 6030 } 6031 idDelete(&F1); 6032 6090 F1 = idrMoveR(F, oldRing,currRing); 6091 if(printout > 2) 6092 { 6093 PrintS("\n //** Mpwalk: reduce the Groebner basis.\n"); 6094 } 6095 to=clock(); 6096 G = kInterRedCC(F1, NULL); 6097 if(endwalks != 1) 6098 tred = tred+clock()-to; 6099 else 6100 xtred=clock()-to; 6101 idDelete(&F1); 6102 } 6033 6103 if(endwalks == 1) 6034 6104 break; … … 6036 6106 to=clock(); 6037 6107 // compute a next weight vector 6038 //next_weight = MwalkNextWeightCC(curr_weight,target_weight,G);6039 6108 next_weight = MkInterRedNextWeight(curr_weight,target_weight, G); 6040 6109 tnw=tnw+clock()-to; 6041 6110 //#ifdef PRINT_VECTORS 6042 6111 if(printout > 0) 6043 6112 { 6044 6113 MivString(curr_weight, target_weight, next_weight); 6045 6114 } 6046 6115 //#endif 6047 6116 6048 6117 if(Overflow_Error == TRUE) 6049 6118 { 6050 6119 ntwC = 0; 6120 //ntestomega = 1; 6121 //Print("\n// ring r%d = %s;\n", nstep, rString(currRing)); 6122 //idElements(G, "G"); 6051 6123 delete next_weight; 6052 break; 6053 //goto FINISH_160302; 6054 } 6055 if(MivComp(next_weight, ivNull) == 1) 6056 { 6124 goto FINISH_160302; 6125 } 6126 if(MivComp(next_weight, ivNull) == 1){ 6057 6127 newRing = currRing; 6058 6128 delete next_weight; 6129 //Print("\n// ring r%d = %s;\n", nstep, rString(currRing)); 6059 6130 break; 6060 6131 } 6061 if(MivComp(next_weight, target_weight) == 1 || test_w_in_ConeCC(G, target_weight)==1) //AENDERUNG!! 6062 { 6132 if(MivComp(next_weight, target_weight) == 1) 6063 6133 endwalks = 1; 6064 } 6134 6065 6135 for(i=nV-1; i>=0; i--) 6066 {6067 6136 (*curr_weight)[i] = (*next_weight)[i]; 6068 } 6137 6069 6138 delete next_weight; 6070 6139 }//end of while-loop … … 6090 6159 #endif 6091 6160 6161 6092 6162 // check whether the pertubed target vector stays in the correct cone 6093 6163 if(ntwC != 0){ … … 6097 6167 if( ntestw != 1 || ntwC == 0) 6098 6168 { 6099 if(printout > 0) 6100 { 6101 if(printout > 1) 6102 { 6103 ivString(pert_target_vector, "tau"); 6104 } 6105 PrintS("\n //** Mpwalk: perturbed target vector doesn't stay in cone. \n"); 6106 if(printout > 2) 6107 { 6108 Print("\n// ring r%d = %s;\n", nstep, rString(currRing)); 6109 //idElements(F1, "G"); 6110 } 6111 } 6112 6169 if(ntestw != 1 && printout >2) 6170 { 6171 ivString(pert_target_vector, "tau"); 6172 PrintS("\n// ** perturbed target vector doesn't stay in cone!!"); 6173 Print("\n// ring r%d = %s;\n", nstep, rString(currRing)); 6174 //idElements(F1, "G"); 6175 } 6113 6176 // LastGB is "better" than the kStd subroutine 6114 6177 to=clock(); 6115 6178 ideal eF1; 6116 if(nP == 0 || tp_deg == 1 || MivSame(orig_target, exivlp) != 1) 6117 { 6118 if(printout > 1) 6119 { 6120 PrintS("\n //** Mpwalk: call \"std\" to compute a GB.\n"); 6121 } 6179 if(nP == 0 || tp_deg == 1 || MivSame(orig_target, exivlp) != 1){ 6180 // PrintS("\n// ** calls \"std\" to compute a GB"); 6122 6181 eF1 = MstdCC(F1); 6123 6182 idDelete(&F1); 6124 6183 } 6125 else 6126 { 6127 if(printout > 1) 6128 { 6129 PrintS("\n //** Mpwalk: call \"LastGB\" to compute a GB.\n"); 6130 } 6184 else { 6185 // PrintS("\n// ** calls \"LastGB\" to compute a GB"); 6131 6186 rChangeCurrRing(newRing); 6132 6187 ideal F2 = idrMoveR(F1, TargetRing,currRing); 6133 6188 eF1 = LastGB(F2, curr_weight, tp_deg-1); 6134 idDelete(&F2); 6135 //F2=NULL; 6189 F2=NULL; 6136 6190 } 6137 6191 xtextra=clock()-to; … … 6140 6194 rChangeCurrRing(XXRing); 6141 6195 Eresult = idrMoveR(eF1, exTargetRing,currRing); 6142 idDelete(&eF1); 6143 } 6144 else 6145 { 6196 } 6197 else{ 6146 6198 rChangeCurrRing(XXRing); 6147 6199 Eresult = idrMoveR(F1, TargetRing,currRing); 6148 idDelete(&F1); 6149 } 6150 } 6151 else 6152 { 6200 } 6201 } 6202 else { 6153 6203 rChangeCurrRing(XXRing); 6154 6204 Eresult = idrMoveR(G, newRing,currRing); 6155 idDelete(&G);6156 6205 } 6157 6206 si_opt_1 = save1; //set original options, e. g. option(RedSB) 6158 6207 delete ivNull; 6159 6208 if(tp_deg != 1) 6160 {6161 6209 delete target_weight; 6162 } 6210 6163 6211 if(op_deg != 1 ) 6164 {6165 6212 delete curr_weight; 6166 } 6213 6167 6214 delete exivlp; 6168 6215 delete last_omega; … … 6190 6237 si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis 6191 6238 //si_opt_1 &= (~Sy_bit(OPT_REDTAIL)); // not tail reductions 6239 //si_opt_1|=(Sy_bit(OPT_REDTAIL)|Sy_bit(OPT_REDSB)); 6192 6240 } 6193 6241 Set_Error(FALSE); … … 6206 6254 int endwalks=0; 6207 6255 6208 ideal Gomega, M, F, G, Gomega1, Gomega2, M1,F1,Eresult,ssG;6256 ideal Gomega, M, F, FF, G, Gomega1, Gomega2, M1,F1,Eresult,ssG; 6209 6257 ring newRing, oldRing, TargetRing; 6210 6258 intvec* iv_M_dp; … … 6246 6294 { 6247 6295 iv_M_dp = MivMatrixOrderdp(nV); 6248 //ivString(iv_M_dp, "iv_M_dp");6249 6296 curr_weight = MPertVectors(G, iv_M_dp, op_deg); 6250 6297 } … … 6300 6347 { 6301 6348 iv_M_lp = MivMatrixOrderlp(nV); 6302 //ivString(iv_M_lp, "iv_M_lp");6303 //target_weight = MPertVectorslp(ssG, iv_M_lp, tp_deg);6304 6349 target_weight = MPertVectors(ssG, iv_M_lp, tp_deg); 6305 6350 } … … 6307 6352 { 6308 6353 iv_M_lp = MivMatrixOrder(target_weight); 6309 //target_weight = MPertVectorslp(ssG, iv_M_lp, tp_deg);6310 6354 target_weight = MPertVectors(ssG, iv_M_lp, tp_deg); 6311 6355 } … … 6339 6383 // "curr_weight" 6340 6384 Gomega = MwalkInitialForm(G, curr_weight); 6385 polylength = lengthpoly(Gomega); 6341 6386 //#ifdef CHECK_IDEAL_MWALK 6342 6387 if(printout > 0) … … 6345 6390 } 6346 6391 //#endif 6347 polylength = lengthpoly(Gomega); 6392 if(reduction == 0 && nstep > 1) 6393 { 6394 while(1) 6395 { 6396 // check whether weight vector is in the interior of the cone 6397 FF = middleOfCone(G,Gomega); 6398 if(FF != NULL) 6399 { 6400 idDelete(&G); 6401 G = idCopy(FF); 6402 idDelete(&FF); 6403 next_weight = MwalkNextWeightCC(curr_weight,target_weight,G); 6404 if(printout > 0) 6405 { 6406 MivString(curr_weight, target_weight, next_weight); 6407 } 6408 } 6409 else 6410 { 6411 if(polylength > 0) 6412 { 6413 Print("\n //**Mprwalk: there is a polynomial in Gomega with at least 3 monomials, low-dimensional facet of the cone.\n"); 6414 delete next_weight; 6415 next_weight = MWalkRandomNextWeight(G, curr_weight, target_weight, weight_rad, op_deg); 6416 } 6417 break; 6418 } 6419 for(i=nV-1; i>=0; i--) 6420 { 6421 (*curr_weight)[i] = (*next_weight)[i]; 6422 } 6423 Gomega = MwalkInitialForm(G, curr_weight); 6424 polylength = lengthpoly(Gomega); 6425 if(printout > 1) 6426 { 6427 idString(Gomega,"//** Mprwalk: Gomega"); 6428 } 6429 } 6430 } 6348 6431 #ifdef ENDWALKS 6349 6432 if(endwalks == 1) … … 6437 6520 else 6438 6521 xtlift=clock()-to; 6439 Print("\n //** Mprwalk: F.\n"); 6522 6440 6523 //#ifdef CHECK_IDEAL_MWALK 6441 6524 if(printout > 2) … … 6451 6534 // change the ring to newRing 6452 6535 rChangeCurrRing(newRing); 6453 //F1 = idrMoveR(F, oldRing,currRing); 6454 F1 = idrMoveR(F,oldRing,currRing); 6455 to=clock(); 6456 Print("\n //** Mprwalk: reducing the Groebner basis.\n"); 6457 G = kInterRedCC(F1, NULL); 6458 if(endwalks != 1) 6459 tred = tred+clock()-to; 6536 if(reduction == 0) 6537 { 6538 G = idrMoveR(F,oldRing,currRing); 6539 } 6460 6540 else 6461 xtred=clock()-to; 6462 6463 idDelete(&F1); 6541 { 6542 F1 = idrMoveR(F, oldRing,currRing); 6543 if(printout > 2) 6544 { 6545 PrintS("\n //** Mprwalk: reduce the Groebner basis.\n"); 6546 } 6547 to=clock(); 6548 G = kInterRedCC(F1, NULL); 6549 if(endwalks != 1) 6550 tred = tred+clock()-to; 6551 else 6552 xtred=clock()-to; 6553 idDelete(&F1); 6554 } 6464 6555 6465 6556 if(endwalks == 1) … … 6467 6558 6468 6559 to=clock(); 6469 Print("\n //** Mprwalk: compute a next weight vector.\n"); 6560 6470 6561 next_weight = MkInterRedNextWeight(curr_weight,target_weight, G); 6471 6562 if(polylength > 0) 6472 6563 { 6473 Print("\n //**Mprwalk: there is a polynomial in Gomega with at least 3 monomials, low-dimensional facet of the cone.\n"); 6564 if(printout > 2) 6565 { 6566 Print("\n //**Mprwalk: there is a polynomial in Gomega with at least 3 monomials, low-dimensional facet of the cone.\n"); 6567 } 6474 6568 delete next_weight; 6475 6569 next_weight = MWalkRandomNextWeight(G, curr_weight, target_weight, weight_rad, op_deg); … … 6534 6628 6535 6629 // check whether the pertubed target vector stays in the correct cone 6536 if(ntwC != 0){ 6630 if(ntwC != 0) 6631 { 6537 6632 ntestw = test_w_in_ConeCC(F1, pert_target_vector); 6538 6633 } 6539 6540 if( ntestw != 1 || ntwC == 0) 6541 { 6542 /* 6543 if(ntestw != 1){ 6634 if(ntestw != 1 || ntwC == 0) 6635 { 6636 if(ntestw != 1 && printout > 2) 6637 { 6544 6638 ivString(pert_target_vector, "tau"); 6545 PrintS("\n// ** perturbed target vector doesn't stay in cone!!");6639 PrintS("\n// **Mprwalk: perturbed target vector doesn't stay in cone."); 6546 6640 Print("\n// ring r%d = %s;\n", nstep, rString(currRing)); 6547 idElements(F1, "G"); 6548 } 6549 */ 6641 //idElements(F1, "G"); 6642 } 6550 6643 // LastGB is "better" than the kStd subroutine 6551 6644 to=clock(); 6552 6645 ideal eF1; 6553 if(nP == 0 || tp_deg == 1 || MivSame(orig_target, exivlp) != 1 || target_M->length() != nV){ 6554 // PrintS("\n// ** calls \"std\" to compute a GB"); 6646 if(nP == 0 || tp_deg == 1 || MivSame(orig_target, exivlp) != 1 || target_M->length() != nV) 6647 { 6648 if(printout > 2) 6649 { 6650 PrintS("\n// ** Mprwalk: Call \"std\" to compute a Groebner basis.\n"); 6651 } 6555 6652 eF1 = MstdCC(F1); 6556 6653 idDelete(&F1); 6557 6654 } 6558 else { 6559 // PrintS("\n// ** calls \"LastGB\" to compute a GB"); 6655 else 6656 { 6657 if(printout > 2) 6658 { 6659 PrintS("\n// **Mprwalk: Call \"LastGB\" to compute a Groebner basis.\n"); 6660 } 6560 6661 rChangeCurrRing(newRing); 6561 6662 ideal F2 = idrMoveR(F1, TargetRing,currRing); … … 7047 7148 ************************************************************************/ 7048 7149 static ideal rec_r_fractal_call(ideal G, int nlev, intvec* ivtarget, 7049 int weight_rad, int printout)7150 int weight_rad, int reduction, int printout) 7050 7151 { 7051 7152 Overflow_Error = FALSE; … … 7055 7156 ring new_ring, testring; 7056 7157 //ring extoRing; 7057 ideal Gomega, Gomega1, Gomega2, F, F 1, Gresult, Gresult1, G1, Gt;7158 ideal Gomega, Gomega1, Gomega2, F, FF, F1, Gresult, Gresult1, G1, Gt; 7058 7159 int nwalks = 0; 7059 7160 intvec* Mwlp; … … 7123 7224 delete next_vect; 7124 7225 next_vect = MWalkRandomNextWeight(G,omega,omega2,weight_rad,nlev); 7125 if(isNegNolVector(next_vect)==1 || MivSame(omega,next_vect) == 1)7226 if(isNegNolVector(next_vect)==1) 7126 7227 { 7127 7228 delete next_vect; … … 7208 7309 delete next_vect; 7209 7310 next_vect = MWalkRandomNextWeight(G,omega,omega2,weight_rad,nlev); 7210 if(isNegNolVector(next_vect)==1 || MivSame(omega,next_vect) == 1)7311 if(isNegNolVector(next_vect)==1) 7211 7312 { 7212 7313 delete next_vect; … … 7267 7368 Print("\n//** rec_r_fractal_call: Leaving the %d-th recursion with %d steps.\n", 7268 7369 nlev, nwalks); 7269 /* 7270 Print(" ** Overflow_Error? (%d)", Overflow_Error); 7271 idString(G1,"//** rec_r_fractal_call: G1"); 7272 */ 7370 //Print(" ** Overflow_Error? (%d)", Overflow_Error); 7273 7371 } 7274 7372 nnflow ++; … … 7310 7408 Print("\n//** rec_r_fractal_call: Leaving the %d-th recursion with %d steps.\n", 7311 7409 nlev, nwalks); 7312 /* 7313 Print(" ** Overflow_Error? (%d)", Overflow_Error); 7314 idString(Gt,"//** rec_r_fractal_call: Gt"); 7315 */ 7410 //Print(" ** Overflow_Error? (%d)", Overflow_Error); 7316 7411 } 7317 7412 return (Gt); … … 7416 7511 Print("\n//** rec_r_fractal_call: Leaving the %d-th recursion with %d steps.\n", 7417 7512 nlev,nwalks); 7418 /* 7419 Print(" ** Overflow_Error? (%d)", Overflow_Error); 7420 idString(G,"//** rec_r_fractal_call: G"); 7421 */ 7513 //Print(" ** Overflow_Error? (%d)", Overflow_Error); 7422 7514 } 7423 7515 if(Overflow_Error == TRUE) … … 7446 7538 idString(Gomega,"//** rec_r_fractal_call: Gomega"); 7447 7539 } 7540 7541 7542 //////////////////////////////////// hier neu!! 7543 7544 7545 if(reduction == 0) 7546 { 7547 //PrintS("\n//** rec_r_fractal_call: test middle of cone!\n"); 7548 FF = middleOfCone(G,Gomega); 7549 //PrintS("\n//** rec_r_fractal_call: Test F!\n"); 7550 if( FF != NULL) 7551 { 7552 idDelete(&G); 7553 G = idCopy(FF); 7554 idDelete(&FF); 7555 PrintS("\n//** rec_r_fractal_call: FF nicht NULL! Compue next vector.\n"); 7556 goto NEXT_VECTOR_FRACTAL; 7557 } 7558 } 7559 7560 7561 7562 /////////////////////////////////////////////////// 7563 7564 7448 7565 #ifndef BUCHBERGER_ALG 7449 7566 if(isNolVector(omega) == 0) … … 7483 7600 rChangeCurrRing(oRing); 7484 7601 Gomega1 = idrMoveR(Gomega1, oRing,currRing); 7485 Gresult = rec_r_fractal_call(idCopy(Gomega1),nlev+1,omega,weight_rad, printout);7602 Gresult = rec_r_fractal_call(idCopy(Gomega1),nlev+1,omega,weight_rad,reduction,printout); 7486 7603 } 7487 7604 if(printout > 2) … … 7827 7944 ring helpRing = currRing; 7828 7945 7829 J = rec_r_fractal_call(J,1,ivtarget,weight_rad, printout);7946 J = rec_r_fractal_call(J,1,ivtarget,weight_rad,reduction,printout); 7830 7947 7831 7948 rChangeCurrRing(oldRing);
Note: See TracChangeset
for help on using the changeset viewer.