Changeset 5a229c in git
- Timestamp:
- Nov 5, 2002, 7:16:12 PM (21 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '0604212ebb110535022efecad887940825b97c3f')
- Children:
- 030fcb083622316619951241eba12a84c7c3cd28
- Parents:
- 21a8befd0c11806b3654c34f88c08f7a750354cb
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/tgb.cc
r21a8be r5a229c 2 2 #include <omalloc.h> 3 3 #include "p_polys.h" 4 #include "prCopy.h"4 //#include "prCopy.h" 5 5 #include "ideals.h" 6 6 #include "ring.h" … … 17 17 18 18 #define FULLREDUCTIONS 19 #define HALFREDUCTIONS19 //#define HALFREDUCTIONS 20 20 #define HEAD_BIN 21 21 //#define HOMOGENEOUS_EXAMPLE 22 22 #define REDTAIL_S 23 #define PAR_N 5 23 24 //#define REDTAIL_PROT 24 25 //#define QUICK_SPOLY_TEST … … 30 31 int b; 31 32 }; 33 int bucket_guess(kBucket* bucket){ 34 int sum=0; 35 int i; 36 for (i=0;i<MAX_BUCKET+1;i++){ 37 sum+=bucket->buckets_length[i]; 38 } 39 return sum; 40 } 41 struct redNF_inf{ 42 poly h; 43 LObject* P; 44 int_pair_node* pending; 45 int len_upper_bound; 46 int i; 47 int j; 48 BOOLEAN need_std_rep; 49 BOOLEAN is_free; 50 BOOLEAN started; 51 }; 52 32 53 #ifdef RANDOM_WALK 33 54 int my_rand(int n){ … … 42 63 UNCALCULATED, 43 64 HASTREP, 44 UNIMPORTANT 65 UNIMPORTANT, 66 SOONTREP 45 67 }; 46 68 struct calc_dat … … 57 79 int* misses; 58 80 int_pair_node* soon_free; 81 redNF_inf* work_on; 59 82 #ifdef HEAD_BIN 60 83 struct omBin_s* HeadBin; … … 73 96 int misses_series; 74 97 }; 75 boolfind_next_pair(calc_dat* c);98 BOOLEAN find_next_pair(calc_dat* c); 76 99 void shorten_tails(calc_dat* c, poly monom); 77 100 void replace_pair(int & i, int & j, calc_dat* c); … … 80 103 void do_this_spoly_stuff(int i,int j,calc_dat* c); 81 104 ideal t_rep_gb(ring r,ideal arg_I); 82 boolhas_t_rep(const int & arg_i, const int & arg_j, calc_dat* state);105 BOOLEAN has_t_rep(const int & arg_i, const int & arg_j, calc_dat* state); 83 106 int* make_connections(int from, poly bound, calc_dat* c); 84 107 int* make_connections(int from, int to, poly bound, calc_dat* c); 85 void now_t_rep(int arg_i, int arg_j, calc_dat* c); 108 void now_t_rep(const int & arg_i, const int & arg_j, calc_dat* c); 109 void soon_t_rep(const int & arg_i, const int & arg_j, calc_dat* c); 86 110 int pLcmDeg(poly a, poly b); 87 111 int simple_posInS (kStrategy strat, poly p,int len); 88 112 89 boolfind_next_pair(calc_dat* c)113 BOOLEAN find_next_pair(calc_dat* c) 90 114 { 91 115 int start_i,start_j,i,j; … … 118 142 c->continue_i=c->found_i=i; 119 143 c->continue_j=c->found_j=j; 120 return true;144 return TRUE; 121 145 } 122 146 else … … 152 176 c->continue_i=c->found_i=i; 153 177 c->continue_j=c->found_j=j; 154 return true;178 return TRUE; 155 179 } 156 180 else … … 175 199 return find_next_pair(c); 176 200 } 177 return false;201 return FALSE; 178 202 } 179 203 void move_forward_in_S(int old_pos, int new_pos,kStrategy strat) … … 255 279 if (pFDeg(lm)>=deciding_deg) 256 280 { 281 soon_t_rep(i_con[m],j_con[n],c); 257 282 int_pair_node* h= (int_pair_node*)omalloc(sizeof(int_pair_node)); 258 283 if (last!=NULL) … … 391 416 int con_checked=0; 392 417 int pos; 393 bool can_find_more=true;418 BOOLEAN can_find_more=TRUE; 394 419 while(((not_yet_found>0) && (con_checked<connected_length))||can_find_more){ 395 420 if ((con_checked<connected_length)&& (not_yet_found>0)){ … … 473 498 } 474 499 #endif 500 int init_red_phase1(calc_dat* c, int i, int j){ 501 int counter; 502 for(counter=0;(counter<PAR_N)||(c->work_on[i].is_free);counter++){} 503 assume(counter<PAR_N); 504 505 int pos=counter; 506 c->work_on[pos].is_free=FALSE; 507 c->work_on[pos].i=i; 508 c->work_on[pos].j=j; 509 return pos; 510 } 511 void init_red_spoly_phase2(calc_dat* c,int pos){ 512 poly h=ksOldCreateSpoly(c->S->m[c->work_on[pos].i], c->S->m[c->work_on[pos].j], NULL, c->r); 513 if (h==NULL){ 514 c->work_on[pos].is_free=TRUE; 515 return; 516 } 517 if (c->work_on[pos].P!=NULL) 518 delete c->work_on[pos].P; 519 c->work_on[pos].P=new LObject(h); 520 521 522 int len=pLength(h); 523 c->work_on[pos].len_upper_bound=len; 524 c->work_on[pos].P=new LObject(h); 525 c->work_on[pos].P->SetShortExpVector(); 526 c->work_on[pos].P->bucket = kBucketCreate(currRing); 527 kBucketInit(c->work_on[pos].P->bucket,c->work_on[pos].P->p,len /*pLength(P.p)*/); 528 529 }; 475 530 void initial_data(calc_dat* c){ 476 531 void* h; 477 532 int i,j; 533 c->work_on=(redNF_inf*) omalloc(PAR_N*sizeof(redNF_inf)); 534 int counter; 535 for(counter=0;counter<PAR_N;counter++){ 536 c->work_on[counter].is_free=TRUE; 537 } 478 538 c->misses_series=0; 479 539 c->soon_free=NULL; … … 804 864 } 805 865 #else 866 806 867 static poly redNF2 (poly h,calc_dat* c , int &len) 807 868 { … … 824 885 loop 825 886 { 887 int compare_bound; 888 compare_bound=bucket_guess(P.bucket); 889 len_upper_bound=min(compare_bound,len_upper_bound); 826 890 j=kFindDivisibleByInS(strat->S,strat->sevS,strat->sl,&P); 827 891 if (j>=0) … … 829 893 poly sec_copy=NULL; 830 894 //pseudo code 831 boolmust_replace_in_basis=(len_upper_bound<=strat->lenS[j]);//first test895 BOOLEAN must_replace_in_basis=(len_upper_bound<=strat->lenS[j]);//first test 832 896 if (must_replace_in_basis) 833 897 { … … 841 905 else 842 906 { 843 must_replace_in_basis= false;907 must_replace_in_basis=FALSE; 844 908 } 845 909 } … … 857 921 number coef=kBucketPolyRed(P.bucket,strat->S[j], 858 922 strat->lenS[j]/*pLength(strat->S[j])*/, 859 strat->kNoether);860 nDelete(&coef);861 h = kBucketGetLm(P.bucket);862 //pseudo code863 if (must_replace_in_basis){864 int old_pos_in_c=-1;865 poly p=strat->S[j];866 int z;923 strat->kNoether); 924 nDelete(&coef); 925 h = kBucketGetLm(P.bucket); 926 //pseudo code 927 if (must_replace_in_basis){ 928 int old_pos_in_c=-1; 929 poly p=strat->S[j]; 930 int z; 867 931 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 length871 int new_pos=simple_posInS(c->strat,strat->S[j],new_length); 932 int new_length=pLength(sec_copy); 933 Print("%i",strat->lenS[j]-new_length); 934 len_upper_bound=new_length +strat->lenS[j]-2;//old entries length 935 int new_pos=simple_posInS(c->strat,strat->S[j],new_length);//hack 872 936 strat->S[j]=sec_copy; 873 937 c->strat->lenS[j]=new_length; … … 907 971 908 972 int old_pos=j; 973 new_pos=min(old_pos, new_pos); 909 974 assume(new_pos<=old_pos); 910 975 … … 1209 1274 return(I); 1210 1275 } 1211 void now_t_rep( int arg_i, intarg_j, calc_dat* c){1276 void now_t_rep(const int & arg_i, const int & arg_j, calc_dat* c){ 1212 1277 int i,j; 1213 1278 if (arg_i==arg_j){ … … 1223 1288 c->states[j][i]=HASTREP; 1224 1289 } 1225 bool has_t_rep(const int & arg_i, const int & arg_j, calc_dat* state){ 1290 void soon_t_rep(const int& arg_i, const int& arg_j, calc_dat* c) 1291 { 1292 int i,j; 1293 if (arg_i==arg_j){ 1294 return; 1295 } 1296 if (arg_i>arg_j){ 1297 i=arg_j; 1298 j=arg_i; 1299 } else { 1300 i=arg_i; 1301 j=arg_j; 1302 } 1303 if (! 1304 (c->states[j][i]==HASTREP)) 1305 c->states[j][i]=SOONTREP; 1306 } 1307 BOOLEAN has_t_rep(const int & arg_i, const int & arg_j, calc_dat* state){ 1226 1308 1227 1309 if (arg_i==arg_j) 1228 1310 { 1229 return ( true);1311 return (TRUE); 1230 1312 } 1231 1313 if (arg_i>arg_j) … … 1281 1363 poly tail=c->S->m[i]->next; 1282 1364 poly prev=c->S->m[i]; 1283 bool did_something=false;1365 BOOLEAN did_something=FALSE; 1284 1366 while((tail!=NULL)&& (pLmCmp(tail, monom)>=0)) 1285 1367 { 1286 1368 if (p_LmDivisibleBy(monom,tail,c->r)) 1287 1369 { 1288 did_something= true;1370 did_something=TRUE; 1289 1371 prev->next=tail->next; 1290 1372 tail->next=NULL;
Note: See TracChangeset
for help on using the changeset viewer.