/********************************************************************** * print_matrix * * Print the best guesses out of the match rating matrix. **********************************************************************/ void print_matrix(MATRIX rating_matrix) { int x; int dimension; int spread; CHOICES rating; cprintf ("Ratings Matrix (top choices)\n"); dimension = matrix_dimension (rating_matrix); /* Do each diagonal */ for (spread = 0; spread < dimension; spread++) { /* For each spot */ for (x = 0; x < dimension - spread; x++) { /* Process one square */ rating = matrix_get (rating_matrix, x, x + spread); if (rating != NOT_CLASSIFIED) { cprintf ("\t[%d,%d] : ", x, x + spread); if (first_node (rating)) cprintf ("%-10s%4.0f\t|\t", class_string (first_node (rating)), class_probability (first_node (rating))); if (second_node (rating)) cprintf ("%-10s%4.0f\t|\t", class_string (second_node (rating)), class_probability (second_node (rating))); if (third (rating)) cprintf ("%-10s%4.0f\n", class_string (third (rating)), class_probability (third (rating))); else new_line(); } } } }
static inline void apply(nodes_container_type & additional_nodes, Node & n, Box & n_box, parameters_type const& parameters, Translator const& translator, Allocators & allocators) { // TODO - consider creating nodes always with sufficient memory allocated // create additional node, use auto ptr for automatic destruction on exception node_auto_ptr second_node(rtree::create_node<Allocators, Node>::apply(allocators), allocators); // MAY THROW, STRONG (N: alloc) // create reference to the newly created node Node & n2 = rtree::get<Node>(*second_node); // NOTE: thread-safety // After throwing an exception by redistribute_elements the original node may be not changed or // both nodes may be empty. In both cases the tree won't be valid r-tree. // The alternative is to create 2 (or more) additional nodes here and store backup info // in the original node, then, if exception was thrown, the node would always have more than max // elements. // The alternative is to use moving semantics in the implementations of redistribute_elements, // it will be possible to throw from boost::move() in the case of e.g. static size nodes. // redistribute elements Box box2; redistribute_elements< Value, Options, Translator, Box, Allocators, typename Options::redistribute_tag >::apply(n, n2, n_box, box2, parameters, translator, allocators); // MAY THROW (V, E: alloc, copy, copy) // check numbers of elements BOOST_GEOMETRY_INDEX_ASSERT(parameters.get_min_elements() <= rtree::elements(n).size() && rtree::elements(n).size() <= parameters.get_max_elements(), "unexpected number of elements"); BOOST_GEOMETRY_INDEX_ASSERT(parameters.get_min_elements() <= rtree::elements(n2).size() && rtree::elements(n2).size() <= parameters.get_max_elements(), "unexpected number of elements"); // return the list of newly created nodes (this algorithm returns one) additional_nodes.push_back(rtree::make_ptr_pair(box2, second_node.get())); // MAY THROW, STRONG (alloc, copy) // release the ptr second_node.release(); }