Changeset 194c2e7 in git
- Timestamp:
- Feb 9, 2010, 6:50:36 PM (13 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'cdfcdb8287f66bc6070028082cbbc6eff10e609b')
- Children:
- 6c939eebfd221f2512b1e27d158d1b5457206987
- Parents:
- a477f80136c773f8acffd73512f53bf88a7c6fe8
- Location:
- IntegerProgramming
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
IntegerProgramming/Buchberger.cc
ra477f80 r194c2e7 63 63 // we reach this element. 64 64 65 short supp2=bin2.head_support%Number_of_Lists;66 short supp_union=(bin1.head_support%Number_of_Lists)|supp2;65 int supp2=bin2.head_support%Number_of_Lists; 66 int supp_union=(bin1.head_support%Number_of_Lists)|supp2; 67 67 // supp_union (read as binary vector) is the union of the supports of 68 68 // first_iter.get_element() and second_iter.get_element() 69 69 // (restricted to List_Support_Variables variables). 70 70 71 for( short i=0;i<S.number_of_subsets[supp_union];i++)71 for(int i=0;i<S.number_of_subsets[supp_union];i++) 72 72 // Go through the lists that contain elements whose support is a 73 73 // subset of supp_union. 74 74 { 75 short actual_list=S.subsets_of_support[supp_union][i];75 int actual_list=S.subsets_of_support[supp_union][i]; 76 76 iter.set_to_list(generators[actual_list]); 77 77 // This is the i-th list among the generator list with elements … … 136 136 // Additionally,we can override lists whose support is to small. 137 137 138 short supp1=bin1.head_support%Number_of_Lists;139 short supp2=bin2.head_support%Number_of_Lists;140 short supp_union=supp1|supp2;138 int supp1=bin1.head_support%Number_of_Lists; 139 int supp2=bin2.head_support%Number_of_Lists; 140 int supp_union=supp1|supp2; 141 141 // supp_union (read as binary vector) is the union of the supports of 142 142 // first_iter.get_element() and second_iter.get_element() 143 143 // (restricted to List_Support_Variables variables). 144 144 145 for( short i=0;i<S.number_of_subsets[supp_union];i++)145 for(int i=0;i<S.number_of_subsets[supp_union];i++) 146 146 // Go through the lists that contain elements whose support is a 147 147 // subset of supp_union. 148 148 { 149 short actual_list=S.subsets_of_support[supp_union][i];149 int actual_list=S.subsets_of_support[supp_union][i]; 150 150 151 151 if((actual_list|supp2) != supp_union) … … 221 221 // (second_iter.get_element()).head_support. 222 222 223 short supp2=bin2.head_support%Number_of_Lists;224 short supp_union=(bin1.head_support%Number_of_Lists)|supp2;223 int supp2=bin2.head_support%Number_of_Lists; 224 int supp_union=(bin1.head_support%Number_of_Lists)|supp2; 225 225 // supp_union (read as binary vector) is the union of the supports of 226 226 // first_iter.get_element() and second_iter.get_element() … … 231 231 // subset of supp_union. 232 232 { 233 short actual_list=S.subsets_of_support[supp_union][i];233 int actual_list=S.subsets_of_support[supp_union][i]; 234 234 235 235 if(actual_list<=supp2) … … 291 291 // and (second_iter.get_element()).head_support. 292 292 293 short supp1=bin1.head_support%Number_of_Lists;294 short supp2=bin2.head_support%Number_of_Lists;295 short supp_union=supp1|supp2;293 int supp1=bin1.head_support%Number_of_Lists; 294 int supp2=bin2.head_support%Number_of_Lists; 295 int supp_union=supp1|supp2; 296 296 // supp_union (read as binary vector) is the union of the supports of 297 297 // first_iter.get_element() and second_iter.get_element() 298 298 // (restricted to List_Support_Variables variables) 299 299 300 for( short i=0;i<S.number_of_subsets[supp_union];i++)300 for(int i=0;i<S.number_of_subsets[supp_union];i++) 301 301 // Go through the lists that contain elements whose support is a 302 302 // subset of supp_union. 303 303 { 304 short actual_list=S.subsets_of_support[supp_union][i];304 int actual_list=S.subsets_of_support[supp_union][i]; 305 305 306 306 if((actual_list==supp1) || (actual_list==supp2)) … … 434 434 list_iterator first_iter; 435 435 436 for( short i=0;i<Number_of_Lists;i++)436 for(int i=0;i<Number_of_Lists;i++) 437 437 { 438 438 first_iter.set_to_list(generators[i]); … … 460 460 // Then search over the remaining lists. 461 461 462 for( short j=i+1;j<Number_of_Lists;j++)462 for(int j=i+1;j<Number_of_Lists;j++) 463 463 { 464 464 second_iter.set_to_list(generators[j]); … … 485 485 list_iterator second_iter; 486 486 487 for( short j=i+1;j<Number_of_Lists;j++)487 for(int j=i+1;j<Number_of_Lists;j++) 488 488 // search over remaining lists 489 489 { … … 548 548 list_iterator first_iter; 549 549 550 for( short i=0;i<Number_of_Lists;i++)550 for(int i=0;i<Number_of_Lists;i++) 551 551 { 552 552 first_iter.set_to_list(generators[i]); … … 575 575 // Then search over the remaining lists. 576 576 577 for( short j=i+1;j<Number_of_Lists;j++)577 for(int j=i+1;j<Number_of_Lists;j++) 578 578 { 579 579 second_iter.set_to_list(generators[j]); … … 601 601 list_iterator second_iter; 602 602 603 for( short j=i+1;j<Number_of_Lists;j++)603 for(int j=i+1;j<Number_of_Lists;j++) 604 604 // search over remaining lists 605 605 { … … 731 731 732 732 733 for( short i=0;i<Number_of_Lists;i++)733 for(int i=0;i<Number_of_Lists;i++) 734 734 { 735 735 first_iter.set_to_list(generators[i]); … … 784 784 // Then search over the remaining lists. 785 785 786 for( short j=i+1;(j<Number_of_Lists) && (first_reduced<=0);j++)786 for(int j=i+1;(j<Number_of_Lists) && (first_reduced<=0);j++) 787 787 { 788 788 second_iter.set_to_list(generators[j]); … … 841 841 second_iter.next(); 842 842 843 for( short j=i+1;(j<Number_of_Lists) && (first_reduced<=0);j++)843 for(int j=i+1;(j<Number_of_Lists) && (first_reduced<=0);j++) 844 844 { 845 845 second_iter.set_to_list(generators[j]); … … 995 995 996 996 997 for( short i=0;i<Number_of_Lists;i++)997 for(int i=0;i<Number_of_Lists;i++) 998 998 { 999 999 first_iter.set_to_list(generators[i]); … … 1048 1048 // Then search over the remaining lists. 1049 1049 1050 for( short j=i+1;(j<Number_of_Lists) && (first_reduced<=0);j++)1050 for(int j=i+1;(j<Number_of_Lists) && (first_reduced<=0);j++) 1051 1051 { 1052 1052 second_iter.set_to_list(generators[j]); … … 1105 1105 second_iter.next(); 1106 1106 1107 for( short j=i+1;(j<Number_of_Lists) && (first_reduced<=0);j++)1107 for(int j=i+1;(j<Number_of_Lists) && (first_reduced<=0);j++) 1108 1108 { 1109 1109 second_iter.set_to_list(generators[j]); … … 1258 1258 #ifdef SUPPORT_DRIVEN_METHODS_EXTENDED 1259 1259 1260 short supp1=(first_iter.get_element()).head_support%Number_of_Lists;1261 short supp2=(second_iter.get_element()).head_support%Number_of_Lists;1260 int supp1=(first_iter.get_element()).head_support%Number_of_Lists; 1261 int supp2=(second_iter.get_element()).head_support%Number_of_Lists; 1262 1262 1263 1263 // Determine the lists over which we have to iterate. … … 1270 1270 // With this formulation, we can use the subset tree as follows: 1271 1271 1272 short supp=bin.head_support%Number_of_Lists;1273 short inv_supp=Number_of_Lists-supp-1;1272 int supp=bin.head_support%Number_of_Lists; 1273 int inv_supp=Number_of_Lists-supp-1; 1274 1274 // This bit vector is the bitwise inverse of bin.head_support (restricted 1275 1275 // to the variables considered in the list indices. … … 1279 1279 1280 1280 1281 for( short i=0;i<S.number_of_subsets[inv_supp];i++)1282 { 1283 short actual_list=Number_of_Lists-S.subsets_of_support[inv_supp][i]-1;1281 for(int i=0;i<S.number_of_subsets[inv_supp];i++) 1282 { 1283 int actual_list=Number_of_Lists-S.subsets_of_support[inv_supp][i]-1; 1284 1284 // the actual list for iteration 1285 1285 // The support of S.subsets_of_support[inv_supp][i] as a bit vector … … 1483 1483 1484 1484 list_iterator first_iter; 1485 short found;1485 int found; 1486 1486 // to control if a reduction has occurred during the actual iteration 1487 1487 … … 1497 1497 1498 1498 binomial& bin1=first_iter.get_element(); 1499 short first_changed=0;1499 int first_changed=0; 1500 1500 // to control if the first element has been reduced 1501 1501 … … 1508 1508 { 1509 1509 binomial& bin2=second_iter.get_element(); 1510 short second_changed=0;1510 int second_changed=0; 1511 1511 1512 1512 if(bin1.reduce_head_by(bin2,w)!=0) … … 1600 1600 1601 1601 list_iterator first_iter; 1602 short found;1602 int found; 1603 1603 // to control if a reduction has occurred during the actual iteration 1604 1604 … … 1614 1614 { 1615 1615 binomial& bin1=first_iter.get_element(); 1616 short first_changed=0;1616 int first_changed=0; 1617 1617 // to control if the first element has been reduced 1618 1618 … … 1754 1754 list_iterator first_iter; 1755 1755 list_iterator second_iter; 1756 short found;1756 int found; 1757 1757 // to control if a reduction has occurred during the actual iteration 1758 1758 … … 1762 1762 // no reduction occurred yet 1763 1763 1764 for( short i=0;i<Number_of_Lists;i++)1764 for(int i=0;i<Number_of_Lists;i++) 1765 1765 { 1766 1766 first_iter.set_to_list(new_generators[i]); … … 1782 1782 // two iterators reference different lists. 1783 1783 1784 for( short j=0;(j<S.number_of_subsets[i]-1)&&(changed==0);j++)1784 for(int j=0;(j<S.number_of_subsets[i]-1)&&(changed==0);j++) 1785 1785 { 1786 1786 second_iter.set_to_list(new_generators[S.subsets_of_support[i][j]]); … … 1880 1880 // two iterators reference different lists. 1881 1881 1882 for( short j=0;(j<S.number_of_subsets[i]-1)&&(changed==0);j++)1882 for(int j=0;(j<S.number_of_subsets[i]-1)&&(changed==0);j++) 1883 1883 { 1884 1884 second_iter.set_to_list(new_generators[S.subsets_of_support[i][j]]); … … 2050 2050 2051 2051 list_iterator first_iter; 2052 short found;2052 int found; 2053 2053 // to control if a reduction has occurred during the actual iteration 2054 2054 … … 2064 2064 { 2065 2065 binomial& bin1=first_iter.get_element(); 2066 short first_changed=0;2066 int first_changed=0; 2067 2067 // to control if the first element has been reduced 2068 2068 … … 2227 2227 list_iterator first_iter; 2228 2228 list_iterator second_iter; 2229 short found;2229 int found; 2230 2230 // to control if a reduction has occurred during the actual iteration 2231 2231 … … 2235 2235 // no reduction occurred yet 2236 2236 2237 for( short i=0;i<Number_of_Lists;i++)2237 for(int i=0;i<Number_of_Lists;i++) 2238 2238 { 2239 2239 first_iter.set_to_list(generators[i]); … … 2255 2255 // two iterators reference different lists. 2256 2256 2257 for( short j=0;(j<S.number_of_subsets[i]-1)&&(changed==0);j++)2257 for(int j=0;(j<S.number_of_subsets[i]-1)&&(changed==0);j++) 2258 2258 { 2259 2259 second_iter.set_to_list(generators[S.subsets_of_support[i][j]]); … … 2357 2357 // two iterators reference different lists. 2358 2358 2359 for( short j=0;(j<S.number_of_subsets[i]-1)&&(changed==0);j++)2359 for(int j=0;(j<S.number_of_subsets[i]-1)&&(changed==0);j++) 2360 2360 { 2361 2361 second_iter.set_to_list(generators[S.subsets_of_support[i][j]]); … … 2560 2560 { 2561 2561 binomial& bin=first_iter.get_element(); 2562 short changed;2562 int changed; 2563 2563 // to control if bin has been reduced 2564 2564 … … 2594 2594 list_iterator first_iter; 2595 2595 2596 for( short i=0;i<Number_of_Lists;i++)2596 for(int i=0;i<Number_of_Lists;i++) 2597 2597 { 2598 2598 first_iter.set_to_list(generators[i]); … … 2601 2601 { 2602 2602 binomial& bin=first_iter.get_element(); 2603 short changed;2603 int changed; 2604 2604 // to control if bin has been reduced 2605 2605 … … 2609 2609 list_iterator second_iter; 2610 2610 2611 short supp=bin.tail_support%Number_of_Lists;2611 int supp=bin.tail_support%Number_of_Lists; 2612 2612 // determine the lists over which we have to iterate 2613 2613 2614 for( short j=0;(j<S.number_of_subsets[supp]) && (changed==0);j++)2614 for(int j=0;(j<S.number_of_subsets[supp]) && (changed==0);j++) 2615 2615 { 2616 2616 second_iter.set_to_list(generators[S.subsets_of_support[supp][j]]); … … 2652 2652 2653 2653 2654 short ideal::add_new_generators()2654 int ideal::add_new_generators() 2655 2655 { 2656 2656 // Reduces the binomials in the "new_generators" list(s) by the generators … … 2660 2660 #ifdef NO_SUPPORT_DRIVEN_METHODS_EXTENDED 2661 2661 2662 short result=0;2662 int result=0; 2663 2663 // element inserted? 2664 2664 … … 2686 2686 #ifdef SUPPORT_DRIVEN_METHODS_EXTENDED 2687 2687 2688 short result=0;2688 int result=0; 2689 2689 // element inserted? 2690 2690 2691 2691 list_iterator iter; 2692 2692 2693 for( short i=0;i<Number_of_Lists;i++)2693 for(int i=0;i<Number_of_Lists;i++) 2694 2694 { 2695 2695 iter.set_to_list(new_generators[i]); … … 2785 2785 // not yet reduced 2786 2786 2787 short supp=bin.head_support%Number_of_Lists;2787 int supp=bin.head_support%Number_of_Lists; 2788 2788 // determine the lists over which we have to iterate 2789 2789 … … 2792 2792 // that cannot contain reducers any more. 2793 2793 2794 for( short i=0;(i<S.number_of_subsets[supp]) && (reduced==0);i++)2794 for(int i=0;(i<S.number_of_subsets[supp]) && (reduced==0);i++) 2795 2795 { 2796 2796 iter.set_to_list(generators[S.subsets_of_support[supp][i]]); … … 2816 2816 // not yet reduced 2817 2817 2818 short supp=bin.tail_support%Number_of_Lists;2818 int supp=bin.tail_support%Number_of_Lists; 2819 2819 // determine the lists over which we have to iterate 2820 2820 … … 2823 2823 // lists that cannot contain reducers any more. 2824 2824 2825 for( short i=0;(i<S.number_of_subsets[supp]) && (reduced==0);i++)2825 for(int i=0;(i<S.number_of_subsets[supp]) && (reduced==0);i++) 2826 2826 { 2827 2827 iter.set_to_list(generators[S.subsets_of_support[supp][i]]); … … 2859 2859 2860 2860 2861 ideal& ideal::reduced_Groebner_basis_1(const short& S_pair_criteria,2861 ideal& ideal::reduced_Groebner_basis_1(const int& S_pair_criteria, 2862 2862 const float& interred_percentage) 2863 2863 { … … 2872 2872 interreduction_percentage=interred_percentage; 2873 2873 2874 short done;2874 int done; 2875 2875 // control variable for recognizing when Buchberger's algorithm has reached 2876 2876 // his end … … 2940 2940 2941 2941 2942 ideal& ideal::reduced_Groebner_basis_1a(const short& S_pair_criteria,2942 ideal& ideal::reduced_Groebner_basis_1a(const int& S_pair_criteria, 2943 2943 const float& interred_percentage) 2944 2944 { … … 2953 2953 interreduction_percentage=interred_percentage; 2954 2954 2955 short done;2955 int done; 2956 2956 // control variable for recognizing when Buchberger's algorithm has reached 2957 2957 // his end … … 3021 3021 3022 3022 3023 ideal& ideal::reduced_Groebner_basis_2(const short& S_pair_criteria,3023 ideal& ideal::reduced_Groebner_basis_2(const int& S_pair_criteria, 3024 3024 const float& interred_percentage) 3025 3025 { … … 3034 3034 interreduction_percentage=interred_percentage; 3035 3035 3036 short done;3036 int done; 3037 3037 // control variable for recognizing when Buchberger's algorithm has reached 3038 3038 // his end … … 3102 3102 3103 3103 3104 ideal& ideal::reduced_Groebner_basis_3(const short& S_pair_criteria,3104 ideal& ideal::reduced_Groebner_basis_3(const int& S_pair_criteria, 3105 3105 const float& interred_percentage) 3106 3106 { … … 3115 3115 interreduction_percentage=interred_percentage; 3116 3116 3117 short not_done;3117 int not_done; 3118 3118 // control variable for recognizing when Buchberger's algorithm has reached 3119 3119 // his end … … 3168 3168 3169 3169 3170 ideal& ideal::reduced_Groebner_basis(const short& version,3171 const short& S_pair_criteria,3170 ideal& ideal::reduced_Groebner_basis(const int& version, 3171 const int& S_pair_criteria, 3172 3172 const float& interred_percentage) 3173 3173 { … … 3183 3183 return reduced_Groebner_basis_3(S_pair_criteria, interred_percentage); 3184 3184 default: 3185 cerr<<"WARNING: ideal& ideal::reduced_Groebner_basis(const short&, "3186 "const short&, const float&):\n"3185 cerr<<"WARNING: ideal& ideal::reduced_Groebner_basis(const int&, " 3186 "const int&, const float&):\n" 3187 3187 "version argument out of range, nothing done"<<endl; 3188 3188 return*this; -
IntegerProgramming/IP_algorithms.cc
ra477f80 r194c2e7 61 61 62 62 int Conti_Traverso(INPUT_FILE MATRIX, 63 const short& version,64 const short& S_pair_criteria,63 const int& version, 64 const int& S_pair_criteria, 65 65 const float& interred_percentage, 66 66 const BOOLEAN& verbose) … … 71 71 72 72 char format_string[128]; // to verifie file format 73 short constraints; // number of equality constraints74 short variables; // number of variables (without auxiliary variables)73 int constraints; // number of equality constraints 74 int variables; // number of variables (without auxiliary variables) 75 75 76 76 ifstream input(MATRIX); … … 265 265 266 266 char GROEBNER[128]; 267 short i=0;267 int i=0; 268 268 while(MATRIX[i]!='\0' && MATRIX[i]!='.') 269 269 { … … 349 349 350 350 int Positive_Conti_Traverso(INPUT_FILE MATRIX, 351 const short& version,352 const short& S_pair_criteria,351 const int& version, 352 const int& S_pair_criteria, 353 353 const float& interred_percentage, 354 354 const BOOLEAN& verbose) … … 359 359 360 360 char format_string[128]; // to verifie file format 361 short constraints; // number of equality constraints362 short variables; // number of variables (without auxiliary variables)361 int constraints; // number of equality constraints 362 int variables; // number of variables (without auxiliary variables) 363 363 364 364 ifstream input(MATRIX); … … 561 561 562 562 char GROEBNER[128]; 563 short i=0;563 int i=0; 564 564 while(MATRIX[i]!='\0' && MATRIX[i]!='.') 565 565 { … … 646 646 647 647 int Elim_Conti_Traverso(INPUT_FILE MATRIX, 648 const short& version,649 const short& S_pair_criteria,648 const int& version, 649 const int& S_pair_criteria, 650 650 const float& interred_percentage, 651 651 const BOOLEAN& verbose) … … 656 656 657 657 char format_string[128]; // to verifie file format 658 short constraints; // number of equality constraints659 short variables; // number of variables (without auxiliary variables)658 int constraints; // number of equality constraints 659 int variables; // number of variables (without auxiliary variables) 660 660 661 661 ifstream input(MATRIX); … … 852 852 853 853 char GROEBNER[128]; 854 short i=0;854 int i=0; 855 855 while(MATRIX[i]!='\0' && MATRIX[i]!='.') 856 856 { … … 935 935 936 936 int Pottier(INPUT_FILE MATRIX, 937 const short& version,938 const short& S_pair_criteria,937 const int& version, 938 const int& S_pair_criteria, 939 939 const float& interred_percentage, 940 940 const BOOLEAN& verbose) … … 945 945 946 946 char format_string[128]; // to verifie file format 947 short constraints; // number of equality constraints948 short variables; // number of variables (without auxiliary variables)947 int constraints; // number of equality constraints 948 int variables; // number of variables (without auxiliary variables) 949 949 950 950 ifstream input(MATRIX); … … 1140 1140 1141 1141 char GROEBNER[128]; 1142 short i=0;1142 int i=0; 1143 1143 while(MATRIX[i]!='\0' && MATRIX[i]!='.') 1144 1144 { … … 1223 1223 1224 1224 int Hosten_Sturmfels(INPUT_FILE MATRIX, 1225 const short& version,1226 const short& S_pair_criteria,1225 const int& version, 1226 const int& S_pair_criteria, 1227 1227 const float& interred_percentage, 1228 1228 const BOOLEAN& verbose) … … 1233 1233 1234 1234 char format_string[128]; // to verifie file format 1235 short constraints; // number of equality constraints1236 short variables; // number of variables1235 int constraints; // number of equality constraints 1236 int variables; // number of variables 1237 1237 1238 1238 ifstream input(MATRIX); … … 1465 1465 float *hom_grad=new float[variables]; 1466 1466 1467 for( short i=0;i<variables;i++)1467 for(int i=0;i<variables;i++) 1468 1468 { 1469 1469 input>>hom_grad[i]; … … 1506 1506 1507 1507 // determine saturation variables 1508 short *sat_var;1509 short number_of_sat_var=A.hosten_shapiro(sat_var);1508 int *sat_var; 1509 int number_of_sat_var=A.hosten_shapiro(sat_var); 1510 1510 // memory for sat_var is allocated in the hosten_shapiro procedure 1511 1511 1512 1512 // saturate the ideal 1513 for( short i=0;i<number_of_sat_var;i++)1513 for(int i=0;i<number_of_sat_var;i++) 1514 1514 { 1515 1515 I.swap_variables(sat_var[i],variables-1); … … 1551 1551 1552 1552 char GROEBNER[128]; 1553 short i=0;1553 int i=0; 1554 1554 while(MATRIX[i]!='\0' && MATRIX[i]!='.') 1555 1555 { … … 1634 1634 1635 1635 int DiBiase_Urbanke(INPUT_FILE MATRIX, 1636 const short& version,1637 const short& S_pair_criteria,1636 const int& version, 1637 const int& S_pair_criteria, 1638 1638 const float& interred_percentage, 1639 1639 const BOOLEAN& verbose) … … 1644 1644 1645 1645 char format_string[128]; // to verify file format 1646 short constraints; // number of equality constraints1647 short variables; // number of variables1646 int constraints; // number of equality constraints 1647 int variables; // number of variables 1648 1648 1649 1649 ifstream input(MATRIX); … … 1822 1822 1823 1823 // compute flip variables (also to check the suitability of the algorithm) 1824 short* F;1825 short r=A.compute_flip_variables(F);1824 int* F; 1825 int r=A.compute_flip_variables(F); 1826 1826 1827 1827 if(r<0) … … 1862 1862 1863 1863 float* weights=new float[variables]; 1864 for( short j=0;j<variables;j++)1864 for(int j=0;j<variables;j++) 1865 1865 weights[j]=0; 1866 1866 weights[F[0]]=1; … … 1880 1880 // But the following change of the term ordering will correct this. 1881 1881 1882 for( short l=1;l<r;l++)1882 for(int l=1;l<r;l++) 1883 1883 { 1884 1884 w.swap_weights(F[l-1],F[l]); … … 1910 1910 1911 1911 char GROEBNER[128]; 1912 short i=0;1912 int i=0; 1913 1913 while(MATRIX[i]!='\0' && MATRIX[i]!='.') 1914 1914 { … … 2000 2000 2001 2001 int Bigatti_LaScala_Robbiano(INPUT_FILE MATRIX, 2002 const short& version,2003 const short& S_pair_criteria,2002 const int& version, 2003 const int& S_pair_criteria, 2004 2004 const float& interred_percentage, 2005 2005 const BOOLEAN& verbose) … … 2010 2010 2011 2011 char format_string[128]; // to verifie file format 2012 short constraints; // number of equality constraints2013 short variables; // number of variables2012 int constraints; // number of equality constraints 2013 int variables; // number of variables 2014 2014 2015 2015 ifstream input(MATRIX); … … 2253 2253 float *hom_grad=new float[variables]; 2254 2254 2255 for( short _i=0;_i<variables;_i++)2255 for(int _i=0;_i<variables;_i++) 2256 2256 { 2257 2257 input>>hom_grad[_i]; … … 2324 2324 2325 2325 char GROEBNER[128]; 2326 short i=0;2326 int i=0; 2327 2327 while(MATRIX[i]!='\0' && MATRIX[i]!='.') 2328 2328 { … … 2410 2410 2411 2411 char format_string[128]; 2412 short problem_variables;2413 short elimination_variables;2414 short weighted_variables;2412 int problem_variables; 2413 int elimination_variables; 2414 int weighted_variables; 2415 2415 char elimination_refinement[128]; 2416 2416 char weighted_refinement[128]; … … 2683 2683 } 2684 2684 2685 short weighted_ref;2685 int weighted_ref; 2686 2686 if(!strcmp(weighted_refinement,"W_LEX")) 2687 2687 weighted_ref=W_LEX; … … 2712 2712 if(elimination_variables>0) 2713 2713 { 2714 short elimination_ref;2714 int elimination_ref; 2715 2715 if(!strcmp(elimination_refinement,"LEX")) 2716 2716 elimination_ref=LEX; … … 3037 3037 char SOLUTION[128]; 3038 3038 3039 short i=0;3039 int i=0; 3040 3040 while(GROEBNER[i]!='\0' && GROEBNER[i]!='.') 3041 3041 { … … 3083 3083 Integer right_hand[weighted_variables+elimination_variables]; 3084 3084 3085 for( short k=0;k<instances;k++)3085 for(int k=0;k<instances;k++) 3086 3086 { 3087 3087 // at the beginning, the variables of interest are zero … … 3190 3190 BOOLEAN error=FALSE; // to test legality of right hand vectors 3191 3191 3192 for( short k=0;k<instances;k++)3192 for(int k=0;k<instances;k++) 3193 3193 { 3194 3194 // at the beginning, the variables of interest are zero … … 3295 3295 Integer initial_solution[weighted_variables]; 3296 3296 3297 for( short k=0;k<instances;k++)3297 for(int k=0;k<instances;k++) 3298 3298 { 3299 3299 // initial solution vector is read from the input stream into the … … 3363 3363 3364 3364 int change_cost(INPUT_FILE GROEBNER, INPUT_FILE NEW_COST, 3365 const short& version,3366 const short& S_pair_criteria,3365 const int& version, 3366 const int& S_pair_criteria, 3367 3367 const float& interred_percentage, 3368 3368 const BOOLEAN& verbose) … … 3370 3370 3371 3371 char format_string[128]; 3372 short elimination_variables;3373 short weighted_variables;3372 int elimination_variables; 3373 int weighted_variables; 3374 3374 char elimination_refinement[128]; 3375 3375 char weighted_refinement[128]; 3376 short new_variables;3376 int new_variables; 3377 3377 char algorithm[128]; 3378 3378 long old_size; … … 3758 3758 // the term ordering to refine the weight is taken to be the same as that 3759 3759 // for the old Groebner basis 3760 short weighted_ref;3760 int weighted_ref; 3761 3761 if(!strcmp(weighted_refinement,"W_LEX")) 3762 3762 weighted_ref=W_LEX; … … 3787 3787 if(elimination_variables>0) 3788 3788 { 3789 short elimination_ref;3789 int elimination_ref; 3790 3790 if(!strcmp(elimination_refinement,"LEX")) 3791 3791 elimination_ref=LEX; … … 3914 3914 char NEW_GROEBNER[128]; 3915 3915 3916 short i=0;3916 int i=0; 3917 3917 while(NEW_COST[i]!='\0' && NEW_COST[i]!='.') 3918 3918 { -
IntegerProgramming/IP_algorithms.h
ra477f80 r194c2e7 49 49 50 50 extern int Conti_Traverso(INPUT_FILE MATRIX, 51 const short& version=1,52 const short& S_pair_criteria=11,51 const int& version=1, 52 const int& S_pair_criteria=11, 53 53 const float& interred_percentage=12.0, 54 54 const BOOLEAN& verbose=FALSE); … … 58 58 59 59 extern int Positive_Conti_Traverso(INPUT_FILE MATRIX, 60 const short& version=1,61 const short& S_pair_criteria=11,60 const int& version=1, 61 const int& S_pair_criteria=11, 62 62 const float& interred_percentage=12.0, 63 63 const BOOLEAN& verbose=FALSE); … … 66 66 67 67 extern int Elim_Conti_Traverso(INPUT_FILE MATRIX, 68 const short& version=1,69 const short& S_pair_criteria=11,68 const int& version=1, 69 const int& S_pair_criteria=11, 70 70 const float& interred_percentage=12.0, 71 71 const BOOLEAN& verbose=FALSE); … … 75 75 76 76 extern int Pottier(INPUT_FILE MATRIX, 77 const short& version=1,78 const short& S_pair_criteria=11,77 const int& version=1, 78 const int& S_pair_criteria=11, 79 79 const float& interred_percentage=12.0, 80 80 const BOOLEAN& verbose=FALSE); … … 83 83 84 84 extern int Hosten_Sturmfels(INPUT_FILE MATRIX, 85 const short& version=1,86 const short& S_pair_criteria=11,85 const int& version=1, 86 const int& S_pair_criteria=11, 87 87 const float& interred_percentage=12.0, 88 88 const BOOLEAN& verbose=FALSE); … … 92 92 93 93 extern int DiBiase_Urbanke(INPUT_FILE MATRIX, 94 const short& version=1,95 const short& S_pair_criteria=11,94 const int& version=1, 95 const int& S_pair_criteria=11, 96 96 const float& interred_percentage=12.0, 97 97 const BOOLEAN& verbose=FALSE); … … 100 100 101 101 extern int Bigatti_LaScala_Robbiano(INPUT_FILE MATRIX, 102 const short& version=1,103 const short& S_pair_criteria=11,102 const int& version=1, 103 const int& S_pair_criteria=11, 104 104 const float& interred_percentage=12.0, 105 105 const BOOLEAN& verbose=FALSE); … … 128 128 129 129 extern int change_cost(INPUT_FILE GROEBNER, INPUT_FILE NEW_COST, 130 const short& version=1,131 const short& S_pair_criteria=11,130 const int& version=1, 131 const int& S_pair_criteria=11, 132 132 const float& interred_percentage=12.0, 133 133 const BOOLEAN& verbose=FALSE); -
IntegerProgramming/globals.h
ra477f80 r194c2e7 60 60 // The general data type to deal with can be short, long or int... 61 61 62 #define _SHORT_62 //#define _SHORT_ 63 63 // For an overflow control for thE result of the LLL algorithm, we have to 64 64 // know the data type used. -
IntegerProgramming/ideal.cc
ra477f80 r194c2e7 19 19 void ideal::create_subset_tree() 20 20 { 21 for( short i=0;i<Number_of_Lists;i++)21 for(int i=0;i<Number_of_Lists;i++) 22 22 { 23 23 … … 27 27 // bits in i that are 1. Hence the desired number is 2^s. 28 28 29 short s=0;30 31 for( short k=0;k<List_Support_Variables;k++)29 int s=0; 30 31 for(int k=0;k<List_Support_Variables;k++) 32 32 if( (i&(1<<k)) == (1<<k) ) 33 33 // bit k of i is 1 … … 43 43 // in this function.) 44 44 45 S.subsets_of_support[i]=new short[S.number_of_subsets[i]];45 S.subsets_of_support[i]=new int[S.number_of_subsets[i]]; 46 46 // memory allocation for subsets_of_support[i] 47 47 48 short index=0;49 for( short j=0;j<Number_of_Lists;j++)48 int index=0; 49 for(int j=0;j<Number_of_Lists;j++) 50 50 if((i&j)==j) 51 51 // If the support of j as a bit vector is contained in the support of … … 60 60 void ideal::destroy_subset_tree() 61 61 { 62 for( short i=0;i<Number_of_Lists;i++)62 for(int i=0;i<Number_of_Lists;i++) 63 63 delete[] S.subsets_of_support[i]; 64 // The arrays number_of_subsets and subsets_of_support (the ( short*)-array)64 // The arrays number_of_subsets and subsets_of_support (the (int*)-array) 65 65 // are not dynamically allocated and do not have to be deleted. 66 66 } … … 134 134 135 135 // build initial ideal generators 136 for( short j=0;j<A.columns;j++)137 { 138 for( short k=0;k<A.columns;k++)136 for(int j=0;j<A.columns;j++) 137 { 138 for(int k=0;k<A.columns;k++) 139 139 // original variables 140 140 if(j==k) … … 143 143 generator[k]=0; 144 144 145 for( short i=0;i<A.rows;i++)145 for(int i=0;i<A.rows;i++) 146 146 // elimination variables 147 147 generator[A.columns+i]=A.coefficients[i][j]; … … 159 159 160 160 // now add the "inversion generator" 161 for( short j=0;j<A.columns;j++)161 for(int j=0;j<A.columns;j++) 162 162 generator[j]=0; 163 for( short i=0;i<A.rows+1;i++)163 for(int i=0;i<A.rows+1;i++) 164 164 generator[A.columns+i]=1; 165 165 binomial* bin=new binomial(A.rows+1+A.columns,generator,w); … … 188 188 189 189 // build the initial ideal generators 190 for( short j=0;j<A.columns;j++)191 { 192 for( short k=0;k<A.columns;k++)190 for(int j=0;j<A.columns;j++) 191 { 192 for(int k=0;k<A.columns;k++) 193 193 // original variables 194 194 if(j==k) … … 197 197 generator[k]=0; 198 198 199 for( short i=0;i<A.rows;i++)199 for(int i=0;i<A.rows;i++) 200 200 // elimination variables 201 201 generator[A.columns+i]=A.coefficients[i][j]; … … 239 239 240 240 // compute initial generating system from the kernel of A 241 for( short j=0;j<A._kernel_dimension;j++)242 { 243 244 for( short k=0;k<A.columns;k++)241 for(int j=0;j<A._kernel_dimension;j++) 242 { 243 244 for(int k=0;k<A.columns;k++) 245 245 { 246 246 … … 257 257 "term_ordering&):\n" 258 258 "LLL-reduced kernel basis does not fit into the used " 259 "basic data type short."<<endl;259 "basic data type int."<<endl; 260 260 size=-3; 261 261 delete[] generator; … … 315 315 // of the computed saturation generator is smaller if less variables are 316 316 // involved. 317 short* sat_var = NULL;318 short number_of_sat_var = A.hosten_shapiro(sat_var);317 int* sat_var = NULL; 318 int number_of_sat_var = A.hosten_shapiro(sat_var); 319 319 if( (number_of_sat_var == 0) || (sat_var == NULL) ) 320 320 { … … 323 323 } 324 324 325 for( short j=0;j<A.columns;j++)325 for(int j=0;j<A.columns;j++) 326 326 generator[j]=0; 327 327 328 for( short k=0;k<number_of_sat_var;k++)328 for(int k=0;k<number_of_sat_var;k++) 329 329 generator[sat_var[k]]=1; 330 330 … … 373 373 374 374 // compute initial generating system from the kernel of A 375 for( short j=0;j<A._kernel_dimension;j++)376 { 377 378 for( short k=0;k<A.columns;k++)375 for(int j=0;j<A._kernel_dimension;j++) 376 { 377 378 for(int k=0;k<A.columns;k++) 379 379 { 380 380 … … 390 390 cerr<<"\nWARNING: ideal& ideal::Hosten_Sturmfels_ideal(matrix&, const " 391 391 "term_ordering&):\nLLL-reduced kernel basis does not fit " 392 "into the used basic data type short."<<endl;392 "into the used basic data type int."<<endl; 393 393 size=-3; 394 394 delete[] generator; … … 462 462 // now compute flip variables 463 463 464 short* F;464 int* F; 465 465 // set of flip variables 466 466 // If F[i]==j, x_j will be flipped. 467 467 468 short r=A.compute_flip_variables(F);468 int r=A.compute_flip_variables(F); 469 469 // number of flip variables 470 470 … … 485 485 if(r>0) 486 486 { 487 for( short i=0;i<_w.number_of_weighted_variables();i++)487 for(int i=0;i<_w.number_of_weighted_variables();i++) 488 488 if((_w[i]!=0) && (i!=F[0])) 489 489 ordering_okay=FALSE; … … 499 499 500 500 // compute initial generating system from the kernel of A 501 for( short j=0;j<A._kernel_dimension;j++)502 { 503 504 for( short k=0;k<A.columns;k++)501 for(int j=0;j<A._kernel_dimension;j++) 502 { 503 504 for(int k=0;k<A.columns;k++) 505 505 { 506 506 … … 516 516 cerr<<"\nWARNING: ideal& ideal::DiBiase_Urbanke_ideal(matrix&, const " 517 517 "term_ordering&):\nLLL-reduced kernel basis does not fit " 518 "into the used basic data type short."<<endl;518 "into the used basic data type int."<<endl; 519 519 size=-3; 520 520 delete[] generator; … … 555 555 556 556 // flip variables 557 for( short l=0;l<r;l++)557 for(int l=0;l<r;l++) 558 558 generator[F[l]]*=-1; 559 559 … … 599 599 // smaller in term ordering. 600 600 // - The weight of the pseudo-elimination variable is smaller. 601 short* sat_var;602 short number_of_sat_var=A.hosten_shapiro(sat_var);601 int* sat_var; 602 int number_of_sat_var=A.hosten_shapiro(sat_var); 603 603 604 604 float weight=0; 605 for( short i=0;i<number_of_sat_var;i++)605 for(int i=0;i<number_of_sat_var;i++) 606 606 weight+=w[sat_var[i]]; 607 607 … … 614 614 615 615 // first build "saturation generator" 616 for( short k=0;k<A.columns;k++)616 for(int k=0;k<A.columns;k++) 617 617 generator[k]=0; 618 for( short i=0;i<number_of_sat_var;i++)618 for(int i=0;i<number_of_sat_var;i++) 619 619 generator[sat_var[i]]=1; 620 620 generator[A.columns]=-1; … … 626 626 627 627 // compute initial generating system from the kernel of A 628 for( short j=0;j<A._kernel_dimension;j++)629 { 630 for( short k=0;k<A.columns;k++)628 for(int j=0;j<A._kernel_dimension;j++) 629 { 630 for(int k=0;k<A.columns;k++) 631 631 { 632 632 // We should first verifie if the components of the LLL-reduced lattice … … 641 641 cerr<<"\nWARNING: ideal& ideal::Bigatti_LaScala_Robbiano_ideal" 642 642 "(matrix&, const term_ordering&):\nLLL-reduced kernel basis does " 643 "not fit into the used basic data type short."<<endl;643 "not fit into the used basic data type int."<<endl; 644 644 size=-3; 645 645 delete[] generator; … … 701 701 /////////////////// constructors and destructor ///////////////////////////// 702 702 703 ideal::ideal(matrix& A, const term_ordering& _w, const short& algorithm)703 ideal::ideal(matrix& A, const term_ordering& _w, const int& algorithm) 704 704 { 705 705 … … 709 709 { 710 710 cerr<<"\nWARNING: ideal::ideal(matrix&, const term_ordering&, const " 711 " short&):\ncannot create ideal from a corrupt input matrix"<<endl;711 "int&):\ncannot create ideal from a corrupt input matrix"<<endl; 712 712 size=-1; 713 713 return; … … 717 717 { 718 718 cerr<<"\nWARNING: ideal::ideal(matrix&, const term_ordering&, const " 719 " short&):\ncannot create ideal with a corrupt input ordering"<<endl;719 "int&):\ncannot create ideal with a corrupt input ordering"<<endl; 720 720 size=-1; 721 721 return; … … 769 769 default: 770 770 cerr<<"\nWARNING: ideal::ideal(matrix&, const term_ordering&, const " 771 " short&):\nunknown algorithm for ideal construction"<<endl;771 "int&):\nunknown algorithm for ideal construction"<<endl; 772 772 size=-1; 773 773 return; … … 828 828 create_subset_tree(); 829 829 830 for( short i=0;i<Number_of_Lists;i++)830 for(int i=0;i<Number_of_Lists;i++) 831 831 { 832 832 iter.set_to_list(I.generators[i]); … … 840 840 } 841 841 842 for( short i=0;i<Number_of_Lists;i++)842 for(int i=0;i<Number_of_Lists;i++) 843 843 { 844 844 iter.set_to_list(I.new_generators[i]); … … 865 865 } 866 866 867 ideal::ideal(ifstream& input, const term_ordering& _w, const short&867 ideal::ideal(ifstream& input, const term_ordering& _w, const int& 868 868 number_of_generators) 869 869 { … … 871 871 { 872 872 cerr<<"\nWARNING: ideal::ideal(ifstream&, const term_ordering&, const " 873 " short&):\ncannot create ideal with a corrupt input ordering"<<endl;873 "int&):\ncannot create ideal with a corrupt input ordering"<<endl; 874 874 size=-1; 875 875 return; … … 895 895 #endif // SUPPORT_DRIVEN_METHODS_EXTENDED 896 896 897 short number_of_variables=897 int number_of_variables= 898 898 w.number_of_elimination_variables()+w.number_of_weighted_variables(); 899 899 Integer* generator=new Integer[number_of_variables]; … … 901 901 for(long i=0;i<number_of_generators;i++) 902 902 { 903 for( short j=0;j<number_of_variables;j++)903 for(int j=0;j<number_of_variables;j++) 904 904 { 905 905 input>>generator[j]; … … 909 909 { 910 910 cerr<<"\nWARNING: ideal::ideal(ifstream&, const term_ordering&, " 911 "const short&): \ninput failure when reading generator "<<i<<endl;911 "const int&): \ninput failure when reading generator "<<i<<endl; 912 912 size=-2; 913 913 delete[] generator; … … 942 942 } 943 943 944 short ideal::error_status() const944 int ideal::error_status() const 945 945 { 946 946 if(size<0) … … 961 961 #ifdef SUPPORT_DRIVEN_METHODS_EXTENDED 962 962 963 for( short i=0;i<Number_of_Lists;i++)963 for(int i=0;i<Number_of_Lists;i++) 964 964 generators[i].ordered_print(w); 965 965 … … 1002 1002 #ifdef SUPPORT_DRIVEN_METHODS_EXTENDED 1003 1003 1004 for( short i=0;i<Number_of_Lists;i++)1004 for(int i=0;i<Number_of_Lists;i++) 1005 1005 generators[i].ordered_print(output,w); 1006 1006 … … 1043 1043 #ifdef SUPPORT_DRIVEN_METHODS_EXTENDED 1044 1044 1045 for( short i=0;i<Number_of_Lists;i++)1045 for(int i=0;i<Number_of_Lists;i++) 1046 1046 generators[i].ordered_print(output,w); 1047 1047 … … 1079 1079 #ifdef SUPPORT_DRIVEN_METHODS_EXTENDED 1080 1080 1081 for( short i=0;i<Number_of_Lists;i++)1081 for(int i=0;i<Number_of_Lists;i++) 1082 1082 generators[i].ordered_format_print(output,w); 1083 1083 -
IntegerProgramming/ideal.h
ra477f80 r194c2e7 33 33 34 34 35 const short Number_of_Lists=1<<List_Support_Variables;35 const int Number_of_Lists=1<<List_Support_Variables; 36 36 37 37 … … 42 42 typedef struct 43 43 { 44 short* subsets_of_support[Number_of_Lists];45 short number_of_subsets[Number_of_Lists];44 int* subsets_of_support[Number_of_Lists]; 45 int number_of_subsets[Number_of_Lists]; 46 46 } subset_tree; 47 47 … … 80 80 // flags for the use of the S-pair criteria and the autoreduction 81 81 82 short rel_primeness;83 short M_criterion;84 short F_criterion;85 short B_criterion;86 short second_criterion;82 int rel_primeness; 83 int M_criterion; 84 int F_criterion; 85 int B_criterion; 86 int second_criterion; 87 87 // When BuchbergerŽs algorithm is called, we only use one argument which 88 88 // describes the combination of the criteria to be used (see in globals.h). … … 150 150 // Inserts a (new) generator in the appropriate list. 151 151 152 short add_new_generators();152 int add_new_generators(); 153 153 // Moves the new generators to the generator lists. 154 154 … … 221 221 // constructors and destructor (implemented in ideal.cc) 222 222 223 ideal(matrix&, const term_ordering&, const short& algorithm);223 ideal(matrix&, const term_ordering&, const int& algorithm); 224 224 // Creates a binomial ideal from the given matrix using the given algorithm 225 225 // (see in globals.h). … … 239 239 // (or of an ideal and its elimination ideal). 240 240 241 ideal(ifstream&, const term_ordering&, const short& number_of_generators);241 ideal(ifstream&, const term_ordering&, const int& number_of_generators); 242 242 // Reads an ideal from a given ifstream in the following way: 243 243 // A block of integers is converted into a binomial … … 255 255 // Returns the actual number of generators. 256 256 257 short error_status() const;257 int error_status() const; 258 258 // Returns -1 if an error has occurred (i.e. size<0), else 0. 259 259 260 260 // Buchberger stuff (implemented in Buchberger.cc) 261 261 262 ideal& reduced_Groebner_basis_1(const short& S_pair_criteria=11,262 ideal& reduced_Groebner_basis_1(const int& S_pair_criteria=11, 263 263 const float& interred_percentage=12.0); 264 ideal& reduced_Groebner_basis_1a(const short& S_pair_criteria=11,264 ideal& reduced_Groebner_basis_1a(const int& S_pair_criteria=11, 265 265 const float& interred_percentage=12.0); 266 ideal& reduced_Groebner_basis_2(const short& S_pair_criteria=11,266 ideal& reduced_Groebner_basis_2(const int& S_pair_criteria=11, 267 267 const float& interred_percentage=12.0); 268 ideal& reduced_Groebner_basis_3(const short& S_pair_criteria=11,268 ideal& reduced_Groebner_basis_3(const int& S_pair_criteria=11, 269 269 const float& interred_percentage=12.0); 270 270 // Several different versions of BuchbergerŽs algorithm for computing … … 294 294 // "between" the input ideal and its saturation. 295 295 296 ideal& reduced_Groebner_basis(const short& version=1,297 const short& S_pair_criteria=11,296 ideal& reduced_Groebner_basis(const int& version=1, 297 const int& S_pair_criteria=11, 298 298 const float& interred_percentage=12.0); 299 299 // Takes the version of BuchbergerŽs algorithm as above as an argument … … 331 331 // SUPPORT_DRIVEN_METHODS_EXTENDED are enabled. 332 332 333 ideal& swap_variables(const short& i, const short& j);333 ideal& swap_variables(const int& i, const int& j); 334 334 // Swaps the i-th and the j-th variable in all generators as well as the 335 335 // corresponding components of the term ordering's weight vector. … … 337 337 // according to the new order on the variables. 338 338 339 ideal& swap_variables_unsafe(const short& i, const short& j);339 ideal& swap_variables_unsafe(const int& i, const int& j); 340 340 // Swaps the i-th and the j-th variable in all generators as well as the 341 341 // corresponding components of the term ordering's weight vector. 342 342 // DANGER: The head/tail structure is not rebuilt! 343 343 344 ideal& flip_variable_unsafe(const short& i);344 ideal& flip_variable_unsafe(const int& i); 345 345 // Inverts the sign of the i-th variable in all generators. 346 346 // DANGER: The list structure is not rebuilt! -
IntegerProgramming/ideal_stuff.cc
ra477f80 r194c2e7 65 65 66 66 // elimination 67 for( short i=0;i<Number_of_Lists;i++)67 for(int i=0;i<Number_of_Lists;i++) 68 68 { 69 69 iter.set_to_list(generators[i]); … … 125 125 list_iterator iter; 126 126 127 short last_weighted_variable=w.number_of_weighted_variables()-1;127 int last_weighted_variable=w.number_of_weighted_variables()-1; 128 128 129 129 … … 167 167 // For the time needed by this function see the remarks for ideal::eliminate(). 168 168 169 for( short i=0;i<Number_of_Lists;i++)169 for(int i=0;i<Number_of_Lists;i++) 170 170 { 171 171 iter.set_to_list(generators[i]); … … 260 260 // the aux_list and then reinserted according to their new head. 261 261 262 for( short i=0;i<Number_of_Lists;i++)262 for(int i=0;i<Number_of_Lists;i++) 263 263 { 264 264 iter.set_to_list(generators[i]); … … 314 314 315 315 316 ideal& ideal::swap_variables_unsafe(const short& i, const short& j)316 ideal& ideal::swap_variables_unsafe(const int& i, const int& j) 317 317 { 318 318 // first check arguments … … 320 320 || (j<0) || (j>=w.number_of_weighted_variables())) 321 321 { 322 cout<<"WARNING: ideal::swap_variables(const short&, const short&)\n "323 "or ideal::swap_variables_unsafe(const short&, const short&):\n"322 cout<<"WARNING: ideal::swap_variables(const int&, const int&)\n " 323 "or ideal::swap_variables_unsafe(const int&, const int&):\n" 324 324 "index out of range"<<endl; 325 325 return *this; … … 353 353 // But head and tail are not adapted to the new term ordering induced by 354 354 // the change of the variable order - this is only done in the "safe" 355 // routine swap_variables(const short&, const short&).356 357 for( short l=0;l<Number_of_Lists;l++)355 // routine swap_variables(const int&, const int&). 356 357 for(int l=0;l<Number_of_Lists;l++) 358 358 { 359 359 iter.set_to_list(generators[l]); … … 393 393 394 394 395 ideal& ideal::swap_variables(const short& i, const short& j)395 ideal& ideal::swap_variables(const int& i, const int& j) 396 396 { 397 397 … … 407 407 408 408 409 ideal& ideal::flip_variable_unsafe(const short& i)409 ideal& ideal::flip_variable_unsafe(const int& i) 410 410 { 411 411 // first check argument 412 412 if((i<0) || (i>=w.number_of_weighted_variables())) 413 413 { 414 cout<<"WARNING: ideal::flip_variables(const short&):\n"414 cout<<"WARNING: ideal::flip_variables(const int&):\n" 415 415 "argument out of range, nothing done"<<endl; 416 416 return *this; … … 439 439 // to the aux_list and then reinserted according to their new head. 440 440 441 for( short l=0;l<Number_of_Lists;l++)441 for(int l=0;l<Number_of_Lists;l++) 442 442 { 443 443 iter.set_to_list(generators[l]); -
IntegerProgramming/matrix.cc
ra477f80 r194c2e7 12 12 typedef BigInt* BigIntP; 13 13 14 matrix::matrix(const short& row_number, const short& column_number)14 matrix::matrix(const int& row_number, const int& column_number) 15 15 :rows(row_number),columns(column_number) 16 16 { … … 22 22 // bad input, set "error flag" 23 23 { 24 cerr<<"\nWARNING: matrix::matrix(const short&, const short&):\n"24 cerr<<"\nWARNING: matrix::matrix(const int&, const int&):\n" 25 25 "argument out of range"<<endl; 26 26 columns=-1; … … 31 31 32 32 coefficients=new IntegerP[rows]; 33 for( short i=0;i<rows;i++)33 for(int i=0;i<rows;i++) 34 34 coefficients[i]=new Integer[columns]; 35 for( short i=0;i<rows;i++)36 for( short j=0;j<columns;j++)35 for(int i=0;i<rows;i++) 36 for(int j=0;j<columns;j++) 37 37 coefficients[i][j]=0; 38 38 } 39 39 40 matrix::matrix(const short& row_number, const short& column_number,40 matrix::matrix(const int& row_number, const int& column_number, 41 41 Integer** entries) 42 42 :rows(row_number),columns(column_number) … … 49 49 // bad input, set "error flag" 50 50 { 51 cerr<<"\nWARNING: matrix::matrix(const short&, const short&, Integr**):\n"51 cerr<<"\nWARNING: matrix::matrix(const int&, const int&, Integr**):\n" 52 52 "argument out of range"<<endl; 53 53 columns=-1; … … 58 58 59 59 coefficients=new IntegerP[rows]; 60 for( short i=0;i<rows;i++)60 for(int i=0;i<rows;i++) 61 61 coefficients[i]=new Integer[columns]; 62 for( short i=0;i<rows;i++)63 for( short j=0;j<columns;j++)62 for(int i=0;i<rows;i++) 63 for(int j=0;j<columns;j++) 64 64 coefficients[i][j]=entries[i][j]; 65 65 // coefficients[i] is the i-th row vector … … 101 101 102 102 coefficients=new IntegerP[rows]; 103 for( short i=0;i<rows;i++)103 for(int i=0;i<rows;i++) 104 104 coefficients[i]=new Integer[columns]; 105 for( short i=0;i<rows;i++)106 for( short j=0;j<columns;j++)105 for(int i=0;i<rows;i++) 106 for(int j=0;j<columns;j++) 107 107 { 108 108 input>>coefficients[i][j]; … … 120 120 121 121 122 matrix::matrix(const short& m, const short& n, ifstream& input)122 matrix::matrix(const int& m, const int& n, ifstream& input) 123 123 { 124 124 _kernel_dimension=-2; … … 129 129 // bad input, set "error flag" 130 130 { 131 cerr<<"\nWARNING: matrix::matrix(const short&, const short&, ifstream&):\n"131 cerr<<"\nWARNING: matrix::matrix(const int&, const int&, ifstream&):\n" 132 132 "argument out of range"<<endl; 133 133 columns=-1; … … 141 141 142 142 coefficients=new IntegerP[rows]; 143 for( short i=0;i<rows;i++)143 for(int i=0;i<rows;i++) 144 144 coefficients[i]=new Integer[columns]; 145 for( short i=0;i<rows;i++)146 for( short j=0;j<columns;j++)145 for(int i=0;i<rows;i++) 146 for(int j=0;j<columns;j++) 147 147 { 148 148 input>>coefficients[i][j]; … … 173 173 174 174 coefficients=new IntegerP[rows]; 175 for( short i=0;i<rows;i++)175 for(int i=0;i<rows;i++) 176 176 coefficients[i]=new Integer[columns]; 177 for( short i=0;i<rows;i++)178 for( short j=0;j<columns;j++)177 for(int i=0;i<rows;i++) 178 for(int j=0;j<columns;j++) 179 179 coefficients[i][j]=A.coefficients[i][j]; 180 180 … … 182 182 { 183 183 H=new BigIntP[_kernel_dimension]; 184 for( short k=0;k<_kernel_dimension;k++)184 for(int k=0;k<_kernel_dimension;k++) 185 185 H[k]=new BigInt[columns]; 186 for( short k=0;k<_kernel_dimension;k++)187 for( short j=0;j<columns;j++)186 for(int k=0;k<_kernel_dimension;k++) 187 for(int j=0;j<columns;j++) 188 188 H[k][j]=(A.H)[k][j]; 189 189 } … … 195 195 matrix::~matrix() 196 196 { 197 for( short i=0;i<rows;i++)197 for(int i=0;i<rows;i++) 198 198 delete[] coefficients[i]; 199 199 delete[] coefficients; … … 202 202 // LLL-algorithm performed 203 203 { 204 for( short i=0;i<_kernel_dimension;i++)204 for(int i=0;i<_kernel_dimension;i++) 205 205 delete[] H[i]; 206 206 delete[] H; … … 218 218 BOOLEAN matrix::is_nonnegative() const 219 219 { 220 for( short i=0;i<rows;i++)221 for( short j=0;j<columns;j++)220 for(int i=0;i<rows;i++) 221 for(int j=0;j<columns;j++) 222 222 if(coefficients[i][j]<0) 223 223 return FALSE; … … 227 227 228 228 229 short matrix::error_status() const229 int matrix::error_status() const 230 230 { 231 231 if(columns<0) … … 237 237 238 238 239 short matrix::row_number() const239 int matrix::row_number() const 240 240 { 241 241 return rows; … … 244 244 245 245 246 short matrix::column_number() const246 int matrix::column_number() const 247 247 { 248 248 return columns; … … 257 257 258 258 259 short matrix::LLL_kernel_basis()259 int matrix::LLL_kernel_basis() 260 260 { 261 261 … … 263 263 // (They are modified by the LLL-algorithm!) 264 264 BigInt** b=new BigIntP[columns]; 265 for( short n=0;n<columns;n++)265 for(int n=0;n<columns;n++) 266 266 b[n]=new BigInt[rows]; 267 for( short n=0;n<columns;n++)268 for( short m=0;m<rows;m++)267 for(int n=0;n<columns;n++) 268 for(int m=0;m<rows;m++) 269 269 b[n][m]=coefficients[m][n]; 270 270 … … 276 276 277 277 // delete auxiliary vectors 278 for( short n=0;n<columns;n++)278 for(int n=0;n<columns;n++) 279 279 delete[] b[n]; 280 280 delete[] b; … … 286 286 287 287 288 short matrix::compute_nonzero_kernel_vector()288 int matrix::compute_nonzero_kernel_vector() 289 289 { 290 290 … … 295 295 if(_kernel_dimension==-1) 296 296 { 297 cerr<<"\nWARNING: short matrix::compute_non_zero_kernel_vector(BigInt*&):"297 cerr<<"\nWARNING: int matrix::compute_non_zero_kernel_vector(BigInt*&):" 298 298 "\nerror in kernel basis, cannot compute the desired vector"<<endl; 299 299 return 0; … … 302 302 if(_kernel_dimension==0) 303 303 { 304 cerr<<"\nWARNING: short matrix::compute_non_zero_kernel_vector(BigInt*&): "304 cerr<<"\nWARNING: int matrix::compute_non_zero_kernel_vector(BigInt*&): " 305 305 "\nkernel dimension is zero"<<endl; 306 306 return 0; … … 318 318 319 319 // determine number of zero components 320 for( short i=0;i<_kernel_dimension;i++)320 for(int i=0;i<_kernel_dimension;i++) 321 321 { 322 322 M[i]=0; 323 for( short j=0;j<columns;j++)323 for(int j=0;j<columns;j++) 324 324 if(H[i][j]==BigInt(0)) 325 325 M[i]++; … … 330 330 // columns is an upper bound (not reached because the kernel basis cannot 331 331 // contain the zero vector) 332 for( short i=0;i<_kernel_dimension;i++)332 for(int i=0;i<_kernel_dimension;i++) 333 333 if(M[i]<min) 334 334 min=M[i]; … … 337 337 // and discard the others (the norm computation is why we have chosen the 338 338 // M[i] to be BigInts) 339 for( short i=0;i<_kernel_dimension;i++)339 for(int i=0;i<_kernel_dimension;i++) 340 340 if(M[i]!=min) 341 341 M[i]=-1; 342 342 else 343 for( short j=0;j<columns;j++)343 for(int j=0;j<columns;j++) 344 344 M[i]+=H[i][j]*H[i][j]; 345 345 // As the lattice basis does not contain the zero vector, at least one M[i] … … 348 348 // determine the start vector, i.e. the one with least zero components, but 349 349 // smallest possible (euclidian) norm 350 short min_index=-1;351 for( short i=0;i<_kernel_dimension;i++)350 int min_index=-1; 351 for(int i=0;i<_kernel_dimension;i++) 352 352 if(M[i]>BigInt(0)) 353 353 if(min_index==-1) … … 377 377 // still a l a t t i c e basis). 378 378 379 for( short current_position=1;current_position<columns;current_position++)379 for(int current_position=1;current_position<columns;current_position++) 380 380 // in fact, this loop will terminate before the condition in the 381 381 // for-statement is satisfied... … … 386 386 387 387 BOOLEAN found=TRUE; 388 for( short j=0;j<columns;j++)388 for(int j=0;j<columns;j++) 389 389 if(H[0][j]==BigInt(0)) 390 390 found=FALSE; … … 401 401 // determine number of components in each remaining vector that are zero 402 402 // in the vector itself as well as in the already constructed vector 403 for( short i=current_position;i<_kernel_dimension;i++)403 for(int i=current_position;i<_kernel_dimension;i++) 404 404 M[i]=0; 405 405 406 short remaining_zero_components=0;407 408 for( short j=0;j<columns;j++)406 int remaining_zero_components=0; 407 408 for(int j=0;j<columns;j++) 409 409 if(H[0][j]==BigInt(0)) 410 410 { 411 411 remaining_zero_components++; 412 for( short i=current_position;i<_kernel_dimension;i++)412 for(int i=current_position;i<_kernel_dimension;i++) 413 413 if(H[i][j]==BigInt(0)) 414 414 M[i]++; … … 419 419 // this is the number of zero components in H[0] and an upper bound 420 420 // for the M[i] 421 for( short i=current_position;i<_kernel_dimension;i++)421 for(int i=current_position;i<_kernel_dimension;i++) 422 422 if(M[i]<min) 423 423 min=M[i]; … … 431 431 // components 432 432 // discard the others 433 for( short i=current_position;i<_kernel_dimension;i++)433 for(int i=current_position;i<_kernel_dimension;i++) 434 434 if(M[i]!=min) 435 435 M[i]=-1; 436 436 else 437 for( short j=0;j<columns;j++)437 for(int j=0;j<columns;j++) 438 438 M[i]+=H[i][j]*H[i][j]; 439 439 // Again, at least one M[i] is positive! … … 442 442 // This is the vector with the least common zero components with respect 443 443 // to H[0], but the smallest possible norm. 444 short min_index=0;445 for( short i=current_position;i<_kernel_dimension;i++)444 int min_index=0; 445 for(int i=current_position;i<_kernel_dimension;i++) 446 446 if(M[i]>BigInt(0)) 447 447 if(min_index==0) … … 472 472 found=FALSE; 473 473 474 for( short mult=1;found==FALSE;mult++)474 for(int mult=1;found==FALSE;mult++) 475 475 { 476 476 found=TRUE; … … 478 478 // check if any component !=0 of H[0] becomes zero by adding 479 479 // mult*H[current_position] 480 for( short j=0;j<columns;j++)480 for(int j=0;j<columns;j++) 481 481 if(H[0][j]!=BigInt(0)) 482 482 if(H[0][j]+(const BigInt&)mult*H[current_position][j] … … 485 485 486 486 if(found==TRUE) 487 for( short j=0;j<columns;j++)487 for(int j=0;j<columns;j++) 488 488 H[0][j]+=(const BigInt&)mult*H[current_position][j]; 489 489 else … … 495 495 // check if any component !=0 of H[0] becomes zero by subtracting 496 496 // mult*H[current_position] 497 for( short j=0;j<columns;j++)497 for(int j=0;j<columns;j++) 498 498 if(H[0][j]!=BigInt(0)) 499 499 if(H[0][j]-(const BigInt&)mult*H[current_position][j] … … 502 502 503 503 if(found==TRUE) 504 for( short j=0;j<columns;j++)504 for(int j=0;j<columns;j++) 505 505 H[0][j]-=(const BigInt&)mult*H[current_position][j]; 506 506 } … … 509 509 510 510 // When reaching this line, an error must have occurred. 511 cerr<<"FATAL ERROR in short matrix::compute_nonnegative_vector()"<<endl;511 cerr<<"FATAL ERROR in int matrix::compute_nonnegative_vector()"<<endl; 512 512 abort(); 513 513 } 514 514 515 short matrix::compute_flip_variables(short*& F)515 int matrix::compute_flip_variables(int*& F) 516 516 { 517 517 // first compute nonzero vector … … 520 520 if(!okay) 521 521 { 522 cout<<"\nWARNING: short matrix::compute_flip_variables(short*&):\n"522 cout<<"\nWARNING: int matrix::compute_flip_variables(int*&):\n" 523 523 "kernel of the matrix contains no vector with nonzero components,\n" 524 524 "no flip variables computed"<<endl; … … 530 530 // or those corresponding to the negative ones 531 531 532 short r=0;532 int r=0; 533 533 // number of flip variables 534 534 535 for( short j=0;j<columns;j++)535 for(int j=0;j<columns;j++) 536 536 if(H[0][j]<BigInt(0)) 537 537 r++; … … 547 547 { 548 548 r=columns-r; 549 F=new short[r];550 memset(F,0,r*sizeof( short));551 short counter=0;552 for( short j=0;j<columns;j++)549 F=new int[r]; 550 memset(F,0,r*sizeof(int)); 551 int counter=0; 552 for(int j=0;j<columns;j++) 553 553 if(H[0][j]> BigInt(0)) 554 554 { … … 561 561 // all variables corresponding to negative components will be flipped 562 562 { 563 F=new short[r];564 memset(F,0,r*sizeof( short));565 short counter=0;566 for( short j=0;j<columns;j++)563 F=new int[r]; 564 memset(F,0,r*sizeof(int)); 565 int counter=0; 566 for(int j=0;j<columns;j++) 567 567 if(H[0][j]< BigInt(0)) 568 568 { … … 578 578 579 579 580 short matrix::hosten_shapiro(short*& sat_var)580 int matrix::hosten_shapiro(int*& sat_var) 581 581 { 582 582 … … 587 587 if(_kernel_dimension==-1) 588 588 { 589 cerr<<"\nWARNING: short matrix::hosten_shapiro(short*&):\n"589 cerr<<"\nWARNING: int matrix::hosten_shapiro(int*&):\n" 590 590 "error in kernel basis, cannot compute the saturation variables"<<endl; 591 591 return 0; … … 604 604 return 0; 605 605 606 short number_of_sat_var=0;607 sat_var=new short[columns/2];608 memset(sat_var,0,sizeof( short)*(columns/2));606 int number_of_sat_var=0; 607 sat_var=new int[columns/2]; 608 memset(sat_var,0,sizeof(int)*(columns/2)); 609 609 610 610 BOOLEAN* ideal_saturated_by_var=new BOOLEAN[columns]; 611 611 // auxiliary array used to remember by which variables the ideal has still to 612 612 // be saturated 613 for( short j=0;j<columns;j++)613 for(int j=0;j<columns;j++) 614 614 ideal_saturated_by_var[j]=FALSE; 615 615 616 for( short k=0;k<_kernel_dimension;k++)616 for(int k=0;k<_kernel_dimension;k++) 617 617 { 618 618 // determine number of positive and negative components in H[k] 619 619 // corresponding to variables by which the ideal has still to be saturated 620 short pos_sat_var=0;621 short neg_sat_var=0;622 623 for( short j=0;j<columns;j++)620 int pos_sat_var=0; 621 int neg_sat_var=0; 622 623 for(int j=0;j<columns;j++) 624 624 { 625 625 if(ideal_saturated_by_var[j]==FALSE) … … 637 637 if(pos_sat_var<=neg_sat_var) 638 638 { 639 for( short j=0;j<columns;j++)639 for(int j=0;j<columns;j++) 640 640 if(ideal_saturated_by_var[j]==FALSE) 641 641 if(H[k][j]> BigInt(0)) … … 655 655 else 656 656 { 657 for( short j=0;j<columns;j++)657 for(int j=0;j<columns;j++) 658 658 if(ideal_saturated_by_var[j]==FALSE) 659 659 if(H[k][j]< BigInt(0)) … … 691 691 printf("\n%3d x %3d\n",rows,columns); 692 692 693 for( short i=0;i<rows;i++)694 { 695 for( short j=0;j<columns;j++)693 for(int i=0;i<rows;i++) 694 { 695 for(int j=0;j<columns;j++) 696 696 printf("%6d",coefficients[i][j]); 697 697 printf("\n"); … … 704 704 fprintf(output,"\n%3d x %3d\n",rows,columns); 705 705 706 for( short i=0;i<rows;i++)707 { 708 for( short j=0;j<columns;j++)706 for(int i=0;i<rows;i++) 707 { 708 for(int j=0;j<columns;j++) 709 709 fprintf(output,"%6d",coefficients[i][j]); 710 710 fprintf(output,"\n"); … … 717 717 output<<endl<<setw(3)<<rows<<" x "<<setw(3)<<columns<<endl; 718 718 719 for( short i=0;i<rows;i++)720 { 721 for( short j=0;j<columns;j++)719 for(int i=0;i<rows;i++) 720 { 721 for(int j=0;j<columns;j++) 722 722 output<<setw(6)<<coefficients[i][j]; 723 723 output<<endl; -
IntegerProgramming/matrix.h
ra477f80 r194c2e7 32 32 private: 33 33 34 short rows;34 int rows; 35 35 36 short columns;36 int columns; 37 37 // Also used as error flag (values <0): 38 38 // -1 indicates a "semantic" error (which occurs e.g. if some constructor … … 48 48 // allocated if such a basis is really computed. 49 49 50 short _kernel_dimension;50 int _kernel_dimension; 51 51 // the number of vectors stored in H (the size of these vectors is columns) 52 52 // If _kernel_dimension==-2, no kernel basis has been computed yet. … … 62 62 // constructors and destructor 63 63 64 matrix(const short& row_number, const short& column_number);64 matrix(const int& row_number, const int& column_number); 65 65 // Creates a zero matrix of the specified size. 66 66 67 matrix(const short& row_number, const short& column_number,67 matrix(const int& row_number, const int& column_number, 68 68 Integer** entries); 69 69 // Builds a matrix from its coefficient array. … … 80 80 // coefficients 0..n-1 of row m 81 81 82 matrix(const short& m, const short& n, ifstream& input);82 matrix(const int& m, const int& n, ifstream& input); 83 83 // Reads a (m x n)-matrix from the given ifstream. 84 84 // The input stream must have the following format: … … 102 102 // Returns TRUE, if all entries of the matrix are >=0, else FALSE. 103 103 104 short error_status() const;104 int error_status() const; 105 105 // Returns columns iff columns<0 (this is the "error flag"), else 0. 106 106 107 short row_number() const;107 int row_number() const; 108 108 // Retuns the row number. 109 109 110 short column_number() const;110 int column_number() const; 111 111 // Returns the column number. 112 112 113 short kernel_dimension() const;113 int kernel_dimension() const; 114 114 // Returns the kernel dimension. 115 115 … … 118 118 // special routines for the IP-algorithms 119 119 120 short LLL_kernel_basis();120 int LLL_kernel_basis(); 121 121 // Computes a LLL-reduced integer basis of the matrix kernel and returns 122 122 // the kernel dimension (-1 if an error has occurred). 123 123 // This dimension is also stored in the member kernel_dimension. 124 124 125 short compute_nonzero_kernel_vector();125 int compute_nonzero_kernel_vector(); 126 126 // Transforms the kernel lattice basis stored in H so that it contains 127 127 // a vector whose components are all !=0; … … 129 129 // If no such basis has been computed before, this is done now. 130 130 131 short compute_flip_variables(short*&);131 int compute_flip_variables(int*&); 132 132 // Computes a set of flip variables for the algorithm of DiBiase and 133 133 // Urbanke from a kernel vector with no zero components. … … 137 137 // is done in the routine) to be accessible for the calling function. 138 138 139 short hosten_shapiro(short*& sat_var);139 int hosten_shapiro(int*& sat_var); 140 140 // Computes a set of saturation variables for the ideal defined by the 141 141 // kernel lattice and returns the size of that set. -
IntegerProgramming/solve_IP.cc
ra477f80 r194c2e7 16 16 // with default settings 17 17 BOOLEAN verbose=FALSE; 18 short version=1;19 short S_pair_criteria=11;18 int version=1; 19 int S_pair_criteria=11; 20 20 double interreduction_percentage=12.0; 21 21 22 22 ///////////////////////// parse options ///////////////////////////////////// 23 23 24 short alg_option=0;24 int alg_option=0; 25 25 // no algorithm specified yet 26 26 … … 30 30 { 31 31 32 for( short i=1;i<argc-2;i++)32 for(int i=1;i<argc-2;i++) 33 33 // these are the input options 34 34 { … … 250 250 char* GROEBNER=new char[128]; 251 251 memset(GROEBNER,0,128); 252 short i=0;252 int i=0; 253 253 while(argv[argc-2][i]!='\0' && argv[argc-2][i]!='.' && argv[argc-2][i]>' ') 254 254 {
Note: See TracChangeset
for help on using the changeset viewer.