compiled
This commit is contained in:
Binary file not shown.
@@ -74,9 +74,9 @@ class BinaryTree {
|
||||
Result_t *ptr_;
|
||||
index_t num_;
|
||||
};
|
||||
BinaryTree();
|
||||
BinaryTree(){}
|
||||
~BinaryTree();
|
||||
void Init(BinaryDataset<Precision_t> &data);
|
||||
void Init(BinaryDataset<Precision_t> *data);
|
||||
void Destruct() {}
|
||||
// Call this function to build Depth first a tree
|
||||
void BuildDepthFirst();
|
||||
@@ -153,7 +153,7 @@ class BinaryTree {
|
||||
// Parent/Root
|
||||
NodePtr_t parent_;
|
||||
// Source of data
|
||||
BinaryDataset<Precision_t> data_;
|
||||
BinaryDataset<Precision_t> *data_;
|
||||
// Total number of points on the tree
|
||||
index_t num_of_points_;
|
||||
// Number of Leafs on the tree
|
||||
|
||||
@@ -76,7 +76,7 @@ class BinaryTree {
|
||||
};
|
||||
BinaryTree();
|
||||
~BinaryTree();
|
||||
void Init(BinaryDataset<Precision_t> &data);
|
||||
void Init(BinaryDataset<Precision_t> *data);
|
||||
void Destruct() {}
|
||||
// Call this function to build Depth first a tree
|
||||
void BuildDepthFirst();
|
||||
@@ -87,7 +87,7 @@ class BinaryTree {
|
||||
// Builds tree k depth first. It builds all the subtrees depth first up to k level
|
||||
void BuildKDepthFirst();
|
||||
template<typename POINTTYPE, typename NEIGHBORTYPE>
|
||||
void NearestNeighbor(POINTTYPE &test_point,
|
||||
void NearestNeighbor(POINTTYPE test_point,
|
||||
vector<pair<Precision_t, Point_t> > *nearest_point,
|
||||
NEIGHBORTYPE range);
|
||||
|
||||
@@ -153,7 +153,7 @@ class BinaryTree {
|
||||
// Parent/Root
|
||||
NodePtr_t parent_;
|
||||
// Source of data
|
||||
BinaryDataset<Precision_t> data_;
|
||||
BinaryDataset<Precision_t> *data_;
|
||||
// Total number of points on the tree
|
||||
index_t num_of_points_;
|
||||
// Number of Leafs on the tree
|
||||
|
||||
@@ -10,10 +10,10 @@ template<typename TYPELIST, bool diagnostic>
|
||||
// traits_nearest_neighbor.h file
|
||||
|
||||
TEMPLATE__
|
||||
void TREE__::Init(BinaryDataset<Precision_t> &data) {
|
||||
void TREE__::Init(BinaryDataset<Precision_t> *data) {
|
||||
data_ = data;
|
||||
dimension_ = data.get_dimension();
|
||||
num_of_points_ = data.get_num_of_points();
|
||||
dimension_ = data->get_dimension();
|
||||
num_of_points_ = data->get_num_of_points();
|
||||
node_id_=0;
|
||||
num_of_leafs_=0;
|
||||
current_level_=0;
|
||||
@@ -89,7 +89,7 @@ void TREE__::BuildBreadthFirst(
|
||||
fifo_pair.second->start_,
|
||||
fifo_pair.second->num_of_points_,
|
||||
dimension_,
|
||||
&data_);
|
||||
data_);
|
||||
|
||||
num_of_leafs_++;
|
||||
node_id_++;
|
||||
@@ -144,7 +144,7 @@ void TREE__::BuildDepthFirst(typename TREE__::NodePtr_t &ptr,
|
||||
pivot_pair.second->start_,
|
||||
pivot_pair.second->num_of_points_,
|
||||
dimension_,
|
||||
&data_);
|
||||
data_);
|
||||
|
||||
node_id_++;
|
||||
num_of_leafs_++;
|
||||
@@ -176,7 +176,7 @@ void TREE__::BuildDepthFirst(typename TREE__::NodePtr_t &ptr,
|
||||
pivot_info->start_,
|
||||
pivot_info->num_of_points_,
|
||||
dimension_,
|
||||
&data_);
|
||||
data_);
|
||||
|
||||
node_id_++;
|
||||
num_of_leafs_++;
|
||||
|
||||
@@ -10,7 +10,7 @@ template<typename TYPELIST, bool diagnostic>
|
||||
// traits_nearest_neighbor.h file
|
||||
|
||||
TEMPLATE__
|
||||
void TREE__::Init(BinaryDataset<Precision_t> &data) {
|
||||
void TREE__::Init(BinaryDataset<Precision_t> *data) {
|
||||
data_ = data;
|
||||
dimension_ = data.get_dimension();
|
||||
num_of_points_ = data.get_num_of_points();
|
||||
@@ -89,7 +89,7 @@ void TREE__::BuildBreadthFirst(
|
||||
fifo_pair.second->start_,
|
||||
fifo_pair.second->num_of_points_,
|
||||
dimension_,
|
||||
&data_);
|
||||
data_);
|
||||
|
||||
num_of_leafs_++;
|
||||
node_id_++;
|
||||
@@ -144,7 +144,7 @@ void TREE__::BuildDepthFirst(typename TREE__::NodePtr_t &ptr,
|
||||
pivot_pair.second->start_,
|
||||
pivot_pair.second->num_of_points_,
|
||||
dimension_,
|
||||
&data_);
|
||||
data_);
|
||||
|
||||
node_id_++;
|
||||
num_of_leafs_++;
|
||||
@@ -176,7 +176,7 @@ void TREE__::BuildDepthFirst(typename TREE__::NodePtr_t &ptr,
|
||||
pivot_info->start_,
|
||||
pivot_info->num_of_points_,
|
||||
dimension_,
|
||||
&data_);
|
||||
data_);
|
||||
|
||||
node_id_++;
|
||||
num_of_leafs_++;
|
||||
@@ -347,8 +347,8 @@ void TREE__::AllNearestNeighbors(typename TREE__::NodePtr_t query,
|
||||
range,
|
||||
closest_child.second.second);
|
||||
query->set_min_dist_so_far(
|
||||
min<Precision_t>(query->get_min_dist_so_far(),
|
||||
max<Precision_t>(query->get_left()->get_min_dist_so_far(),
|
||||
std::min<Precision_t>(query->get_min_dist_so_far(),
|
||||
std::max<Precision_t>(query->get_left()->get_min_dist_so_far(),
|
||||
query->get_right()->get_min_dist_so_far())));
|
||||
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ class BinaryTreeTest {
|
||||
}
|
||||
data_.set_id(i,i);
|
||||
}
|
||||
tree_.Init(data_);
|
||||
tree_.Init(&data_);
|
||||
}
|
||||
void Destruct() {
|
||||
tree_.Destruct();
|
||||
|
||||
@@ -104,7 +104,7 @@ class BinaryTreeTest {
|
||||
&nearest_tree,
|
||||
range_);
|
||||
Naive(i, nearest_naive);
|
||||
for(index_t j=0; j<nearest_tree.size(); j++) {
|
||||
for(index_t j=0; j<(index_t)nearest_tree.size(); j++) {
|
||||
TEST_DOUBLE_APPROX(nearest_naive[j+1].first,
|
||||
nearest_tree[j].first,
|
||||
numeric_limits<Precision_t>::epsilon());
|
||||
|
||||
@@ -152,7 +152,7 @@ class Node {
|
||||
NodePtr_t right_;
|
||||
typename Allocator_t::template ArrayPtr<index_t> index_;
|
||||
typename Allocator_t::template ArrayPtr<Precision_t> points_;
|
||||
typename Allocator_t::template Ptr<NodeCachedStatistics_t> statistics_;
|
||||
NodeCachedStatistics_t statistics_;
|
||||
index_t num_of_points_;
|
||||
union {
|
||||
NNResult *kneighbors_;
|
||||
|
||||
@@ -19,7 +19,7 @@ class Node {
|
||||
typedef typename TYPELIST::Metric_t Metric_t;
|
||||
typedef typename TYPELIST::BoundingBox_t BoundingBox_t;
|
||||
typedef typename TYPELIST::NodeCachedStatistics_t NodeCachedStatistics_t;
|
||||
typedef typename TYPELIST::PointIdDescriminator_t PointIdDiscriminator_t;
|
||||
typedef typename TYPELIST::PointIdDiscriminator_t PointIdDiscriminator_t;
|
||||
typedef typename Allocator_t::template ArrayPtr<Precision_t> Array_t;
|
||||
typedef Node<TYPELIST, diagnostic> Node_t;
|
||||
typedef typename Allocator_t::template Ptr<Node> NodePtr_t;
|
||||
|
||||
@@ -22,8 +22,8 @@ void NODE__::Init(const BoundingBox_t &box,
|
||||
const NodeCachedStatistics_t &statistics,
|
||||
index_t node_id,
|
||||
index_t num_of_points) {
|
||||
box_=box;
|
||||
statistics_=statistics;
|
||||
box_.Alias(box);
|
||||
statistics_.Alias(statistics);
|
||||
node_id_ = node_id;
|
||||
num_of_points_ = num_of_points;
|
||||
}
|
||||
@@ -37,7 +37,7 @@ void NODE__::Init(const typename NODE__::BoundingBox_t &box,
|
||||
int32 dimension,
|
||||
BinaryDataset<Precision_t> *dataset) {
|
||||
box_.Alias(box);
|
||||
statistics_->Alias(statistics);
|
||||
statistics_.Alias(statistics);
|
||||
node_id_ = node_id;
|
||||
num_of_points_ = num_of_points;
|
||||
points_.Reset(Allocator_t::template malloc<Precision_t>
|
||||
|
||||
@@ -22,8 +22,8 @@ void NODE__::Init(const BoundingBox_t &box,
|
||||
const NodeCachedStatistics_t &statistics,
|
||||
index_t node_id,
|
||||
index_t num_of_points) {
|
||||
box_=box;
|
||||
statistics_=statistics;
|
||||
box_.Alias(box);
|
||||
statistics_.Alias(statistics);
|
||||
node_id_ = node_id;
|
||||
num_of_points_ = num_of_points;
|
||||
}
|
||||
@@ -195,8 +195,8 @@ inline void NODE__::FindAllNearest(
|
||||
==temp[j].second.get_id()) {
|
||||
break;
|
||||
}
|
||||
query_node->kneighbors_[i*range+j].distance_=temp[j].first;
|
||||
query_node->kneighbors_[i*range+j].nearest_=temp[j].second;
|
||||
query_node->kneighbors_[i*(index_t)range+j].distance_=temp[j].first;
|
||||
query_node->kneighbors_[i*(index_t)range+j].nearest_=temp[j].second;
|
||||
}
|
||||
// Estimate the maximum nearest neighbor distance
|
||||
comp.UpdateComparisons();
|
||||
|
||||
Reference in New Issue
Block a user