Changeset 1242 for applications
- Timestamp:
- 10/31/10 08:59:04 (14 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/robust/robustlib.h
r1234 r1242 170 170 } 171 171 172 void triangulate( )172 void triangulate(bool should_integrate) 173 173 { 174 174 for(list<polyhedron*>::iterator child_ref = children.begin();child_ref!=children.end();child_ref++) 175 175 { 176 set<double> simplex_integrals; 177 176 178 for(list<set<vertex*>>::iterator t_ref = (*child_ref)->triangulation.begin();t_ref!=(*child_ref)->triangulation.end();t_ref++) 177 179 { … … 184 186 { 185 187 triangulation.push_back(new_simplex); 188 189 if(should_integrate) 190 { 191 toprow* as_toprow = (toprow*)this; 192 193 vertex* base_vertex = (*new_simplex.begin()); 194 195 double a_0 = base_vertex->get_coordinates()*as_toprow->condition(1,as_toprow->condition.size()-1)+as_toprow->condition[0]; 196 list<double> as; 197 198 for(set<vertex*>::iterator vert_ref = (++new_simplex.begin()); vert_ref!=new_simplex.end();vert_ref++) 199 { 200 vec relative_coords = (*vert_ref)->get_coordinates()-base_vertex->get_coordinates(); 201 202 double new_a = relative_coords*as_toprow->condition(1,as_toprow->condition.size()-1); 203 204 as.push_back(new_a); 205 } 206 207 for(list<double>::iterator as_ref = as.begin();as_ref!=as.end();as_ref++) 208 { 209 //TODO DODELAT VYPOCET! 210 } 211 } 186 212 } 213 } 214 215 if(should_integrate) 216 { 217 ((toprow*)this)->probability = 0.0; 218 219 for(set<double>::iterator integ_ref = simplex_integrals.begin();integ_ref!=simplex_integrals.end();integ_ref++) 220 { 221 ((toprow*)this)->probability += (*integ_ref); 222 } 187 223 } 188 224 } … … 245 281 246 282 public: 283 double probability; 284 247 285 /// A condition used for determining the function of a Laplace-Inverse-Gamma density resulting from Bayesian estimation 248 286 vec condition; 249 287 288 int condition_order; 289 250 290 /// Default constructor 251 291 toprow(){}; 252 292 253 293 /// Constructor creating a toprow from the condition 254 toprow(vec condition) 255 { 256 this->condition = condition; 257 } 294 toprow(vec condition, int condition_order) 295 { 296 this->condition = condition; 297 this->condition_order = condition_order; 298 } 258 299 259 300 }; … … 587 628 else 588 629 { 630 ((toprow*)current_parent)->condition_order++; 631 589 632 if(current_parent->negativechildren.size()>0) 590 633 { 591 634 current_parent->set_state(-1, SPLIT); 592 635 593 ((toprow*)current_parent)->condition-=toadd; 636 ((toprow*)current_parent)->condition-=toadd; 637 594 638 } 595 639 else if(current_parent->positivechildren.size()>0) … … 597 641 current_parent->set_state(1, SPLIT); 598 642 599 ((toprow*)current_parent)->condition+=toadd; 643 ((toprow*)current_parent)->condition+=toadd; 600 644 } 601 645 else … … 673 717 674 718 void remove_condition(vec toremove) 675 { 719 { 676 720 vec null_vector = ""; 677 721 … … 841 885 } 842 886 843 toprow* positive_poly = new toprow(((toprow*)current_polyhedron)->condition+toadd );844 toprow* negative_poly = new toprow(((toprow*)current_polyhedron)->condition-toadd );887 toprow* positive_poly = new toprow(((toprow*)current_polyhedron)->condition+toadd, ((toprow*)current_polyhedron)->condition_order+1); 888 toprow* negative_poly = new toprow(((toprow*)current_polyhedron)->condition-toadd, ((toprow*)current_polyhedron)->condition_order+1); 845 889 846 890 for(list<polyhedron*>::iterator parent_ref = current_polyhedron->parents.begin();parent_ref!=current_polyhedron->parents.end();parent_ref++) … … 897 941 negative_poly->vertices.insert(new_totally_neutral_child->vertices.begin(),new_totally_neutral_child->vertices.end()); 898 942 899 new_totally_neutral_child->triangulate( );900 901 positive_poly->triangulate( );902 negative_poly->triangulate( );943 new_totally_neutral_child->triangulate(false); 944 945 positive_poly->triangulate(k==for_splitting.size()-1); 946 negative_poly->triangulate(k==for_splitting.size()-1); 903 947 904 948 statistic.append_polyhedron(k-1, new_totally_neutral_child); … … 1058 1102 1059 1103 // We create a new toprow with the previously specified condition. 1060 toprow* current_copy1 = new toprow(vec1 );1061 toprow* current_copy2 = new toprow(vec2 );1104 toprow* current_copy1 = new toprow(vec1, 0); 1105 toprow* current_copy2 = new toprow(vec2, 0); 1062 1106 1063 1107 // The vertices of the copies will be inherited, because there will be a parent/child relation