Changeset 1272 for applications/robust/robustlib.cpp
- Timestamp:
- 01/14/11 18:28:55 (13 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/robust/robustlib.cpp
r1271 r1272 55 55 vec cur_condition = as_toprow->condition.get(1,as_toprow->condition.size()-1); 56 56 57 // cout << as_toprow->condition << endl; 58 57 59 vertex* base_vertex = (*simplex.begin()); 58 60 … … 61 63 mat jacobian(dimension,dimension); 62 64 63 double a_0 = base_vertex->get_coordinates()*cur_condition+as_toprow->condition[0]; 65 // cout << base_vertex->get_coordinates() << endl; 66 67 double a_0 = base_vertex->get_coordinates()*cur_condition-as_toprow->condition[0]; 64 68 map<double,int> as; 65 69 … … 69 73 vec relative_coords = (*vert_ref)->get_coordinates()-base_vertex->get_coordinates(); 70 74 75 // cout << (*vert_ref)->get_coordinates() << endl; 71 76 // cout << relative_coords << endl; 72 77 … … 80 85 (*returned.first).second++; 81 86 } 87 /* 82 88 else 83 89 { 84 90 cout << "a[" << row_count << "] = " << new_a << endl; 85 91 } 92 */ 93 86 94 //as.ins(as.size(),new_a); 87 95 … … 89 97 } 90 98 91 // cout << endl;99 92 100 93 101 double int_value = 0; … … 95 103 // cout << jacobian << endl; 96 104 97 double det_jacobian = det(jacobian); 105 double det_jacobian = abs(det(jacobian)); 106 double correction_term = det_jacobian; 98 107 for(map<double,int>::iterator as_ref = as.begin();as_ref!=as.end();as_ref++) 99 108 { 100 109 double multiplier = det_jacobian; 110 101 111 if(a_0!=(*as_ref).first) 102 { 112 { 103 113 int as1_order = (*as_ref).second; 104 114 115 correction_term /= -pow((*as_ref).first,as1_order); 116 105 117 current_emlig->set_correction_factors(as1_order); 106 118 … … 126 138 multiplier /= (*as_ref).first; 127 139 number_of_factors += 1; 128 } 140 } 141 129 142 } 130 143 131 double bracket = fact(condition_order-number_of_factors)/fact(as1_order-1)/pow( (*as_ref).first-a_0,condition_order-number_of_factors);144 double bracket = fact(condition_order-number_of_factors)/fact(as1_order-1)/pow(a_0+(*as_ref).first,condition_order-number_of_factors+1); 132 145 for(int k = 0;k < as1_order-1;k++) 133 146 { 134 double bracket_factor = pow((double)-1,k+1)*fact(condition_order-1-number_of_factors-k)/fact(as1_order-2-k)/pow( (*as_ref).first-a_0,condition_order-1-number_of_factors-k);147 double bracket_factor = pow((double)-1,k+1)*fact(condition_order-1-number_of_factors-k)/fact(as1_order-2-k)/pow(a_0+(*as_ref).first,condition_order-number_of_factors-k); 135 148 136 149 for(set<my_ivec>::iterator combi_ref = this->my_emlig->correction_factors[k].begin();combi_ref!=this->my_emlig->correction_factors[k].end();combi_ref++) … … 144 157 bracket+=bracket_factor*bracket_combination; 145 158 } 146 } 159 } 147 160 148 int_value += multiplier*bracket;161 149 162 163 int_value += multiplier*bracket; 150 164 } 151 165 else 152 166 { 153 167 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)"); 154 } 168 } 169 } 155 170 156 // cout << c << int_value << endl; 171 172 correction_term *= fact(condition_order-my_emlig->number_of_parameters)/pow(a_0,condition_order-my_emlig->number_of_parameters+1); 157 173 158 return int_value; 159 } 174 // cout << c << int_value << endl; 175 176 int_value += correction_term; 177 178 // cout << int_value << endl; 179 180 // cout << "***************************" << endl << endl; 181 182 return int_value; 160 183 161 184 }