@@ -670,7 +670,11 @@ \subsubsection{flann::Index::knnSearch}
670
670
\item [indices]{Matrix that will contain the indices of the K-nearest neighbors found (size should be at least
671
671
$ num\_ queries \times knn$ for the pre-allocated version).}
672
672
\item [dists]{Matrix that will contain the distances to the K-nearest neighbors found (size should be at least
673
- $ num\_ queries \times knn$ for the pre-allocated version).}
673
+ $ num\_ queries \times knn$ for the pre-allocated version). \\
674
+ \emph {Note: } For Euclidean distances, the \texttt {flann::L2 } functor computes squared distances,
675
+ so the value passed here needs to be a squared
676
+ distance as well.
677
+ }
674
678
\item [knn]{Number of nearest neighbors to search for.}
675
679
\item [params]{Search parameters.} Structure containing parameters used during search.
676
680
@@ -679,16 +683,16 @@ \subsubsection{flann::Index::knnSearch}
679
683
struct SearchParams
680
684
{
681
685
SearchParams(int checks = 32,
682
- float eps = 0,
683
- bool sorted = true);
684
-
685
- int checks;
686
- float eps;
687
- bool sorted;
688
- int max_neighbors;
689
- tri_type use_heap;
690
- int cores;
691
- bool matrices_in_gpu_ram;
686
+ float eps = 0,
687
+ bool sorted = true);
688
+
689
+ int checks;
690
+ float eps;
691
+ bool sorted;
692
+ int max_neighbors;
693
+ tri_type use_heap;
694
+ int cores;
695
+ bool matrices_in_gpu_ram;
692
696
};
693
697
\end {Verbatim }
694
698
\begin {description }
@@ -737,9 +741,15 @@ \subsubsection{flann::Index::radiusSearch}
737
741
will be resized as needed to fit all the neighbors to be returned, except if the `` max\_ neighbors'' search parameter is
738
742
set.}
739
743
\item [dists]{Matrix that will contain the distances to the K-nearest neighbors found. The same number of values are
740
- returned here as for the \texttt {indices } matrix.}
741
- \item [radius]{The search radius}
742
- \item [params]{Search parameters}
744
+ returned here as for the \texttt {indices } matrix. \\
745
+ \emph {Note: } For Euclidean distances, the
746
+ \texttt {flann::L2 } functor computes squared distances, so the value passed here needs to
747
+ be a squared distance as well.}
748
+ \item [radius]{The search radius. \\
749
+ \emph {Note: } For Euclidean distances, the \texttt {flann::L2 } functor computes squared distances,
750
+ so the value passed here needs to be a squared
751
+ distance as well.}
752
+ \item [params]{Search parameters.}
743
753
\end {description }
744
754
The method returns the number of nearest neighbors found.
745
755
@@ -759,10 +769,10 @@ \subsubsection{flann::hierarchicalClustering}
759
769
760
770
\begin {Verbatim }[fontsize=\footnotesize,frame=single]
761
771
template <typename Distance>
762
- int hierarchicalClustering(const Matrix<typename Distance::ElementType>& features ,
763
- Matrix<typename Distance::ResultType>& centers,
764
- const KMeansIndexParams& params,
765
- Distance d = Distance())
772
+ int hierarchicalClustering(const Matrix<typename Distance::ElementType>& points ,
773
+ Matrix<typename Distance::ResultType>& centers,
774
+ const KMeansIndexParams& params,
775
+ Distance d = Distance())
766
776
\end {Verbatim }
767
777
\begin {description }
768
778
\item [features]{The points to be clustered}
@@ -815,7 +825,7 @@ \subsubsection{flann::KdTreeCuda3dIndex}
815
825
\begin {description }
816
826
\item First, a GPU buffer of float4 values is created and filled with points. \footnote {For index creation, only \texttt {float4 } points are supported, \texttt {float3 } or structure-of-array (SOA) representations are currently not supported since
817
827
\texttt {float4 } proved to be best in terms of access speed for tree creation and search.}
818
- \item Then, a GPU pointer to the buffer is stored in a flann matrix with 3 columns and a stride of 4 (since the last element in the \texttt {float4 } is unused ).
828
+ \item Then, a GPU pointer to the buffer is stored in a flann matrix with 3 columns and a stride of 4 (the last element in the \texttt {float4 } should be zero ).
819
829
\item Last, the index is created. The \texttt {input\_ is\_ gpu\_ float4 } flag tells the index to treat the matrix as a gpu buffer.
820
830
\end {description }
821
831
@@ -892,52 +902,66 @@ \subsubsection{flann\_build\_index()}
892
902
\item [flann\_ params] - is a structure containing the parameters passed to
893
903
the function. This structure is defined as follows:
894
904
\begin {Verbatim }[fontsize=\footnotesize]
895
- struct FLANNParameters {
896
- enum flann_algorithm_t algorithm; /* the algorithm to use */
897
-
898
- /* search parameters */
899
- int checks; /* how many leafs (features) to check in one search */
900
- float cb_index; /* cluster boundary index. Used when searching the
901
- kmeans tree */
902
-
903
- /* kdtree index parameters */
904
- int trees; /* number of randomized trees to use (for kdtree) */
905
-
906
- /* kmeans index parameters */
907
- int branching; /* branching factor (for kmeans tree) */
908
- int iterations; /* max iterations to perform in one kmeans cluetering
909
- (kmeans tree) */
910
- enum flann_centers_init_t centers_init; /* algorithm used for picking the initial
911
- cluster centers for kmeans tree */
912
-
913
- /* autotuned index parameters */
914
- float target_precision; /* precision desired (used for autotuning, -1 otherwise) */
915
- float build_weight; /* build tree time weighting factor */
916
- float memory_weight; /* index memory weigthing factor */
917
- float sample_fraction; /* what fraction of the dataset to use for autotuning */
918
-
919
- /* LSH parameters */
920
- unsigned int table_number_; /** The number of hash tables to use */
921
- unsigned int key_size_; /** The length of the key in the hash tables */
922
- unsigned int multi_probe_level_; /** Number of levels to use in multi-probe LSH, 0 for standard LSH */
923
-
924
- /* other parameters */
925
- enum flann_log_level_t log_level; /* determines the verbosity of each flann function */
926
- long random_seed; /* random seed to use */
905
+ struct FLANNParameters
906
+ {
907
+ enum flann_algorithm_t algorithm; /* the algorithm to use */
908
+
909
+ /* search time parameters */
910
+ int checks; /* how many leafs (features) to check in one search */
911
+ float eps; /* eps parameter for eps-knn search */
912
+ int sorted; /* indicates if results returned by radius search should be
913
+ sorted or not */
914
+ int max_neighbors; /* limits the maximum number of neighbors should be
915
+ returned by radius search */
916
+ int cores; /* number of paralel cores to use for searching */
917
+
918
+ /* kdtree index parameters */
919
+ int trees; /* number of randomized trees to use (for kdtree) */
920
+ int leaf_max_size;
921
+
922
+ /* kmeans index parameters */
923
+ int branching; /* branching factor (for kmeans tree) */
924
+ int iterations; /* max iterations to perform in one kmeans cluetering
925
+ (kmeans tree) */
926
+ enum flann_centers_init_t centers_init; /* algorithm used for picking the
927
+ initial cluster centers for kmeans tree */
928
+ float cb_index; /* cluster boundary index. Used when searching the kmeans
929
+ tree */
930
+
931
+ /* autotuned index parameters */
932
+ float target_precision; /* precision desired (used for autotuning, -1
933
+ otherwise) */
934
+ float build_weight; /* build tree time weighting factor */
935
+ float memory_weight; /* index memory weigthing factor */
936
+ float sample_fraction; /* what fraction of the dataset to use for autotuning */
937
+ /* LSH parameters */
938
+ unsigned int table_number_; /** The number of hash tables to use */
939
+ unsigned int key_size_; /** The length of the key in the hash tables */
940
+ unsigned int multi_probe_level_; /** Number of levels to use in multi-probe
941
+ LSH, 0 for standard LSH */
942
+
943
+ /* other parameters */
944
+ enum flann_log_level_t log_level; /* determines the verbosity of each flann
945
+ function */
946
+ long random_seed; /* random seed to use */
927
947
};
928
948
\end {Verbatim }
929
949
930
950
The \texttt {algorithm } and \texttt {centers\_ init } fields can take the
931
951
following values:
932
952
\begin {Verbatim }[fontsize=\footnotesize]
933
- enum flann_algorithm_t {
953
+ enum flann_algorithm_t
954
+ {
934
955
FLANN_INDEX_LINEAR = 0,
935
956
FLANN_INDEX_KDTREE = 1,
936
957
FLANN_INDEX_KMEANS = 2,
937
958
FLANN_INDEX_COMPOSITE = 3,
938
- FLANN_INDEX_KDTREE_SINGLE = 3,
959
+ FLANN_INDEX_KDTREE_SINGLE = 4,
960
+ FLANN_INDEX_HIERARCHICAL = 5,
961
+ FLANN_INDEX_LSH = 6,
962
+ FLANN_INDEX_KDTREE_CUDA = 7, // available if compiled with CUDA
939
963
FLANN_INDEX_SAVED = 254,
940
- FLANN_INDEX_AUTOTUNED = 255
964
+ FLANN_INDEX_AUTOTUNED = 255,
941
965
};
942
966
943
967
enum flann_centers_init_t {
@@ -966,20 +990,22 @@ \subsubsection{flann\_build\_index()}
966
990
The field \texttt {log\_ level } controls the verbosity of the messages generated by the FLANN
967
991
library functions. It can take the following values:
968
992
\begin {Verbatim }[fontsize=\footnotesize]
969
- enum flann_log_level_t {
970
- FLANN_LOG_NONE = 0,
971
- FLANN_LOG_FATAL = 1,
972
- FLANN_LOG_ERROR = 2,
973
- FLANN_LOG_WARN = 3,
974
- FLANN_LOG_INFO = 4
993
+ enum flann_log_level_t
994
+ {
995
+ FLANN_LOG_NONE = 0,
996
+ FLANN_LOG_FATAL = 1,
997
+ FLANN_LOG_ERROR = 2,
998
+ FLANN_LOG_WARN = 3,
999
+ FLANN_LOG_INFO = 4,
1000
+ FLANN_LOG_DEBUG = 5
975
1001
};
976
1002
\end {Verbatim }
977
1003
\end {description }
978
1004
979
1005
980
1006
\subsubsection {flann\_ find\_ nearest\_ neighbors\_ index() }
981
1007
\begin {Verbatim }[fontsize=\footnotesize,frame=single]
982
- int flann_find_nearest_neighbors_index(FLANN_INDEX index_id,
1008
+ int flann_find_nearest_neighbors_index(flann_index_t index_id,
983
1009
float* testset,
984
1010
int trows,
985
1011
int* indices,
@@ -1023,15 +1049,13 @@ \subsubsection{flann\_find\_nearest\_neighbors()}
1023
1049
\subsubsection {flann\_ radius\_ search() }
1024
1050
1025
1051
\begin {Verbatim }[fontsize=\footnotesize,frame=single]
1026
- int flann_radius_search(FLANN_INDEX index_ptr,
1027
- float* query, /* query point */
1028
- int* indices, /* array for storing the indices */
1052
+ int flann_radius_search(flann_index_t index_ptr, /* the index */
1053
+ float* query, /* query point */
1054
+ int* indices, /* array for storing the indices found (will be modified) */
1029
1055
float* dists, /* similar, but for storing distances */
1030
1056
int max_nn, /* size of arrays indices and dists */
1031
1057
float radius, /* search radius (squared radius for euclidian metric) */
1032
- int checks, /* number of features to check, sets the level
1033
- of approximation */
1034
- FLANNParameters* flann_params);
1058
+ struct FLANNParameters* flann_params);
1035
1059
\end {Verbatim }
1036
1060
1037
1061
This function performs a radius search to single query point. The indices of the neighbors found and
@@ -1061,7 +1085,7 @@ \subsubsection{flann\_load\_index()}
1061
1085
1062
1086
\subsubsection {flann\_ free\_ index() }
1063
1087
\begin {Verbatim }[fontsize=\footnotesize,frame=single]
1064
- int flann_free_index(FLANN_INDEX index_id,
1088
+ int flann_free_index(flann_index_t index_id,
1065
1089
struct FLANNParameters* flann_params);
1066
1090
\end {Verbatim }
1067
1091
This function deletes a previously constructed index and frees all the memory
@@ -1077,14 +1101,22 @@ \subsubsection{flann\_set\_distance\_type}
1077
1101
\begin {description }
1078
1102
\item [distance\_ type] The distance type to use. Possible values are
1079
1103
\begin {Verbatim }[fontsize=\footnotesize]
1080
- enum flann_distance_t {
1081
- FLANN_DIST_EUCLIDEAN = 1, // squared euclidean distance
1104
+ enum flann_distance_t
1105
+ {
1106
+ FLANN_DIST_EUCLIDEAN = 1,
1107
+ FLANN_DIST_L2 = 1,
1082
1108
FLANN_DIST_MANHATTAN = 2,
1109
+ FLANN_DIST_L1 = 2,
1083
1110
FLANN_DIST_MINKOWSKI = 3,
1084
- FLANN_DIST_HIST_INTERSECT = 5,
1085
- FlANN_DIST_HELLINGER = 6,
1086
- FLANN_DIST_CHI_SQUARE = 7, // chi-square
1087
- FLANN_DIST_KULLBACK_LEIBLER = 8, // kullback-leibler divergence
1111
+ FLANN_DIST_MAX = 4,
1112
+ FLANN_DIST_HIST_INTERSECT = 5,
1113
+ FLANN_DIST_HELLINGER = 6,
1114
+ FLANN_DIST_CHI_SQUARE = 7,
1115
+ FLANN_DIST_KULLBACK_LEIBLER = 8,
1116
+ FLANN_DIST_HAMMING = 9,
1117
+ FLANN_DIST_HAMMING_LUT = 10,
1118
+ FLANN_DIST_HAMMING_POPCNT = 11,
1119
+ FLANN_DIST_L2_SIMPLE = 12,
1088
1120
};
1089
1121
\end {Verbatim }
1090
1122
\item [order] Used in for the \texttt {FLANN\_ DIST\_ MINKOWSKI } distance type, to choose the order of the Minkowski distance.
0 commit comments