Changeset 1262 for applications/robust
- Timestamp:
- 12/13/10 19:25:45 (14 years ago)
- Location:
- applications/robust
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/robust/robustlib.cpp
r1254 r1262 31 31 32 32 double a_0 = base_vertex->get_coordinates()*cur_condition+as_toprow->condition[0]; 33 vecas;33 map<double,int> as; 34 34 35 35 int row_count = 0; … … 41 41 42 42 double new_a = relative_coords*cur_condition; 43 44 as.ins(as.size(),new_a); 43 44 pair<map<double,int>::iterator,bool> returned = as.insert(pair<double,int>(new_a,1)); 45 if(returned.second == false) 46 { 47 (*returned.first).second++; 48 } 49 //as.ins(as.size(),new_a); 45 50 46 51 row_count++; … … 48 53 49 54 double int_value = 0; 50 for( int a_count = 0;a_count<as.size();a_count++)55 for(map<double,int>::iterator as_ref = as.begin();as_ref!=as.end();as_ref++) 51 56 { 52 vec reduced_as = (as.get(a_count)-as);57 int fac_order = ((toprow*)this)->condition_order-as.size()-1; 53 58 54 reduced_as.del(a_count); 59 double fac_value = 1; 60 if(a_0!=(*as_ref).first) 61 { 62 //fac_value = ((double)tgamma(fac_order)*det(jacobian))/(*as_ref).first/pow((*as_ref).first-a_0,fac_order); 63 64 fac_value /= (*as_ref).first; 55 65 56 int fac_order = ((toprow*)this)->condition_order-reduced_as.size()-1; 66 for(map<double,int>::iterator as2_ref = as.begin();as2_ref!=as.end();as2_ref++) 67 { 68 if(as2_ref!=as_ref) 69 { 70 double current_factor = (*as_ref).first-(*as2_ref).first; 57 71 58 double fac_value = ((double)tgamma(fac_order)*det(jacobian))/as[a_count]/pow(as[a_count]-a_0,fac_order);72 fac_value /= current_factor; 59 73 60 for(int b_count = 0;b_count<reduced_as.size();b_count++) 74 75 } 76 } 77 } 78 else 61 79 { 62 fac_value /= reduced_as[b_count];80 throw new exception("Should this happen? a_i=a_0 in the formula for integrating over a simplex! I think it can happen with 0 probability(when phi*2*v_0=phi*v_i)"); 63 81 } 64 82 83 65 84 int_value += fac_value; 66 85 } -
applications/robust/robustlib.h
r1254 r1262 12 12 #include <vector> 13 13 #include <list> 14 #include <map> 14 15 #include <set> 15 16 #include <algorithm> 17 #include <string> 16 18 17 19 using namespace bdm; … … 413 415 class emlig // : eEF 414 416 { 417 vector<set<ivec>> correction_factors; 415 418 416 419 /// A statistic in a form of a Hasse diagram representing a complex of convex polyhedrons obtained as a result … … 425 428 426 429 double normalization_factor; 430 431 427 432 428 433 void alter_toprow_conditions(vec condition, bool should_be_added) … … 915 920 sizevector.push_back(statistic.row_size(s)); 916 921 }*/ 917 } 922 923 924 } 925 926 vector<list<ivec>> get_correction_factors(int order) 927 { 928 for(int remaining_order = correction_factors.size();remaining_order>order;remaining_order++) 929 { 930 set<ivec> factor_templates; 931 set<ivec> final_factors; 932 933 for(int i = 1;i==number_of_parameters-order+1;i++) 934 { 935 for(int j = 1;j==remaining_order;j++) 936 { 937 factor_templates.insert(zeros(number_of_parameters-order+2)); 938 939 for(set<ivec>::iterator fac_ref = factor_templates.begin();fac_ref!=factor_templates.end();fac_ref++) 940 { 941 ivec current_template = (*fac_ref); 942 943 current_template[0]+=1; 944 current_template[i]+=1; 945 946 if(current_template[0]==remaining_order) 947 { 948 final_factors.insert(current_template.right(current_template.size()-1); 949 } 950 else 951 { 952 factor_templates.insert(current_template); 953 } 954 } 955 } 956 } 957 958 correction_factors.push_back(final_factors); 959 960 } 961 } 918 962 919 963 protected: … … 1234 1278 1235 1279 1280 1236 1281 #endif //TRAGE_H