提交 f5fa05cc 编写于 作者: M Marius Muja

Merge branch 'master' of ubc:lci/fann

Conflicts:
	src/cpp/flann/algorithms/kdtree_index.h
......@@ -8,7 +8,7 @@ project(flann)
string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER)
include(${PROJECT_SOURCE_DIR}/cmake/flann_utils.cmake)
set(FLANN_VERSION 1.6.6)
set(FLANN_VERSION 1.6.7)
DISSECT_VERSION()
GET_OS_INFO()
......
VER=1.6.6
VER=1.6.7
dist-src:
......
......@@ -91,7 +91,7 @@ int main(int argc, char** argv)
p = DEFAULT_FLANN_PARAMETERS;
p.algorithm = KDTREE;
p.trees = 8;
p.log_level = LOG_INFO;
p.log_level = FLANN_LOG_INFO;
p.checks = 64;
printf("Computing index.\n");
......
......@@ -16,6 +16,7 @@ set_target_properties(flann_cpp_s PROPERTIES COMPILE_FLAGS -fPIC)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_COMPILER_IS_GNUCC)
add_library(flann_cpp SHARED "")
set_target_properties(flann_cpp PROPERTIES LINKER_LANGUAGE CXX)
target_link_libraries(flann_cpp -Wl,-whole-archive flann_cpp_s -Wl,-no-whole-archive)
else()
add_library(flann_cpp SHARED ${CPP_SOURCES})
......@@ -32,6 +33,7 @@ if (BUILD_C_BINDINGS)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_COMPILER_IS_GNUCC)
add_library(flann SHARED "")
set_target_properties(flann PROPERTIES LINKER_LANGUAGE CXX)
target_link_libraries(flann -Wl,-whole-archive flann_s -Wl,-no-whole-archive)
else()
add_library(flann SHARED ${C_SOURCES})
......
......@@ -144,7 +144,7 @@ class AutotunedIndex : public NNIndex<Distance>
/**
* Index parameters
*/
const AutotunedIndexParams& index_params;
const AutotunedIndexParams index_params;
Distance distance;
public:
......@@ -161,9 +161,11 @@ public:
{
if (bestIndex!=NULL) {
delete bestIndex;
bestIndex = NULL;
}
if (bestParams!=NULL) {
delete bestParams;
bestParams = NULL;
}
};
......
......@@ -102,7 +102,7 @@ class CompositeIndex : public NNIndex<Distance>
const Matrix<ElementType> dataset;
const IndexParams& index_params;
const CompositeIndexParams index_params;
Distance distance;
......
......@@ -123,7 +123,7 @@ class KDTreeIndex : public NNIndex<Distance>
*/
const Matrix<ElementType> dataset;
const IndexParams& index_params;
const KDTreeIndexParams index_params;
size_t size_;
size_t veclen_;
......@@ -421,7 +421,7 @@ private:
/* If either list is empty, it means that all remaining features
* are identical. Split in the middle to maintain a balanced tree.
*/
if (lim1==cnt || lim2==0) index = count/2;
if (lim1==count || lim2==0) index = count/2;
}
......
......@@ -102,7 +102,7 @@ class KDTreeSingleIndex : public NNIndex<Distance>
*/
const Matrix<ElementType> dataset;
const IndexParams& index_params;
const KDTreeSingleIndexParams index_params;
size_t size_;
size_t veclen_;
......
......@@ -134,7 +134,7 @@ class KMeansIndex : public NNIndex<Distance>
*/
const Matrix<ElementType> dataset;
const IndexParams& index_params;
const KMeansIndexParams index_params;
/**
* Number of features in the dataset.
......
......@@ -66,7 +66,7 @@ class LinearIndex
typedef typename Distance::ResultType DistanceType;
const Matrix<ElementType> dataset;
const LinearIndexParams& index_params;
const LinearIndexParams index_params;
Distance distance;
......
......@@ -44,7 +44,7 @@ EXPORTED struct FLANNParameters DEFAULT_FLANN_PARAMETERS = {
4, 4,
32, 11, CENTERS_RANDOM,
0.9, 0.01, 0, 0.1,
LOG_NONE, 0
FLANN_LOG_NONE, 0
};
......@@ -100,6 +100,7 @@ flann_index_t __flann_build_index(typename Distance::ElementType* dataset, int r
*speedup = autotuned_index->getSpeedup();
}
delete params;
return index;
}
catch (std::runtime_error& e) {
......@@ -620,9 +621,7 @@ int __flann_free_index(flann_index_t index_ptr, FLANNParameters* flann_params)
throw FLANNException("Invalid index");
}
Index<Distance>* index = (Index<Distance>*) index_ptr;
const IndexParams* index_params = index->getIndexParameters();
delete index;
delete index_params;
return 0;
}
......
......@@ -53,11 +53,11 @@ enum flann_centers_init_t {
};
enum flann_log_level_t {
LOG_NONE = 0,
LOG_FATAL = 1,
LOG_ERROR = 2,
LOG_WARN = 3,
LOG_INFO = 4
FLANN_LOG_NONE = 0,
FLANN_LOG_FATAL = 1,
FLANN_LOG_ERROR = 2,
FLANN_LOG_WARN = 3,
FLANN_LOG_INFO = 4
};
enum flann_distance_t {
......
......@@ -43,17 +43,18 @@ void find_nearest(const Matrix<typename Distance::ElementType>& dataset, typenam
int skip = 0, Distance distance = Distance())
{
typedef typename Distance::ElementType ElementType;
typedef typename Distance::ResultType DistanceType;
int n = nn + skip;
int* match = new int[n];
ElementType* dists = new ElementType[n];
DistanceType* dists = new DistanceType[n];
dists[0] = distance(dataset[0], query, dataset.cols);
match[0] = 0;
int dcnt = 1;
for (size_t i=1;i<dataset.rows;++i) {
ElementType tmp = distance(dataset[i], query, dataset.cols);
DistanceType tmp = distance(dataset[i], query, dataset.cols);
if (dcnt<n) {
match[dcnt] = i;
......
......@@ -76,9 +76,9 @@ int Logger::log(int level, const char* fmt, va_list arglist)
}
LOG_METHOD(fatal, LOG_FATAL)
LOG_METHOD(error, LOG_ERROR)
LOG_METHOD(warn, LOG_WARN)
LOG_METHOD(info, LOG_INFO)
LOG_METHOD(fatal, FLANN_LOG_FATAL)
LOG_METHOD(error, FLANN_LOG_ERROR)
LOG_METHOD(warn, FLANN_LOG_WARN)
LOG_METHOD(info, FLANN_LOG_INFO)
}
......@@ -45,7 +45,7 @@ class Logger
public:
Logger() : stream(stdout), logLevel(LOG_WARN) {};
Logger() : stream(stdout), logLevel(FLANN_LOG_WARN) {};
~Logger()
{
......
......@@ -309,7 +309,7 @@ TEST_F(Flann_SIFT100K_Test, KMeansTreeTest)
TEST_F(Flann_SIFT100K_Test, AutotunedTest)
{
flann::log_verbosity(LOG_INFO);
flann::log_verbosity(FLANN_LOG_INFO);
Index<L2<float> > index(data, flann::AutotunedIndexParams(0.8,0.01,0,0.1)); // 80% precision
start_timer("Building autotuned index...");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册