Changeset a14482 in git for Singular/walk.cc
- Timestamp:
- Feb 26, 2015, 6:55:30 PM (9 years ago)
- Branches:
- (u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'b4f17ed1d25f93d46dbe29e4b499baecc2fd51bb')
- Children:
- e57a75c6d0050e3db7e1a87294a311d4784df43c
- Parents:
- eca8d9cc9b3584a2f5741c75f69099751c4cbe8f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/walk.cc
reca8d9 ra14482 1106 1106 if(pdeg > nV || pdeg <= 0) 1107 1107 { 1108 WerrorS("//** The perturbed degree is wrong!!");1108 WerrorS("//**MPertVectors: The perturbed degree is wrong!!"); 1109 1109 return v_null; 1110 1110 } … … 1116 1116 } 1117 1117 mpz_t *pert_vector = (mpz_t*)omAlloc(nV*sizeof(mpz_t)); 1118 //mpz_t *pert_vector1 = (mpz_t*)omAlloc(nV*sizeof(mpz_t));1119 1118 1120 1119 for(i=0; i<nV; i++) … … 1123 1122 // mpz_init_set_si(pert_vector1[i], (*ivtarget)[i]); 1124 1123 } 1125 // C alculate max1 = Max(A2)+Max(A3)+...+Max(Apdeg),1124 // Compute max1 = Max(A2)+Max(A3)+...+Max(Apdeg), 1126 1125 // where the Ai are the i-te rows of the matrix target_ord. 1127 1126 int ntemp, maxAi, maxA=0; … … 1148 1147 } 1149 1148 1150 // C alculate inveps = 1/eps, where 1/eps > totaldeg(p)*max1 for all p in G.1149 // Compute inveps = 1/eps, where 1/eps > totaldeg(p)*max1 for all p in G. 1151 1150 1152 1151 intvec* ivUnit = Mivdp(nV); … … 1180 1179 } 1181 1180 #else 1182 // PrintS("\n// the \"big\" inverse epsilon:");1181 PrintS("\n //**MPertVectors: the \"big\" inverse epsilon:"); 1183 1182 mpz_out_str(stdout, 10, inveps); 1184 1183 #endif … … 1234 1233 if(j > nV - 1) 1235 1234 { 1236 // Print("\n// MPertVectors: geaenderter vector gleich Null! \n");1235 //perturbed vector equals zero 1237 1236 delete pert_vector1; 1238 1237 goto CHECK_OVERFLOW; 1239 1238 } 1240 1239 1241 // check that the perturbed weight vector lies in the Groebner cone1240 // check that the perturbed weight vector lies in the Groebner cone 1242 1241 if(test_w_in_ConeCC(G,pert_vector1) != 0) 1243 1242 { 1244 // Print("\n// MPertVectors: geaenderter vector liegt in Groebnerkegel! \n");1245 1243 for(i=0; i<nV; i++) 1246 1244 { … … 1248 1246 } 1249 1247 } 1250 else 1251 { 1252 //Print("\n// MpertVectors: geaenderter vector liegt nicht in Groebnerkegel! \n"); 1253 } 1248 1254 1249 delete pert_vector1; 1255 1250 … … 1257 1252 intvec* result = new intvec(nV); 1258 1253 1259 / * 2147483647 is max. integer representation in SINGULAR */1254 // 2147483647 is max. integer representation in SINGULAR 1260 1255 mpz_t sing_int; 1261 1256 mpz_init_set_ui(sing_int, 2147483647); … … 1644 1639 { 1645 1640 mpz_divexact(pert_vector[i], pert_vector[i], ztmp); 1646 (* result)[i] = mpz_get_si(pert_vector[i]); 1647 } 1648 1641 (* result1)[i] = mpz_get_si(pert_vector[i]); 1642 } 1649 1643 j = 0; 1650 for(i=0; i<nV; i++) 1651 { 1652 (* result1)[i] = mpz_get_si(pert_vector[i]); 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 while(test_w_in_ConeCC(G,result1) && j<nV) 1645 { 1646 j = 0; 1673 1647 for(i=0; i<nV; i++) 1674 1648 { 1649 (* result)[i] = (* result1)[i]; 1675 1650 mpz_set_si(pert_vector[i], (*result1)[i]); 1676 } 1677 } 1678 else 1679 { 1680 delete result1; 1681 // Print("\n// Mfpertwalk: geaenderter vector liegt nicht in Groebnerkegel! \n"); 1682 } 1651 (* result1)[i] = floor(0.1*(mpz_get_si(pert_vector[i])) + 0.5); 1652 if((* result1)[i] == 0) 1653 { 1654 j++; 1655 } 1656 } 1657 } 1658 delete result1; 1683 1659 1684 1660 CHECK_OVERFLOW: … … 4343 4319 assume(currRing != NULL && curr_weight != NULL && 4344 4320 target_weight != NULL && G->m[0] != NULL); 4345 4346 int i,weight_norm,nV = currRing->N; 4321 //PrintS("\n //**MWalkRandomNextWeight: Anfang ok!\n"); 4322 int i,k,nV = currRing->N; 4323 long weight_norm; 4347 4324 intvec* next_weight2; 4348 intvec* next_weight22 = new intvec(nV);4325 //intvec* next_weight22 = new intvec(nV); 4349 4326 intvec* result = new intvec(nV); 4327 ideal G_test; 4328 ideal G_test2; 4329 BOOLEAN random = FALSE; 4350 4330 4351 4331 intvec* next_weight1 =MkInterRedNextWeight(curr_weight,target_weight,G); 4352 4332 //compute a random next weight vector "next_weight2" 4353 while(1) 4354 { 4333 k = 1; 4334 while(k<4) 4335 { 4336 k++; 4355 4337 weight_norm = 0; 4338 intvec* next_weight22 = new intvec(nV); 4356 4339 while(weight_norm == 0) 4357 4340 { 4358 4341 //PrintS("\nWhile WeightNorm\n"); 4359 4342 for(i=0; i<nV; i++) 4360 4343 { 4361 (*next_weight22)[i] = rand() % 60000 - 30000;4344 (*next_weight22)[i] = rand() % 60000 ; 4362 4345 weight_norm = weight_norm + (*next_weight22)[i]*(*next_weight22)[i]; 4363 4346 } 4347 //Print("\n// weight_norm vor Wurzel = %d\n", weight_norm); 4364 4348 weight_norm = 1 + floor(sqrt(weight_norm)); 4365 } 4366 4349 4350 } 4351 //Print("\n// weight_norm nach Wurzel = %d\n", weight_norm); 4367 4352 for(i=0; i<nV; i++) 4368 4353 { 4369 4354 if((*next_weight22)[i] < 0) 4370 4355 { 4371 (*next_weight22)[i] = 1 + (*curr_weight)[i] + floor( weight_rad*(*next_weight22)[i]/weight_norm);4356 (*next_weight22)[i] = 1 + (*curr_weight)[i] + floor((weight_rad)*(*next_weight22)[i]/weight_norm); 4372 4357 } 4373 4358 else 4374 4359 { 4375 (*next_weight22)[i] = (*curr_weight)[i] + floor( weight_rad*(*next_weight22)[i]/weight_norm);4360 (*next_weight22)[i] = (*curr_weight)[i] + floor((weight_rad)*(*next_weight22)[i]/weight_norm); 4376 4361 } 4377 4362 } … … 4379 4364 if(test_w_in_ConeCC(G, next_weight22) == 1) 4380 4365 { 4366 //PrintS("\n //** MWalkRandomNextWeight: test ob in Kegel.\n"); 4381 4367 next_weight2 = MkInterRedNextWeight(next_weight22,target_weight,G); 4382 4368 if(MivAbsMax(next_weight2)>1147483647) … … 4395 4381 } 4396 4382 } 4397 delete next_weight22;4383 random = TRUE; 4398 4384 break; 4399 4385 } 4400 } 4401 4386 delete next_weight22; 4387 } 4388 //PrintS("\n //**MWalkRandomNextWeight: Ende while-Schleife!\n"); 4389 4402 4390 // compute "usual" next weight vector 4403 4391 intvec* next_weight = MwalkNextWeightCC(curr_weight,target_weight, G); 4404 ideal G_test = MwalkInitialForm(G, next_weight); 4405 ideal G_test2 = MwalkInitialForm(G, next_weight2); 4406 4392 G_test = MwalkInitialForm(G, next_weight); 4393 if(random == TRUE) 4394 { 4395 G_test2 = MwalkInitialForm(G, next_weight2); 4396 } 4407 4397 // compare next weights 4408 4398 if(Overflow_Error == FALSE) 4409 4399 { 4410 4400 ideal G_test1 = MwalkInitialForm(G, next_weight1); 4411 if(G_test1->m[0] != NULL && maxlengthpoly(G_test1) < maxlengthpoly(G_test))//if(IDELEMS(G_test1) < IDELEMS(G_test)) 4412 { 4413 if(G_test2->m[0] != NULL && maxlengthpoly(G_test2) < maxlengthpoly(G_test1)) //if(IDELEMS(G_test2) < IDELEMS(G_test1)) 4414 { 4415 // |G_test2| < |G_test1| < |G_test| 4401 if(G_test1->m[0] != NULL && maxlengthpoly(G_test1) < maxlengthpoly(G_test)) 4402 { 4403 if(random == TRUE && 4404 G_test2->m[0] != NULL && 4405 maxlengthpoly(G_test2) < maxlengthpoly(G_test1)) 4406 { 4416 4407 for(i=0; i<nV; i++) 4417 4408 { … … 4421 4412 else 4422 4413 { 4423 // |G_test1| < |G_test|, |G_test1| <= |G_test2|4424 4414 for(i=0; i<nV; i++) 4425 4415 { … … 4430 4420 else 4431 4421 { 4432 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| 4422 if(random == TRUE && 4423 G_test2->m[0] != NULL && 4424 maxlengthpoly(G_test2) < maxlengthpoly(G_test)) 4433 4425 { 4434 4426 for(i=0; i<nV; i++) … … 4439 4431 else 4440 4432 { 4441 // |G_test| < |G_test1|, |G_test| <= |G_test2|4442 4433 for(i=0; i<nV; i++) 4443 4434 { … … 4451 4442 { 4452 4443 Overflow_Error = FALSE; 4453 if(G_test2->m[0] != NULL && maxlengthpoly(G_test2) < maxlengthpoly(G_test))//if(IDELEMS(G_test2) < IDELEMS(G_test)) 4444 if(random == TRUE && 4445 G_test2->m[0] != NULL && 4446 maxlengthpoly(G_test2) < maxlengthpoly(G_test)) 4454 4447 { 4455 4448 for(i=1; i<nV; i++) … … 4466 4459 } 4467 4460 } 4468 PrintS("\n MWalkRandomNextWeight: Ende ok!\n");4461 //PrintS("\n MWalkRandomNextWeight: Ende ok!\n"); 4469 4462 idDelete(&G_test); 4470 idDelete(&G_test2); 4463 if(random == TRUE) 4464 { 4465 idDelete(&G_test2); 4466 } 4471 4467 if(test_w_in_ConeCC(G, result) == 1) 4472 4468 { 4473 delete next_weight2; 4469 if(random == TRUE) 4470 { 4471 delete next_weight2; 4472 } 4474 4473 delete next_weight; 4475 4474 delete next_weight1; … … 4479 4478 { 4480 4479 delete result; 4481 delete next_weight2; 4480 if(random == TRUE) 4481 { 4482 delete next_weight2; 4483 } 4482 4484 delete next_weight1; 4483 4485 return next_weight; … … 6029 6031 to=clock(); 6030 6032 // compute a next weight vector 6031 next_weight = M kInterRedNextWeight(curr_weight,target_weight, G);6033 next_weight = MwalkNextWeightCC(curr_weight,target_weight,G);//MkInterRedNextWeight(curr_weight,target_weight, G); 6032 6034 tnw=tnw+clock()-to; 6033 6035 //#ifdef PRINT_VECTORS … … 7095 7097 delete next_vect; 7096 7098 next_vect = MWalkRandomNextWeight(G,omega,omega2,weight_rad,nlev); 7097 if(isNegNolVector(next_vect)==1 )7099 if(isNegNolVector(next_vect)==1 || MivSame(omega,next_vect) == 1) 7098 7100 { 7099 7101 delete next_vect; … … 7180 7182 delete next_vect; 7181 7183 next_vect = MWalkRandomNextWeight(G,omega,omega2,weight_rad,nlev); 7182 if(isNegNolVector(next_vect)==1 )7184 if(isNegNolVector(next_vect)==1 || MivSame(omega,next_vect) == 1) 7183 7185 { 7184 7186 delete next_vect; … … 7239 7241 Print("\n//** rec_r_fractal_call: Leaving the %d-th recursion with %d steps.\n", 7240 7242 nlev, nwalks); 7241 //Print(" ** Overflow_Error? (%d)", Overflow_Error); 7243 /* 7244 Print(" ** Overflow_Error? (%d)", Overflow_Error); 7245 idString(G1,"//** rec_r_fractal_call: G1"); 7246 */ 7242 7247 } 7243 7248 nnflow ++; … … 7279 7284 Print("\n//** rec_r_fractal_call: Leaving the %d-th recursion with %d steps.\n", 7280 7285 nlev, nwalks); 7281 //Print(" ** Overflow_Error? (%d)", Overflow_Error); 7286 /* 7287 Print(" ** Overflow_Error? (%d)", Overflow_Error); 7288 idString(Gt,"//** rec_r_fractal_call: Gt"); 7289 */ 7282 7290 } 7283 7291 return (Gt); … … 7382 7390 Print("\n//** rec_r_fractal_call: Leaving the %d-th recursion with %d steps.\n", 7383 7391 nlev,nwalks); 7384 //Print(" ** Overflow_Error? (%d)", Overflow_Error); 7392 /* 7393 Print(" ** Overflow_Error? (%d)", Overflow_Error); 7394 idString(G,"//** rec_r_fractal_call: G"); 7395 */ 7385 7396 } 7386 7397 if(Overflow_Error == TRUE)
Note: See TracChangeset
for help on using the changeset viewer.