Changeset 7724a3 in git
- Timestamp:
- Oct 24, 2002, 9:52:39 AM (21 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '0604212ebb110535022efecad887940825b97c3f')
- Children:
- ec989caa0706a8f53442d9f6380c1d7cbd076081
- Parents:
- cae0b6dbd933345aaf77e7ea69081a445c804819
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/tgb.cc
rcae0b6 r7724a3 17 17 18 18 #define FULLREDUCTIONS 19 #define HALFREDUCTIONS 19 20 #define HEAD_BIN 20 21 //#define HOMOGENEOUS_EXAMPLE … … 38 39 #endif 39 40 enum calc_state 40 {41 UNCALCULATED,42 HASTREP,43 UNIMPORTANT44 };41 { 42 UNCALCULATED, 43 HASTREP, 44 UNIMPORTANT 45 }; 45 46 struct calc_dat 46 47 { … … 56 57 int* misses; 57 58 int_pair_node* soon_free; 58 59 #ifdef HEAD_BIN 59 60 struct omBin_s* HeadBin; 60 61 #endif 61 62 int max_misses; 62 63 int found_i; … … 92 93 start_j=-1; 93 94 #ifndef HOMOGENEOUS_EXAMPLE 94 95 96 97 95 if (c->misses_series>80){ 96 c->current_degree++; 97 c->misses_series=0; 98 } 98 99 #endif 99 100 start_i=c->continue_i; … … 102 103 for (int i=start_i;i<c->n;i++){ 103 104 if (c->T_deg[i]>c->current_degree) 104 {105 106 107 }105 { 106 c->skipped_pairs++; 107 continue; 108 } 108 109 for(int j=(i==start_i)?start_j+1:0;j<i;j++){ 109 110 // printf("searching at %d,%d",i,j); … … 111 112 c->skipped_pairs++; 112 113 break; 113 114 } 114 115 if (c->states[i][j]==UNCALCULATED){ 115 116 if(c->deg[i][j]<=c->current_degree) 116 117 118 119 120 121 117 { 118 c->continue_i=c->found_i=i; 119 c->continue_j=c->found_j=j; 120 return true; 121 } 122 else 122 123 { 123 124 ++(c->skipped_pairs); … … 125 126 } 126 127 } 127 128 c->misses_counter=0; 128 129 } 129 130 … … 148 149 if(c->states[i][j]==UNCALCULATED){ 149 150 if (c->deg[i][j]<=c->current_degree) 150 151 152 153 154 151 { 152 c->continue_i=c->found_i=i; 153 c->continue_j=c->found_j=j; 154 return true; 155 } 155 156 else 156 157 158 157 { 158 ++(c->skipped_pairs); 159 } 159 160 } 160 161 } … … 195 196 strat->lenS[i] = strat->lenS[i-1]; 196 197 197 198 strat->S[new_pos]=p; 198 199 strat->ecartS[new_pos]=ecart; 199 200 strat->sevS[new_pos]=sev; … … 215 216 for (int n=0;((n<c->n) && (i_con[n]>=0));n++){ 216 217 if (i_con[n]==j){ 217 // curr_deg=pFDeg(lm);218 // for(int z1=0;((z1<c->n) && (i_con[z1]>=0));z1++)219 // for (int z2=z1+1;((z2<c->n)&&(i_con[z2]>=0));z2++)220 // {221 // pLcm(c->S->m[i_con[z1]], c->S->m[i_con[z2]], lm);222 // pSetm(lm);223 // if (pFDeg(lm)==curr_deg)224 // now_t_rep(i_con[z1],i_con[z2],c);225 // }218 // curr_deg=pFDeg(lm); 219 // for(int z1=0;((z1<c->n) && (i_con[z1]>=0));z1++) 220 // for (int z2=z1+1;((z2<c->n)&&(i_con[z2]>=0));z2++) 221 // { 222 // pLcm(c->S->m[i_con[z1]], c->S->m[i_con[z2]], lm); 223 // pSetm(lm); 224 // if (pFDeg(lm)==curr_deg) 225 // now_t_rep(i_con[z1],i_con[z2],c); 226 // } 226 227 now_t_rep(i,j,c); 227 228 omfree(i_con); … … 253 254 pSetm(lm); 254 255 if (pFDeg(lm)>=deciding_deg) 255 256 257 258 259 260 261 262 263 264 265 256 { 257 int_pair_node* h= (int_pair_node*)omalloc(sizeof(int_pair_node)); 258 if (last!=NULL) 259 last->next=h; 260 else 261 c->soon_free=h; 262 h->next=NULL; 263 h->a=i_con[m]; 264 h->b=j_con[n]; 265 last=h; 266 } 266 267 // if ((comp_deg<curr_deg) 267 268 // || … … 304 305 <= 305 306 c->misses[i_con[m]]+c->misses[j_con[n]]))) 306 // if ((comp_deg<curr_deg)307 // ||308 // ((comp_deg==curr_deg) &&309 // (c->lengths[i]+c->lengths[j]310 // <=311 // c->lengths[i_con[m]]+c->lengths[j_con[n]])))312 313 314 315 316 317 307 // if ((comp_deg<curr_deg) 308 // || 309 // ((comp_deg==curr_deg) && 310 // (c->lengths[i]+c->lengths[j] 311 // <= 312 // c->lengths[i_con[m]]+c->lengths[j_con[n]]))) 313 314 { 315 curr_deg=comp_deg; 316 i=i_con[m]; 317 j=j_con[n]; 318 } 318 319 } 319 320 } … … 379 380 long neg_bounds_short= ~p_GetShortExpVector(bound,c->r); 380 381 // for (int i=0;i<c->n;i++){ 381 // if (c->T_deg[i]>s) continue;382 // if (i!=from){383 // if(p_LmShortDivisibleBy(I->m[i],c->short_Exps[i],bound,neg_bounds_short,c->r)){384 // cans[cans_length]=i;385 // cans_length++;386 // }387 // }388 // }382 // if (c->T_deg[i]>s) continue; 383 // if (i!=from){ 384 // if(p_LmShortDivisibleBy(I->m[i],c->short_Exps[i],bound,neg_bounds_short,c->r)){ 385 // cans[cans_length]=i; 386 // cans_length++; 387 // } 388 // } 389 // } 389 390 int not_yet_found=cans_length; 390 391 int con_checked=0; … … 488 489 c->continue_j=0; 489 490 c->skipped_i=-1; 490 491 #ifdef HEAD_BIN 491 492 c->HeadBin=omGetSpecBin(POLYSIZE + (currRing->ExpL_Size)*sizeof(long)); 492 493 #endif 493 494 /* omUnGetSpecBin(&(c->HeadBin)); */ 494 495 h=omalloc(n*sizeof(char*)); … … 512 513 c->short_Exps=(long*) omalloc(n*sizeof(long)); 513 514 for (i=0;i<n;i++) 514 {515 516 c->S->m[i]=p_MoveHead(c->S->m[i],c->HeadBin);517 518 c->T_deg[i]=pFDeg(c->S->m[i]);519 c->lengths[i]=pLength(c->S->m[i]);520 c->misses[i]=0;521 c->states[i]=(char *)omAlloc((i+1)*sizeof(char));522 c->deg[i]=(int*) omAlloc((i+1)*sizeof(int));523 for (j=0;j<i;j++){524 525 526 527 528 529 530 531 }532 if ((c->lengths[i]==1) && (c->lengths[j]==1))533 534 c->rep[i]=i;535 c->short_Exps[i]=p_GetShortExpVector(c->S->m[i],c->r);536 537 }515 { 516 #ifdef HEAD_BIN 517 c->S->m[i]=p_MoveHead(c->S->m[i],c->HeadBin); 518 #endif 519 c->T_deg[i]=pFDeg(c->S->m[i]); 520 c->lengths[i]=pLength(c->S->m[i]); 521 c->misses[i]=0; 522 c->states[i]=(char *)omAlloc((i+1)*sizeof(char)); 523 c->deg[i]=(int*) omAlloc((i+1)*sizeof(int)); 524 for (j=0;j<i;j++){ 525 //check product criterion 526 if (pHasNotCF(c->S->m[i],c->S->m[j])){ 527 c->states[i][j]=HASTREP; 528 } else { 529 c->states[i][j]=UNCALCULATED; 530 } 531 c->deg[i][j]=pLcmDeg(c->S->m[i],c->S->m[j]); 532 } 533 if ((c->lengths[i]==1) && (c->lengths[j]==1)) 534 c->states[i][j]=HASTREP; 535 c->rep[i]=i; 536 c->short_Exps[i]=p_GetShortExpVector(c->S->m[i],c->r); 537 538 } 538 539 539 540 … … 546 547 c->strat->sl = -1; 547 548 /* initS(c->S,NULL,c->strat); */ 548 549 550 551 552 553 554 555 556 557 558 559 {560 int pos;561 assume (c->S->m[i]!=NULL);562 LObject h;563 h.p = c->S->m[i];564 h.pNorm();565 c->strat->initEcart(&h);566 assume(c->lengths[i]==pLength(h.p));567 if (c->strat->sl==-1) pos=0;568 else pos = simple_posInS(c->strat,h.p,c->lengths[i]);569 h.sev = pGetShortExpVector(h.p);570 c->strat->enterS(h,pos,c->strat);571 c->strat->lenS[pos]=c->lengths[i];572 }573 574 575 576 577 578 579 549 /* intS start: */ 550 i=((i+IDELEMS(c->S)+15)/16)*16; 551 c->strat->ecartS=(intset)omAlloc(i*sizeof(int)); /*initec(i);*/ 552 c->strat->sevS=(unsigned long*)omAlloc0(i*sizeof(unsigned long)); 553 /*initsevS(i);*/ 554 c->strat->S_2_R=(int*)omAlloc0(i*sizeof(int));/*initS_2_R(i);*/ 555 c->strat->fromQ=NULL; 556 c->strat->Shdl=idInit(i,1); 557 c->strat->S=c->strat->Shdl->m; 558 c->strat->lenS=(int*)omAlloc0(i*sizeof(int)); 559 for (i=0; i<IDELEMS(c->S); i++) 560 { 561 int pos; 562 assume (c->S->m[i]!=NULL); 563 LObject h; 564 h.p = c->S->m[i]; 565 h.pNorm(); 566 c->strat->initEcart(&h); 567 assume(c->lengths[i]==pLength(h.p)); 568 if (c->strat->sl==-1) pos=0; 569 else pos = simple_posInS(c->strat,h.p,c->lengths[i]); 570 h.sev = pGetShortExpVector(h.p); 571 c->strat->enterS(h,pos,c->strat); 572 c->strat->lenS[pos]=c->lengths[i]; 573 } 574 //c->strat->lenS=(int*)omAlloc0(IDELEMS(c->strat->Shdl)*sizeof(int)); 575 //for (i=c->strat->sl;i>=0;i--) 576 //{ 577 // pNorm(c->strat->S[i]); 578 // c->strat->lenS[i]=pLength(c->strat->S[i]); 579 //} 580 /* initS end */ 580 581 } 581 582 int simple_posInS (kStrategy strat, poly p,int len) … … 590 591 591 592 if ((len>setL[length]) 592 || ((len==setL[length]) && (pLmCmp(set[length],p)== -1)))593 || ((len==setL[length]) && (pLmCmp(set[length],p)== -1))) 593 594 return length+1; 594 595 595 596 loop 596 {597 if (an >= en-1)598 599 600 || ((len==setL[length]) && (pLmCmp(set[an],p) == 1))) return an;601 602 603 i=(an+en) / 2;604 if ((len<setL[i])605 606 //else if ((len>setL[i])607 //|| ((len==setL[i]) && (pLmCmp(set[i],p) == -1))) an=i;608 else an=i;609 }597 { 598 if (an >= en-1) 599 { 600 if ((len<setL[an]) 601 || ((len==setL[length]) && (pLmCmp(set[an],p) == 1))) return an; 602 return en; 603 } 604 i=(an+en) / 2; 605 if ((len<setL[i]) 606 || ((len==setL[i]) && (pLmCmp(set[i],p) == 1))) en=i; 607 //else if ((len>setL[i]) 608 //|| ((len==setL[i]) && (pLmCmp(set[i],p) == -1))) an=i; 609 else an=i; 610 } 610 611 } 611 612 /*2 612 *if the leading term of p613 *divides the leading term of some S[i] it will be canceled614 */613 *if the leading term of p 614 *divides the leading term of some S[i] it will be canceled 615 */ 615 616 static inline void clearS (poly p, unsigned long p_sev,int l, int* at, int* k, 616 617 kStrategy strat) 617 618 { 618 619 assume(p_sev == pGetShortExpVector(p)); … … 678 679 for (j=0;j<i;j++){ 679 680 c->deg[i][j]=pLcmDeg(c->S->m[i],c->S->m[j]); 680 681 if (c->rep[j]==j){ 681 682 //check product criterion 682 683 683 684 c->states[i][j]=UNCALCULATED; 684 685 685 686 686 687 //lies I[i] under I[j] ? 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 688 if(p_LmShortDivisibleBy(c->S->m[i],c->short_Exps[i],c->S->m[j],~(c->short_Exps[j]),c->r)){ 689 c->rep[j]=i; 690 PrintS("R"); R_found=TRUE; 691 692 c->misses[i_pos]--; 693 c->misses[j_pos]--; 694 for(int z=0;z<j;z++){ 695 if (c->states[j][z]==UNCALCULATED){ 696 c->states[j][z]=UNIMPORTANT; 697 } 698 } 699 for(int z=j+1;z<i;z++){ 700 if (c->states[z][j]==UNCALCULATED){ 701 c->states[z][j]=UNIMPORTANT; 702 } 703 } 704 } 705 } 705 706 else { 706 707 707 c->states[i][j]=UNIMPORTANT; 708 } 708 709 if ((c->lengths[i]==1) && (c->lengths[j]==1)) 709 710 c->states[i][j]=HASTREP; … … 719 720 720 721 //i=posInS(c->strat,c->strat->sl,h,0 /*ecart*/); 721 i=simple_posInS(c->strat,h,c->lengths[c->n-1]);722 723 LObject P; memset(&P,0,sizeof(P));724 P.tailRing=c->r;725 P.p=h; /*p_Copy(h,c->r);*/726 P.FDeg=pFDeg(P.p,c->r);727 if (!rField_is_Zp(c->r)) pCleardenom(P.p);728 //enterT(P,c->strat,-1);729 c->strat->enterS(P,i,c->strat);730 c->strat->lenS[i]=/*pLength(c->strat->S[i]);*/ c->lengths[c->n-1];731 pNorm(c->strat->S[i]);732 if (0 /*R_found && (i<c->strat->sl)*/)733 {734 735 736 737 738 739 740 741 742 }743 if (c->lengths[c->n-1]==1)744 shorten_tails(c,c->S->m[c->n-1]);722 i=simple_posInS(c->strat,h,c->lengths[c->n-1]); 723 724 LObject P; memset(&P,0,sizeof(P)); 725 P.tailRing=c->r; 726 P.p=h; /*p_Copy(h,c->r);*/ 727 P.FDeg=pFDeg(P.p,c->r); 728 if (!rField_is_Zp(c->r)) pCleardenom(P.p); 729 //enterT(P,c->strat,-1); 730 c->strat->enterS(P,i,c->strat); 731 c->strat->lenS[i]=/*pLength(c->strat->S[i]);*/ c->lengths[c->n-1]; 732 pNorm(c->strat->S[i]); 733 if (0 /*R_found && (i<c->strat->sl)*/) 734 { 735 i++; 736 unsigned long h_sev = pGetShortExpVector(h); 737 loop 738 { 739 if (i>c->strat->sl) break; 740 clearS(h,h_sev,c->lengths[c->n-1], &i,&(c->strat->sl),c->strat); 741 i++; 742 } 743 } 744 if (c->lengths[c->n-1]==1) 745 shorten_tails(c,c->S->m[c->n-1]); 745 746 //you should really update c->lengths, c->strat->lenS, and the oder of polys in strat if you sort after lengths 746 747 747 //for(i=c->strat->sl; i>0;i--)748 // if(c->strat->lenS[i]<c->strat->lenS[i-1]) printf("fehler bei %d\n",i);748 //for(i=c->strat->sl; i>0;i--) 749 // if(c->strat->lenS[i]<c->strat->lenS[i-1]) printf("fehler bei %d\n",i); 749 750 } 750 751 #if 0 … … 756 757 757 758 if (0 > strat->sl) 758 {759 return h;760 }759 { 760 return h; 761 } 761 762 not_sev = ~ pGetShortExpVector(h); 762 763 loop 763 {764 if (pLmShortDivisibleBy(strat->S[j], strat->sevS[j], h, not_sev))765 766 767 764 { 765 if (pLmShortDivisibleBy(strat->S[j], strat->sevS[j], h, not_sev)) 766 { 767 //if (strat->interpt) test_int_std(strat->kIdeal); 768 /*- compute the s-polynomial -*/ 768 769 #ifdef KDEBUG 769 770 771 772 773 774 775 776 #endif 777 770 if (TEST_OPT_DEBUG) 771 { 772 PrintS("red:"); 773 wrp(h); 774 PrintS(" with "); 775 wrp(strat->S[j]); 776 } 777 #endif 778 h = ksOldSpolyRed(strat->S[j],h,strat->kNoether); 778 779 #ifdef KDEBUG 779 780 781 782 783 784 785 #endif 786 787 788 789 790 791 792 793 794 795 796 797 else798 799 800 801 802 }780 if (TEST_OPT_DEBUG) 781 { 782 PrintS("\nto:"); 783 wrp(h); 784 PrintLn(); 785 } 786 #endif 787 if (h == NULL) return NULL; 788 z++; 789 if (z>=10) 790 { 791 z=0; 792 pNormalize(h); 793 } 794 /*- try to reduce the s-polynomial -*/ 795 j = 0; 796 not_sev = ~ pGetShortExpVector(h); 797 } 798 else 799 { 800 if (j >= strat->sl) return h; 801 j++; 802 } 803 } 803 804 } 804 805 #else 805 static poly redNF (poly h,kStrategy strat, int &len)806 static poly redNF2 (poly h,calc_dat* c , int &len) 806 807 { 807 808 len=0; … … 809 810 int j; 810 811 812 kStrategy strat=c->strat; 811 813 len=pLength(h); 814 int len_upper_bound=len; 812 815 if (0 > strat->sl) 813 {814 return h;815 }816 { 817 return h; 818 } 816 819 LObject P(h); 817 820 P.SetShortExpVector(); … … 820 823 //int max_pos=simple_posInS(strat,P.p); 821 824 loop 822 { 823 j=kFindDivisibleByInS(strat->S,strat->sevS,strat->sl,&P); 824 if (j>=0) 825 { 826 nNormalize(pGetCoeff(P.p)); 825 { 826 j=kFindDivisibleByInS(strat->S,strat->sevS,strat->sl,&P); 827 if (j>=0) 828 { 829 poly sec_copy=NULL; 830 //pseudo code 831 bool must_replace_in_basis=(len_upper_bound<=strat->lenS[j]);//first test 832 if (must_replace_in_basis) 833 { 834 //second test 835 if (pLmEqual(P.p,strat->S[j])) 836 { 837 PrintS("b"); 838 sec_copy=kBucketClear(P.bucket); 839 kBucketInit(P.bucket,pCopy(sec_copy),pLength(sec_copy)); 840 } 841 else 842 { 843 must_replace_in_basis=false; 844 } 845 } 846 nNormalize(pGetCoeff(P.p)); 827 847 #ifdef KDEBUG 828 if (TEST_OPT_DEBUG) 848 if (TEST_OPT_DEBUG) 849 { 850 PrintS("red:"); 851 wrp(h); 852 PrintS(" with "); 853 wrp(strat->S[j]); 854 } 855 #endif 856 len_upper_bound=len_upper_bound+strat->lenS[j]-2; 857 number coef=kBucketPolyRed(P.bucket,strat->S[j], 858 strat->lenS[j]/*pLength(strat->S[j])*/, 859 strat->kNoether); 860 nDelete(&coef); 861 h = kBucketGetLm(P.bucket); 862 //pseudo code 863 if (must_replace_in_basis){ 864 int old_pos_in_c=-1; 865 poly p=strat->S[j]; 866 int z; 867 868 int new_length=pLength(sec_copy); 869 Print("%i",strat->lenS[j]-new_length); 870 len_upper_bound=new_length +strat->lenS[j]-2;//old entries length 871 int new_pos=simple_posInS(c->strat,strat->S[j],new_length); 872 strat->S[j]=sec_copy; 873 c->strat->lenS[j]=new_length; 874 875 for (z=c->n;z;z--) 876 { 877 if(p==c->S->m[z-1]) 878 { 879 c->S->m[z-1]=sec_copy; 880 old_pos_in_c=z-1; 881 c->lengths[z-1]=new_length; 882 if (new_length==1) 883 { 884 int i; 885 for ( i=0;i<z-1;i++) 886 { 887 if (c->lengths[i]==1) 888 c->states[z-1][i]=HASTREP; 889 } 890 for ( i=z;i<c->n;i++){ 891 if (c->lengths[i]==1) 892 c->states[i][z-1]=HASTREP; 893 } 894 shorten_tails(c,sec_copy); 895 } 896 break; 897 } 898 } 899 pDelete(&p); 900 901 // replace_quietly(c,j,sec_copy); 902 // have to do many additional things for consistency 903 { 904 905 906 907 908 int old_pos=j; 909 assume(new_pos<=old_pos); 910 911 912 c->strat->lenS[old_pos]=new_length; 913 int i=0; 914 for(i=new_pos;i<old_pos;i++){ 915 if (strat->lenS[i]<=new_length) 916 new_pos++; 917 else 918 break; 919 } 920 if (new_pos<old_pos) 921 move_forward_in_S(old_pos,new_pos,c->strat); 922 923 924 } 925 } 926 if (h==NULL) return NULL; 927 P.p=h; 928 P.t_p=NULL; 929 P.SetShortExpVector(); 930 #ifdef KDEBUG 931 if (TEST_OPT_DEBUG) 932 { 933 PrintS("\nto:"); 934 wrp(h); 935 PrintLn(); 936 } 937 #endif 938 } 939 else 829 940 { 830 PrintS("red:"); 831 wrp(h); 832 PrintS(" with "); 833 wrp(strat->S[j]); 834 } 835 #endif 836 number coef=kBucketPolyRed(P.bucket,strat->S[j], 837 strat->lenS[j]/*pLength(strat->S[j])*/, 838 strat->kNoether); 839 nDelete(&coef); 840 h = kBucketGetLm(P.bucket); 841 if (h==NULL) return NULL; 842 P.p=h; 843 P.t_p=NULL; 844 P.SetShortExpVector(); 941 kBucketClear(P.bucket,&(P.p),&len); 942 kBucketDestroy(&P.bucket); 943 pNormalize(P.p); 944 return P.p; 945 } 946 } 947 } 948 static poly redNF (poly h,kStrategy strat, int &len) 949 { 950 len=0; 951 if (h==NULL) return NULL; 952 int j; 953 954 len=pLength(h); 955 if (0 > strat->sl) 956 { 957 return h; 958 } 959 LObject P(h); 960 P.SetShortExpVector(); 961 P.bucket = kBucketCreate(currRing); 962 kBucketInit(P.bucket,P.p,len /*pLength(P.p)*/); 963 //int max_pos=simple_posInS(strat,P.p); 964 loop 965 { 966 j=kFindDivisibleByInS(strat->S,strat->sevS,strat->sl,&P); 967 if (j>=0) 968 { 969 nNormalize(pGetCoeff(P.p)); 845 970 #ifdef KDEBUG 846 if (TEST_OPT_DEBUG) 971 if (TEST_OPT_DEBUG) 972 { 973 PrintS("red:"); 974 wrp(h); 975 PrintS(" with "); 976 wrp(strat->S[j]); 977 } 978 #endif 979 number coef=kBucketPolyRed(P.bucket,strat->S[j], 980 strat->lenS[j]/*pLength(strat->S[j])*/, 981 strat->kNoether); 982 nDelete(&coef); 983 h = kBucketGetLm(P.bucket); 984 if (h==NULL) return NULL; 985 P.p=h; 986 P.t_p=NULL; 987 P.SetShortExpVector(); 988 #ifdef KDEBUG 989 if (TEST_OPT_DEBUG) 990 { 991 PrintS("\nto:"); 992 wrp(h); 993 PrintLn(); 994 } 995 #endif 996 } 997 else 847 998 { 848 PrintS("\nto:"); 849 wrp(h); 850 PrintLn(); 851 } 852 #endif 853 } 854 else 855 { 856 kBucketClear(P.bucket,&(P.p),&len); 857 kBucketDestroy(&P.bucket); 858 pNormalize(P.p); 859 return P.p; 860 } 861 } 999 kBucketClear(P.bucket,&(P.p),&len); 1000 kBucketDestroy(&P.bucket); 1001 pNormalize(P.p); 1002 return P.p; 1003 } 1004 } 862 1005 } 863 1006 #endif … … 883 1026 pTest(h); 884 1027 loop 885 {886 P.p=h;887 P.t_p=NULL;888 P.SetShortExpVector();889 loop890 891 892 893 894 895 896 897 1028 { 1029 P.p=h; 1030 P.t_p=NULL; 1031 P.SetShortExpVector(); 1032 loop 1033 { 1034 j=kFindDivisibleByInS(strat->S,strat->sevS,sl,&P); 1035 if (j>=0) 1036 { 1037 #ifdef REDTAIL_PROT 1038 PrintS("r"); 1039 #endif 1040 nNormalize(pGetCoeff(P.p)); 898 1041 #ifdef KDEBUG 899 900 901 902 903 904 905 906 #endif 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 pTest(h);923 924 925 1042 if (TEST_OPT_DEBUG) 1043 { 1044 PrintS("red tail:"); 1045 wrp(h); 1046 PrintS(" with "); 1047 wrp(strat->S[j]); 1048 } 1049 #endif 1050 number coef; 1051 pTest(strat->S[j]); 1052 coef=kBucketPolyRed(P.bucket,strat->S[j], 1053 strat->lenS[j]/*pLength(strat->S[j])*/,strat->kNoether); 1054 pMult_nn(res,coef); 1055 nDelete(&coef); 1056 h = kBucketGetLm(P.bucket); 1057 pTest(h); 1058 if (h==NULL) 1059 { 1060 #ifdef REDTAIL_PROT 1061 PrintS(" "); 1062 #endif 1063 return res; 1064 } 1065 pTest(h); 1066 P.p=h; 1067 P.t_p=NULL; 1068 P.SetShortExpVector(); 926 1069 #ifdef KDEBUG 927 928 929 930 931 932 933 #endif 934 935 936 937 938 939 940 941 942 943 poly tmp=pHead(h /*kBucketGetLm(P.bucket)*/);944 act->next=tmp;pIter(act);945 poly tmp2=pHead(h);946 pNeg(tmp2);947 int ltmp2=1;948 pTest(tmp2);949 kBucket_Add_q(P.bucket, tmp2, <mp2);950 951 h = kBucketGetLm(P.bucket);952 if (h==NULL)953 954 955 956 957 958 959 pTest(h);960 }1070 if (TEST_OPT_DEBUG) 1071 { 1072 PrintS("\nto tail:"); 1073 wrp(h); 1074 PrintLn(); 1075 } 1076 #endif 1077 } 1078 else 1079 { 1080 #ifdef REDTAIL_PROT 1081 PrintS("n"); 1082 #endif 1083 break; 1084 } 1085 } /* end loop current mon */ 1086 poly tmp=pHead(h /*kBucketGetLm(P.bucket)*/); 1087 act->next=tmp;pIter(act); 1088 poly tmp2=pHead(h); 1089 pNeg(tmp2); 1090 int ltmp2=1; 1091 pTest(tmp2); 1092 kBucket_Add_q(P.bucket, tmp2, <mp2); 1093 1094 h = kBucketGetLm(P.bucket); 1095 if (h==NULL) 1096 { 1097 #ifdef REDTAIL_PROT 1098 PrintS(" "); 1099 #endif 1100 return res; 1101 } 1102 pTest(h); 1103 } 961 1104 } 962 1105 #endif … … 969 1112 #ifdef FULLREDUCTIONS 970 1113 if (h!=NULL) 971 { 972 int len; 973 hr=redNF(h,c->strat,len); 974 if (hr!=NULL) 975 #ifdef REDTAIL_S 976 hr = redNFTail(hr,c->strat->sl,c->strat,len); 977 #else 1114 { 1115 int len; 1116 1117 hr=redNF2(h,c,len); 1118 #ifdef HALFREDUCTIONS 1119 int real_sl=c->strat->sl; 1120 int l; 1121 for(l=0;l<c->n;l++){ 1122 if (c->strat->lenS[l]>4) 1123 break; 1124 } 1125 c->strat->sl=l; 1126 #endif 1127 if (hr!=NULL) 1128 #ifdef REDTAIL_S 1129 hr = redNFTail(hr,c->strat->sl,c->strat,len); 1130 #else 978 1131 hr = redtailBba(hr,c->strat->sl,c->strat); 979 #endif 980 } 1132 #endif 1133 #ifdef HALFREDUCTIONS 1134 c->strat->sl=real_sl; 1135 #endif 1136 } 981 1137 #else 982 1138 if (h!=NULL) 983 {984 int len;985 hr=redNF(h,c->strat,&len);986 }1139 { 1140 int len; 1141 hr=redNF2(h,c,len); 1142 } 987 1143 #endif 988 1144 c->normal_forms++; 989 1145 if (hr==NULL) 990 {991 PrintS("-");992 c->misses_counter++;993 c->misses[i]++;994 c->misses[j]++;995 c->misses_series++;996 }1146 { 1147 PrintS("-"); 1148 c->misses_counter++; 1149 c->misses[i]++; 1150 c->misses[j]++; 1151 c->misses_series++; 1152 } 997 1153 else 998 {999 c->misses_series=0;1000 1001 hr=p_MoveHead(hr,c->HeadBin);1002 1003 add_to_basis(hr, i,j,c);1004 }1154 { 1155 c->misses_series=0; 1156 #ifdef HEAD_BIN 1157 hr=p_MoveHead(hr,c->HeadBin); 1158 #endif 1159 add_to_basis(hr, i,j,c); 1160 } 1005 1161 } 1006 1162 1007 1163 ideal t_rep_gb(ring r,ideal arg_I){ 1008 ideal I_temp= kInterRed(arg_I);1164 ideal I_temp=idCopy(arg_I); //kInterRed(arg_I); 1009 1165 ideal I=idCompactify(I_temp); 1010 1166 idDelete(&I_temp); … … 1033 1189 int_pair_node* h=c->soon_free; 1034 1190 while(h!=NULL) 1035 {1036 1037 1038 1039 1040 1041 }1191 { 1192 int_pair_node* s=h; 1193 now_t_rep(h->a,h->b,c); 1194 1195 h=h->next; 1196 omfree(s); 1197 } 1042 1198 1043 1199 … … 1070 1226 1071 1227 if (arg_i==arg_j) 1072 {1073 return (true);1074 }1228 { 1229 return (true); 1230 } 1075 1231 if (arg_i>arg_j) 1076 {1077 return (state->states[arg_i][arg_j]==HASTREP);1078 } else1079 {1080 1081 }1232 { 1233 return (state->states[arg_i][arg_j]==HASTREP); 1234 } else 1235 { 1236 return (state->states[arg_j][arg_i]==HASTREP); 1237 } 1082 1238 } 1083 1239 int pLcmDeg(poly a, poly b) … … 1086 1242 int n=0; 1087 1243 for (i=pVariables; i; i--) 1088 {1089 n+=max( pGetExp(a,i), pGetExp(b,i));1090 }1244 { 1245 n+=max( pGetExp(a,i), pGetExp(b,i)); 1246 } 1091 1247 return n; 1092 1248 … … 1119 1275 1120 1276 for(int i=0;i<c->n;i++) 1121 { 1122 //enter tail 1123 if (c->rep[i]!=i) continue; 1124 if (c->S->m[i]==NULL) continue; 1125 poly tail=c->S->m[i]->next; 1126 poly prev=c->S->m[i]; 1127 bool did_something=false; 1128 while((tail!=NULL)&& (pLmCmp(tail, monom)>=0)) 1129 { 1130 if (p_LmDivisibleBy(monom,tail,c->r)) 1131 { 1132 did_something=true; 1133 prev->next=tail->next; 1134 tail->next=NULL; 1135 p_Delete(& tail,c->r); 1136 tail=prev; 1137 //PrintS("Shortened"); 1138 c->lengths[i]--; 1139 } 1140 prev=tail; 1141 tail=tail->next; 1142 } 1143 if (did_something) 1144 { 1145 int new_pos=simple_posInS(c->strat,c->S->m[i],c->lengths[i]); 1146 int old_pos=-1; 1147 //assume new_pos<old_pos 1148 for (int z=new_pos;z<=c->strat->sl;z++) 1149 { 1150 if (c->strat->S[z]==c->S->m[i]) 1151 { 1152 old_pos=z; 1153 break; 1154 } 1155 } 1156 if (old_pos== -1) 1157 for (int z=new_pos-1;z>=0l;z--) 1158 { 1159 if (c->strat->S[z]==c->S->m[i]) 1160 { 1161 old_pos=z; 1162 break; 1163 } 1164 } 1165 assume(old_pos>=0); 1166 assume(pLength(c->strat->S[old_pos])==c->lengths[i]); 1167 c->strat->lenS[old_pos]=c->lengths[i]; 1168 if (new_pos<old_pos) 1169 move_forward_in_S(old_pos,new_pos,c->strat); 1170 if (c->lengths[i]==1) 1171 { 1172 int j; 1173 for ( j=0;j<i;j++) 1174 { 1175 if (c->lengths[j]==1) 1176 c->states[i][j]=HASTREP; 1177 } 1178 for ( j=i+1;j<c->n;j++){ 1179 if (c->lengths[j]==1) 1180 c->states[j][i]=HASTREP; 1181 } 1182 } 1183 } 1184 } 1185 } 1277 { 1278 //enter tail 1279 if (c->rep[i]!=i) continue; 1280 if (c->S->m[i]==NULL) continue; 1281 poly tail=c->S->m[i]->next; 1282 poly prev=c->S->m[i]; 1283 bool did_something=false; 1284 while((tail!=NULL)&& (pLmCmp(tail, monom)>=0)) 1285 { 1286 if (p_LmDivisibleBy(monom,tail,c->r)) 1287 { 1288 did_something=true; 1289 prev->next=tail->next; 1290 tail->next=NULL; 1291 p_Delete(& tail,c->r); 1292 tail=prev; 1293 //PrintS("Shortened"); 1294 c->lengths[i]--; 1295 } 1296 prev=tail; 1297 tail=tail->next; 1298 } 1299 if (did_something) 1300 { 1301 int new_pos=simple_posInS(c->strat,c->S->m[i],c->lengths[i]); 1302 int old_pos=-1; 1303 //assume new_pos<old_pos 1304 for (int z=new_pos;z<=c->strat->sl;z++) 1305 { 1306 if (c->strat->S[z]==c->S->m[i]) 1307 { 1308 old_pos=z; 1309 break; 1310 } 1311 } 1312 if (old_pos== -1) 1313 for (int z=new_pos-1;z>=0;z--) 1314 { 1315 if (c->strat->S[z]==c->S->m[i]) 1316 { 1317 old_pos=z; 1318 break; 1319 } 1320 } 1321 assume(old_pos>=0); 1322 assume(pLength(c->strat->S[old_pos])==c->lengths[i]); 1323 c->strat->lenS[old_pos]=c->lengths[i]; 1324 if (new_pos<old_pos) 1325 move_forward_in_S(old_pos,new_pos,c->strat); 1326 if (c->lengths[i]==1) 1327 { 1328 1329 int j; 1330 for ( j=0;j<i;j++) 1331 { 1332 if (c->lengths[j]==1) 1333 c->states[i][j]=HASTREP; 1334 } 1335 for ( j=i+1;j<c->n;j++){ 1336 if (c->lengths[j]==1) 1337 c->states[j][i]=HASTREP; 1338 } 1339 shorten_tails(c,c->S->m[i]); 1340 } 1341 } 1342 } 1343 }
Note: See TracChangeset
for help on using the changeset viewer.