* compute a next weight vector * ********************************/
| 4515 | * compute a next weight vector * |
| 4516 | ********************************/ |
| 4517 | static intvec* MWalkRandomNextWeight(ideal G, intvec* orig_M, intvec* target_weight, |
| 4518 | int weight_rad, int pert_deg) |
| 4519 | { |
| 4520 | assume(currRing != NULL && orig_M != NULL && |
| 4521 | target_weight != NULL && G->m[0] != NULL); |
| 4522 | |
| 4523 | //BOOLEAN nError = Overflow_Error; |
| 4524 | Overflow_Error = FALSE; |
| 4525 | |
| 4526 | BOOLEAN found_random_weight = FALSE; |
| 4527 | int i,nV = currRing->N; |
| 4528 | intvec* curr_weight = new intvec(nV); |
| 4529 | |
| 4530 | for(i=0; i<nV; i++) |
| 4531 | { |
| 4532 | (*curr_weight)[i] = (*orig_M)[i]; |
| 4533 | } |
| 4534 | |
| 4535 | int k=0,weight_norm; |
| 4536 | intvec* next_weight; |
| 4537 | intvec* next_weight1 = MkInterRedNextWeight(curr_weight,target_weight,G); |
| 4538 | intvec* next_weight2 = new intvec(nV); |
| 4539 | intvec* result = new intvec(nV); |
| 4540 | intvec* curr_weight1; |
| 4541 | ideal G_test, G_test1, G_test2; |
| 4542 | |
| 4543 | //try to find a random next weight vector "next_weight2" |
| 4544 | if(weight_rad > 0) |
| 4545 | { |
| 4546 | while(k<10) |
| 4547 | { |
| 4548 | weight_norm = 0; |
| 4549 | while(weight_norm == 0) |
| 4550 | { |
| 4551 | for(i=0; i<nV; i++) |
| 4552 | { |
| 4553 | (*next_weight2)[i] = rand() % 60000 - 30000; |
| 4554 | weight_norm = weight_norm + (*next_weight2)[i]*(*next_weight2)[i]; |
| 4555 | } |
| 4556 | weight_norm = 1 + static_cast<int>(sqrt(double(weight_norm))); |
| 4557 | } |
| 4558 | for(i=0; i<nV; i++) |
| 4559 | { |
| 4560 | if((*next_weight2)[i] < 0) |
| 4561 | { |
| 4562 | (*next_weight2)[i] = 1 + (*curr_weight)[i] + weight_rad*(*next_weight2)[i]/weight_norm; |
| 4563 | } |
| 4564 | else |
| 4565 | { |
| 4566 | (*next_weight2)[i] = (*curr_weight)[i] + weight_rad*(*next_weight2)[i]/weight_norm; |
| 4567 | } |
| 4568 | } |
| 4569 | if(test_w_in_ConeCC(G,next_weight2) == 1) |
| 4570 | { |
| 4571 | if(maxlengthpoly(MwalkInitialForm(G,next_weight2))<2) |
| 4572 | { |
| 4573 | next_weight2 = MkInterRedNextWeight(next_weight2,target_weight,G); |
| 4574 | } |
no test coverage detected