gen_metric_tree.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00043 #ifndef TREE_GEN_METRIC_TREE_H
00044 #define TREE_GEN_METRIC_TREE_H
00045
00046 #include "general_spacetree.h"
00047
00048 #include "fastlib/base/common.h"
00049 #include "fastlib/col/arraylist.h"
00050 #include "fastlib/fx/fx.h"
00051
00052 #include "gen_metric_tree_impl.h"
00053
00057 namespace proximity {
00058
00075 template<typename TMetricTree>
00076 TMetricTree *MakeGenMetricTree(Matrix& matrix, index_t leaf_size,
00077 ArrayList<index_t> *old_from_new = NULL,
00078 ArrayList<index_t> *new_from_old = NULL) {
00079
00080 TMetricTree *node = new TMetricTree();
00081 index_t *old_from_new_ptr;
00082
00083 if (old_from_new) {
00084 old_from_new->Init(matrix.n_cols());
00085
00086 for (index_t i = 0; i < matrix.n_cols(); i++) {
00087 (*old_from_new)[i] = i;
00088 }
00089
00090 old_from_new_ptr = old_from_new->begin();
00091 } else {
00092 old_from_new_ptr = NULL;
00093 }
00094
00095 node->Init(0, matrix.n_cols());
00096 node->bound().center().Init(matrix.n_rows());
00097 tree_gen_metric_tree_private::SplitGenMetricTree<TMetricTree>
00098 (matrix, node, leaf_size, old_from_new_ptr);
00099
00100 if (new_from_old) {
00101 new_from_old->Init(matrix.n_cols());
00102 for (index_t i = 0; i < matrix.n_cols(); i++) {
00103 (*new_from_old)[(*old_from_new)[i]] = i;
00104 }
00105 }
00106
00107 return node;
00108 }
00109
00110 };
00111
00112 #endif