Changeset ad6ad2 in git
- Timestamp:
- Feb 17, 2006, 12:23:59 PM (18 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- df497afd2bc88c62fa31b51b14c27cda326ca087
- Parents:
- ca086fff3254b7760369d86835edcfb4b02f4d1d
- Location:
- kernel
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/tgb.cc
rca086f rad6ad2 5 5 * Computer Algebra System SINGULAR * 6 6 ****************************************/ 7 /* $Id: tgb.cc,v 1.5 5 2006-02-17 10:25:32bricken Exp $ */7 /* $Id: tgb.cc,v 1.56 2006-02-17 11:23:58 bricken Exp $ */ 8 8 /* 9 9 * ABSTRACT: slimgb and F4 implementation … … 673 673 } 674 674 675 static void notice_miss(int i, int j, slimgb_alg* c){676 if (TEST_OPT_PROT)677 PrintS("-");678 679 }680 675 681 676 static void cleanS(kStrategy strat, slimgb_alg* c){ … … 814 809 //assume(lenS_correct(strat)); 815 810 } 816 static void replace_pair(int & i, int & j, slimgb_alg* c) 817 { 818 c->soon_free=NULL; 819 int curr_deg; 820 poly lm=pOne(); 821 822 pLcm(c->S->m[i], c->S->m[j], lm); 823 pSetm(lm); 824 int deciding_deg= pTotaldegree(lm); 825 int* i_con =make_connections(i,j,lm,c); 826 827 for (int n=0;((n<c->n) && (i_con[n]>=0));n++){ 828 if (i_con[n]==j){ 829 now_t_rep(i,j,c); 830 omfree(i_con); 831 p_Delete(&lm,c->r); 832 return; 833 } 834 } 835 836 int* j_con =make_connections(j,lm,c); 837 i= i_con[0]; 838 j=j_con[0]; 839 if(c->n>1){ 840 if (i_con[1]>=0) 841 i=i_con[1]; 842 else { 843 if (j_con[1]>=0) 844 j=j_con[1]; 845 } 846 } 847 pLcm(c->S->m[i], c->S->m[j], lm); 848 pSetm(lm); 849 poly short_s; 850 curr_deg=pTotaldegree(lm); 851 int_pair_node* last=NULL; 852 853 for (int n=0;((n<c->n) && (j_con[n]>=0));n++){ 854 for (int m=0;((m<c->n) && (i_con[m]>=0));m++){ 855 pLcm(c->S->m[i_con[m]], c->S->m[j_con[n]], lm); 856 pSetm(lm); 857 if (pTotaldegree(lm)>=deciding_deg) 858 { 859 soon_t_rep(i_con[m],j_con[n],c); 860 int_pair_node* h= (int_pair_node*)omalloc(sizeof(int_pair_node)); 861 if (last!=NULL) 862 last->next=h; 863 else 864 c->soon_free=h; 865 h->next=NULL; 866 h->a=i_con[m]; 867 h->b=j_con[n]; 868 last=h; 869 } 870 // if ((comp_deg<curr_deg) 871 // || 872 // ((comp_deg==curr_deg) && 873 short_s=ksCreateShortSpoly(c->S->m[i_con[m]],c->S->m[j_con[n]],c->r); 874 if (short_s==NULL) { 875 i=i_con[m]; 876 j=j_con[n]; 877 now_t_rep(i_con[m],j_con[n],c); 878 p_Delete(&lm,c->r); 879 omfree(i_con); 880 omfree(j_con); 881 882 return; 883 } 884 #ifdef QUICK_SPOLY_TEST 885 for (int dz=0;dz<=c->n;dz++){ 886 if (dz==c->n) { 887 //have found not head reducing pair 888 i=i_con[m]; 889 j=j_con[n]; 890 p_Delete(&short_s,c->r); 891 p_Delete(&lm,c->r); 892 omfree(i_con); 893 omfree(j_con); 894 895 return; 896 } 897 if (p_LmDivisibleBy(c->S->m[dz],short_s,c->r)) break; 898 } 899 #endif 900 int comp_deg(pTotaldegree(short_s)); 901 p_Delete(&short_s,c->r); 902 if ((comp_deg<curr_deg)) 903 904 { 905 curr_deg=comp_deg; 906 i=i_con[m]; 907 j=j_con[n]; 908 } 909 } 910 } 911 p_Delete(&lm,c->r); 912 omfree(i_con); 913 omfree(j_con); 914 return; 915 } 916 917 918 static int* make_connections(int from, poly bound, slimgb_alg* c) 919 { 920 ideal I=c->S; 921 int s=pTotaldegree(bound); 922 int* cans=(int*) omalloc(c->n*sizeof(int)); 923 int* connected=(int*) omalloc(c->n*sizeof(int)); 924 int cans_length=0; 925 connected[0]=from; 926 int connected_length=1; 927 long neg_bounds_short= ~p_GetShortExpVector(bound,c->r); 928 for (int i=0;i<c->n;i++){ 929 if (c->T_deg[i]>s) continue; 930 if (i!=from){ 931 if(p_LmShortDivisibleBy(I->m[i],c->short_Exps[i],bound,neg_bounds_short,c->r)){ 932 cans[cans_length]=i; 933 cans_length++; 934 } 935 } 936 } 937 int not_yet_found=cans_length; 938 int con_checked=0; 939 int pos; 940 while((not_yet_found>0) && (con_checked<connected_length)){ 941 pos=connected[con_checked]; 942 for(int i=0;i<cans_length;i++){ 943 if (cans[i]<0) continue; 944 if (has_t_rep(pos,cans[i],c)) 945 { 946 connected[connected_length]=cans[i]; 947 connected_length++; 948 cans[i]=-1; 949 --not_yet_found; 950 } 951 } 952 con_checked++; 953 } 954 if (connected_length<c->n){ 955 connected[connected_length]=-1; 956 } 957 omfree(cans); 958 return connected; 959 } 811 960 812 static int* make_connections(int from, int to, poly bound, slimgb_alg* c) 961 813 { … … 1080 932 if (strat->lenSw) return pos_helper(strat,p,(wlen_type) wlen,(wlen_set) strat->lenSw,strat->S); 1081 933 return pos_helper(strat,p,len,strat->lenS,strat->S); 1082 // 1083 //if (strat->lenSw) setL=strat->lenSw; 1084 //int length=strat->sl; 1085 //int i; 1086 //int an = 0; 1087 //int en= length; 1088 // 1089 //if ((len>setL[length]) 1090 // || ((len==setL[length]) && (pLmCmp(set[length],p)== -1))) 1091 // return length+1; 1092 // 1093 //loop 1094 //{ 1095 // if (an >= en-1) 1096 // { 1097 // if ((len<setL[an]) 1098 // || ((len==setL[an]) && (pLmCmp(set[an],p) == 1))) return an; 1099 // return en; 1100 // } 1101 // i=(an+en) / 2; 1102 // if ((len<setL[i]) 1103 // || ((len==setL[i]) && (pLmCmp(set[i],p) == 1))) en=i; 1104 // //else if ((len>setL[i]) 1105 // //|| ((len==setL[i]) && (pLmCmp(set[i],p) == -1))) an=i; 1106 // else an=i; 1107 //} 934 1108 935 } 1109 936 … … 2361 2188 c->states[j][i]=HASTREP; 2362 2189 } 2363 static void soon_t_rep(const int& arg_i, const int& arg_j, slimgb_alg* c) 2364 { 2365 assume(0<=arg_i); 2366 assume(0<=arg_j); 2367 assume(arg_i<c->n); 2368 assume(arg_j<c->n); 2369 int i,j; 2370 if (arg_i==arg_j){ 2371 return; 2372 } 2373 if (arg_i>arg_j){ 2374 i=arg_j; 2375 j=arg_i; 2376 } else { 2377 i=arg_i; 2378 j=arg_j; 2379 } 2380 if (! 2381 (c->states[j][i]==HASTREP)) 2382 c->states[j][i]=SOONTREP; 2383 } 2190 2384 2191 static BOOLEAN has_t_rep(const int & arg_i, const int & arg_j, slimgb_alg* state){ 2385 2192 assume(0<=arg_i); -
kernel/tgb_obsolete.cc
rca086f rad6ad2 1 1 #include "tgb_internal.h" 2 #if 0 3 static void notice_miss(int i, int j, slimgb_alg* c){ 4 if (TEST_OPT_PROT) 5 PrintS("-"); 6 7 } 8 #endif 2 9 static poly redNF (poly h,kStrategy strat, int &len) 3 10 { … … 391 398 } 392 399 } 400 401 #if 0 402 static void replace_pair(int & i, int & j, slimgb_alg* c) 403 { 404 c->soon_free=NULL; 405 int curr_deg; 406 poly lm=pOne(); 407 408 pLcm(c->S->m[i], c->S->m[j], lm); 409 pSetm(lm); 410 int deciding_deg= pTotaldegree(lm); 411 int* i_con =make_connections(i,j,lm,c); 412 413 for (int n=0;((n<c->n) && (i_con[n]>=0));n++){ 414 if (i_con[n]==j){ 415 now_t_rep(i,j,c); 416 omfree(i_con); 417 p_Delete(&lm,c->r); 418 return; 419 } 420 } 421 422 int* j_con =make_connections(j,lm,c); 423 i= i_con[0]; 424 j=j_con[0]; 425 if(c->n>1){ 426 if (i_con[1]>=0) 427 i=i_con[1]; 428 else { 429 if (j_con[1]>=0) 430 j=j_con[1]; 431 } 432 } 433 pLcm(c->S->m[i], c->S->m[j], lm); 434 pSetm(lm); 435 poly short_s; 436 curr_deg=pTotaldegree(lm); 437 int_pair_node* last=NULL; 438 439 for (int n=0;((n<c->n) && (j_con[n]>=0));n++){ 440 for (int m=0;((m<c->n) && (i_con[m]>=0));m++){ 441 pLcm(c->S->m[i_con[m]], c->S->m[j_con[n]], lm); 442 pSetm(lm); 443 if (pTotaldegree(lm)>=deciding_deg) 444 { 445 soon_t_rep(i_con[m],j_con[n],c); 446 int_pair_node* h= (int_pair_node*)omalloc(sizeof(int_pair_node)); 447 if (last!=NULL) 448 last->next=h; 449 else 450 c->soon_free=h; 451 h->next=NULL; 452 h->a=i_con[m]; 453 h->b=j_con[n]; 454 last=h; 455 } 456 // if ((comp_deg<curr_deg) 457 // || 458 // ((comp_deg==curr_deg) && 459 short_s=ksCreateShortSpoly(c->S->m[i_con[m]],c->S->m[j_con[n]],c->r); 460 if (short_s==NULL) { 461 i=i_con[m]; 462 j=j_con[n]; 463 now_t_rep(i_con[m],j_con[n],c); 464 p_Delete(&lm,c->r); 465 omfree(i_con); 466 omfree(j_con); 467 468 return; 469 } 470 #ifdef QUICK_SPOLY_TEST 471 for (int dz=0;dz<=c->n;dz++){ 472 if (dz==c->n) { 473 //have found not head reducing pair 474 i=i_con[m]; 475 j=j_con[n]; 476 p_Delete(&short_s,c->r); 477 p_Delete(&lm,c->r); 478 omfree(i_con); 479 omfree(j_con); 480 481 return; 482 } 483 if (p_LmDivisibleBy(c->S->m[dz],short_s,c->r)) break; 484 } 485 #endif 486 int comp_deg(pTotaldegree(short_s)); 487 p_Delete(&short_s,c->r); 488 if ((comp_deg<curr_deg)) 489 490 { 491 curr_deg=comp_deg; 492 i=i_con[m]; 493 j=j_con[n]; 494 } 495 } 496 } 497 p_Delete(&lm,c->r); 498 omfree(i_con); 499 omfree(j_con); 500 return; 501 } 502 #endif 503 504 #if 0 505 //not needed any more, but should work 506 static int* make_connections(int from, poly bound, slimgb_alg* c) 507 { 508 ideal I=c->S; 509 int s=pTotaldegree(bound); 510 int* cans=(int*) omalloc(c->n*sizeof(int)); 511 int* connected=(int*) omalloc(c->n*sizeof(int)); 512 int cans_length=0; 513 connected[0]=from; 514 int connected_length=1; 515 long neg_bounds_short= ~p_GetShortExpVector(bound,c->r); 516 for (int i=0;i<c->n;i++){ 517 if (c->T_deg[i]>s) continue; 518 if (i!=from){ 519 if(p_LmShortDivisibleBy(I->m[i],c->short_Exps[i],bound,neg_bounds_short,c->r)){ 520 cans[cans_length]=i; 521 cans_length++; 522 } 523 } 524 } 525 int not_yet_found=cans_length; 526 int con_checked=0; 527 int pos; 528 while((not_yet_found>0) && (con_checked<connected_length)){ 529 pos=connected[con_checked]; 530 for(int i=0;i<cans_length;i++){ 531 if (cans[i]<0) continue; 532 if (has_t_rep(pos,cans[i],c)) 533 { 534 connected[connected_length]=cans[i]; 535 connected_length++; 536 cans[i]=-1; 537 --not_yet_found; 538 } 539 } 540 con_checked++; 541 } 542 if (connected_length<c->n){ 543 connected[connected_length]=-1; 544 } 545 omfree(cans); 546 return connected; 547 } 548 #endif 549 #if 0 550 static void soon_t_rep(const int& arg_i, const int& arg_j, slimgb_alg* c) 551 { 552 assume(0<=arg_i); 553 assume(0<=arg_j); 554 assume(arg_i<c->n); 555 assume(arg_j<c->n); 556 int i,j; 557 if (arg_i==arg_j){ 558 return; 559 } 560 if (arg_i>arg_j){ 561 i=arg_j; 562 j=arg_i; 563 } else { 564 i=arg_i; 565 j=arg_j; 566 } 567 if (! 568 (c->states[j][i]==HASTREP)) 569 c->states[j][i]=SOONTREP; 570 } 571 #endif
Note: See TracChangeset
for help on using the changeset viewer.