Changeset 4052dc in git
- Timestamp:
- Feb 6, 2015, 10:25:18 AM (9 years ago)
- Branches:
- (u'spielwiese', '17f1d200f27c5bd38f5dfc6e8a0879242279d1d8')
- Children:
- 99f4c6811eadeb02db7dd8cfde8940b9519df3c1e05649bb049ee8f1b6dfccd3446c63020e099649
- Parents:
- dbf60932968d7dd0d5f400c4209b39e40b442f58
- Location:
- Singular
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/LIB/grwalk.lib
rdbf609 r4052dc 274 274 string ord_str = OSCTW[2]; 275 275 intvec curr_weight = OSCTW[3]; /* original weight vector */ 276 intvec target_weight = OSCTW[4]; /* t erget weight vector */276 intvec target_weight = OSCTW[4]; /* target weight vector */ 277 277 kill OSCTW; 278 278 option(redSB); … … 299 299 //** compute a Groebner basis of I w.r.t. lp. 300 300 ring r = 32003,(z,y,x), lp; 301 ideal I = y3+xyz+y2z+xz3, 3+xy+x2y+y2z; 301 ideal I = zy2+yx2+yx+3, 302 z3x+y3+zyx-yx2-yx-3, 303 z2yx3-y5+z2yx2+y3x2+y2x3+y3x+y2x2+3z2x+3y2+3yx, 304 zyx5+y6-y4x2-y3x3+2zyx4-y4x-y3x2+zyx3-3z2yx+3zx3-3y3-3y2x+3zx2, 305 yx7-y7+y5x2+y4x3+3yx6+y5x+y4x2+3yx5-6zyx3+yx4+3x5+3y4+3y3x-6zyx2+6x4+3x3-9zx; 302 306 gwalk(I,0,1); 303 307 } … … 479 483 ideal G = fetch(xR, Go); 480 484 481 <<<<<<< HEAD482 485 G = system("Mpwalk",G,n1,n2,curr_weight,target_weight,nP,reduction,printout); 483 486 484 =======485 G = system("Mpwalk", G, n1, n2, curr_weight, target_weight,nP);486 487 >>>>>>> f533f6f7667328bccb271b19b2f603aaebe41596488 487 setring xR; 489 //kill Go; 488 //kill Go; //unused 490 489 491 490 keepring basering; -
Singular/walk.cc
rdbf609 r4052dc 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, if29 #define MSTDCC_FRACTAL // apply Buchberger alg to compute a red GB, if 30 30 // tau doesn't stay in the correct cone 31 31 … … 42 42 #include <Singular/ipshell.h> 43 43 #include <Singular/ipconv.h> 44 #include <coeffs/ffields.h> 44 45 #include <coeffs/coeffs.h> 45 46 #include <Singular/subexpr.h> 47 #include <polys/templates/p_Procs.h> 46 48 47 49 #include <polys/monomials/maps.h> … … 988 990 intvec* MivMatrixOrderRefine(intvec* iv, intvec* iw) 989 991 { 990 <<<<<<< HEAD991 992 assume((iv->length())*(iv->length()) == iw->length()); 992 993 int i,j, nR = iv->length(); 993 994 994 =======995 assume(iv->length() == iw->length());996 int i, nR = iv->length();997 998 >>>>>>> f533f6f7667328bccb271b19b2f603aaebe41596999 995 intvec* ivm = new intvec(nR*nR); 1000 996 … … 2460 2456 //rChangeCurrRing(r); 2461 2457 } 2462 //unused 2463 #if 0 2464 static ring VMrDefault1(intvec* va) 2465 { 2466 2467 if ((currRing->ppNoether)!=NULL) 2468 { 2469 pDelete(&(currRing->ppNoether)); 2470 } 2471 if (((sLastPrinted.rtyp>BEGIN_RING) && (sLastPrinted.rtyp<END_RING)) || 2472 ((sLastPrinted.rtyp==LIST_CMD)&&(lRingDependend((lists)sLastPrinted.data)))) 2473 { 2474 sLastPrinted.CleanUp(); 2475 } 2476 2477 ring r = (ring) omAlloc0Bin(sip_sring_bin); 2478 int i, nv = currRing->N; 2479 2480 r->cf = currRing->cf; 2481 r->N = currRing->N; 2482 2483 int nb = 4; 2484 2485 //names 2486 char* Q; // In order to avoid the corrupted memory, do not change. 2487 r->names = (char **) omAlloc0(nv * sizeof(char_ptr)); 2488 for(i=0; i<nv; i++) 2489 { 2490 Q = currRing->names[i]; 2491 r->names[i] = omStrDup(Q); 2492 } 2493 2494 /*weights: entries for 3 blocks: NULL Made:???*/ 2495 r->wvhdl = (int **)omAlloc0(nb * sizeof(int_ptr)); 2496 r->wvhdl[0] = (int*) omAlloc(nv*sizeof(int)); 2497 for(i=0; i<nv; i++) 2498 r->wvhdl[0][i] = (*va)[i]; 2499 2500 /* order: a,lp,C,0 */ 2501 r->order = (int *) omAlloc(nb * sizeof(int *)); 2502 r->block0 = (int *)omAlloc0(nb * sizeof(int *)); 2503 r->block1 = (int *)omAlloc0(nb * sizeof(int *)); 2504 2505 // ringorder a for the first block: var 1..nv 2506 r->order[0] = ringorder_a; 2507 r->block0[0] = 1; 2508 r->block1[0] = nv; 2509 2510 // ringorder lp for the second block: var 1..nv 2511 r->order[1] = ringorder_lp; 2512 r->block0[1] = 1; 2513 r->block1[1] = nv; 2514 2515 // ringorder C for the third block 2516 // it is very important within "idLift", 2517 // especially, by ring syz_ring=rCurrRingAssure_SyzComp(); 2518 // therefore, nb must be (nBlocks(currRing) + 1) 2519 r->order[2] = ringorder_C; 2520 2521 // the last block: everything is 0 2522 r->order[3] = 0; 2523 2524 // polynomial ring 2525 r->OrdSgn = 1; 2526 2527 // complete ring intializations 2528 2529 rComplete(r); 2530 2531 //rChangeCurrRing(r); 2532 return r; 2533 } 2534 #endif 2458 2535 2459 /**************************************************************** 2536 2460 * define and execute a new ring with ordering (a(va),Wp(vb),C) * 2537 2461 * **************************************************************/ 2538 2539 2462 static ring VMrRefine(intvec* va, intvec* vb) 2540 2463 { … … 2610 2533 2611 2534 // complete ring intializations 2612 2535 2613 2536 rComplete(r); 2614 2537 … … 2840 2763 } 2841 2764 2842 2843 /* define a ring with parameters und change to it */ 2844 /* DefRingPar and DefRingParlp corrupt still memory */ 2765 /*************************************************** 2766 * define a ring with parameters und change to it * 2767 * DefRingPar and DefRingParlp corrupt still memory * 2768 ****************************************************/ 2845 2769 static void DefRingPar(intvec* va) 2846 2770 { … … 2990 2914 } 2991 2915 2992 //unused 2993 /************************************************************** 2994 * check wheather one or more components of a vector are zero * 2995 **************************************************************/ 2996 //#if 0 2916 /************************************************************* 2917 * check whether one or more components of a vector are zero * 2918 *************************************************************/ 2997 2919 static int isNolVector(intvec* hilb) 2998 2920 { … … 3007 2929 return 0; 3008 2930 } 3009 //#endif 2931 2932 /************************************************************* 2933 * check whether one or more components of a vector are <= 0 * 2934 *************************************************************/ 2935 static int isNegNolVector(intvec* hilb) 2936 { 2937 int i; 2938 for(i=hilb->length()-1; i>=0; i--) 2939 { 2940 if((* hilb)[i]<=0) 2941 { 2942 return 1; 2943 } 2944 } 2945 return 0; 2946 } 2947 2948 /************************************************************************** 2949 * Gomega is the initial ideal of G w. r. t. the current weight vector * 2950 * curr_weight. Check whether curr_weight lies on a border of the Groebner * 2951 * cone, i. e. check whether a monomial is divisible by a leading monomial * 2952 ***************************************************************************/ 2953 static ideal middleOfCone(ideal G, ideal Gomega) 2954 { 2955 BOOLEAN middle = FALSE; 2956 int i,j,N = IDELEMS(Gomega); 2957 poly p,lm,factor1,factor2; 2958 PrintS("\n//** idCopy\n"); 2959 ideal Go = idCopy(G); 2960 2961 PrintS("\n//** jetzt for-Loop!\n"); 2962 for(i=0; i<N; i++) 2963 { 2964 for(j=0; j<N; j++) 2965 { 2966 if(i!=j) 2967 { 2968 p = pCopy(Gomega->m[i]); 2969 lm = pCopy(Gomega->m[j]); 2970 pIter(p); 2971 while(p!=NULL) 2972 { 2973 if(pDivisibleBy(lm,p)) 2974 { 2975 if(middle == FALSE) 2976 { 2977 middle = TRUE; 2978 } 2979 factor1 = singclap_pdivide(pHead(p),lm,currRing); 2980 factor2 = pMult(pCopy(factor1),pCopy(Go->m[j])); 2981 pDelete(&factor1); 2982 Go->m[i] = pAdd((Go->m[i]),pNeg(pCopy(factor2))); 2983 pDelete(&factor2); 2984 } 2985 pIter(p); 2986 } 2987 pDelete(&lm); 2988 pDelete(&p); 2989 } 2990 } 2991 } 2992 2993 //PrintS("\n//** jetzt Delete!\n"); 2994 //pDelete(&p); 2995 //pDelete(&factor); 2996 //pDelete(&lm); 2997 if(middle == TRUE) 2998 { 2999 PrintS("\n//** middle TRUE!\n"); 3000 return Go; 3001 } 3002 PrintS("\n//** middle FALSE!\n"); 3003 idDelete(&Go); 3004 return NULL; 3005 } 3010 3006 3011 3007 /****************************** Februar 2002 **************************** … … 3314 3310 } 3315 3311 return 0; 3312 } 3313 3314 /***************************************** 3315 * return maximal polynomial length of G * 3316 *****************************************/ 3317 static int maxlengthpoly(ideal G) 3318 { 3319 int i,k,length=0; 3320 for(i=IDELEMS(G)-1; i>=0; i--) 3321 { 3322 k = pLength(G->m[i]); 3323 if(k>length) 3324 { 3325 length = k; 3326 } 3327 } 3328 return length; 3316 3329 } 3317 3330 … … 4325 4338 * compute a next weight vector * 4326 4339 ********************************/ 4327 static intvec* MWalkRandomNextWeight(ideal G, intvec* curr_weight, intvec* target_weight, int weight_rad, int pert_deg) 4328 { 4329 int i, weight_norm; 4330 //int randCount=0; 4331 int nV = currRing->N; 4340 static intvec* MWalkRandomNextWeight(ideal G, intvec* curr_weight, 4341 intvec* target_weight, int weight_rad, int pert_deg) 4342 { 4343 assume(currRing != NULL && curr_weight != NULL && 4344 target_weight != NULL && G->m[0] != NULL); 4345 4346 int i,weight_norm,nV = currRing->N; 4332 4347 intvec* next_weight2; 4333 4348 intvec* next_weight22 = new intvec(nV); 4334 4349 intvec* result = new intvec(nV); 4335 4350 4336 //compute a perturbed next weight vector "next_weight1"4337 4351 intvec* next_weight1 =MkInterRedNextWeight(curr_weight,target_weight,G); 4338 4352 //compute a random next weight vector "next_weight2" … … 4342 4356 while(weight_norm == 0) 4343 4357 { 4358 4344 4359 for(i=0; i<nV; i++) 4345 4360 { … … 4349 4364 weight_norm = 1 + floor(sqrt(weight_norm)); 4350 4365 } 4366 4351 4367 for(i=0; i<nV; i++) 4352 4368 { … … 4360 4376 } 4361 4377 } 4378 4362 4379 if(test_w_in_ConeCC(G, next_weight22) == 1) 4363 4380 { … … 4370 4387 } 4371 4388 i = 0; 4389 /* reduce the size of the maximal entry of the vector*/ 4372 4390 while(test_w_in_ConeCC(G,next_weight22)) 4373 4391 { … … 4381 4399 } 4382 4400 } 4401 4383 4402 // compute "usual" next weight vector 4384 4403 intvec* next_weight = MwalkNextWeightCC(curr_weight,target_weight, G); … … 4390 4409 { 4391 4410 ideal G_test1 = MwalkInitialForm(G, next_weight1); 4392 if( IDELEMS(G_test1) < IDELEMS(G_test))4393 { 4394 if( IDELEMS(G_test2) < IDELEMS(G_test1))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)) 4395 4414 { 4396 4415 // |G_test2| < |G_test1| < |G_test| … … 4407 4426 (*result)[i] = (*next_weight1)[i]; 4408 4427 } 4409 } 4428 } 4410 4429 } 4411 4430 else 4412 4431 { 4413 if( IDELEMS(G_test2) < IDELEMS(G_test)) // |G_test2| < |G_test| <= |G_test1|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| 4414 4433 { 4415 4434 for(i=0; i<nV; i++) … … 4432 4451 { 4433 4452 Overflow_Error = FALSE; 4434 if( IDELEMS(G_test2) < IDELEMS(G_test))4453 if(G_test2->m[0] != NULL && maxlengthpoly(G_test2) < maxlengthpoly(G_test))//if(IDELEMS(G_test2) < IDELEMS(G_test)) 4435 4454 { 4436 4455 for(i=1; i<nV; i++) … … 4447 4466 } 4448 4467 } 4468 PrintS("\n MWalkRandomNextWeight: Ende ok!\n"); 4449 4469 idDelete(&G_test); 4450 4470 idDelete(&G_test2); … … 5023 5043 int nV = baseRing->N; 5024 5044 5025 ideal Gomega, M, F, Gomega1, Gomega2, M1; //, F1;5045 ideal Gomega, M, F, FF, Gomega1, Gomega2, M1; //, F1; 5026 5046 ring newRing; 5027 5047 ring XXRing = baseRing; … … 5070 5090 } 5071 5091 rChangeCurrRing(newRing); 5072 ideal G = MstdCC(idrMoveR(Go,baseRing,currRing)); 5092 //ideal G = MstdCC(idrMoveR(Go,baseRing,currRing)); 5093 ideal G = idrMoveR(Go,baseRing,currRing); 5073 5094 baseRing = currRing; 5074 5095 #ifdef TIME_TEST … … 5102 5123 } 5103 5124 //#endif 5125 5126 5127 if(reduction == 0) 5128 { 5129 PrintS("\n//** Mwalk: test middle of cone!\n"); 5130 FF = middleOfCone(G,Gomega); 5131 PrintS("\n//** Mwalk: Test F!\n"); 5132 if( FF != NULL) 5133 { 5134 idDelete(&G); 5135 G = idCopy(FF); 5136 idDelete(&FF); 5137 PrintS("\n//** Mwalk: FF nicht NULL! Compue next vector.\n"); 5138 goto NEXT_VECTOR; 5139 } 5140 } 5141 5104 5142 #ifndef BUCHBERGER_ALG 5105 5143 if(isNolVector(curr_weight) == 0) 5106 5144 { 5107 5145 hilb_func = hFirstSeries(Gomega,NULL,NULL,curr_weight,currRing); 5108 } 5146 } 5109 5147 else 5110 5148 { … … 5204 5242 to = clock(); 5205 5243 #endif 5244 NEXT_VECTOR: 5245 PrintS("\n//** Mwalk: NEXT_VECTOR!\n"); 5206 5246 intvec* next_weight = MwalkNextWeightCC(curr_weight,target_weight,G); 5207 5247 #ifdef TIME_TEST … … 5239 5279 idString(Gomega1, "//** Mwalk: Gomega"); 5240 5280 } 5281 PrintS("\n //** Mwalk: kStd(Gomega)"); 5241 5282 //#endif 5242 5283 M = kStd(Gomega1,NULL,testHomog,NULL,NULL,0,0,NULL); … … 5252 5293 Gomega2 = idrMoveR(Gomega1, newRing,currRing); 5253 5294 idDelete(&Gomega1); 5295 PrintS("\n //** Mwalk: MLifttwoIdeal"); 5254 5296 F = MLifttwoIdeal(Gomega2, M1, G); 5255 5297 //#ifdef CHECK_IDEAL_MWALK … … 5270 5312 to = clock(); 5271 5313 #endif 5314 //PrintS("\n //**Mwalk: Interreduce"); 5272 5315 //interreduce the Groebner basis <G> w.r.t. currRing 5273 G = kInterRedCC(G,NULL);5316 //G = kInterRedCC(G,NULL); 5274 5317 #ifdef TIME_TEST 5275 5318 tred = tred + clock() - to; … … 5369 5412 } 5370 5413 rChangeCurrRing(newRing); 5371 ideal G = MstdCC(idrMoveR(Go,baseRing,currRing)); 5414 //ideal G = MstdCC(idrMoveR(Go,baseRing,currRing)); 5415 ideal G = idrMoveR(Go,baseRing,currRing); 5372 5416 baseRing = currRing; 5373 5417 #ifdef TIME_TEST … … 5405 5449 { 5406 5450 hilb_func = hFirstSeries(Gomega,NULL,NULL,curr_weight,currRing); 5407 } 5451 } 5408 5452 else 5409 5453 { … … 5514 5558 } 5515 5559 //#endif 5516 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)5560 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) 5517 5561 { 5518 5562 #ifdef CHECK_IDEAL_MWALK … … 5565 5609 idString(G,"//** Mrwalk: G"); 5566 5610 } 5567 / *#endif5611 ///#endif 5568 5612 if(si_opt_1 == (Sy_bit(OPT_REDSB))) 5569 { */5570 G = kInterRedCC(G,NULL); //interreduce the Groebner basis <G> w.r.t. currRing5571 //}5613 { 5614 //G = kInterRedCC(G,NULL); //interreduce the Groebner basis <G> w.r.t. currRing 5615 } 5572 5616 #ifdef TIME_TEST 5573 5617 tred = tred + clock() - to; … … 5861 5905 nstep ++; 5862 5906 to = clock(); 5863 / *compute an initial form ideal of <G> w.r.t. the weight vector5864 "curr_weight" */5907 // compute an initial form ideal of <G> w.r.t. the weight vector 5908 // "curr_weight" 5865 5909 Gomega = MwalkInitialForm(G, curr_weight); 5866 5910 //#ifdef CHECK_IDEAL_MWALK 5867 5868 5869 5870 5911 if(printout > 1) 5912 { 5913 idString(Gomega,"//** Mpwalk: Gomega"); 5914 } 5871 5915 //#endif 5872 5916 … … 5916 5960 tim = clock(); 5917 5961 to = clock(); 5918 / * compute a reduced Groebner basis of <Gomega> w.r.t. "newRing" */5962 // compute a reduced Groebner basis of <Gomega> w.r.t. "newRing" 5919 5963 #ifdef BUCHBERGER_ALG 5920 5964 M = MstdhomCC(Gomega1); … … 5940 5984 tstd=tstd+clock()-to; 5941 5985 5942 / * change the ring to oldRing */5986 // change the ring to oldRing 5943 5987 rChangeCurrRing(oldRing); 5944 5988 M1 = idrMoveR(M, newRing,currRing); … … 5966 6010 idDelete(&G); 5967 6011 5968 / * change the ring to newRing */6012 // change the ring to newRing 5969 6013 rChangeCurrRing(newRing); 5970 6014 F1 = idrMoveR(F, oldRing,currRing); 5971 6015 //G = idrMoveR(F,oldRing,currRing); 5972 6016 to=clock(); 5973 /* reduce the Groebner basis <G> w.r.t. new ring */6017 PrintS("\n //** Mpwalk: reduce the Groebner basis.\n"); 5974 6018 G = kInterRedCC(F1, NULL); 5975 6019 if(endwalks != 1) … … 5988 6032 tnw=tnw+clock()-to; 5989 6033 //#ifdef PRINT_VECTORS 5990 if(printout > 2)6034 if(printout > 0) 5991 6035 { 5992 6036 MivString(curr_weight, target_weight, next_weight); … … 6016 6060 6017 6061 delete next_weight; 6018 }// while6062 }//end of while-loop 6019 6063 6020 6064 if(tp_deg != 1) … … 6264 6308 nstep ++; 6265 6309 to = clock(); 6266 / *compute an initial form ideal of <G> w.r.t. the weight vector6267 "curr_weight" */6310 // compute an initial form ideal of <G> w.r.t. the weight vector 6311 // "curr_weight" 6268 6312 Gomega = MwalkInitialForm(G, curr_weight); 6269 6313 //#ifdef CHECK_IDEAL_MWALK 6270 if(printout > 1)6314 if(printout > 0) 6271 6315 { 6272 6316 idString(Gomega,"//** Mprwalk: Gomega"); … … 6308 6352 newRing = currRing; 6309 6353 Gomega1 = idrMoveR(Gomega, oldRing,currRing); 6310 6354 PrintS("\n //** Mprwalk: Changed ring.\n"); 6311 6355 #ifdef ENDWALKS 6312 6356 if(endwalks==1) … … 6325 6369 tim = clock(); 6326 6370 to = clock(); 6327 / * compute a reduced Groebner basis of <Gomega> w.r.t. "newRing" */6371 // compute a reduced Groebner basis of <Gomega> w.r.t. "newRing" 6328 6372 #ifdef BUCHBERGER_ALG 6329 6373 M = MstdhomCC(Gomega1); … … 6333 6377 #endif 6334 6378 //#ifdef CHECK_IDEAL_MWALK 6379 Print("\n //** Mprwalk: M"); 6335 6380 if(printout > 2) 6336 6381 { … … 6364 6409 else 6365 6410 xtlift=clock()-to; 6366 6411 Print("\n //** Mprwalk: F.\n"); 6367 6412 //#ifdef CHECK_IDEAL_MWALK 6368 6413 if(printout > 2) … … 6376 6421 idDelete(&G); 6377 6422 6378 / * change the ring to newRing */6423 // change the ring to newRing 6379 6424 rChangeCurrRing(newRing); 6380 F1 = idrMoveR(F, oldRing,currRing);6381 6425 //F1 = idrMoveR(F, oldRing,currRing); 6426 F1 = idrMoveR(F,oldRing,currRing); 6382 6427 to=clock(); 6383 /* reduce the Groebner basis <G> w.r.t. new ring */6428 Print("\n //** Mprwalk: reducing the Groebner basis.\n"); 6384 6429 G = kInterRedCC(F1, NULL); 6385 6430 if(endwalks != 1) … … 6394 6439 6395 6440 to=clock(); 6396 // compute a next weight vector6441 Print("\n //** Mprwalk: compute a next weight vector.\n"); 6397 6442 next_weight = MkInterRedNextWeight(curr_weight,target_weight, G); 6398 6443 if(polylength > 0) 6399 6444 { 6400 //there is a polynomial in Gomega with at least 3 monomials, 6401 //low-dimensional facet of the cone 6445 Print("\n //**Mprwalk: there is a polynomial in Gomega with at least 3 monomials, low-dimensional facet of the cone.\n"); 6402 6446 delete next_weight; 6403 6447 next_weight = MWalkRandomNextWeight(G, curr_weight, target_weight, weight_rad, op_deg); … … 6405 6449 tnw=tnw+clock()-to; 6406 6450 //#ifdef PRINT_VECTORS 6407 if(printout > 2)6451 if(printout > 0) 6408 6452 { 6409 6453 MivString(curr_weight, target_weight, next_weight); … … 6763 6807 Gt = idrMoveR(G, oRing,currRing); 6764 6808 6765 if(test_w_in_ConeCC(Gt, omega2) == 1) { 6809 if(test_w_in_ConeCC(Gt, omega2) == 1) 6810 { 6766 6811 delete omega2; 6767 6812 delete next_vect; … … 6771 6816 Print("\n//** rec_fractal_call: Leaving the %d-th recursion with %d steps.\n", 6772 6817 nlev, nwalks); 6773 //Print(" ** Overflow_Error? (%d)", Overflow_Error);6774 6818 } 6775 6819 return (Gt); … … 6777 6821 else 6778 6822 { 6779 //ivString(omega2, "tau'"); 6780 //Print("\n// tau' doesn't stay in the correct cone!!"); 6781 6823 if(printout > 0) 6824 { 6825 Print("\n//** rec_fractal_call: tau' doesn't stay in the correct cone!!"); 6826 } 6782 6827 #ifndef MSTDCC_FRACTAL 6783 //07.08.036784 //ivString(Xtau, "old Xtau");6785 6828 intvec* Xtautmp; 6786 6829 if(ivtarget->length() == nV) … … 6799 6842 if(MivSame(Xtau, Xtautmp) == 1) 6800 6843 { 6801 //PrintS("\n// Update vectors are equal to the old vectors!!"); 6844 if(printout > 0) 6845 { 6846 Print("\n//** rec_fractal_call: Update vectors are equal to the old vectors!!"); 6847 } 6802 6848 delete Xtautmp; 6803 6849 goto FRACTAL_MSTDCC; … … 6806 6852 Xtau = Xtautmp; 6807 6853 Xtautmp = NULL; 6808 //ivString(Xtau, "new Xtau");6809 6854 6810 6855 for(i=nV-1; i>=0; i--) 6811 6856 (*omega2)[i] = (*Xtau)[(nlev-1)*nV+i]; 6812 6857 6813 //Print("\n// ring tau = %s;", rString(currRing));6814 6858 rChangeCurrRing(oRing); 6815 6859 G = idrMoveR(Gt, testring,currRing); … … 6851 6895 Gt = idrMoveR(G, oRing,currRing); 6852 6896 6853 delete Xtau; 6854 Xtau = NewVectorlp(Gt); 6897 // perturb the original target vector w.r.t. the current GB 6898 if(ivtarget->length() == nV) 6899 { 6900 delete Xtau; 6901 Xtau = NewVectorlp(Gt); 6902 } 6903 else 6904 { 6905 delete Xtau; 6906 Xtau = Mfpertvector(Gt,ivtarget); 6907 } 6855 6908 6856 6909 rChangeCurrRing(oRing); … … 6893 6946 else 6894 6947 hilb_func = hFirstSeries(Gomega,NULL,NULL,last_omega,currRing); 6895 #endif // BUCHBERGER_ALG 6948 #endif 6949 6896 6950 if(ivtarget->length() == nV) 6897 6951 { … … 6910 6964 // Fractal walk with the alternative recursion 6911 6965 // alternative recursion 6912 // if(nlev == nV || lengthpoly(Gomega1) == 0)6913 6966 if(nlev == Xnlev || lengthpoly(Gomega1) == 0) 6914 //if(nlev == nV) // blind recursion6915 6967 { 6916 6968 to=clock(); … … 6920 6972 Gresult =kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,omega); 6921 6973 delete hilb_func; 6922 #endif // BUCHBERGER_ALG6974 #endif 6923 6975 xtstd=xtstd+clock()-to; 6924 6976 } … … 6953 7005 6954 7006 rChangeCurrRing(new_ring); 6955 F1 = idrMoveR(F, oRing,currRing);6956 7007 //F1 = idrMoveR(F, oRing,currRing); 7008 G = idrMoveR(F,oRing,currRing); 6957 7009 to=clock(); 6958 7010 /* Interreduce G */ 6959 G = kInterRedCC(F1, NULL);7011 // G = kInterRedCC(F1, NULL); 6960 7012 xtred=xtred+clock()-to; 6961 idDelete(&F1);7013 //idDelete(&F1); 6962 7014 } 6963 7015 } … … 7017 7069 { 7018 7070 #ifdef FIRST_STEP_FRACTAL 7019 // perturb the current weight vector only on the top level or 7020 // after perturbation of the both vectors, nlev = 2 as the top level 7071 /* 7072 perturb the current weight vector only on the top level or 7073 after perturbation of the both vectors, nlev = 2 as the top level 7074 */ 7021 7075 if((nlev == 1 && Xcall == 0) || (nlev == 2 && Xngleich == 1)) 7022 7076 if(islengthpoly2(G) == 1) … … 7033 7087 /* determine the next border */ 7034 7088 next_vect = MkInterRedNextWeight(omega,omega2,G); 7035 if(polylength > 0) 7036 { 7037 //there is a polynomial in Gomega with at least 3 monomials, 7038 //low-dimensional facet of the cone 7089 if(polylength > 0 && G->m[0] != NULL) 7090 { 7091 /* 7092 there is a polynomial in Gomega with at least 3 monomials, 7093 low-dimensional facet of the cone 7094 */ 7039 7095 delete next_vect; 7040 next_vect = MWalkRandomNextWeight(G,omega,omega2,weight_rad, 1+nlev);7041 if(isN olVector(next_vect))7096 next_vect = MWalkRandomNextWeight(G,omega,omega2,weight_rad,nlev); 7097 if(isNegNolVector(next_vect)==1) 7042 7098 { 7043 7099 delete next_vect; … … 7057 7113 if(printout > 0) 7058 7114 { 7059 Print("\n//** rec_r_fractal_call: Perturb theboth vectors with degree %d.",nlev);7115 Print("\n//** rec_r_fractal_call: Perturb both vectors with degree %d.",nlev); 7060 7116 //idElements(G, "G"); 7061 7117 } … … 7109 7165 to=clock(); 7110 7166 7111 /* to avoid the value of Overflow_Error that occur in Mfpertvector*/ 7167 /* 7168 to avoid the value of Overflow_Error that occur in 7169 Mfpertvector 7170 */ 7112 7171 Overflow_Error = FALSE; 7113 7172 7114 7173 next_vect = MkInterRedNextWeight(omega,omega2,G); 7115 if( polylength > 0)7174 if(G->m[0] != NULL && polylength > 0) 7116 7175 { 7117 //there is a polynomial in Gomega with at least 3 monomials, 7118 //low-dimensional facet of the cone 7176 /* 7177 there is a polynomial in Gomega with at least 3 monomials, 7178 low-dimensional facet of the cone 7179 */ 7119 7180 delete next_vect; 7120 next_vect = MWalkRandomNextWeight(G,omega,omega2,weight_rad, 1+nlev);7121 if(isN olVector(next_vect))7181 next_vect = MWalkRandomNextWeight(G,omega,omega2,weight_rad,nlev); 7182 if(isNegNolVector(next_vect)==1) 7122 7183 { 7123 7184 delete next_vect; … … 7228 7289 Print("\n//** rec_r_fractal_call: target weight doesn't stay in the correct cone.\n"); 7229 7290 } 7291 7230 7292 #ifndef MSTDCC_FRACTAL 7231 7293 //ivString(Xtau, "old Xtau"); … … 7268 7330 if(printout > 0) 7269 7331 { 7270 Print("\n//** rec_r_fractal_call: apply Buchberge 's algorithm in ring = %s.\n",7332 Print("\n//** rec_r_fractal_call: apply Buchberger's algorithm in ring = %s.\n", 7271 7333 rString(currRing)); 7272 7334 } … … 7298 7360 Gt = idrMoveR(G, oRing,currRing); 7299 7361 7300 delete Xtau; 7301 Xtau = NewVectorlp(Gt); 7362 // perturb the original target vector w.r.t. the current GB 7363 if(ivtarget->length() == nV) 7364 { 7365 delete Xtau; 7366 Xtau = NewVectorlp(Gt); 7367 } 7368 else 7369 { 7370 delete Xtau; 7371 Xtau = Mfpertvector(Gt,ivtarget); 7372 } 7302 7373 7303 7374 rChangeCurrRing(oRing); … … 7319 7390 return(G); 7320 7391 } 7321 } 7322 7323 for(i=nV-1; i>=0; i--) { 7392 } //end of if(MivComp(next_vect, XivNull) == 1) 7393 7394 for(i=nV-1; i>=0; i--) 7395 { 7324 7396 (*altomega)[i] = (*omega)[i]; 7325 7397 (*omega)[i] = (*next_vect)[i]; … … 7374 7446 rChangeCurrRing(oRing); 7375 7447 Gomega1 = idrMoveR(Gomega1, oRing,currRing); 7376 Gresult = rec_ fractal_call(idCopy(Gomega1),nlev+1,omega,printout);7448 Gresult = rec_r_fractal_call(idCopy(Gomega1),nlev+1,omega,weight_rad,printout); 7377 7449 } 7378 7450 if(printout > 2) … … 7402 7474 7403 7475 rChangeCurrRing(new_ring); 7404 F1 = idrMoveR(F, oRing,currRing);7405 7476 //F1 = idrMoveR(F, oRing,currRing); 7477 G = idrMoveR(F,oRing,currRing); 7406 7478 to=clock(); 7407 7479 // Interreduce G 7408 G = kInterRedCC(F1, NULL);7480 //G = kInterRedCC(F1, NULL); 7409 7481 xtred=xtred+clock()-to; 7410 idDelete(&F1);7482 //idDelete(&F1); 7411 7483 } 7412 7484 } … … 8916 8988 8917 8989 //Print("\n// \"Mpwalk\" (1,%d) took %d steps and %.2f sec. Overflow_Error (%d)", tp_deg, nwalk, ((double) clock()-tinput)/1000000, nOverflow_Error); 8918 <<<<<<< HEAD8919 =======8920 8921 return(result);8922 }8923 8924 /*******************************************************8925 * THE PERTURBATION WALK ALGORITHM WITH RANDOM ELEMENT *8926 *******************************************************/8927 ideal Mprwalk(ideal Go, intvec* curr_weight, intvec* target_weight, int weight_rad, int op_deg, int tp_deg, ring baseRing)8928 {8929 BITSET save1 = si_opt_1; // save current options8930 si_opt_1 &= (~Sy_bit(OPT_REDSB)); // no reduced Groebner basis8931 Set_Error(FALSE);8932 Overflow_Error = FALSE;8933 #ifdef TIME_TEST8934 clock_t tinput=0, tostd=0, tif=0, tstd=0, tlift=0, tred=0, tnw=0;8935 xtif=0; xtstd=0; xtlift=0; xtred=0; xtnw=0;8936 tinput = clock();8937 clock_t tim;8938 #endif8939 int i,nwalk,nV = baseRing->N;8940 8941 ideal G, Gomega, M, F, Gomega1, Gomega2, M1;8942 ring newRing;8943 ring XXRing = baseRing;8944 intvec* exivlp = Mivlp(nV);8945 intvec* orig_target = target_weight;8946 intvec* pert_target_vector = target_weight;8947 intvec* ivNull = new intvec(nV);8948 intvec* tmp_weight = new intvec(nV);8949 #ifdef CHECK_IDEAL_MWALK8950 poly p;8951 #endif8952 for(i=0; i<nV; i++)8953 {8954 (*tmp_weight)[i] = (*curr_weight)[i];8955 }8956 #ifndef BUCHBERGER_ALG8957 intvec* hilb_func;8958 // to avoid (1,0,...,0) as the target vector8959 intvec* last_omega = new intvec(nV);8960 for(i=0 i<nV; i++)8961 {8962 (*last_omega)[i] = 1;8963 }8964 (*last_omega)[0] = 10000;8965 #endif8966 baseRing = currRing;8967 newRing = VMrDefault(curr_weight);8968 rChangeCurrRing(newRing);8969 G = idrMoveR(Go,baseRing,currRing);8970 #ifdef TIME_TEST8971 to = clock();8972 #endif8973 G = kStd(G,NULL,testHomog,NULL,NULL,0,0,NULL);8974 idSkipZeroes(G);8975 #ifdef TIME_TEST8976 tostd = tostd + to - clock();8977 #endif8978 #ifdef CHECK_IDEAL_MWALK8979 idString(G,"G");8980 #endif8981 if(op_deg >1)8982 {8983 if(MivComp(curr_weight,MivUnit(nV)) == 1) //ring order is "dp"8984 {8985 curr_weight = MPertVectors(G, MivMatrixOrderdp(nV), op_deg);8986 }8987 else //ring order is not "dp"8988 {8989 curr_weight = MPertVectors(G, MivMatrixOrder(curr_weight), op_deg);8990 }8991 }8992 baseRing = currRing;8993 if(tp_deg > 1 && tp_deg <= nV)8994 {8995 pert_target_vector = target_weight;8996 }8997 #ifdef CHECK_IDEAL_MWALK8998 ivString(curr_weight, "new curr_weight");8999 ivString(target_weight, "new target_weight");9000 #endif9001 nwalk = 0;9002 while(1)9003 {9004 nwalk ++;9005 #ifdef TIME_TEST9006 to = clock();9007 #endif9008 Gomega = MwalkInitialForm(G, curr_weight); // compute an initial form ideal of <G> w.r.t. "curr_vector"9009 #ifdef TIME_TEST9010 tif = tif + clock()-to; //time for computing initial form ideal9011 #endif9012 #ifdef CHECK_IDEAL_MWALK9013 idString(Gomega,"Gomega");9014 #endif9015 #ifndef BUCHBERGER_ALG9016 if(isNolVector(curr_weight) == 0)9017 {9018 hilb_func = hFirstSeries(Gomega,NULL,NULL,curr_weight,currRing);9019 }9020 else9021 {9022 hilb_func = hFirstSeries(Gomega,NULL,NULL,last_omega,currRing);9023 }9024 #endif9025 if(nwalk == 1)9026 {9027 newRing = VMrDefault(curr_weight); // define a new ring with ordering "(a(curr_weight),lp)9028 }9029 else9030 {9031 newRing = VMrRefine(curr_weight,target_weight); //define a new ring with ordering "(a(curr_weight),Wp(target_weight))"9032 }9033 rChangeCurrRing(newRing);9034 Gomega1 = idrMoveR(Gomega, baseRing,currRing);9035 idDelete(&Gomega);9036 // compute a Groebner basis of <Gomega> w.r.t. "newRing"9037 #ifdef TIME_TEST9038 to = clock();9039 #endif9040 #ifndef BUCHBERGER_ALG9041 M=kStd(Gomega1,NULL,isHomog,NULL,hilb_func,0,NULL,curr_weight);9042 delete hilb_func;9043 #else9044 M = kStd(Gomega1,NULL,testHomog,NULL,NULL,0,0,NULL);9045 #endif9046 idSkipZeroes(M);9047 #ifdef TIME_TEST9048 tstd = tstd + clock() - to;9049 #endif9050 #ifdef CHECK_IDEAL_MWALK9051 idString(M, "M");9052 #endif9053 //change the ring to baseRing9054 rChangeCurrRing(baseRing);9055 M1 = idrMoveR(M, newRing,currRing);9056 idDelete(&M);9057 Gomega2 = idrMoveR(Gomega1, newRing,currRing);9058 idDelete(&Gomega1);9059 to = clock();9060 // compute a representation of the generators of submod (M) with respect to those of mod (Gomega), where Gomega is a reduced Groebner basis w.r.t. the current ring9061 F = MLifttwoIdeal(Gomega2, M1, G);9062 idSkipZeroes(F);9063 #ifdef TIME_TEST9064 tlift = tlift + clock() - to;9065 #endif9066 #ifdef CHECK_IDEAL_MWALK9067 idString(F,"F");9068 #endif9069 rChangeCurrRing(newRing); // change the ring to newRing9070 G = idrMoveR(F,baseRing,currRing);9071 idDelete(&F);9072 baseRing = currRing; // set baseRing equal to newRing9073 #ifdef CHECK_IDEAL_MWALK9074 idString(G,"G");9075 #endif9076 #ifdef TIME_TEST9077 to = clock();9078 #endif9079 intvec* next_weight = MWalkRandomNextWeight(G, curr_weight, target_weight, weight_rad, op_deg);9080 #ifdef TIME_TEST9081 tnw = tnw + clock() - to;9082 #endif9083 #ifdef PRINT_VECTORS9084 MivString(curr_weight, target_weight, next_weight);9085 #endif9086 if(Overflow_Error == TRUE)9087 {9088 PrintS("\n//**Mprwalk: OVERFLOW: The computed vector does not stay in cone, the result may be wrong.\n");9089 delete next_weight;9090 break;9091 }9092 9093 if(test_w_in_ConeCC(G,target_weight) == 1 || MivComp(next_weight, ivNull) == 1)9094 {9095 delete next_weight;9096 break;9097 }9098 //update tmp_weight and curr_weight9099 for(i=nV-1; i>=0; i--)9100 {9101 (*tmp_weight)[i] = (*curr_weight)[i];9102 (*curr_weight)[i] = (*next_weight)[i];9103 }9104 delete next_weight;9105 } //end of while-loop9106 >>>>>>> f533f6f7667328bccb271b19b2f603aaebe415969107 8990 Print("\n// Mprwalk took %d steps. Ring= %s;\n", nwalk, rString(currRing)); 9108 8991 return(result); -
Singular/walk.h
rdbf609 r4052dc 52 52 53 53 /* Okt -- Nov'01 */ 54 // compute a Groebner basis of an ideal G w.r.t. lexicographic order 54 // compute a Groebner basis of an ideal G w.r.t. lexicographic order 55 55 //ideal Mwalk(ideal Go, intvec* orig_M, intvec* target_M); 56 56 ideal Mwalk(ideal Go, intvec* orig_M, intvec* target_M, ring baseRing, int reduction, int printout);
Note: See TracChangeset
for help on using the changeset viewer.