diff --git a/fastlib/trunk/contrib/march/npt/multi_matcher.cc b/fastlib/trunk/contrib/march/npt/multi_matcher.cc index 3c96914d92..10f193a1b9 100644 --- a/fastlib/trunk/contrib/march/npt/multi_matcher.cc +++ b/fastlib/trunk/contrib/march/npt/multi_matcher.cc @@ -26,7 +26,7 @@ bool MultiMatcher::TestPointPair(double dist_sq, index_t tuple_index_1, continue; } - if (dist_sq >= distances_[num_bins_ - 1]) { + if (dist_sq > distances_[num_bins_ - 1]) { // this permutation is bad permutation_ok[perm_ind] = false; @@ -42,7 +42,13 @@ bool MultiMatcher::TestPointPair(double dist_sq, index_t tuple_index_1, double* ind_ptr = std::upper_bound(distances_.begin(), distances_.end(), dist_sq); int ind = (int)(ind_ptr - distances_.begin()); - permutation_ranges[perm_ind].set(tuple_index_1, tuple_index_2, ind); + DEBUG_ASSERT(ind < num_bins_ && ind >= 0); + // these need to be whereever they go in the permutation + index_t perm_index_1 = GetPermutationIndex_(perm_ind, tuple_index_1); + index_t perm_index_2 = GetPermutationIndex_(perm_ind, tuple_index_2); + + permutation_ranges[perm_ind].set(perm_index_1, perm_index_2, ind); + permutation_ranges[perm_ind].set(perm_index_2, perm_index_1, ind); this_point_works = true; diff --git a/fastlib/trunk/contrib/march/npt/n_point_multi.cc b/fastlib/trunk/contrib/march/npt/n_point_multi.cc index 080e7e1694..3c63c047d8 100644 --- a/fastlib/trunk/contrib/march/npt/n_point_multi.cc +++ b/fastlib/trunk/contrib/march/npt/n_point_multi.cc @@ -167,7 +167,8 @@ void NPointMulti::BaseCaseHelper_(ArrayList >& point_sets, double point_dist_sq = la::DistanceSqEuclidean(point_i, point_j); - //printf("Testing point pair (%d, %d)\n", j, k); + //printf("Testing point pair (%d, %d)\n", point_index_j, + // point_index_i); // This needs to fill in the permutation_ok_copy for each matcher this_point_works = matcher_.TestPointPair(point_dist_sq, j, k, permutation_ok_copy, @@ -193,6 +194,8 @@ void NPointMulti::BaseCaseHelper_(ArrayList >& point_sets, results_.ClearFilledResults(); + //ot::Print(permutation_ok_copy); + for (index_t perm_index = 0; perm_index < matcher_.num_permutations(); perm_index++) { @@ -201,6 +204,10 @@ void NPointMulti::BaseCaseHelper_(ArrayList >& point_sets, continue; } + //printf("perm_index: %d\n", perm_index); + //permutation_ranges_copy[perm_index].PrintDebug("PermutationRangesCopy"); + //ot::Print(permutation_ranges_copy[perm_index]); + results_.IncrementRange(permutation_ranges_copy[perm_index]); @@ -292,14 +299,15 @@ void NPointMulti::DepthFirstRecursion_(NodeTuple& nodes, can_prune = true; break; } // check if the range is empty - + */ // TODO: make sure that it's not too small or large for any matcher + if (valid_ranges[i].first > matcher_.max_dist()) { - printf("Pruning on too much separation for any matcher.\n"); + //printf("Pruning on too much separation for any matcher.\n"); can_prune = true; break; } // too large - */ + // add lower bounds here later @@ -307,12 +315,12 @@ void NPointMulti::DepthFirstRecursion_(NodeTuple& nodes, // check prune - i.e. check if it's still possible to contribute to anything if (can_prune) { - printf("Pruned all\n"); + //printf("Pruned all\n"); num_total_prunes_++; return; } // check prune else if (nodes.all_leaves()) { - printf("Base Case\n"); + //printf("Base Case\n"); BaseCase_(nodes, valid_ranges); } // base case else { diff --git a/fastlib/trunk/contrib/march/npt/n_point_multi.h b/fastlib/trunk/contrib/march/npt/n_point_multi.h index c720a3fa1e..3cee012384 100644 --- a/fastlib/trunk/contrib/march/npt/n_point_multi.h +++ b/fastlib/trunk/contrib/march/npt/n_point_multi.h @@ -39,6 +39,8 @@ private: int num_total_prunes_; + int num_points_; + ArrayList > invalid_indices_; @@ -84,6 +86,8 @@ public: leaf_size_ = fx_param_int(mod_, "leaf_size", 1); + num_points_ = data_points_.n_cols(); + // initialize results tensor results_.Init(tuple_size_, num_bands); @@ -116,6 +120,8 @@ public: FindInvalidIndices_(); + fx_result_int(mod_, "num_points", num_points_); + } // Init() void Compute() { diff --git a/fastlib/trunk/contrib/march/npt/results_tensor.h b/fastlib/trunk/contrib/march/npt/results_tensor.h index 2709e8aa7a..572380a31f 100644 --- a/fastlib/trunk/contrib/march/npt/results_tensor.h +++ b/fastlib/trunk/contrib/march/npt/results_tensor.h @@ -144,6 +144,8 @@ public: while(!done) { + //ot::Print(indices_copy); + Matrix this_matcher; this_matcher.Init(tuple_size_, tuple_size_);