Skip to content

Commit bc99fa6

Browse files
committed
Merge branch 'master' of github.com:mariusmuja/flann
2 parents 77a03e6 + 5590307 commit bc99fa6

25 files changed

+269
-167
lines changed

CMakeLists.txt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ set(FLANN_VERSION 1.8.4)
1212
DISSECT_VERSION()
1313
GET_OS_INFO()
1414

15-
# CMAKE_C_COMPILER_ID and CMAKE_CXX_COMPILER_ID are documented as internal variables subject to
16-
# change at: http://www.cmake.org/cmake/help/v2.8.8/cmake.html#variable:CMAKE_LANG_COMPILER_ID
17-
# however currently this seems the most robust way to detect the presence of the Clang compiler
15+
16+
# detect if using the Clang compiler
1817
if("${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
1918
set(CMAKE_COMPILER_IS_CLANG 1)
2019
endif ()
@@ -54,6 +53,7 @@ option(BUILD_C_BINDINGS "Build C bindings" ON)
5453
option(BUILD_PYTHON_BINDINGS "Build Python bindings" ON)
5554
option(BUILD_MATLAB_BINDINGS "Build Matlab bindings" ON)
5655
option(BUILD_CUDA_LIB "Build CUDA library" OFF)
56+
option(BUILD_EXAMPLES "Build examples" ON)
5757
option(USE_OPENMP "Use OpenMP multi-threading" ON)
5858
option(USE_MPI "Use MPI" OFF)
5959

@@ -146,16 +146,18 @@ include_directories(BEFORE ${PROJECT_SOURCE_DIR}/src/cpp)
146146
# require proper c++
147147
#add_definitions( "-Wall -ansi -pedantic" )
148148
# HDF5 uses long long which is not ansi
149-
if (MSVC)
149+
if("${CMAKE_C_COMPILER_ID}" MATCHES "MSVC" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC")
150150
# lots of warnings with cl.exe right now, use /W1
151151
add_definitions("/W1 -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS /bigobj")
152-
else(MSVC)
152+
else()
153153
add_definitions( "-Wall -Wno-unknown-pragmas -Wno-unused-function" )
154-
endif(MSVC)
154+
endif()
155155

156156
add_subdirectory( cmake )
157157
add_subdirectory( src )
158-
add_subdirectory( examples )
158+
if (BUILD_EXAMPLES)
159+
add_subdirectory( examples )
160+
endif(BUILD_EXAMPLES)
159161
add_subdirectory( test )
160162
add_subdirectory( doc )
161163

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ FLANN is written in C++ and contains bindings for the following languages: C, MA
88
Documentation
99
-------------
1010

11-
Check FLANN web page [here](http://www.cs.ubc.ca/~mariusm/flann).
11+
Check FLANN web page [here](http://www.cs.ubc.ca/research/flann).
1212

1313
Documentation on how to use the library can be found in the doc/manual.pdf file included in the release archives.
1414

cmake/flann.pc.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ Name: @PROJECT_NAME@
88
Description: @PKG_DESC@
99
Version: @FLANN_VERSION@
1010
Requires: @PKG_EXTERNAL_DEPS@
11-
Libs: -L${libdir} -lflann_cpp
11+
Libs: -L${libdir} -lflann -lflann_cpp
1212
Cflags: -I${includedir}
1313

doc/manual.pdf

530 Bytes
Binary file not shown.

doc/manual.tex

Lines changed: 106 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,11 @@ \subsubsection{flann::Index::knnSearch}
670670
\item[indices]{Matrix that will contain the indices of the K-nearest neighbors found (size should be at least
671671
$num\_queries \times knn$ for the pre-allocated version).}
672672
\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+
}
674678
\item[knn]{Number of nearest neighbors to search for.}
675679
\item[params]{Search parameters.} Structure containing parameters used during search.
676680

@@ -679,16 +683,16 @@ \subsubsection{flann::Index::knnSearch}
679683
struct SearchParams
680684
{
681685
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;
692696
};
693697
\end{Verbatim}
694698
\begin{description}
@@ -737,9 +741,15 @@ \subsubsection{flann::Index::radiusSearch}
737741
will be resized as needed to fit all the neighbors to be returned, except if the ``max\_neighbors'' search parameter is
738742
set.}
739743
\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.}
743753
\end{description}
744754
The method returns the number of nearest neighbors found.
745755

@@ -759,10 +769,10 @@ \subsubsection{flann::hierarchicalClustering}
759769

760770
\begin{Verbatim}[fontsize=\footnotesize,frame=single]
761771
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())
766776
\end{Verbatim}
767777
\begin{description}
768778
\item[features]{The points to be clustered}
@@ -815,7 +825,7 @@ \subsubsection{flann::KdTreeCuda3dIndex}
815825
\begin{description}
816826
\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
817827
\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).
819829
\item Last, the index is created. The \texttt{input\_is\_gpu\_float4} flag tells the index to treat the matrix as a gpu buffer.
820830
\end{description}
821831

@@ -892,52 +902,66 @@ \subsubsection{flann\_build\_index()}
892902
\item [flann\_params] - is a structure containing the parameters passed to
893903
the function. This structure is defined as follows:
894904
\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 */
927947
};
928948
\end{Verbatim}
929949

930950
The \texttt{algorithm} and \texttt{centers\_init} fields can take the
931951
following values:
932952
\begin{Verbatim}[fontsize=\footnotesize]
933-
enum flann_algorithm_t {
953+
enum flann_algorithm_t
954+
{
934955
FLANN_INDEX_LINEAR = 0,
935956
FLANN_INDEX_KDTREE = 1,
936957
FLANN_INDEX_KMEANS = 2,
937958
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
939963
FLANN_INDEX_SAVED = 254,
940-
FLANN_INDEX_AUTOTUNED = 255
964+
FLANN_INDEX_AUTOTUNED = 255,
941965
};
942966
943967
enum flann_centers_init_t {
@@ -966,20 +990,22 @@ \subsubsection{flann\_build\_index()}
966990
The field \texttt{log\_level} controls the verbosity of the messages generated by the FLANN
967991
library functions. It can take the following values:
968992
\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
9751001
};
9761002
\end{Verbatim}
9771003
\end{description}
9781004

9791005

9801006
\subsubsection{flann\_find\_nearest\_neighbors\_index()}
9811007
\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,
9831009
float* testset,
9841010
int trows,
9851011
int* indices,
@@ -1023,15 +1049,13 @@ \subsubsection{flann\_find\_nearest\_neighbors()}
10231049
\subsubsection{flann\_radius\_search()}
10241050

10251051
\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) */
10291055
float* dists, /* similar, but for storing distances */
10301056
int max_nn, /* size of arrays indices and dists */
10311057
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);
10351059
\end{Verbatim}
10361060

10371061
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()}
10611085

10621086
\subsubsection{flann\_free\_index()}
10631087
\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,
10651089
struct FLANNParameters* flann_params);
10661090
\end{Verbatim}
10671091
This function deletes a previously constructed index and frees all the memory
@@ -1077,14 +1101,22 @@ \subsubsection{flann\_set\_distance\_type}
10771101
\begin{description}
10781102
\item[distance\_type] The distance type to use. Possible values are
10791103
\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,
10821108
FLANN_DIST_MANHATTAN = 2,
1109+
FLANN_DIST_L1 = 2,
10831110
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,
10881120
};
10891121
\end{Verbatim}
10901122
\item[order] Used in for the \texttt{FLANN\_DIST\_MINKOWSKI} distance type, to choose the order of the Minkowski distance.

src/cpp/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ if (BUILD_C_BINDINGS)
8888
target_link_libraries(flann -Wl,-whole-archive flann_s -Wl,-no-whole-archive)
8989
else()
9090
add_library(flann SHARED ${C_SOURCES})
91+
92+
if(MINGW)
93+
target_link_libraries(flann -lgomp)
94+
endif(MINGW)
9195
endif()
9296

9397
set_target_properties(flann PROPERTIES

0 commit comments

Comments
 (0)