├── docs ├── sff-main.png └── sff-expansion.png ├── lib ├── ann │ ├── ann │ │ ├── doc │ │ │ └── ANNmanual.pdf │ │ ├── sample │ │ │ ├── query.pts │ │ │ ├── data.pts │ │ │ ├── sample.save │ │ │ └── Makefile │ │ ├── test │ │ │ ├── test1-query.pts │ │ │ ├── test1.in │ │ │ ├── test1-data.pts │ │ │ ├── test2.in │ │ │ ├── test1.save │ │ │ └── Makefile │ │ ├── Copyright.txt │ │ ├── src │ │ │ ├── kd_fix_rad_search.h │ │ │ ├── kd_search.h │ │ │ ├── kd_pr_search.h │ │ │ ├── bd_search.cpp │ │ │ ├── bd_fix_rad_search.cpp │ │ │ ├── bd_pr_search.cpp │ │ │ ├── kd_split.h │ │ │ └── Makefile │ │ ├── MS_Win32 │ │ │ ├── Makefile │ │ │ └── Ann.sln │ │ ├── ReadMe.txt │ │ └── ann2fig │ │ │ └── Makefile │ ├── Makefile │ └── main.cc ├── flann │ ├── bin │ │ ├── indent.sh │ │ ├── make_release.sh │ │ ├── run_test.py │ │ ├── download_checkmd5.py │ │ └── uncrustify.cfg │ ├── doc │ │ ├── images │ │ │ └── cmake-gui.png │ │ └── CMakeLists.txt │ ├── cmake │ │ ├── Config.cmake.in │ │ ├── CMakeLists.txt │ │ ├── flann.pc.in │ │ ├── uninstall_target.cmake.in │ │ └── FindFlann.cmake │ ├── src │ │ ├── CMakeLists.txt │ │ ├── ruby │ │ │ ├── Manifest.txt │ │ │ ├── LICENSE.txt │ │ │ ├── Gemfile │ │ │ ├── lib │ │ │ │ └── flann │ │ │ │ │ └── version.rb │ │ │ ├── spec │ │ │ │ ├── spec_helper.rb │ │ │ │ └── flann_spec.rb │ │ │ ├── flann.gemspec │ │ │ └── Rakefile │ │ ├── python │ │ │ ├── CMakeLists.txt │ │ │ ├── setup.py.tpl │ │ │ └── pyflann │ │ │ │ ├── __init__.py │ │ │ │ └── exceptions.py │ │ ├── cpp │ │ │ └── flann │ │ │ │ ├── mpi │ │ │ │ ├── flann_mpi_server.cpp │ │ │ │ ├── flann_mpi_client.cpp │ │ │ │ ├── matrix.h │ │ │ │ ├── client.h │ │ │ │ └── queries.h │ │ │ │ ├── flann_cpp.cpp │ │ │ │ ├── config.h │ │ │ │ ├── config.h.in │ │ │ │ ├── util │ │ │ │ ├── timer.h │ │ │ │ ├── sampling.h │ │ │ │ └── object_factory.h │ │ │ │ └── nn │ │ │ │ └── ground_truth.h │ │ └── matlab │ │ │ ├── flann_save_index.m │ │ │ ├── flann_load_index.m │ │ │ ├── flann_free_index.m │ │ │ ├── flann_set_distance_type.m │ │ │ ├── flann_build_index.m │ │ │ ├── CMakeLists.txt │ │ │ └── flann_search.m │ ├── examples │ │ ├── README │ │ ├── flann_example.cpp │ │ ├── CMakeLists.txt │ │ ├── flann_example.c │ │ └── flann_example_mpi.cpp │ ├── ChangeLog │ ├── COPYING │ ├── README.md │ └── test │ │ ├── memusage_clustering.py │ │ ├── memusage_nn.py │ │ ├── test_nn_index.py │ │ ├── test_nn_autotune.py │ │ ├── flann_linear_test.cpp │ │ ├── test_clustering.py │ │ ├── CMakeLists.txt │ │ ├── test_index_save.py │ │ ├── flann_lsh_test.cpp │ │ ├── flann_hierarchical_test.cpp │ │ └── flann_kdtree_test.cpp ├── rapid-2.01 │ └── README.md └── rapidxml │ ├── license.txt │ └── rapidxml_utils.hpp ├── models ├── 3D │ ├── README │ ├── robot_cylinder.obj │ └── robot_cylinder_small.obj ├── robot_small.mtl └── robot_small.obj ├── .gitignore ├── src ├── main.h └── dijkstra.h ├── test_2D.xml ├── test_triang.xml ├── test_building.xml ├── LICENSE ├── makefile └── maps └── var_density.tri /docs/sff-main.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ctu-mrs/space_filling_forest_star/HEAD/docs/sff-main.png -------------------------------------------------------------------------------- /docs/sff-expansion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ctu-mrs/space_filling_forest_star/HEAD/docs/sff-expansion.png -------------------------------------------------------------------------------- /lib/ann/ann/doc/ANNmanual.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ctu-mrs/space_filling_forest_star/HEAD/lib/ann/ann/doc/ANNmanual.pdf -------------------------------------------------------------------------------- /lib/flann/bin/indent.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | DIR=`dirname $0` 4 | uncrustify --no-backup -c ${DIR}/uncrustify.cfg $1 5 | 6 | -------------------------------------------------------------------------------- /lib/flann/doc/images/cmake-gui.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ctu-mrs/space_filling_forest_star/HEAD/lib/flann/doc/images/cmake-gui.png -------------------------------------------------------------------------------- /models/3D/README: -------------------------------------------------------------------------------- 1 | Forward: -Y 2 | Up: Z 3 | 4 | robot: polomer 1, vyska 1 5 | robot_small: polomer 0.3, vyska 0.3 6 | building: 4x4x12 7 | -------------------------------------------------------------------------------- /lib/flann/cmake/Config.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | 3 | include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake") 4 | check_required_components("flann") 5 | 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | output 2 | debug 3 | release 4 | obj 5 | .vscode 6 | lib/* 7 | scripts/* 8 | tempTsp.result 9 | output.log 10 | tempTsp.tsp 11 | results/* 12 | tests_2.zip 13 | -------------------------------------------------------------------------------- /lib/flann/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | add_subdirectory( cpp ) 3 | 4 | if (BUILD_MATLAB_BINDINGS) 5 | add_subdirectory( matlab ) 6 | endif() 7 | 8 | if (BUILD_PYTHON_BINDINGS) 9 | add_subdirectory( python ) 10 | endif() 11 | -------------------------------------------------------------------------------- /lib/ann/ann/sample/query.pts: -------------------------------------------------------------------------------- 1 | 0.0902484 -0.207129 2 | -0.419567 0.485743 3 | 0.826225 -0.30962 4 | 0.694758 0.987088 5 | -0.410807 -0.465182 6 | -0.836501 0.490184 7 | 0.588289 0.656408 8 | 0.325807 0.38721 9 | -0.532226 -0.727036 10 | -0.52506 -0.853508 11 | -------------------------------------------------------------------------------- /lib/flann/src/ruby/Manifest.txt: -------------------------------------------------------------------------------- 1 | Rakefile 2 | Gemfile 3 | LICENSE.txt 4 | Manifest.txt 5 | flann.gemspec 6 | lib/flann.rb 7 | lib/index.rb 8 | lib/flann/index.rb 9 | lib/flann/version.rb 10 | spec/spec_helper.rb 11 | spec/flann_spec.rb 12 | spec/index_spec.rb -------------------------------------------------------------------------------- /lib/ann/ann/test/test1-query.pts: -------------------------------------------------------------------------------- 1 | 0.0902484 -0.207129 2 | -0.419567 0.485743 3 | 0.826225 -0.30962 4 | 0.694758 0.987088 5 | -0.410807 -0.465182 6 | -0.836501 0.490184 7 | 0.588289 0.656408 8 | 0.325807 0.38721 9 | -0.532226 -0.727036 10 | -0.52506 -0.853508 11 | -------------------------------------------------------------------------------- /lib/rapid-2.01/README.md: -------------------------------------------------------------------------------- 1 | # RAPID dependency # 2 | Although the RAPID library is not included due to its different terms and conditions, it is essential for this project. The library is free to use for non-commercial projects and can be requested at http://gamma.cs.unc.edu/OBB/. -------------------------------------------------------------------------------- /lib/flann/bin/make_release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | VERSION=`grep "set(FLANN_VERSION" CMakeLists.txt | sed 's/[^0-9]*\([0-9]*\.[0-9]*\.[0-9]*\)[^0-9]*/\1/'` 3 | 4 | echo "Creating flann-$VERSION-src.zip" 5 | 6 | git archive --prefix=flann-$VERSION-src/ -o flann-$VERSION-src.zip $VERSION-src 7 | -------------------------------------------------------------------------------- /models/robot_small.mtl: -------------------------------------------------------------------------------- 1 | # Blender MTL File: 'robot.blend' 2 | # Material Count: 1 3 | 4 | newmtl Default_OBJ.001 5 | Ns 225.000000 6 | Ka 1.000000 1.000000 1.000000 7 | Kd 0.800000 0.800000 0.800000 8 | Ks 0.500000 0.500000 0.500000 9 | Ke 0.000000 0.000000 0.000000 10 | Ni 1.450000 11 | d 1.000000 12 | illum 2 13 | -------------------------------------------------------------------------------- /lib/flann/cmake/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(PKG_DESC "Fast Library for Approximate Nearest Neighbors") 2 | set(pkg_conf_file ${CMAKE_CURRENT_BINARY_DIR}/flann.pc) 3 | configure_file(flann.pc.in ${pkg_conf_file} @ONLY) 4 | install(FILES ${pkg_conf_file} 5 | DESTINATION ${FLANN_LIB_INSTALL_DIR}/pkgconfig/ COMPONENT pkgconfig) 6 | 7 | -------------------------------------------------------------------------------- /lib/ann/ann/test/test1.in: -------------------------------------------------------------------------------- 1 | validate on 2 | stats query_stats 3 | dim 2 4 | data_size 20 5 | query_size 10 6 | read_data_pts test1-data.pts 7 | read_query_pts test1-query.pts 8 | bucket_size 1 9 | near_neigh 3 10 | split_rule suggest 11 | shrink_rule none 12 | build_ann 13 | epsilon 0.0 14 | run_queries standard 15 | run_queries priority 16 | -------------------------------------------------------------------------------- /lib/flann/examples/README: -------------------------------------------------------------------------------- 1 | 2 | These examples use some datasets that are not included in the source distribution. You can download the datasets from here: 3 | 4 | http://people.cs.ubc.ca/~mariusm/uploads/FLANN/datasets/dataset.hdf5 5 | http://people.cs.ubc.ca/~mariusm/uploads/FLANN/datasets/dataset.dat 6 | http://people.cs.ubc.ca/~mariusm/uploads/FLANN/datasets/testset.dat 7 | -------------------------------------------------------------------------------- /lib/flann/cmake/flann.pc.in: -------------------------------------------------------------------------------- 1 | # This file was generated by CMake for @PROJECT_NAME@ 2 | prefix=@CMAKE_INSTALL_PREFIX@ 3 | exec_prefix=${prefix} 4 | libdir=${prefix}/@FLANN_LIB_INSTALL_DIR@ 5 | includedir=${prefix}/include 6 | 7 | Name: @PROJECT_NAME@ 8 | Description: @PKG_DESC@ 9 | Version: @FLANN_VERSION@ 10 | Requires: @PKG_EXTERNAL_DEPS@ 11 | Libs: -L${libdir} -lflann -lflann_cpp 12 | Cflags: -I${includedir} 13 | 14 | -------------------------------------------------------------------------------- /lib/flann/bin/run_test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | 3 | 4 | import sys 5 | import os.path as op 6 | import unittest 7 | 8 | if __name__ == "__main__": 9 | if len(sys.argv)==1: 10 | print "Usage: %s file"%sys.argv[0] 11 | sys.exit(1) 12 | 13 | python_path = op.abspath(op.join( op.dirname(__file__),"..","src","python")) 14 | sys.path.append(python_path) 15 | 16 | test_file = sys.argv[1] 17 | sys.argv = sys.argv[1:] 18 | execfile(test_file) 19 | -------------------------------------------------------------------------------- /lib/ann/ann/sample/data.pts: -------------------------------------------------------------------------------- 1 | -0.297462 0.176102 2 | 0.565538 -0.361496 3 | 0.909313 -0.182785 4 | 0.920712 0.478408 5 | 0.167682 0.0499836 6 | 0.305223 -0.0805835 7 | 0.114973 0.882453 8 | 0.742916 0.16376 9 | 0.0724605 -0.826775 10 | 0.690960 -0.559284 11 | 0.188485 -0.643934 12 | 0.749427 -0.942415 13 | -0.970662 -0.223466 14 | 0.916110 0.879597 15 | 0.927417 -0.382593 16 | -0.711327 0.278713 17 | -0.519172 0.986146 18 | 0.135338 0.924588 19 | -0.0837537 0.61687 20 | 0.0520465 0.896306 21 | -------------------------------------------------------------------------------- /lib/ann/ann/test/test1-data.pts: -------------------------------------------------------------------------------- 1 | -0.297462 0.176102 2 | 0.565538 -0.361496 3 | 0.909313 -0.182785 4 | 0.920712 0.478408 5 | 0.167682 0.0499836 6 | 0.305223 -0.0805835 7 | 0.114973 0.882453 8 | 0.742916 0.16376 9 | 0.0724605 -0.826775 10 | 0.690960 -0.559284 11 | 0.188485 -0.643934 12 | 0.749427 -0.942415 13 | -0.970662 -0.223466 14 | 0.916110 0.879597 15 | 0.927417 -0.382593 16 | -0.711327 0.278713 17 | -0.519172 0.986146 18 | 0.135338 0.924588 19 | -0.0837537 0.61687 20 | 0.0520465 0.896306 21 | -------------------------------------------------------------------------------- /lib/ann/ann/test/test2.in: -------------------------------------------------------------------------------- 1 | validate on 2 | stats query_stats 3 | dim 8 4 | data_size 5000 5 | read_data_pts test2-data.pts 6 | query_size 100 7 | read_query_pts test2-query.pts 8 | bucket_size 1 9 | near_neigh 3 10 | split_rule suggest 11 | shrink_rule none 12 | build_ann 13 | epsilon 0.0 14 | run_queries standard 15 | run_queries priority 16 | epsilon 0.10 17 | run_queries standard 18 | run_queries priority 19 | epsilon 0.50 20 | run_queries standard 21 | run_queries priority 22 | -------------------------------------------------------------------------------- /lib/flann/src/python/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | configure_file( setup.py.tpl setup.py ) 2 | 3 | install( DIRECTORY pyflann DESTINATION share/flann/python ) 4 | install( FILES ${CMAKE_CURRENT_BINARY_DIR}/setup.py DESTINATION share/flann/python ) 5 | 6 | 7 | # python instalation 8 | if (PYTHON_EXECUTABLE) 9 | install(CODE "execute_process( 10 | COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/setup.py install 11 | WORKING_DIRECTORY \"${CMAKE_CURRENT_SOURCE_DIR}\")") 12 | endif() 13 | -------------------------------------------------------------------------------- /lib/ann/Makefile: -------------------------------------------------------------------------------- 1 | 2 | CXX=g++ 3 | CXXINCLUDE+=-I/usr/local/include 4 | LDFLAGS+=-L/usr/local/lib -lpthread -lm 5 | TARGET=ann_test 6 | 7 | LDFLAGS+=-Lann/lib -lANN 8 | 9 | SRC=$(wildcard *.cc) 10 | OBJS=$(patsubst %.cc,%.o,$(wildcard *.cc)) 11 | 12 | all: $(OBJS) lib_dir mpnn 13 | $(CXX) $(OBJS) $(LDFLAGS) -o $(TARGET) 14 | 15 | lib_dir: 16 | mkdir -p ann/lib/ 17 | 18 | mpnn: 19 | $(MAKE) -C ann/src linux-g++ 20 | 21 | .cc.o: 22 | $(CXX) $(CXXINCLUDE) -c $< 23 | 24 | 25 | clean: 26 | rm -f $(OBJS) $(TARGET) $(TARGET).core 27 | $(MAKE) -C ann/src clean 28 | 29 | 30 | -------------------------------------------------------------------------------- /lib/flann/src/cpp/flann/mpi/flann_mpi_server.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int main(int argc, char* argv[]) 7 | { 8 | boost::mpi::environment env(argc, argv); 9 | 10 | try { 11 | if (argc != 4) { 12 | std::cout << "Usage: " << argv[0] << " \n"; 13 | return 1; 14 | } 15 | flann::mpi::Server > server(argv[1], argv[2], std::atoi(argv[3]), 16 | flann::KDTreeIndexParams(4)); 17 | 18 | server.run(); 19 | } 20 | catch (std::exception& e) { 21 | std::cerr << "Exception: " << e.what() << "\n"; 22 | } 23 | 24 | return 0; 25 | } 26 | 27 | -------------------------------------------------------------------------------- /models/robot_small.obj: -------------------------------------------------------------------------------- 1 | # Blender v2.83.2 OBJ File: 'robot.blend' 2 | # www.blender.org 3 | mtllib robot_small.mtl 4 | o Plane_Plane.001 5 | v -0.115025 -0.246761 -0.009776 6 | v 0.132521 -0.243339 0.000343 7 | v 0.245000 -0.122495 0.000000 8 | v 0.246610 0.107060 -0.000997 9 | v -0.244938 -0.107179 0.000967 10 | v 0.120904 0.245032 0.003517 11 | v -0.108574 0.246664 -0.000834 12 | v -0.245000 0.115126 0.000000 13 | vn -0.0414 0.0413 0.9983 14 | vn 0.0021 0.0043 1.0000 15 | vn -0.0193 -0.0502 0.9986 16 | vn 0.0019 0.0044 1.0000 17 | vn -0.0004 -0.0771 0.9970 18 | usemtl Default_OBJ.001 19 | s off 20 | f 1//1 2//1 3//1 21 | f 3//2 4//2 5//2 22 | f 4//3 6//3 7//3 23 | f 5//4 7//4 8//4 24 | f 4//2 7//2 5//2 25 | f 5//5 1//5 3//5 26 | -------------------------------------------------------------------------------- /lib/flann/doc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_package(LATEX) 2 | 3 | if (NOT DOCDIR) 4 | set(DOCDIR share/doc/flann) 5 | endif () 6 | 7 | if (EXISTS ${PDFLATEX_COMPILER} AND EXISTS ${BIBTEX_COMPILER}) 8 | include(${PROJECT_SOURCE_DIR}/cmake/UseLATEX.cmake) 9 | 10 | add_latex_document(manual.tex BIBFILES references.bib IMAGE_DIRS images DEFAULT_PDF) 11 | 12 | add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/manual.pdf 13 | COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/manual.pdf ${CMAKE_CURRENT_SOURCE_DIR}/manual.pdf 14 | DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/manual.pdf 15 | ) 16 | add_custom_target(doc DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/manual.pdf) 17 | endif() 18 | 19 | install( 20 | FILES manual.pdf 21 | DESTINATION ${DOCDIR} 22 | OPTIONAL 23 | ) 24 | -------------------------------------------------------------------------------- /src/main.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file main.h 3 | * @author Jaroslav Janos (janosjar@fel.cvut.cz) 4 | * @brief 5 | * @version 1.0 6 | * @date 25/06/2020 7 | * 8 | * @copyright Copyright (c) 2020 9 | * 10 | */ 11 | 12 | #ifndef __MAIN_H__ 13 | #define __MAIN_H__ 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include "rapidxml.hpp" 21 | 22 | #include "primitives.h" 23 | #include "environment.h" 24 | #include "problemStruct.h" 25 | #include "forest.h" 26 | #include "rrt.h" 27 | #include "lazy.h" 28 | 29 | using namespace std; 30 | using namespace rapidxml; 31 | 32 | void parseFile(const std::string &fileName, Problem &problem); 33 | bool getFile(rapidxml::xml_node<> *node, FileStruct &file, int iteration = 0, bool includeIter = true); 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /lib/flann/cmake/uninstall_target.cmake.in: -------------------------------------------------------------------------------- 1 | if(NOT EXISTS "@PROJECT_BINARY_DIR@/install_manifest.txt") 2 | message(FATAL_ERROR "Cannot find install manifest: \"@PROJECT_BINARY_DIR@/install_manifest.txt\"") 3 | endif(NOT EXISTS "@PROJECT_BINARY_DIR@/install_manifest.txt") 4 | 5 | file(READ "@PROJECT_BINARY_DIR@/install_manifest.txt" files) 6 | string(REGEX REPLACE "\n" ";" files "${files}") 7 | foreach(file ${files}) 8 | message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") 9 | if(EXISTS "$ENV{DESTDIR}${file}") 10 | exec_program("@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" 11 | OUTPUT_VARIABLE rm_out RETURN_VALUE rm_retval) 12 | if(NOT "${rm_retval}" STREQUAL 0) 13 | message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") 14 | endif(NOT "${rm_retval}" STREQUAL 0) 15 | else(EXISTS "$ENV{DESTDIR}${file}") 16 | message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.") 17 | endif(EXISTS "$ENV{DESTDIR}${file}") 18 | endforeach(file) 19 | 20 | -------------------------------------------------------------------------------- /lib/flann/cmake/FindFlann.cmake: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Find Flann 3 | # 4 | # This sets the following variables: 5 | # FLANN_FOUND - True if FLANN was found. 6 | # FLANN_INCLUDE_DIRS - Directories containing the FLANN include files. 7 | # FLANN_LIBRARIES - Libraries needed to use FLANN. 8 | # FLANN_DEFINITIONS - Compiler flags for FLANN. 9 | 10 | find_package(PkgConfig) 11 | pkg_check_modules(PC_FLANN flann) 12 | set(FLANN_DEFINITIONS ${PC_FLANN_CFLAGS_OTHER}) 13 | 14 | find_path(FLANN_INCLUDE_DIR flann/flann.hpp 15 | HINTS ${PC_FLANN_INCLUDEDIR} ${PC_FLANN_INCLUDE_DIRS}) 16 | 17 | find_library(FLANN_LIBRARY flann 18 | HINTS ${PC_FLANN_LIBDIR} ${PC_FLANN_LIBRARY_DIRS}) 19 | 20 | set(FLANN_INCLUDE_DIRS ${FLANN_INCLUDE_DIR}) 21 | set(FLANN_LIBRARIES ${FLANN_LIBRARY}) 22 | 23 | include(FindPackageHandleStandardArgs) 24 | find_package_handle_standard_args(Flann DEFAULT_MSG 25 | FLANN_LIBRARY FLANN_INCLUDE_DIR) 26 | 27 | mark_as_advanced(FLANN_LIBRARY FLANN_INCLUDE_DIR) 28 | 29 | -------------------------------------------------------------------------------- /lib/flann/src/python/setup.py.tpl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | 3 | from distutils.core import setup 4 | from os.path import exists, abspath, dirname, join 5 | import os 6 | import sys 7 | 8 | 9 | def find_path(): 10 | lib_paths = [ os.path.abspath('@LIBRARY_OUTPUT_PATH@'), abspath(join(dirname(dirname(sys.argv[0])), '../../../lib')) ] 11 | possible_libs = ['libflann.so', 'flann.dll', 'libflann.dll', 'libflann.dylib'] 12 | 13 | for path in lib_paths: 14 | for lib in possible_libs: 15 | if exists(join(path,lib)): 16 | return path 17 | 18 | setup(name='flann', 19 | version='@FLANN_VERSION@', 20 | description='Fast Library for Approximate Nearest Neighbors', 21 | author='Marius Muja', 22 | author_email='mariusm@cs.ubc.ca', 23 | license='BSD', 24 | url='http://www.cs.ubc.ca/~mariusm/flann/', 25 | packages=['pyflann', 'pyflann.lib'], 26 | package_dir={'pyflann.lib': find_path() }, 27 | package_data={'pyflann.lib': ['libflann.so', 'flann.dll', 'libflann.dll', 'libflann.dylib']}, 28 | ) 29 | -------------------------------------------------------------------------------- /test_2D.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /lib/flann/examples/flann_example.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | #include 6 | 7 | using namespace flann; 8 | 9 | int main(int argc, char** argv) 10 | { 11 | int nn = 3; 12 | 13 | Matrix dataset; 14 | Matrix query; 15 | load_from_file(dataset, "dataset.hdf5","dataset"); 16 | load_from_file(query, "dataset.hdf5","query"); 17 | 18 | Matrix indices(new int[query.rows*nn], query.rows, nn); 19 | Matrix dists(new float[query.rows*nn], query.rows, nn); 20 | 21 | // construct an randomized kd-tree index using 4 kd-trees 22 | Index > index(dataset, flann::KDTreeIndexParams(4)); 23 | index.buildIndex(); 24 | 25 | // do a knn search, using 128 checks 26 | index.knnSearch(query, indices, dists, nn, flann::SearchParams(128)); 27 | 28 | flann::save_to_file(indices,"result.hdf5","result"); 29 | 30 | delete[] dataset.ptr(); 31 | delete[] query.ptr(); 32 | delete[] indices.ptr(); 33 | delete[] dists.ptr(); 34 | 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /lib/flann/ChangeLog: -------------------------------------------------------------------------------- 1 | Version 1.6.11 2 | * bug fixes 3 | 4 | Version 1.6.10 5 | * fixed a radiusSearch bug introduced in 1.6.9 6 | 7 | Version 1.6.9 8 | * bug fixes 9 | * fixed radius search bug on MSVC compiler 10 | * fixed windows linking problems 11 | 12 | Version 1.6.8 13 | * bug fixes, low dimensional search speedup 14 | 15 | Version 1.6.7 16 | * bug fixes 17 | 18 | Version 1.6.6 19 | * misc bug fixes 20 | 21 | Version 1.6.5 22 | * fix compilation problem on some C++ compilers 23 | * fixes in the python bindings 24 | 25 | Version 1.6.4 26 | * small bug fix 27 | 28 | Version 1.6.3 29 | * radius search speedup 30 | 31 | Version 1.6.2 32 | * slight API changes to the C++ bindings, now the main index type is templated 33 | * on the distance functor which makes it easier to use custom distances 34 | * new kd-tree implementation optimized for low dimensionality data 35 | * experimental MPI support for cluster computing 36 | 37 | Version 1.5 38 | * new C++ templated API 39 | * saving/loading of indices to disk 40 | * threadsafe search 41 | * new distance types (thanks to Radu Bogdan Rusu and Romain Thibaux for the patch) 42 | * (api change) autotuned is no longer selected by passing a precision >0, it's used when the algorithm type is set to autotuned 43 | -------------------------------------------------------------------------------- /lib/flann/examples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_custom_target(examples ALL) 2 | 3 | 4 | if (BUILD_C_BINDINGS) 5 | add_executable(flann_example_c flann_example.c) 6 | target_link_libraries(flann_example_c flann) 7 | set_target_properties(flann_example_c PROPERTIES COMPILE_FLAGS -std=c99) 8 | 9 | add_dependencies(examples flann_example_c) 10 | install (TARGETS flann_example_c DESTINATION bin ) 11 | endif() 12 | 13 | if (HDF5_FOUND) 14 | include_directories(${HDF5_INCLUDE_DIR}) 15 | 16 | add_executable(flann_example_cpp flann_example.cpp) 17 | target_link_libraries(flann_example_cpp ${HDF5_LIBRARIES} flann_cpp) 18 | if (HDF5_IS_PARALLEL) 19 | target_link_libraries(flann_example_cpp ${MPI_LIBRARIES}) 20 | endif() 21 | 22 | add_dependencies(examples flann_example_cpp) 23 | install (TARGETS flann_example_cpp DESTINATION bin) 24 | 25 | 26 | if (USE_MPI AND HDF5_IS_PARALLEL) 27 | add_executable(flann_example_mpi flann_example_mpi.cpp) 28 | target_link_libraries(flann_example_mpi flann_cpp ${HDF5_LIBRARIES} ${MPI_LIBRARIES} ${Boost_LIBRARIES}) 29 | 30 | add_dependencies(examples flann_example_mpi) 31 | install (TARGETS flann_example_mpi DESTINATION bin) 32 | endif() 33 | else() 34 | message("hdf5 library not found, not compiling flann_example.cpp") 35 | endif() 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /lib/ann/ann/sample/sample.save: -------------------------------------------------------------------------------- 1 | Data Points: 2 | (-0.297462, 0.176102) 3 | (0.565538, -0.361496) 4 | (0.909313, -0.182785) 5 | (0.920712, 0.478408) 6 | (0.167682, 0.0499836) 7 | (0.305223, -0.0805835) 8 | (0.114973, 0.882453) 9 | (0.742916, 0.16376) 10 | (0.0724605, -0.826775) 11 | (0.69096, -0.559284) 12 | (0.188485, -0.643934) 13 | (0.749427, -0.942415) 14 | (-0.970662, -0.223466) 15 | (0.91611, 0.879597) 16 | (0.927417, -0.382593) 17 | (-0.711327, 0.278713) 18 | (-0.519172, 0.986146) 19 | (0.135338, 0.924588) 20 | (-0.0837537, 0.61687) 21 | (0.0520465, 0.896306) 22 | Query point: (0.0902484, -0.207129) 23 | NN: Index Distance 24 | 0 5 0.249455 25 | Query point: (-0.419567, 0.485743) 26 | NN: Index Distance 27 | 0 0 0.332847 28 | Query point: (0.826225, -0.30962) 29 | NN: Index Distance 30 | 0 14 0.124759 31 | Query point: (0.694758, 0.987088) 32 | NN: Index Distance 33 | 0 13 0.246071 34 | Query point: (-0.410807, -0.465182) 35 | NN: Index Distance 36 | 0 8 0.60357 37 | Query point: (-0.836501, 0.490184) 38 | NN: Index Distance 39 | 0 15 0.245741 40 | Query point: (0.588289, 0.656408) 41 | NN: Index Distance 42 | 0 3 0.37708 43 | Query point: (0.325807, 0.38721) 44 | NN: Index Distance 45 | 0 4 0.372458 46 | Query point: (-0.532226, -0.727036) 47 | NN: Index Distance 48 | 0 8 0.612857 49 | Query point: (-0.52506, -0.853508) 50 | NN: Index Distance 51 | 0 8 0.598118 52 | -------------------------------------------------------------------------------- /test_triang.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /lib/flann/src/ruby/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014, John Woods, WVU Applied Space Exploration Laboratory, and West Virginia Robotic Technology Center. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 6 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | 8 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 9 | 10 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 11 | -------------------------------------------------------------------------------- /lib/ann/main.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "../ann/ann/include/ANN/ANN.h" 7 | 8 | using namespace std; 9 | 10 | int main(int argc, char **argv) { 11 | 12 | const int dimension = 2; 13 | 14 | const int numPoints = 1000; 15 | const int k = 1; 16 | ANNidxArray idx = new ANNidx[k]; 17 | ANNdistArray dist = new ANNdist[k]; 18 | ANNpoint query = annAllocPt(dimension); 19 | ANNpointArray ap = annAllocPts(numPoints,dimension); 20 | 21 | for(int i=0;iannkSearch(query,k,idx,dist,0); 37 | 38 | for(int j=0;j 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /lib/flann/src/python/pyflann/__init__.py: -------------------------------------------------------------------------------- 1 | #Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. 2 | #Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. 3 | # 4 | #THE BSD LICENSE 5 | # 6 | #Redistribution and use in source and binary forms, with or without 7 | #modification, are permitted provided that the following conditions 8 | #are met: 9 | # 10 | #1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | #2. Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | #THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 | #IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 | #OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | #IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | #INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | #NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | #DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | #THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | #(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | #THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | #import sys 28 | #import os 29 | #sys.path.insert(0, os.path.split(__file__)[0]) # make python3 happy 30 | 31 | from pyflann.index import * 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2020, Multi-robot Systems (MRS) group at Czech Technical University in Prague 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /lib/flann/src/ruby/Gemfile: -------------------------------------------------------------------------------- 1 | # Copyright 2014 John O. Woods (john.o.woods@gmail.com), West Virginia 2 | # University's Applied Space Exploration Lab, and West Virginia Robotic 3 | # Technology Center. All rights reserved. 4 | # 5 | # THE BSD LICENSE 6 | # 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions 9 | # are met: 10 | # 11 | # 1. Redistributions of source code must retain the above copyright 12 | # notice, this list of conditions and the following disclaimer. 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | 28 | source 'https://rubygems.org' 29 | gemspec 30 | 31 | gem "ffi" 32 | gem "nmatrix" 33 | 34 | group :development do 35 | 36 | end -------------------------------------------------------------------------------- /lib/flann/src/matlab/flann_save_index.m: -------------------------------------------------------------------------------- 1 | %Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. 2 | %Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. 3 | % 4 | %THE BSD LICENSE 5 | % 6 | %Redistribution and use in source and binary forms, with or without 7 | %modification, are permitted provided that the following conditions 8 | %are met: 9 | % 10 | %1. Redistributions of source code must retain the above copyright 11 | % notice, this list of conditions and the following disclaimer. 12 | %2. Redistributions in binary form must reproduce the above copyright 13 | % notice, this list of conditions and the following disclaimer in the 14 | % documentation and/or other materials provided with the distribution. 15 | % 16 | %THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 | %IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 | %OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | %IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | %INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | %NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | %DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | %THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | %(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | %THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | function flann_save_index(index_id, filename) 28 | %FLANN_SAVE_INDEX Saves an index to disk 29 | % 30 | 31 | % Marius Muja, March 2010 32 | 33 | nearest_neighbors('save_index',index_id, filename); 34 | end -------------------------------------------------------------------------------- /lib/flann/src/python/pyflann/exceptions.py: -------------------------------------------------------------------------------- 1 | #Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. 2 | #Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. 3 | # 4 | #THE BSD LICENSE 5 | # 6 | #Redistribution and use in source and binary forms, with or without 7 | #modification, are permitted provided that the following conditions 8 | #are met: 9 | # 10 | #1. Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | #2. Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the distribution. 15 | # 16 | #THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 | #IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 | #OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | #IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | #INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | #NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | #DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | #THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | #(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | #THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | 28 | # This module defines exceptions that are used by the flann python bindings 29 | 30 | class FLANNException(Exception): 31 | def __init__(self, *args): 32 | Exception.__init__(self, *args) 33 | -------------------------------------------------------------------------------- /lib/flann/src/matlab/flann_load_index.m: -------------------------------------------------------------------------------- 1 | %Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. 2 | %Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. 3 | % 4 | %THE BSD LICENSE 5 | % 6 | %Redistribution and use in source and binary forms, with or without 7 | %modification, are permitted provided that the following conditions 8 | %are met: 9 | % 10 | %1. Redistributions of source code must retain the above copyright 11 | % notice, this list of conditions and the following disclaimer. 12 | %2. Redistributions in binary form must reproduce the above copyright 13 | % notice, this list of conditions and the following disclaimer in the 14 | % documentation and/or other materials provided with the distribution. 15 | % 16 | %THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 | %IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 | %OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | %IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | %INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | %NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | %DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | %THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | %(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | %THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | function index = flann_load_index(filename, dataset) 28 | %FLANN_LOAD_INDEX Loads an index from disk 29 | % 30 | % Marius Muja, March 2009 31 | 32 | index = nearest_neighbors('load_index', filename, dataset); 33 | end -------------------------------------------------------------------------------- /lib/flann/COPYING: -------------------------------------------------------------------------------- 1 | 2 | The BSD License 3 | 4 | Copyright (c) 2008-2011 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. 5 | Copyright (c) 2008-2011 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. 6 | Copyright (c) 2015 Google Inc (Jack Rae, jwrae@google.com). All Rights Reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 | 10 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 12 | * Neither the name of the "University of British Columbia" nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 13 | 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 16 | -------------------------------------------------------------------------------- /lib/flann/src/cpp/flann/flann_cpp.cpp: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. 5 | * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | *************************************************************************/ 28 | 29 | 30 | #include "flann/flann.hpp" 31 | -------------------------------------------------------------------------------- /lib/flann/src/matlab/flann_free_index.m: -------------------------------------------------------------------------------- 1 | %Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. 2 | %Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. 3 | % 4 | %THE BSD LICENSE 5 | % 6 | %Redistribution and use in source and binary forms, with or without 7 | %modification, are permitted provided that the following conditions 8 | %are met: 9 | % 10 | %1. Redistributions of source code must retain the above copyright 11 | % notice, this list of conditions and the following disclaimer. 12 | %2. Redistributions in binary form must reproduce the above copyright 13 | % notice, this list of conditions and the following disclaimer in the 14 | % documentation and/or other materials provided with the distribution. 15 | % 16 | %THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 | %IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 | %OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | %IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | %INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | %NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | %DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | %THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | %(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | %THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | function flann_free_index(index_id) 28 | %FLANN_FREE_INDEX Deletes the nearest-neighbors index 29 | % 30 | % Deletes an index constructed using flann_build_index. 31 | 32 | % Marius Muja, January 2008 33 | 34 | nearest_neighbors('free_index',index_id); 35 | end -------------------------------------------------------------------------------- /lib/flann/src/ruby/lib/flann/version.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2014 John O. Woods (john.o.woods@gmail.com), West Virginia 2 | # University's Applied Space Exploration Lab, and West Virginia Robotic 3 | # Technology Center. All rights reserved. 4 | # 5 | # THE BSD LICENSE 6 | # 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions 9 | # are met: 10 | # 11 | # 1. Redistributions of source code must retain the above copyright 12 | # notice, this list of conditions and the following disclaimer. 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | 28 | module Flann 29 | module VERSION 30 | MAJOR = 1 31 | MINOR = 8 32 | TINY = 4 33 | MINISCULE = 2 34 | 35 | STRING = [MAJOR, MINOR, TINY, MINISCULE].compact.join('.') 36 | end 37 | end -------------------------------------------------------------------------------- /lib/ann/ann/Copyright.txt: -------------------------------------------------------------------------------- 1 | ANN: Approximate Nearest Neighbors 2 | Version: 1.1.2 3 | Release Date: Jan 27, 2010 4 | ---------------------------------------------------------------------------- 5 | Copyright (c) 1997-2010 University of Maryland and Sunil Arya and David 6 | Mount All Rights Reserved. 7 | 8 | This program is free software; you can redistribute it and/or modify it 9 | under the terms of the GNU Lesser Public License as published by the 10 | Free Software Foundation; either version 2.1 of the License, or (at your 11 | option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, but 14 | WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | Lesser Public License for more details. 17 | 18 | A copy of the terms and conditions of the license can be found in 19 | License.txt or online at 20 | 21 | http://www.gnu.org/copyleft/lesser.html 22 | 23 | To obtain a copy, write to the Free Software Foundation, Inc., 24 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 25 | 26 | Disclaimer 27 | ---------- 28 | The University of Maryland and the authors make no representations about 29 | the suitability or fitness of this software for any purpose. It is 30 | provided "as is" without express or implied warranty. 31 | --------------------------------------------------------------------- 32 | 33 | Authors 34 | ------- 35 | David Mount 36 | Dept of Computer Science 37 | University of Maryland, 38 | College Park, MD 20742 USA 39 | mount@cs.umd.edu 40 | http://www.cs.umd.edu/~mount/ 41 | 42 | Sunil Arya 43 | Dept of Computer Science 44 | Hong University of Science and Technology 45 | Clearwater Bay, HONG KONG 46 | arya@cs.ust.hk 47 | http://www.cs.ust.hk/faculty/arya/ 48 | -------------------------------------------------------------------------------- /lib/flann/README.md: -------------------------------------------------------------------------------- 1 | FLANN - Fast Library for Approximate Nearest Neighbors 2 | ====================================================== 3 | 4 | FLANN is a library for performing fast approximate nearest neighbor searches in high dimensional spaces. It contains a collection of algorithms we found to work best for nearest neighbor search and a system for automatically choosing the best algorithm and optimum parameters depending on the dataset. 5 | FLANN is written in C++ and contains bindings for the following languages: C, MATLAB, Python, and Ruby. 6 | 7 | 8 | Documentation 9 | ------------- 10 | 11 | Check FLANN web page [here](http://www.cs.ubc.ca/research/flann). 12 | 13 | Documentation on how to use the library can be found in the doc/manual.pdf file included in the release archives. 14 | 15 | More information and experimental results can be found in the following paper: 16 | 17 | * Marius Muja and David G. Lowe, "Fast Approximate Nearest Neighbors with Automatic Algorithm Configuration", in International Conference on Computer Vision Theory and Applications (VISAPP'09), 2009 [(PDF)](http://people.cs.ubc.ca/~mariusm/uploads/FLANN/flann_visapp09.pdf) [(BibTex)](http://people.cs.ubc.ca/~mariusm/index.php/FLANN/BibTex) 18 | 19 | 20 | Getting FLANN 21 | ------------- 22 | 23 | If you want to try out the latest changes or contribute to FLANN, then it's recommended that you checkout the git source repository: `git clone git://github.com/mariusmuja/flann.git` 24 | 25 | If you just want to browse the repository, you can do so by going [here](https://github.com/mariusmuja/flann). 26 | 27 | 28 | Conditions of use 29 | ----------------- 30 | 31 | FLANN is distributed under the terms of the [BSD License](https://github.com/mariusmuja/flann/blob/master/COPYING). 32 | 33 | Bug reporting 34 | ------------- 35 | 36 | Please report bugs or feature requests using [github's issue tracker](http://github.com/mariusmuja/flann/issues). 37 | -------------------------------------------------------------------------------- /lib/flann/src/cpp/flann/config.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Copyright 2008-2011 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. 5 | * Copyright 2008-2011 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | *************************************************************************/ 28 | 29 | 30 | #ifndef FLANN_CONFIG_H_ 31 | #define FLANN_CONFIG_H_ 32 | 33 | #ifdef FLANN_VERSION_ 34 | #undef FLANN_VERSION_ 35 | #endif 36 | #define FLANN_VERSION_ "1.9.1" 37 | 38 | #endif /* FLANN_CONFIG_H_ */ 39 | -------------------------------------------------------------------------------- /lib/flann/src/cpp/flann/config.h.in: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Copyright 2008-2011 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. 5 | * Copyright 2008-2011 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | *************************************************************************/ 28 | 29 | 30 | #ifndef FLANN_CONFIG_H_ 31 | #define FLANN_CONFIG_H_ 32 | 33 | #ifdef FLANN_VERSION_ 34 | #undef FLANN_VERSION_ 35 | #endif 36 | #define FLANN_VERSION_ "${FLANN_VERSION}" 37 | 38 | #endif /* FLANN_CONFIG_H_ */ 39 | -------------------------------------------------------------------------------- /makefile: -------------------------------------------------------------------------------- 1 | TARGET := main 2 | OBJDIR := obj 3 | DBGDIR := debug 4 | RELDIR := release 5 | 6 | SOURCES := $(wildcard src/*.cpp) 7 | SOURCES := $(SOURCES:src/%=%) 8 | OBJECTS := $(patsubst %.c,%.o, $(patsubst %.cpp,%.o,$(SOURCES))) 9 | 10 | INCLUDE := -I. -I./lib/rapid-2.01 -I./lib/ann/ann/include -I./lib/rapidxml 11 | LIBPATH := -L./lib/ -L./lib/ann/ -L./lib/flann/ -L./lib/rapid-2.01 -L./lib/rapidxml 12 | LIBS := -lgmp -lRAPID -llz4 13 | 14 | CXXFLAGS := -std=c++17 15 | CXX := g++ 16 | 17 | DBGEXE := $(DBGDIR)/$(TARGET) 18 | DBGOBJS := $(addprefix $(OBJDIR)/, $(addprefix $(DBGDIR)/, $(OBJECTS))) 19 | DBGFLAGS := $(CXXFLAGS) -g -Og 20 | 21 | RELEXE := $(RELDIR)/$(TARGET) 22 | RELOBJS := $(addprefix $(OBJDIR)/, $(addprefix $(RELDIR)/, $(OBJECTS))) 23 | RELFLAGS := $(CXXFLAGS) -O3 24 | 25 | .PHONY: all clean debug release prep rapid flann install 26 | 27 | all: release 28 | 29 | ############ DEBUG ############### 30 | debug: prep $(DBGEXE) 31 | 32 | $(DBGEXE): $(DBGOBJS) 33 | $(CXX) $(DBGFLAGS) $(INCLUDE) -o $(DBGEXE) $^ $(LIBPATH) $(LIBS) 34 | 35 | $(OBJDIR)/$(DBGDIR)/%.o: src/%.cpp 36 | $(CXX) $(DBGFLAGS) $(INCLUDE) -c $< -o $@ 37 | 38 | ############ RELEASE ############### 39 | release: prep $(RELEXE) 40 | 41 | $(RELEXE): $(RELOBJS) 42 | $(CXX) $(RELFLAGS) $(INCLUDE) -o $(RELEXE) $^ $(LIBPATH) $(LIBS) 43 | 44 | $(OBJDIR)/$(RELDIR)/%.o: src/%.cpp 45 | $(CXX) $(RELFLAGS) $(INCLUDE) -c $< -o $@ 46 | 47 | ############# COMMON ############## 48 | prep: 49 | @echo "Creating directories.." 50 | @mkdir -p $(OBJDIR) 51 | @mkdir -p $(OBJDIR)/$(DBGDIR) 52 | @mkdir -p $(OBJDIR)/$(RELDIR) 53 | @mkdir -p $(DBGDIR) 54 | @mkdir -p $(RELDIR) 55 | 56 | install: rapid flann release 57 | 58 | rapid: 59 | @echo "Installing RAPID..." 60 | @$(MAKE) -C lib/rapid-2.01/ 61 | 62 | flann: 63 | @echo "Installing FLANN..." 64 | @cd ./lib/flann; mkdir build; cd build; cmake .. -DCMAKE_INSTALL_PREFIX=../install; make -j4; make install 65 | 66 | clean: 67 | @echo "Cleaning..." 68 | @rm -rf $(OBJDIR) 69 | @rm -rf $(RELDIR) 70 | @rm -rf $(DBGDIR) 71 | -------------------------------------------------------------------------------- /lib/flann/test/memusage_clustering.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import sys 3 | from os.path import * 4 | from pyflann import * 5 | from guppy import hpy 6 | from numpy.random import rand 7 | 8 | import os, gc 9 | 10 | _proc_status = '/proc/%d/status' % os.getpid() 11 | 12 | _scale = {'kB': 1024.0, 'mB': 1024.0*1024.0, 13 | 'KB': 1024.0, 'MB': 1024.0*1024.0} 14 | 15 | def _VmB(VmKey): 16 | '''Private. 17 | ''' 18 | global _proc_status, _scale 19 | # get pseudo file /proc//status 20 | try: 21 | t = open(_proc_status) 22 | v = t.read() 23 | t.close() 24 | except: 25 | return 0.0 # non-Linux? 26 | # get VmKey line e.g. 'VmRSS: 9999 kB\n ...' 27 | i = v.index(VmKey) 28 | v = v[i:].split(None, 3) # whitespace 29 | if len(v) < 3: 30 | return 0.0 # invalid format? 31 | # convert Vm value to bytes 32 | return float(v[1]) * _scale[v[2]] 33 | 34 | 35 | def memory(since=0.0): 36 | '''Return memory usage in bytes. 37 | ''' 38 | return _VmB('VmSize:') - since 39 | 40 | 41 | def resident(since=0.0): 42 | '''Return resident memory usage in bytes. 43 | ''' 44 | return _VmB('VmRSS:') - since 45 | 46 | 47 | def stacksize(since=0.0): 48 | '''Return stack size in bytes. 49 | ''' 50 | return _VmB('VmStk:') - since 51 | 52 | 53 | 54 | if __name__ == '__main__': 55 | 56 | print 'Profiling Memory usage for pyflann; CTRL-C to stop.' 57 | print 'Increasing total process memory, relative to the python memory, ' 58 | print 'implies a memory leak in the external libs.' 59 | print 'Increasing python memory implies a memory leak in the python code.' 60 | 61 | h = hpy() 62 | 63 | while True: 64 | s = str(h.heap()) 65 | 66 | print 'Python: %s; Process Total: %s' % (s[:s.find('\n')], memory()) 67 | 68 | X = rand(30000, 2) 69 | pf = FLANN() 70 | cl = pf.kmeans(X, 20) 71 | del X 72 | del cl 73 | del pf 74 | gc.collect() 75 | 76 | -------------------------------------------------------------------------------- /lib/ann/ann/src/kd_fix_rad_search.h: -------------------------------------------------------------------------------- 1 | //---------------------------------------------------------------------- 2 | // File: kd_fix_rad_search.h 3 | // Programmer: Sunil Arya and David Mount 4 | // Description: Standard kd-tree fixed-radius kNN search 5 | // Last modified: 05/03/05 (Version 1.1) 6 | //---------------------------------------------------------------------- 7 | // Copyright (c) 1997-2005 University of Maryland and Sunil Arya and 8 | // David Mount. All Rights Reserved. 9 | // 10 | // This software and related documentation is part of the Approximate 11 | // Nearest Neighbor Library (ANN). This software is provided under 12 | // the provisions of the Lesser GNU Public License (LGPL). See the 13 | // file ../ReadMe.txt for further information. 14 | // 15 | // The University of Maryland (U.M.) and the authors make no 16 | // representations about the suitability or fitness of this software for 17 | // any purpose. It is provided "as is" without express or implied 18 | // warranty. 19 | //---------------------------------------------------------------------- 20 | // History: 21 | // Revision 1.1 05/03/05 22 | // Initial release 23 | //---------------------------------------------------------------------- 24 | 25 | #ifndef ANN_kd_fix_rad_search_H 26 | #define ANN_kd_fix_rad_search_H 27 | 28 | #include "../../../ann/ann/include/ANN/ANNperf.h" // performance evaluation 29 | #include "../../../ann/ann/src/kd_tree.h" // kd-tree declarations 30 | #include "../../../ann/ann/src/kd_util.h" // kd-tree utilities 31 | #include "../../../ann/ann/src/pr_queue_k.h" // k-element priority queue 32 | 33 | //---------------------------------------------------------------------- 34 | // Global variables 35 | // These are active for the life of each call to 36 | // annRangeSearch(). They are set to save the number of 37 | // variables that need to be passed among the various search 38 | // procedures. 39 | //---------------------------------------------------------------------- 40 | 41 | extern ANNpoint ANNkdFRQ; // query point (static copy) 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /lib/flann/test/memusage_nn.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import sys 3 | from os.path import * 4 | from pyflann import * 5 | from guppy import hpy 6 | from numpy.random import rand 7 | 8 | import os, gc 9 | 10 | _proc_status = '/proc/%d/status' % os.getpid() 11 | 12 | _scale = {'kB': 1024.0, 'mB': 1024.0*1024.0, 13 | 'KB': 1024.0, 'MB': 1024.0*1024.0} 14 | 15 | def _VmB(VmKey): 16 | '''Private. 17 | ''' 18 | global _proc_status, _scale 19 | # get pseudo file /proc//status 20 | try: 21 | t = open(_proc_status) 22 | v = t.read() 23 | t.close() 24 | except: 25 | return 0.0 # non-Linux? 26 | # get VmKey line e.g. 'VmRSS: 9999 kB\n ...' 27 | i = v.index(VmKey) 28 | v = v[i:].split(None, 3) # whitespace 29 | if len(v) < 3: 30 | return 0.0 # invalid format? 31 | # convert Vm value to bytes 32 | return float(v[1]) * _scale[v[2]] 33 | 34 | 35 | def memory(since=0.0): 36 | '''Return memory usage in bytes. 37 | ''' 38 | return _VmB('VmSize:') - since 39 | 40 | 41 | def resident(since=0.0): 42 | '''Return resident memory usage in bytes. 43 | ''' 44 | return _VmB('VmRSS:') - since 45 | 46 | 47 | def stacksize(since=0.0): 48 | '''Return stack size in bytes. 49 | ''' 50 | return _VmB('VmStk:') - since 51 | 52 | 53 | 54 | if __name__ == '__main__': 55 | 56 | print 'Profiling Memory usage for pyflann; CTRL-C to stop.' 57 | print 'Increasing total process memory, relative to the python memory, ' 58 | print 'implies a memory leak in the external libs.' 59 | print 'Increasing python memory implies a memory leak in the python code.' 60 | 61 | h = hpy() 62 | 63 | while True: 64 | s = str(h.heap()) 65 | 66 | print 'Python: %s; Process Total: %s' % (s[:s.find('\n')], memory()) 67 | 68 | X1 = rand(50000, 2) 69 | X2 = rand(50000, 2) 70 | pf = FLANN() 71 | nnlist = pf.nn(X1, X2) 72 | del X1 73 | del X2 74 | del nnlist 75 | del pf 76 | gc.collect() 77 | 78 | -------------------------------------------------------------------------------- /lib/flann/src/matlab/flann_set_distance_type.m: -------------------------------------------------------------------------------- 1 | %Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. 2 | %Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. 3 | % 4 | %THE BSD LICENSE 5 | % 6 | %Redistribution and use in source and binary forms, with or without 7 | %modification, are permitted provided that the following conditions 8 | %are met: 9 | % 10 | %1. Redistributions of source code must retain the above copyright 11 | % notice, this list of conditions and the following disclaimer. 12 | %2. Redistributions in binary form must reproduce the above copyright 13 | % notice, this list of conditions and the following disclaimer in the 14 | % documentation and/or other materials provided with the distribution. 15 | % 16 | %THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 | %IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 | %OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | %IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | %INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | %NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | %DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | %THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | %(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | %THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | function flann_set_distance_type(type, order) 28 | %FLANN_LOAD_INDEX Loads an index from disk 29 | % 30 | % Marius Muja, March 2009 31 | 32 | distances = struct('euclidean', 1, 'manhattan', 2, 'minkowski', 3, 'max_dist', 4, 'hik', 5, 'hellinger', 6, 'chi_square', 7, 'cs', 7, 'kullback_leibler', 8, 'kl', 8); 33 | 34 | if ~isnumeric(type), 35 | type = value2id(distances,type); 36 | end 37 | if type~=3 38 | order = 0; 39 | end 40 | nearest_neighbors('set_distance_type', type, order); 41 | end 42 | 43 | function id = value2id(map,value) 44 | id = map.(value); 45 | end 46 | -------------------------------------------------------------------------------- /lib/flann/src/ruby/spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2014 John O. Woods (john.o.woods@gmail.com), West Virginia 2 | # University's Applied Space Exploration Lab, and West Virginia Robotic 3 | # Technology Center. All rights reserved. 4 | # 5 | # THE BSD LICENSE 6 | # 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions 9 | # are met: 10 | # 11 | # 1. Redistributions of source code must retain the above copyright 12 | # notice, this list of conditions and the following disclaimer. 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | 28 | require 'rspec' 29 | require 'rspec/longrun' 30 | 31 | require "./lib/flann" 32 | 33 | # Helper function for reading a test dataset so we can test nearest neighbors 34 | # and radius search and such. 35 | def read_dataset filename 36 | Dir.chdir("spec") do 37 | f = File.new(filename, 'r') 38 | n = NMatrix.new([65536, 3], dtype: :float32) 39 | i = 0 40 | while line = f.gets 41 | line.chomp! 42 | fields = line.split 43 | n[i,:*] = fields.map { |field| field.to_f } 44 | 45 | i += 1 46 | end 47 | 48 | n 49 | end 50 | end -------------------------------------------------------------------------------- /lib/flann/test/test_nn_index.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | from pyflann import * 4 | from copy import copy 5 | from numpy import * 6 | from numpy.random import * 7 | import unittest 8 | 9 | 10 | class Test_PyFLANN_nn(unittest.TestCase): 11 | 12 | def setUp(self): 13 | self.nn = FLANN() 14 | 15 | 16 | class Test_PyFLANN_nn_index(unittest.TestCase): 17 | 18 | def testnn_index(self): 19 | 20 | dim = 10 21 | N = 100 22 | 23 | x = rand(N, dim) 24 | nn = FLANN() 25 | nn.build_index(x) 26 | 27 | nnidx, nndist = nn.nn_index(x) 28 | correct = all(nnidx == arange(N, dtype = index_type)) 29 | 30 | nn.delete_index() 31 | self.assertTrue(correct) 32 | 33 | 34 | def testnn_index_random_permute(self): 35 | 36 | numtests = 500 37 | dim = 10 38 | N = 100 39 | 40 | nns = [None]*numtests 41 | x = [rand(N, dim) for i in range(numtests)] 42 | correct = ones(numtests, dtype=bool_) 43 | 44 | for i in permutation(numtests): 45 | nns[i] = FLANN() 46 | nns[i].build_index(x[i]) 47 | 48 | # For kicks 49 | if rand() < 0.5: 50 | nns[i].kmeans(x[i], 5) 51 | if rand() < 0.5: 52 | nns[i].nn(x[i], x[i]) 53 | 54 | 55 | for i in permutation(numtests): 56 | nnidx,nndist = nns[i].nn_index(x[i]) 57 | correct[i] = all(nnidx == arange(N, dtype = index_type)) 58 | 59 | for i in reversed(range(numtests)): 60 | if rand() < 0.5: 61 | nns[i].delete_index() 62 | else: 63 | del nns[i] 64 | 65 | self.assertTrue(all(correct)) 66 | 67 | def testnn_index_bad_index_call_noindex(self): 68 | nn = FLANN() 69 | self.assertRaises(FLANNException, lambda: nn.nn_index(rand(5,5))) 70 | 71 | 72 | def testnn_index_bad_index_call_delindex(self): 73 | nn = FLANN() 74 | nn.build_index(rand(5,5)) 75 | nn.delete_index() 76 | 77 | self.assertRaises(FLANNException, lambda: nn.nn_index(rand(5,5))) 78 | 79 | 80 | if __name__ == '__main__': 81 | unittest.main() 82 | -------------------------------------------------------------------------------- /lib/flann/bin/download_checkmd5.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | 3 | import urllib, hashlib, sys, os 4 | from optparse import OptionParser 5 | 6 | class AppURLopener(urllib.FancyURLopener): 7 | version ="Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.0.7) Gecko/20060909 Firefox/1.5.0.7" 8 | 9 | def prompt_user_passwd(self, host, realm): 10 | raise Exception() 11 | urllib._urlopener = AppURLopener() 12 | 13 | def file_md5(file): 14 | m = hashlib.md5() 15 | m.update(open(dest).read()) 16 | return m.hexdigest() 17 | 18 | 19 | def main(): 20 | parser = OptionParser(usage="usage: %prog URI dest [md5sum]", prog=sys.argv[0]) 21 | options, args = parser.parse_args() 22 | md5sum = None 23 | 24 | if len(args)==2: 25 | uri, dest = args 26 | elif len(args)==3: 27 | uri, dest, md5 = args 28 | else: 29 | parser.error("Wrong arguments") 30 | 31 | fresh = False 32 | if not os.path.exists(dest): 33 | print "Downloading from %s to %s..."%(uri, dest), 34 | sys.stdout.flush() 35 | urllib.urlretrieve(uri, dest) 36 | print "done" 37 | fresh = True 38 | 39 | if md5sum: 40 | print "Computing md5sum on downloaded file", 41 | sys.stdout.flush() 42 | checksum = md5_file(dest) 43 | print "done" 44 | 45 | if checksum!=md5sum: 46 | if not fresh: 47 | print "Checksum mismatch (%s != %s), re-downloading file %s"%(checksum, md5sum, dest), 48 | sys.stdout.flush() 49 | os.remove(dest) 50 | urllib.urlretrieve(uri, dest) 51 | print "done" 52 | 53 | print "Computing md5sum on downloaded file", 54 | sys.stdout.flush() 55 | checksum = md5_file(dest) 56 | print "done" 57 | 58 | if checksum!=md5sum: 59 | print "ERROR, checksum mismatch (%s != %s) on %d",(checksum, md5sum, dest) 60 | return 1 61 | return 0 62 | 63 | 64 | if __name__ == '__main__': 65 | try: 66 | sys.exit(main()) 67 | except Exception as e: 68 | print "ERROR, ",e 69 | sys.exit(1) 70 | -------------------------------------------------------------------------------- /lib/flann/src/cpp/flann/mpi/flann_mpi_client.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | 11 | 12 | #define IF_RANK0 if (world.rank()==0) 13 | 14 | timeval start_time_; 15 | void start_timer(const std::string& message = "") 16 | { 17 | if (!message.empty()) { 18 | printf("%s", message.c_str()); 19 | fflush(stdout); 20 | } 21 | gettimeofday(&start_time_,NULL); 22 | } 23 | 24 | double stop_timer() 25 | { 26 | timeval end_time; 27 | gettimeofday(&end_time,NULL); 28 | 29 | return double(end_time.tv_sec-start_time_.tv_sec)+ double(end_time.tv_usec-start_time_.tv_usec)/1000000; 30 | } 31 | 32 | float compute_precision(const flann::Matrix& match, const flann::Matrix& indices) 33 | { 34 | int count = 0; 35 | 36 | assert(match.rows == indices.rows); 37 | size_t nn = std::min(match.cols, indices.cols); 38 | 39 | for(size_t i=0; i query; 58 | flann::Matrix match; 59 | 60 | flann::load_from_file(query, "sift100K.h5","query"); 61 | flann::load_from_file(match, "sift100K.h5","match"); 62 | // flann::load_from_file(gt_dists, "sift100K.h5","dists"); 63 | 64 | flann::mpi::Client index("localhost","9999"); 65 | 66 | int nn = 1; 67 | flann::Matrix indices(new int[query.rows*nn], query.rows, nn); 68 | flann::Matrix dists(new float[query.rows*nn], query.rows, nn); 69 | 70 | start_timer("Performing search...\n"); 71 | index.knnSearch(query, indices, dists, nn, flann::SearchParams(64)); 72 | printf("Search done (%g seconds)\n", stop_timer()); 73 | 74 | printf("Checking results\n"); 75 | float precision = compute_precision(match, indices); 76 | printf("Precision is: %g\n", precision); 77 | 78 | } 79 | catch (std::exception& e) { 80 | std::cerr << "Exception: " << e.what() << "\n"; 81 | } 82 | 83 | return 0; 84 | } 85 | 86 | -------------------------------------------------------------------------------- /lib/ann/ann/src/kd_search.h: -------------------------------------------------------------------------------- 1 | //---------------------------------------------------------------------- 2 | // File: kd_search.h 3 | // Programmer: Sunil Arya and David Mount 4 | // Description: Standard kd-tree search 5 | // Last modified: 01/04/05 (Version 1.0) 6 | //---------------------------------------------------------------------- 7 | // Copyright (c) 1997-2005 University of Maryland and Sunil Arya and 8 | // David Mount. All Rights Reserved. 9 | // 10 | // This software and related documentation is part of the Approximate 11 | // Nearest Neighbor Library (ANN). This software is provided under 12 | // the provisions of the Lesser GNU Public License (LGPL). See the 13 | // file ../ReadMe.txt for further information. 14 | // 15 | // The University of Maryland (U.M.) and the authors make no 16 | // representations about the suitability or fitness of this software for 17 | // any purpose. It is provided "as is" without express or implied 18 | // warranty. 19 | //---------------------------------------------------------------------- 20 | // History: 21 | // Revision 0.1 03/04/98 22 | // Initial release 23 | //---------------------------------------------------------------------- 24 | 25 | #ifndef ANN_kd_search_H 26 | #define ANN_kd_search_H 27 | 28 | #include "../../../ann/ann/include/ANN/ANNperf.h" // performance evaluation 29 | #include "../../../ann/ann/src/kd_tree.h" // kd-tree declarations 30 | #include "../../../ann/ann/src/kd_util.h" // kd-tree utilities 31 | #include "../../../ann/ann/src/pr_queue_k.h" // k-element priority queue 32 | 33 | //---------------------------------------------------------------------- 34 | // More global variables 35 | // These are active for the life of each call to annkSearch(). They 36 | // are set to save the number of variables that need to be passed 37 | // among the various search procedures. 38 | //---------------------------------------------------------------------- 39 | 40 | extern int ANNkdDim; // dimension of space (static copy) 41 | extern ANNpoint ANNkdQ; // query point (static copy) 42 | extern double ANNkdMaxErr; // max tolerable squared error 43 | extern ANNpointArray ANNkdPts; // the points (static copy) 44 | extern ANNmin_k *ANNkdPointMK; // set of k closest points 45 | extern int ANNptsVisited; // number of points visited 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /lib/ann/ann/src/kd_pr_search.h: -------------------------------------------------------------------------------- 1 | //---------------------------------------------------------------------- 2 | // File: kd_pr_search.h 3 | // Programmer: Sunil Arya and David Mount 4 | // Description: Priority kd-tree search 5 | // Last modified: 01/04/05 (Version 1.0) 6 | //---------------------------------------------------------------------- 7 | // Copyright (c) 1997-2005 University of Maryland and Sunil Arya and 8 | // David Mount. All Rights Reserved. 9 | // 10 | // This software and related documentation is part of the Approximate 11 | // Nearest Neighbor Library (ANN). This software is provided under 12 | // the provisions of the Lesser GNU Public License (LGPL). See the 13 | // file ../ReadMe.txt for further information. 14 | // 15 | // The University of Maryland (U.M.) and the authors make no 16 | // representations about the suitability or fitness of this software for 17 | // any purpose. It is provided "as is" without express or implied 18 | // warranty. 19 | //---------------------------------------------------------------------- 20 | // History: 21 | // Revision 0.1 03/04/98 22 | // Initial release 23 | //---------------------------------------------------------------------- 24 | 25 | #ifndef ANN_kd_pr_search_H 26 | #define ANN_kd_pr_search_H 27 | 28 | #include "../../../ann/ann/include/ANN/ANNperf.h" // performance evaluation 29 | #include "../../../ann/ann/src/kd_tree.h" // kd-tree declarations 30 | #include "../../../ann/ann/src/kd_util.h" // kd-tree utilities 31 | #include "../../../ann/ann/src/pr_queue.h" // priority queue declarations 32 | #include "../../../ann/ann/src/pr_queue_k.h" // k-element priority queue 33 | 34 | //---------------------------------------------------------------------- 35 | // Global variables 36 | // Active for the life of each call to Appx_Near_Neigh() or 37 | // Appx_k_Near_Neigh(). 38 | //---------------------------------------------------------------------- 39 | 40 | extern double ANNprEps; // the error bound 41 | extern int ANNprDim; // dimension of space 42 | extern ANNpoint ANNprQ; // query point 43 | extern double ANNprMaxErr; // max tolerable squared error 44 | extern ANNpointArray ANNprPts; // the points 45 | extern ANNpr_queue *ANNprBoxPQ; // priority queue for boxes 46 | extern ANNmin_k *ANNprPointMK; // set of k closest points 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /lib/flann/src/cpp/flann/mpi/matrix.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Copyright 2008-2011 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. 5 | * Copyright 2008-2011 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | *************************************************************************/ 28 | 29 | 30 | #ifndef MPI_MATRIX_H_ 31 | #define MPI_MATRIX_H_ 32 | 33 | #include 34 | #include 35 | 36 | 37 | namespace boost { 38 | namespace serialization { 39 | 40 | template 41 | void serialize(Archive & ar, flann::Matrix & matrix, const unsigned int version) 42 | { 43 | ar & matrix.rows & matrix.cols & matrix.stride; 44 | if (Archive::is_loading::value) { 45 | matrix = flann::Matrix(new T[matrix.rows*matrix.cols], matrix.rows, matrix.cols, matrix.stride); 46 | } 47 | ar & boost::serialization::make_array(matrix.ptr(), matrix.rows*matrix.cols); 48 | } 49 | 50 | } 51 | } 52 | 53 | 54 | #endif /* MPI_MATRIX_H_ */ 55 | -------------------------------------------------------------------------------- /lib/ann/ann/MS_Win32/Makefile: -------------------------------------------------------------------------------- 1 | #----------------------------------------------------------------------------- 2 | # Makefile for Windows Versions. 3 | # 4 | # ANN: Approximate Nearest Neighbors 5 | # Version: 1.1.1 08/04/06 6 | #----------------------------------------------------------------------------- 7 | # Copyright (c) 1997-2005 University of Maryland and Sunil Arya and 8 | # David Mount. All Rights Reserved. 9 | # 10 | # This software and related documentation is part of the Approximate 11 | # Nearest Neighbor Library (ANN). This software is provided under 12 | # the provisions of the Lesser GNU Public License (LGPL). See the 13 | # file ../ReadMe.txt for further information. 14 | # 15 | # The University of Maryland (U.M.) and the authors make no 16 | # representations about the suitability or fitness of this software for 17 | # any purpose. It is provided "as is" without express or implied 18 | # warranty. 19 | #----------------------------------------------------------------------------- 20 | # Revision 1.0 05/03/05 21 | # Initial release 22 | # Revision 1.1.1 08/04/06 23 | # Added copyright/license 24 | #----------------------------------------------------------------------------- 25 | 26 | #----------------------------------------------------------------------------- 27 | # This is not used for compiling the dll. It is just used for cleaning 28 | # things up for distribution. For compilcation, open the Ann.sln 29 | # solution file in Microsoft Windows Visual Studio.NET. 30 | #----------------------------------------------------------------------------- 31 | 32 | default: 33 | @echo "Enter one of the following:" 34 | @echo " make clean remove object files" 35 | @echo " make realclean remove library and executable files" 36 | @echo " " 37 | @echo "See file Makefile for other compilation options." 38 | 39 | #----------------------------------------------------------------------------- 40 | # Remove .o files and core files 41 | #----------------------------------------------------------------------------- 42 | clean: 43 | -rm -f -r ann2fig/Debug ann2fig/Release 44 | -rm -f -r dll/Debug dll/Release 45 | -rm -f -r sample/Debug sample/Release 46 | -rm -f -r test/Debug test/Release 47 | -rm -f Ann.ncb Ann.suo 48 | 49 | #----------------------------------------------------------------------------- 50 | # Remove everthing that can be remade 51 | #----------------------------------------------------------------------------- 52 | realclean: clean 53 | -rm -f bin/* 54 | -------------------------------------------------------------------------------- /lib/flann/src/matlab/flann_build_index.m: -------------------------------------------------------------------------------- 1 | function [index, params, speedup] = flann_build_index(dataset, build_params) 2 | %FLANN_BUILD_INDEX Builds an index for fast approximate nearest neighbors search 3 | % 4 | % [index, params, speedup] = flann_build_index(dataset, build_params) - Constructs the 5 | % index from the provided 'dataset' and (optionally) computes the optimal parameters. 6 | 7 | % Marius Muja, January 2008 8 | 9 | algos = struct( 'linear', 0, 'kdtree', 1, 'kmeans', 2, 'composite', 3, 'kdtree_single', 4, 'hierarchical', 5, 'lsh', 6, 'saved', 254, 'autotuned', 255 ); 10 | center_algos = struct('random', 0, 'gonzales', 1, 'kmeanspp', 2 ); 11 | log_levels = struct('none', 0, 'fatal', 1, 'error', 2, 'warning', 3, 'info', 4); 12 | 13 | default_params = struct('algorithm', 'kdtree' ,'checks', 32, 'eps', 0.0, 'sorted', 1, 'max_neighbors', -1, 'cores', 1, 'trees', 4, 'branching', 32, 'iterations', 5, 'centers_init', 'random', 'cb_index', 0.4, 'target_precision', 0.9,'build_weight', 0.01, 'memory_weight', 0, 'sample_fraction', 0.1, 'table_number', 12, 'key_size', 20, 'multi_probe_level', 2, 'log_level', 'warning', 'random_seed', 0); 14 | 15 | if ~isstruct(build_params) 16 | error('The "build_params" argument must be a structure'); 17 | end 18 | 19 | params = default_params; 20 | fn = fieldnames(build_params); 21 | for i = [1:length(fn)], 22 | name = cell2mat(fn(i)); 23 | params.(name) = build_params.(name); 24 | end 25 | if ~isnumeric(params.algorithm), 26 | params.algorithm = value2id(algos,params.algorithm); 27 | end 28 | if ~isnumeric(params.centers_init), 29 | params.centers_init = value2id(center_algos,params.centers_init); 30 | end 31 | if ~isnumeric(params.log_level), 32 | params.log_level = value2id(log_levels,params.log_level); 33 | end 34 | 35 | [index, params, speedup] = nearest_neighbors('build_index',dataset, params); 36 | 37 | if isnumeric(params.algorithm), 38 | params.algorithm = id2value(algos,params.algorithm); 39 | end 40 | if isnumeric(params.centers_init), 41 | params.centers_init = id2value(center_algos,params.centers_init); 42 | end 43 | end 44 | 45 | function value = id2value(map, id) 46 | fields = fieldnames(map); 47 | for i = 1:length(fields), 48 | val = cell2mat(fields(i)); 49 | if map.(val) == id 50 | value = val; 51 | break; 52 | end 53 | end 54 | end 55 | function id = value2id(map,value) 56 | id = map.(value); 57 | end 58 | -------------------------------------------------------------------------------- /lib/flann/test/test_nn_autotune.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import sys 3 | from os.path import * 4 | import os 5 | from pyflann import * 6 | from copy import copy 7 | from numpy import * 8 | from numpy.random import * 9 | import unittest 10 | 11 | class Test_PyFLANN_nn(unittest.TestCase): 12 | 13 | def setUp(self): 14 | self.nn = FLANN(log_level="warning") 15 | 16 | ################################################################################ 17 | # The typical 18 | 19 | def test_nn_2d_10pt(self): 20 | self.__nd_random_test_autotune(2, 2) 21 | 22 | def test_nn_autotune_2d_1000pt(self): 23 | self.__nd_random_test_autotune(2, 1000) 24 | 25 | def test_nn_autotune_100d_1000pt(self): 26 | self.__nd_random_test_autotune(100, 1000) 27 | 28 | def test_nn_autotune_500d_100pt(self): 29 | self.__nd_random_test_autotune(500, 100) 30 | 31 | # 32 | # ########################################################################################## 33 | # # Stress it should handle 34 | # 35 | def test_nn_stress_1d_1pt_kmeans_autotune(self): 36 | self.__nd_random_test_autotune(1, 1) 37 | 38 | def __ensure_list(self,arg): 39 | if type(arg)!=list: 40 | return [arg] 41 | else: 42 | return arg 43 | 44 | 45 | def __nd_random_test_autotune(self, dim, N, num_neighbors = 1, **kwargs): 46 | """ 47 | Make a set of random points, then pass the same ones to the 48 | query points. Each point should be closest to itself. 49 | """ 50 | seed(0) 51 | x = rand(N, dim) 52 | xq = rand(N, dim) 53 | perm = permutation(N) 54 | 55 | # compute ground truth nearest neighbors 56 | gt_idx, gt_dist = self.nn.nn(x,xq, 57 | algorithm='linear', 58 | num_neighbors=num_neighbors) 59 | 60 | for tp in [0.70, 0.80, 0.90]: 61 | nidx,ndist = self.nn.nn(x, xq, 62 | algorithm='autotuned', 63 | sample_fraction=1.0, 64 | num_neighbors = num_neighbors, 65 | target_precision = tp, checks=-2, **kwargs) 66 | 67 | correctness = 0.0 68 | for i in range(N): 69 | l1 = self.__ensure_list(nidx[i]) 70 | l2 = self.__ensure_list(gt_idx[i]) 71 | correctness += float(len(set(l1).intersection(l2)))/num_neighbors 72 | correctness /= N 73 | self.assertTrue(correctness >= tp*0.9, 74 | 'failed #1: targ_prec=%f, N=%d,correctness=%f' % (tp, N, correctness)) 75 | 76 | if __name__ == '__main__': 77 | unittest.main() 78 | -------------------------------------------------------------------------------- /lib/flann/src/ruby/flann.gemspec: -------------------------------------------------------------------------------- 1 | # Copyright 2014 John O. Woods (john.o.woods@gmail.com), West Virginia 2 | # University's Applied Space Exploration Lab, and West Virginia Robotic 3 | # Technology Center. All rights reserved. 4 | # 5 | # THE BSD LICENSE 6 | # 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions 9 | # are met: 10 | # 11 | # 1. Redistributions of source code must retain the above copyright 12 | # notice, this list of conditions and the following disclaimer. 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | 28 | lib = File.expand_path('../lib/', __FILE__) 29 | $:.unshift lib unless $:.include?(lib) 30 | 31 | require 'flann/version' 32 | 33 | Gem::Specification.new do |gem| 34 | gem.name = "flann" 35 | gem.version = Flann::VERSION::STRING 36 | gem.summary = "Ruby interface for FLANN, approximate nearest neighbors methods in C" 37 | gem.description = "Ruby interface for FLANN, approximate nearest neighbors methods in C" 38 | gem.homepage = 'http://www.cs.ubc.ca/research/flann/' 39 | gem.authors = ['John Woods'] 40 | gem.email = ['john.o.woods@gmail.com'] 41 | gem.license = 'BSD 2-clause' 42 | #gem.post_install_message = <<-EOF 43 | #EOF 44 | 45 | gem.files = `git ls-files`.split("\n") 46 | gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") 47 | gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } 48 | gem.require_paths = ["lib"] 49 | 50 | gem.required_ruby_version = '>= 2.0' 51 | 52 | gem.add_dependency 'rdoc' 53 | gem.add_development_dependency 'rake' 54 | gem.add_development_dependency 'bundler' 55 | gem.add_development_dependency 'rspec' 56 | gem.add_development_dependency 'rspec-longrun' 57 | gem.add_development_dependency 'pry' 58 | end 59 | 60 | -------------------------------------------------------------------------------- /lib/ann/ann/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ANN: Approximate Nearest Neighbors 2 | Version: 1.1.2 3 | Release date: Jan 27, 2010 4 | ---------------------------------------------------------------------------- 5 | Copyright (c) 1997-2010 University of Maryland and Sunil Arya and David 6 | Mount. All Rights Reserved. See Copyright.txt and License.txt for 7 | complete information on terms and conditions of use and distribution of 8 | this software. 9 | ---------------------------------------------------------------------------- 10 | 11 | Authors 12 | ------- 13 | David Mount 14 | Dept of Computer Science 15 | University of Maryland, 16 | College Park, MD 20742 USA 17 | mount@cs.umd.edu 18 | http://www.cs.umd.edu/~mount/ 19 | 20 | Sunil Arya 21 | Dept of Computer Science 22 | Hong University of Science and Technology 23 | Clearwater Bay, HONG KONG 24 | arya@cs.ust.hk 25 | http://www.cs.ust.hk/faculty/arya/ 26 | 27 | Introduction 28 | ------------ 29 | ANN is a library written in the C++ programming language to support both 30 | exact and approximate nearest neighbor searching in spaces of various 31 | dimensions. It was implemented by David M. Mount of the University of 32 | Maryland, and Sunil Arya of the Hong Kong University of Science and 33 | Technology. ANN (pronounced like the name ``Ann'') stands for 34 | Approximate Nearest Neighbors. ANN is also a testbed containing 35 | programs and procedures for generating data sets, collecting and 36 | analyzing statistics on the performance of nearest neighbor algorithms 37 | and data structures, and visualizing the geometric structure of these 38 | data structures. 39 | 40 | The ANN source code and documentation is available from the following 41 | web page: 42 | 43 | http://www.cs.umd.edu/~mount/ANN 44 | 45 | For more information on ANN and its use, see the ``ANN Programming 46 | Manual,'' which is provided with the software distribution. 47 | 48 | ---------------------------------------------------------------------------- 49 | History 50 | Version 0.1 03/04/98 51 | Preliminary release 52 | Version 0.2 06/24/98 53 | Changes for SGI compiler. 54 | Version 1.0 04/01/05 55 | Fixed a number of small bugs 56 | Added dump/load operations 57 | Added annClose to eliminate minor memory leak 58 | Improved compatibility with current C++ compilers 59 | Added compilation for Microsoft Visual Studio.NET 60 | Added compilation for Linux 2.x 61 | Version 1.1 05/03/05 62 | Added make target for Mac OS X 63 | Added fixed-radius range searching and counting 64 | Added instructions on compiling/using ANN on Windows platforms 65 | Fixed minor output bug in ann2fig 66 | Version 1.1.1 08/04/06 67 | Added "planted" distribution 68 | Updated old source comments for GNU LPL. 69 | Version 1.1.2 01/27/10 70 | Fixed minor compilation bugs for new versions of gcc 71 | -------------------------------------------------------------------------------- /lib/ann/ann/MS_Win32/Ann.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 10.00 2 | # Visual Studio 2008 3 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dll", "dll\dll.vcproj", "{A7D00B21-CB9C-4BBB-8DEE-51025104F867}" 4 | EndProject 5 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sample", "sample\sample.vcproj", "{C76F5A10-7A4A-4546-9414-296DB38BE825}" 6 | ProjectSection(ProjectDependencies) = postProject 7 | {A7D00B21-CB9C-4BBB-8DEE-51025104F867} = {A7D00B21-CB9C-4BBB-8DEE-51025104F867} 8 | EndProjectSection 9 | EndProject 10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test\test.vcproj", "{6AC673C7-7B3F-4520-A761-647B212A4BEF}" 11 | ProjectSection(ProjectDependencies) = postProject 12 | {A7D00B21-CB9C-4BBB-8DEE-51025104F867} = {A7D00B21-CB9C-4BBB-8DEE-51025104F867} 13 | EndProjectSection 14 | EndProject 15 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ann2fig", "ann2fig\ann2fig.vcproj", "{622DD7D8-0C0A-4303-9176-C9A8AF467E70}" 16 | ProjectSection(ProjectDependencies) = postProject 17 | {A7D00B21-CB9C-4BBB-8DEE-51025104F867} = {A7D00B21-CB9C-4BBB-8DEE-51025104F867} 18 | EndProjectSection 19 | EndProject 20 | Global 21 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 22 | Debug|Win32 = Debug|Win32 23 | Release|Win32 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 26 | {A7D00B21-CB9C-4BBB-8DEE-51025104F867}.Debug|Win32.ActiveCfg = Debug|Win32 27 | {A7D00B21-CB9C-4BBB-8DEE-51025104F867}.Debug|Win32.Build.0 = Debug|Win32 28 | {A7D00B21-CB9C-4BBB-8DEE-51025104F867}.Release|Win32.ActiveCfg = Release|Win32 29 | {A7D00B21-CB9C-4BBB-8DEE-51025104F867}.Release|Win32.Build.0 = Release|Win32 30 | {C76F5A10-7A4A-4546-9414-296DB38BE825}.Debug|Win32.ActiveCfg = Debug|Win32 31 | {C76F5A10-7A4A-4546-9414-296DB38BE825}.Debug|Win32.Build.0 = Debug|Win32 32 | {C76F5A10-7A4A-4546-9414-296DB38BE825}.Release|Win32.ActiveCfg = Release|Win32 33 | {C76F5A10-7A4A-4546-9414-296DB38BE825}.Release|Win32.Build.0 = Release|Win32 34 | {6AC673C7-7B3F-4520-A761-647B212A4BEF}.Debug|Win32.ActiveCfg = Debug|Win32 35 | {6AC673C7-7B3F-4520-A761-647B212A4BEF}.Debug|Win32.Build.0 = Debug|Win32 36 | {6AC673C7-7B3F-4520-A761-647B212A4BEF}.Release|Win32.ActiveCfg = Release|Win32 37 | {6AC673C7-7B3F-4520-A761-647B212A4BEF}.Release|Win32.Build.0 = Release|Win32 38 | {622DD7D8-0C0A-4303-9176-C9A8AF467E70}.Debug|Win32.ActiveCfg = Debug|Win32 39 | {622DD7D8-0C0A-4303-9176-C9A8AF467E70}.Debug|Win32.Build.0 = Debug|Win32 40 | {622DD7D8-0C0A-4303-9176-C9A8AF467E70}.Release|Win32.ActiveCfg = Release|Win32 41 | {622DD7D8-0C0A-4303-9176-C9A8AF467E70}.Release|Win32.Build.0 = Release|Win32 42 | EndGlobalSection 43 | GlobalSection(SolutionProperties) = preSolution 44 | HideSolutionNode = FALSE 45 | EndGlobalSection 46 | EndGlobal 47 | -------------------------------------------------------------------------------- /lib/flann/src/cpp/flann/util/timer.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. 5 | * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. 6 | * 7 | * THE BSD LICENSE 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | *************************************************************************/ 30 | 31 | #ifndef FLANN_TIMER_H 32 | #define FLANN_TIMER_H 33 | 34 | #include 35 | 36 | 37 | namespace flann 38 | { 39 | 40 | /** 41 | * A start-stop timer class. 42 | * 43 | * Can be used to time portions of code. 44 | */ 45 | class StartStopTimer 46 | { 47 | clock_t startTime; 48 | 49 | public: 50 | /** 51 | * Value of the timer. 52 | */ 53 | double value; 54 | 55 | 56 | /** 57 | * Constructor. 58 | */ 59 | StartStopTimer() 60 | { 61 | reset(); 62 | } 63 | 64 | /** 65 | * Starts the timer. 66 | */ 67 | void start() 68 | { 69 | startTime = clock(); 70 | } 71 | 72 | /** 73 | * Stops the timer and updates timer value. 74 | */ 75 | double stop() 76 | { 77 | clock_t stopTime = clock(); 78 | value += ( (double)stopTime - startTime) / CLOCKS_PER_SEC; 79 | 80 | return value; 81 | } 82 | 83 | /** 84 | * Resets the timer value to 0. 85 | */ 86 | void reset() 87 | { 88 | value = 0; 89 | } 90 | 91 | }; 92 | 93 | } 94 | 95 | #endif // FLANN_TIMER_H 96 | -------------------------------------------------------------------------------- /lib/flann/src/cpp/flann/util/sampling.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. 5 | * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | *************************************************************************/ 28 | 29 | 30 | #ifndef FLANN_SAMPLING_H_ 31 | #define FLANN_SAMPLING_H_ 32 | 33 | #include "flann/util/matrix.h" 34 | #include "flann/util/random.h" 35 | 36 | namespace flann 37 | { 38 | 39 | template 40 | Matrix random_sample(Matrix& srcMatrix, size_t size, bool remove = false) 41 | { 42 | UniqueRandom rand_unique(srcMatrix.rows); 43 | Matrix newSet(new T[size * srcMatrix.cols], size,srcMatrix.cols); 44 | 45 | T* src,* dest; 46 | for (size_t i=0; i(rand_int(srcMatrix.rows-i)); 50 | } 51 | else { 52 | r = static_cast(rand_unique.next()); 53 | } 54 | dest = newSet[i]; 55 | src = srcMatrix[r]; 56 | std::copy(src, src+srcMatrix.cols, dest); 57 | if (remove) { 58 | src = srcMatrix[srcMatrix.rows-i-1]; 59 | dest = srcMatrix[r]; 60 | std::copy(src, src+srcMatrix.cols, dest); 61 | } 62 | } 63 | if (remove) { 64 | srcMatrix.rows -= size; 65 | } 66 | return newSet; 67 | } 68 | 69 | } // namespace 70 | 71 | 72 | #endif /* FLANN_SAMPLING_H_ */ 73 | -------------------------------------------------------------------------------- /lib/ann/ann/src/bd_search.cpp: -------------------------------------------------------------------------------- 1 | //---------------------------------------------------------------------- 2 | // File: bd_search.cpp 3 | // Programmer: David Mount 4 | // Description: Standard bd-tree search 5 | // Last modified: 01/04/05 (Version 1.0) 6 | //---------------------------------------------------------------------- 7 | // Copyright (c) 1997-2005 University of Maryland and Sunil Arya and 8 | // David Mount. All Rights Reserved. 9 | // 10 | // This software and related documentation is part of the Approximate 11 | // Nearest Neighbor Library (ANN). This software is provided under 12 | // the provisions of the Lesser GNU Public License (LGPL). See the 13 | // file ../ReadMe.txt for further information. 14 | // 15 | // The University of Maryland (U.M.) and the authors make no 16 | // representations about the suitability or fitness of this software for 17 | // any purpose. It is provided "as is" without express or implied 18 | // warranty. 19 | //---------------------------------------------------------------------- 20 | // History: 21 | // Revision 0.1 03/04/98 22 | // Initial release 23 | //---------------------------------------------------------------------- 24 | 25 | #include "../../../ann/ann/src/bd_tree.h" // bd-tree declarations 26 | #include "../../../ann/ann/src/kd_search.h" // kd-tree search declarations 27 | 28 | //---------------------------------------------------------------------- 29 | // Approximate searching for bd-trees. 30 | // See the file kd_search.cpp for general information on the 31 | // approximate nearest neighbor search algorithm. Here we 32 | // include the extensions for shrinking nodes. 33 | //---------------------------------------------------------------------- 34 | 35 | //---------------------------------------------------------------------- 36 | // bd_shrink::ann_search - search a shrinking node 37 | //---------------------------------------------------------------------- 38 | 39 | void ANNbd_shrink::ann_search(ANNdist box_dist) 40 | { 41 | // check dist calc term cond. 42 | if (ANNmaxPtsVisited != 0 && ANNptsVisited > ANNmaxPtsVisited) return; 43 | 44 | ANNdist inner_dist = 0; // distance to inner box 45 | for (int i = 0; i < n_bnds; i++) { // is query point in the box? 46 | if (bnds[i].out(ANNkdQ)) { // outside this bounding side? 47 | // add to inner distance 48 | inner_dist = (ANNdist) ANN_SUM(inner_dist, bnds[i].dist(ANNkdQ)); 49 | } 50 | } 51 | if (inner_dist <= box_dist) { // if inner box is closer 52 | child[ANN_IN]->ann_search(inner_dist); // search inner child first 53 | child[ANN_OUT]->ann_search(box_dist); // ...then outer child 54 | } 55 | else { // if outer box is closer 56 | child[ANN_OUT]->ann_search(box_dist); // search outer child first 57 | child[ANN_IN]->ann_search(inner_dist); // ...then outer child 58 | } 59 | ANN_FLOP(3*n_bnds) // increment floating ops 60 | ANN_SHR(1) // one more shrinking node 61 | } 62 | -------------------------------------------------------------------------------- /lib/ann/ann/src/bd_fix_rad_search.cpp: -------------------------------------------------------------------------------- 1 | //---------------------------------------------------------------------- 2 | // File: bd_fix_rad_search.cpp 3 | // Programmer: David Mount 4 | // Description: Standard bd-tree search 5 | // Last modified: 05/03/05 (Version 1.1) 6 | //---------------------------------------------------------------------- 7 | // Copyright (c) 1997-2005 University of Maryland and Sunil Arya and 8 | // David Mount. All Rights Reserved. 9 | // 10 | // This software and related documentation is part of the Approximate 11 | // Nearest Neighbor Library (ANN). This software is provided under 12 | // the provisions of the Lesser GNU Public License (LGPL). See the 13 | // file ../ReadMe.txt for further information. 14 | // 15 | // The University of Maryland (U.M.) and the authors make no 16 | // representations about the suitability or fitness of this software for 17 | // any purpose. It is provided "as is" without express or implied 18 | // warranty. 19 | //---------------------------------------------------------------------- 20 | // History: 21 | // Revision 1.1 05/03/05 22 | // Initial release 23 | //---------------------------------------------------------------------- 24 | 25 | #include "../../../ann/ann/src/bd_tree.h" // bd-tree declarations 26 | #include "../../../ann/ann/src/kd_fix_rad_search.h" // kd-tree FR search declarations 27 | 28 | //---------------------------------------------------------------------- 29 | // Approximate searching for bd-trees. 30 | // See the file kd_FR_search.cpp for general information on the 31 | // approximate nearest neighbor search algorithm. Here we 32 | // include the extensions for shrinking nodes. 33 | //---------------------------------------------------------------------- 34 | 35 | //---------------------------------------------------------------------- 36 | // bd_shrink::ann_FR_search - search a shrinking node 37 | //---------------------------------------------------------------------- 38 | 39 | void ANNbd_shrink::ann_FR_search(ANNdist box_dist) 40 | { 41 | // check dist calc term cond. 42 | if (ANNmaxPtsVisited != 0 && ANNptsVisited > ANNmaxPtsVisited) return; 43 | 44 | ANNdist inner_dist = 0; // distance to inner box 45 | for (int i = 0; i < n_bnds; i++) { // is query point in the box? 46 | if (bnds[i].out(ANNkdFRQ)) { // outside this bounding side? 47 | // add to inner distance 48 | inner_dist = (ANNdist) ANN_SUM(inner_dist, bnds[i].dist(ANNkdFRQ)); 49 | } 50 | } 51 | if (inner_dist <= box_dist) { // if inner box is closer 52 | child[ANN_IN]->ann_FR_search(inner_dist);// search inner child first 53 | child[ANN_OUT]->ann_FR_search(box_dist);// ...then outer child 54 | } 55 | else { // if outer box is closer 56 | child[ANN_OUT]->ann_FR_search(box_dist);// search outer child first 57 | child[ANN_IN]->ann_FR_search(inner_dist);// ...then outer child 58 | } 59 | ANN_FLOP(3*n_bnds) // increment floating ops 60 | ANN_SHR(1) // one more shrinking node 61 | } 62 | -------------------------------------------------------------------------------- /lib/rapidxml/license.txt: -------------------------------------------------------------------------------- 1 | Use of this software is granted under one of the following two licenses, 2 | to be chosen freely by the user. 3 | 4 | 1. Boost Software License - Version 1.0 - August 17th, 2003 5 | =============================================================================== 6 | 7 | Copyright (c) 2006, 2007 Marcin Kalicinski 8 | 9 | Permission is hereby granted, free of charge, to any person or organization 10 | obtaining a copy of the software and accompanying documentation covered by 11 | this license (the "Software") to use, reproduce, display, distribute, 12 | execute, and transmit the Software, and to prepare derivative works of the 13 | Software, and to permit third-parties to whom the Software is furnished to 14 | do so, all subject to the following: 15 | 16 | The copyright notices in the Software and this entire statement, including 17 | the above license grant, this restriction and the following disclaimer, 18 | must be included in all copies of the Software, in whole or in part, and 19 | all derivative works of the Software, unless such copies or derivative 20 | works are solely in the form of machine-executable object code generated by 21 | a source language processor. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 26 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 27 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 28 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 29 | DEALINGS IN THE SOFTWARE. 30 | 31 | 2. The MIT License 32 | =============================================================================== 33 | 34 | Copyright (c) 2006, 2007 Marcin Kalicinski 35 | 36 | Permission is hereby granted, free of charge, to any person obtaining a copy 37 | of this software and associated documentation files (the "Software"), to deal 38 | in the Software without restriction, including without limitation the rights 39 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 40 | of the Software, and to permit persons to whom the Software is furnished to do so, 41 | subject to the following conditions: 42 | 43 | The above copyright notice and this permission notice shall be included in all 44 | copies or substantial portions of the Software. 45 | 46 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 47 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 48 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 49 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 50 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 51 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 52 | IN THE SOFTWARE. 53 | -------------------------------------------------------------------------------- /lib/flann/examples/flann_example.c: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | 9 | float* read_points(const char* filename, int rows, int cols) 10 | { 11 | float* data; 12 | float *p; 13 | FILE* fin; 14 | int i,j; 15 | 16 | fin = fopen(filename,"r"); 17 | if (!fin) { 18 | printf("Cannot open input file.\n"); 19 | exit(1); 20 | } 21 | 22 | data = (float*) malloc(rows*cols*sizeof(float)); 23 | if (!data) { 24 | printf("Cannot allocate memory.\n"); 25 | exit(1); 26 | } 27 | p = data; 28 | 29 | for (i=0;iinsert(box_dist,child[ANN_OUT]); 51 | // continue with inner child 52 | child[ANN_IN]->ann_pri_search(inner_dist); 53 | } 54 | else { // if outer box is closer 55 | if (child[ANN_IN] != KD_TRIVIAL) // enqueue inner if not trivial 56 | ANNprBoxPQ->insert(inner_dist,child[ANN_IN]); 57 | // continue with outer child 58 | child[ANN_OUT]->ann_pri_search(box_dist); 59 | } 60 | ANN_FLOP(3*n_bnds) // increment floating ops 61 | ANN_SHR(1) // one more shrinking node 62 | } 63 | -------------------------------------------------------------------------------- /lib/ann/ann/test/test1.save: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------ 2 | ann_test: Version 1.0 3 | Copyright: David M. Mount and Sunil Arya. 4 | Latest Revision: Mar 1, 2005. 5 | ------------------------------------------------------------ 6 | 7 | validate = on (Warning: this may slow execution time.) 8 | stats = query_stats 9 | [Read Data Points: 10 | data_size = 20 11 | file_name = test1-data.pts 12 | dim = 2 13 | ] 14 | [Read Query Points: 15 | query_size = 10 16 | file_name = test1-query.pts 17 | dim = 2 18 | ] 19 | [Build ann-structure: 20 | split_rule = suggest 21 | shrink_rule = none 22 | data_size = 20 23 | dim = 2 24 | bucket_size = 1 25 | process_time = 0 sec 26 | (Structure Statistics: 27 | n_nodes = 39 (opt = 40, best if < 400) 28 | n_leaves = 20 (0 contain no points) 29 | n_splits = 19 30 | n_shrinks = 0 31 | empty_leaves = 0 percent (best if < 50 percent) 32 | depth = 6 (opt = 4, best if < 17) 33 | avg_aspect_ratio = 1.48847 (best if < 20) 34 | ) 35 | ] 36 | (Computing true nearest neighbors for validation. This may take time.) 37 | [Run Queries: 38 | query_size = 10 39 | dim = 2 40 | search_method = standard 41 | epsilon = 0 42 | near_neigh = 3 43 | true_nn = 13 44 | query_time = 0 sec/query (biased by perf measurements) 45 | (Performance stats: [ mean : stddev ]< min , max > 46 | leaf_nodes = [ 6.3 : 2.751 ]< 4 , 11 > 47 | splitting_nodes = [ 8.8 : 3.676 ]< 5 , 15 > 48 | shrinking_nodes = [ 0 : 0 ]< 0 , 0 > 49 | total_nodes = [ 15.1 : 6.35 ]< 9 , 26 > 50 | points_visited = [ 6.3 : 2.751 ]< 4 , 11 > 51 | coord_hits/pt = [ 0.57 : 0.2201 ]< 0.35 , 0.95 > 52 | floating_ops_(K) = [ 0.156 : 0.0563 ]< 0.101 , 0.254 > 53 | average_error = [ 0 : 0 ]< 0 , 0 > 54 | rank_error = [ 0 : 0 ]< 0 , 0 > 55 | ) 56 | ] 57 | [Run Queries: 58 | query_size = 10 59 | dim = 2 60 | search_method = priority 61 | epsilon = 0 62 | near_neigh = 3 63 | true_nn = 13 64 | query_time = 0 sec/query (biased by perf measurements) 65 | (Performance stats: [ mean : stddev ]< min , max > 66 | leaf_nodes = [ 5.9 : 2.025 ]< 4 , 9 > 67 | splitting_nodes = [ 8.7 : 3.498 ]< 5 , 15 > 68 | shrinking_nodes = [ 0 : 0 ]< 0 , 0 > 69 | total_nodes = [ 14.6 : 5.42 ]< 9 , 24 > 70 | points_visited = [ 5.9 : 2.025 ]< 4 , 9 > 71 | coord_hits/pt = [ 0.535 : 0.1667 ]< 0.35 , 0.8 > 72 | floating_ops_(K) = [ 0.1719 : 0.05861 ]< 0.114 , 0.267 > 73 | average_error = [ 0 : 0 ]< 0 , 0 > 74 | rank_error = [ 0 : 0 ]< 0 , 0 > 75 | ) 76 | ] 77 | -------------------------------------------------------------------------------- /lib/flann/test/flann_linear_test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | 7 | #include "flann_tests.h" 8 | 9 | using namespace flann; 10 | 11 | /** 12 | * Test fixture for SIFT 10K dataset 13 | */ 14 | class Linear_SIFT10K : public DatasetTestFixture { 15 | protected: 16 | Linear_SIFT10K() : DatasetTestFixture("sift10K.h5") {} 17 | }; 18 | 19 | 20 | TEST_F(Linear_SIFT10K, TestSearch) 21 | { 22 | TestSearch >(data, flann::LinearIndexParams(), 23 | query, indices, dists, knn, flann::SearchParams(0), 1.0, gt_indices); 24 | } 25 | 26 | TEST_F(Linear_SIFT10K, TestSearch2) 27 | { 28 | TestSearch2 >(data, flann::LinearIndexParams(), 29 | query, indices, dists, knn, flann::SearchParams(0), 1.0, gt_indices); 30 | } 31 | 32 | TEST_F(Linear_SIFT10K, TestRemove) 33 | { 34 | TestRemove >(data, flann::LinearIndexParams(), 35 | query, indices, dists, knn, flann::SearchParams(0)); 36 | } 37 | 38 | 39 | TEST_F(Linear_SIFT10K, TestSave) 40 | { 41 | TestSave >(data, flann::LinearIndexParams(), 42 | query, indices, dists, knn, flann::SearchParams(0), 1.0, gt_indices); 43 | } 44 | 45 | TEST_F(Linear_SIFT10K, TestCopy) 46 | { 47 | TestCopy >(data, flann::LinearIndexParams(), 48 | query, indices, dists, knn, flann::SearchParams(0), 1.0, gt_indices); 49 | } 50 | 51 | 52 | TEST_F(Linear_SIFT10K, TestCopy2) 53 | { 54 | TestCopy >(data, flann::LinearIndexParams(), 55 | query, indices, dists, knn, flann::SearchParams(0), 1.0, gt_indices); 56 | } 57 | 58 | 59 | /** 60 | * Test fixture for SIFT 100K dataset 61 | */ 62 | class Linear_SIFT100K : public DatasetTestFixture { 63 | protected: 64 | Linear_SIFT100K() : DatasetTestFixture("sift100K.h5") {} 65 | }; 66 | 67 | 68 | TEST_F(Linear_SIFT100K, TestSearch) 69 | { 70 | TestSearch >(data, flann::LinearIndexParams(), 71 | query, indices, dists, knn, flann::SearchParams(0), 1.0, gt_indices); 72 | } 73 | 74 | 75 | /** 76 | * Test fixture for SIFT 10K dataset with byte feature elements 77 | */ 78 | class Linear_SIFT10K_byte : public DatasetTestFixture { 79 | protected: 80 | Linear_SIFT10K_byte() : DatasetTestFixture("sift10K_byte.h5") {} 81 | }; 82 | 83 | 84 | 85 | TEST_F(Linear_SIFT10K_byte, Linear) 86 | { 87 | TestSearch >(data, flann::LinearIndexParams(), 88 | query, indices, dists, knn, flann::SearchParams(0), 1.0, gt_indices); 89 | } 90 | 91 | 92 | 93 | 94 | class Linear_SIFT100K_byte : public DatasetTestFixture { 95 | protected: 96 | Linear_SIFT100K_byte() : DatasetTestFixture("sift100K_byte.h5") {} 97 | }; 98 | 99 | 100 | 101 | TEST_F(Linear_SIFT100K_byte, TestSearch) 102 | { 103 | TestSearch >(data, flann::LinearIndexParams(), 104 | query, indices, dists, knn, flann::SearchParams(0), 1.0, gt_indices); 105 | } 106 | 107 | 108 | 109 | int main(int argc, char** argv) 110 | { 111 | testing::InitGoogleTest(&argc, argv); 112 | return RUN_ALL_TESTS(); 113 | } 114 | -------------------------------------------------------------------------------- /lib/flann/src/cpp/flann/util/object_factory.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. 5 | * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. 6 | * 7 | * THE BSD LICENSE 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | *************************************************************************/ 30 | 31 | #ifndef FLANN_OBJECT_FACTORY_H_ 32 | #define FLANN_OBJECT_FACTORY_H_ 33 | 34 | #include 35 | 36 | namespace flann 37 | { 38 | 39 | class CreatorNotFound 40 | { 41 | }; 42 | 43 | template 46 | class ObjectFactory 47 | { 48 | typedef ObjectFactory ThisClass; 49 | typedef std::map ObjectRegistry; 50 | 51 | // singleton class, private constructor 52 | ObjectFactory() {} 53 | 54 | public: 55 | 56 | bool subscribe(UniqueIdType id, ObjectCreator creator) 57 | { 58 | if (object_registry.find(id) != object_registry.end()) return false; 59 | 60 | object_registry[id] = creator; 61 | return true; 62 | } 63 | 64 | bool unregister(UniqueIdType id) 65 | { 66 | return object_registry.erase(id) == 1; 67 | } 68 | 69 | ObjectCreator create(UniqueIdType id) 70 | { 71 | typename ObjectRegistry::const_iterator iter = object_registry.find(id); 72 | 73 | if (iter == object_registry.end()) { 74 | throw CreatorNotFound(); 75 | } 76 | 77 | return iter->second; 78 | } 79 | 80 | static ThisClass& instance() 81 | { 82 | static ThisClass the_factory; 83 | return the_factory; 84 | } 85 | private: 86 | ObjectRegistry object_registry; 87 | }; 88 | 89 | } 90 | 91 | #endif /* FLANN_OBJECT_FACTORY_H_ */ 92 | -------------------------------------------------------------------------------- /lib/ann/ann/ann2fig/Makefile: -------------------------------------------------------------------------------- 1 | #----------------------------------------------------------------------------- 2 | # Makefile for ann2fig 3 | # 4 | # ANN: Approximate Nearest Neighbors 5 | # Version: 1.1.1 08/04/06 6 | #----------------------------------------------------------------------------- 7 | # Copyright (c) 1997-2005 University of Maryland and Sunil Arya and 8 | # David Mount. All Rights Reserved. 9 | # 10 | # This software and related documentation is part of the Approximate 11 | # Nearest Neighbor Library (ANN). This software is provided under 12 | # the provisions of the Lesser GNU Public License (LGPL). See the 13 | # file ../ReadMe.txt for further information. 14 | # 15 | # The University of Maryland (U.M.) and the authors make no 16 | # representations about the suitability or fitness of this software for 17 | # any purpose. It is provided "as is" without express or implied 18 | # warranty. 19 | #----------------------------------------------------------------------------- 20 | # Revision 0.1 03/04/98 21 | # Initial release 22 | # Revision 1.1.1 08/04/06 23 | # Added copyright/license 24 | #----------------------------------------------------------------------------- 25 | 26 | #----------------------------------------------------------------------------- 27 | # Basic definitions 28 | # BASEDIR where include, src, lib, ... are 29 | # INCDIR include directory 30 | # LIBDIR library directory 31 | # BINDIR bin directory 32 | # LDFLAGS loader flags 33 | # ANNLIB ANN library 34 | # OTHERLIB other libraries 35 | #----------------------------------------------------------------------------- 36 | 37 | BASEDIR = .. 38 | INCDIR = $(BASEDIR)/include 39 | LIBDIR = $(BASEDIR)/lib 40 | BINDIR = $(BASEDIR)/bin 41 | LDFLAGS = -L$(LIBDIR) 42 | ANNLIBS = -lANN 43 | OTHERLIBS = -lm 44 | 45 | #----------------------------------------------------------------------------- 46 | # Some more definitions 47 | # ANN2FIG name of executable 48 | #----------------------------------------------------------------------------- 49 | 50 | ANN2FIG = ann2fig 51 | SOURCES = ann2fig.cpp 52 | OBJECTS = $(SOURCES:.cpp=.o) 53 | 54 | #----------------------------------------------------------------------------- 55 | # Make the program 56 | #----------------------------------------------------------------------------- 57 | 58 | default: 59 | @echo "Specify a target configuration" 60 | 61 | targets: $(BINDIR)/$(ANN2FIG) 62 | 63 | $(BINDIR)/$(ANN2FIG): $(OBJECTS) 64 | $(C++) $(OBJECTS) -o $(ANN2FIG) $(LDFLAGS) $(ANNLIBS) $(OTHERLIBS) 65 | mv $(ANN2FIG) $(BINDIR) 66 | 67 | #----------------------------------------------------------------------------- 68 | # configuration definitions 69 | #----------------------------------------------------------------------------- 70 | 71 | include ../Make-config 72 | 73 | #----------------------------------------------------------------------------- 74 | # Objects 75 | #----------------------------------------------------------------------------- 76 | 77 | ann2fig.o: ann2fig.cpp 78 | $(C++) -c -I$(INCDIR) ann2fig.cpp 79 | 80 | #----------------------------------------------------------------------------- 81 | # Cleaning 82 | #----------------------------------------------------------------------------- 83 | 84 | clean: 85 | -rm -f *.o core 86 | 87 | realclean: clean 88 | -------------------------------------------------------------------------------- /lib/flann/src/cpp/flann/mpi/client.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Copyright 2008-2011 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. 5 | * Copyright 2008-2011 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | *************************************************************************/ 28 | 29 | 30 | #ifndef MPI_CLIENT_H_ 31 | #define MPI_CLIENT_H_ 32 | 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include "queries.h" 38 | 39 | namespace flann { 40 | namespace mpi { 41 | 42 | 43 | class Client 44 | { 45 | public: 46 | Client(const std::string& host, const std::string& service) 47 | { 48 | tcp::resolver resolver(io_service_); 49 | tcp::resolver::query query(tcp::v4(), host, service); 50 | iterator_ = resolver.resolve(query); 51 | } 52 | 53 | 54 | template 55 | void knnSearch(const flann::Matrix& queries, flann::Matrix& indices, flann::Matrix& dists, int knn, const SearchParams& params) 56 | { 57 | tcp::socket sock(io_service_); 58 | sock.connect(*iterator_); 59 | 60 | Request req; 61 | req.nn = knn; 62 | req.queries = queries; 63 | req.checks = params.checks; 64 | // send request 65 | write_object(sock,req); 66 | 67 | Response resp; 68 | // read response 69 | read_object(sock, resp); 70 | 71 | for (size_t i=0;i 1: xc += randn(xc.shape[0], xc.shape[1])*0.000001/dim 53 | 54 | rnseed = int(time.time()) 55 | centroids = self.nn.kmeans(xc[permutation(len(xc))], N, centers_init = "random", random_seed=2) 56 | mindists = array([[ sum((d1-d2)**2) for d1 in x] for d2 in centroids]).min(0) 57 | #print mindists 58 | for m in mindists: self.assertAlmostEqual(m, 0.0, 1) 59 | 60 | rnseed = int(time.time()) 61 | centroids = self.nn.kmeans(xc[permutation(len(xc))], N, centers_init = "gonzales", random_seed=2) 62 | mindists = array([[ sum((d1-d2)**2) for d1 in x] for d2 in centroids]).min(0) 63 | #print mindists 64 | for m in mindists: self.assertAlmostEqual(m, 0.0, 1) 65 | 66 | centroids = self.nn.kmeans(xc[permutation(len(xc))], N, centers_init = "kmeanspp", random_seed=2) 67 | mindists = array([[ sum((d1-d2)**2) for d1 in x] for d2 in centroids]).min(0) 68 | #print mindists 69 | for m in mindists: self.assertAlmostEqual(m, 0.0, 1) 70 | 71 | def testrandomnumber_same(self): 72 | 73 | data = rand(1000,2) # Random, so we can get a lot of local minima 74 | 75 | rnseed = int(time.time()) 76 | cl1 = self.nn.kmeans(data, 50, random_seed = rnseed) 77 | cl2 = self.nn.kmeans(data, 50, random_seed = rnseed) 78 | 79 | self.assertTrue(all(cl1 == cl2)) 80 | 81 | 82 | def testrandnumber_different(self): 83 | 84 | data = rand(1000,100) # Random, so we can get a lot of local minima 85 | 86 | rnseed = int(time.time()) 87 | cl1 = self.nn.kmeans(data, 50, random_seed = rnseed) 88 | cl2 = self.nn.kmeans(data, 50) 89 | 90 | self.assertTrue(any(cl1 != cl2)) 91 | 92 | 93 | 94 | if __name__ == '__main__': 95 | unittest.main() 96 | -------------------------------------------------------------------------------- /lib/flann/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | add_custom_target(tests) 3 | add_custom_target(flann_gtests) 4 | add_custom_target(test) 5 | add_custom_target(flann_gtest) 6 | 7 | add_dependencies(tests flann_gtests) 8 | add_dependencies(test flann_gtest) 9 | add_dependencies(test tests) 10 | 11 | set(EXECUTABLE_OUTPUT_PATH ${TEST_OUTPUT_PATH}) 12 | 13 | if (PYTHON_EXECUTABLE) 14 | flann_download_test_data(sift10K.h5 0964a910946d2dd5fe28337507a8abc3) 15 | flann_download_test_data(sift10K_byte.h5 f835e0148df4618a81f67febfda2b4d0) 16 | flann_download_test_data(sift100K.h5 ae2b08f93f3d9f89f5d68566b0406102) 17 | flann_download_test_data(sift100K_byte.h5 b772255fd2044e9d2a5a0183953e4705) 18 | flann_download_test_data(cloud.h5 dfc77bad391a3ae739a9874f4a5dc0d7) 19 | flann_download_test_data(brief100K.h5 e1e781c0955917bc2f0a27b6344c2342) 20 | endif() 21 | 22 | if (GTEST_FOUND AND HDF5_FOUND) 23 | include_directories(${HDF5_INCLUDE_DIR}) 24 | 25 | set(TEST_LIBRARIES "${HDF5_LIBRARIES}") 26 | if (HDF5_IS_PARALLEL) 27 | set(TEST_LIBRARIES "${TEST_LIBRARIES};${MPI_LIBRARIES}") 28 | endif() 29 | 30 | flann_add_gtest(flann_linear_test flann_linear_test.cpp) 31 | target_link_libraries(flann_linear_test flann_cpp ${TEST_LIBRARIES}) 32 | 33 | flann_add_gtest(flann_kdtree_test flann_kdtree_test.cpp) 34 | target_link_libraries(flann_kdtree_test flann_cpp ${TEST_LIBRARIES}) 35 | 36 | flann_add_gtest(flann_kmeans_test flann_kmeans_test.cpp) 37 | target_link_libraries(flann_kmeans_test flann_cpp ${TEST_LIBRARIES}) 38 | 39 | flann_add_gtest(flann_kdtree_single_test flann_kdtree_single_test.cpp) 40 | target_link_libraries(flann_kdtree_single_test flann_cpp ${TEST_LIBRARIES}) 41 | 42 | flann_add_gtest(flann_hierarchical_test flann_hierarchical_test.cpp) 43 | target_link_libraries(flann_hierarchical_test flann_cpp ${TEST_LIBRARIES}) 44 | 45 | flann_add_gtest(flann_lsh_test flann_lsh_test.cpp) 46 | target_link_libraries(flann_lsh_test flann_cpp ${TEST_LIBRARIES}) 47 | 48 | flann_add_gtest(flann_autotuned_test flann_autotuned_test.cpp) 49 | target_link_libraries(flann_autotuned_test flann_cpp ${TEST_LIBRARIES}) 50 | 51 | if (OPENMP_FOUND) 52 | flann_add_gtest(flann_multithreaded_test flann_multithreaded_test.cpp) 53 | target_link_libraries(flann_multithreaded_test flann_cpp ${TEST_LIBRARIES}) 54 | endif() 55 | 56 | endif() 57 | 58 | if (GTEST_FOUND AND HDF5_FOUND AND BUILD_CUDA_LIB) 59 | set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS};-Xcompiler;-fPIC;-arch=sm_13" ) 60 | if (NVCC_COMPILER_BINDIR) 61 | set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS};--compiler-bindir=${NVCC_COMPILER_BINDIR}") 62 | endif() 63 | flann_add_cuda_gtest(flann_cuda_test flann_cuda_test.cu) 64 | target_link_libraries(flann_cuda_test flann_cpp ${HDF5_LIBRARIES} flann_cuda) 65 | endif() 66 | 67 | 68 | #---------- pyunit tests -------------- 69 | if (BUILD_PYTHON_BINDINGS) 70 | flann_add_pyunit(test_nn.py) 71 | flann_add_pyunit(test_nn_index.py) 72 | flann_add_pyunit(test_index_save.py) 73 | flann_add_pyunit(test_nn_autotune.py) 74 | flann_add_pyunit(test_clustering.py) 75 | endif() 76 | 77 | #---------- ruby spec ---------------- 78 | if (BUILD_C_BINDINGS) 79 | add_custom_target(flann_ruby_spec 80 | COMMAND bundle exec rake spec 81 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/src/ruby) 82 | add_dependencies(test flann_ruby_spec) 83 | endif() 84 | -------------------------------------------------------------------------------- /lib/flann/src/cpp/flann/mpi/queries.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Copyright 2008-2011 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. 5 | * Copyright 2008-2011 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met: 10 | * 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | *************************************************************************/ 28 | 29 | 30 | #ifndef MPI_QUERIES_H_ 31 | #define MPI_QUERIES_H_ 32 | 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | namespace flann 39 | { 40 | 41 | template 42 | struct Request 43 | { 44 | flann::Matrix queries; 45 | int nn; 46 | int checks; 47 | 48 | template 49 | void serialize(Archive& ar, const unsigned int version) 50 | { 51 | ar & queries & nn & checks; 52 | } 53 | }; 54 | 55 | template 56 | struct Response 57 | { 58 | flann::Matrix indices; 59 | flann::Matrix dists; 60 | 61 | template 62 | void serialize(Archive& ar, const unsigned int version) 63 | { 64 | ar & indices & dists; 65 | } 66 | }; 67 | 68 | 69 | using boost::asio::ip::tcp; 70 | 71 | template 72 | void read_object(tcp::socket& sock, T& val) 73 | { 74 | uint32_t size; 75 | boost::asio::read(sock, boost::asio::buffer(&size, sizeof(size))); 76 | size = ntohl(size); 77 | 78 | boost::asio::streambuf archive_stream; 79 | boost::asio::read(sock, archive_stream, boost::asio::transfer_at_least(size)); 80 | 81 | boost::archive::binary_iarchive archive(archive_stream); 82 | archive >> val; 83 | } 84 | 85 | template 86 | void write_object(tcp::socket& sock, const T& val) 87 | { 88 | boost::asio::streambuf archive_stream; 89 | boost::archive::binary_oarchive archive(archive_stream); 90 | archive << val; 91 | 92 | uint32_t size = archive_stream.size(); 93 | size = htonl(size); 94 | boost::asio::write(sock, boost::asio::buffer(&size, sizeof(size))); 95 | boost::asio::write(sock, archive_stream); 96 | 97 | } 98 | 99 | } 100 | 101 | 102 | 103 | #endif /* MPI_QUERIES_H_ */ 104 | -------------------------------------------------------------------------------- /lib/ann/ann/sample/Makefile: -------------------------------------------------------------------------------- 1 | #----------------------------------------------------------------------------- 2 | # Makefile for the sample program 3 | # 4 | # ANN: Approximate Nearest Neighbors 5 | # Version: 1.1.1 08/04/06 6 | #----------------------------------------------------------------------------- 7 | # Copyright (c) 1997-2005 University of Maryland and Sunil Arya and 8 | # David Mount. All Rights Reserved. 9 | # 10 | # This software and related documentation is part of the Approximate 11 | # Nearest Neighbor Library (ANN). This software is provided under 12 | # the provisions of the Lesser GNU Public License (LGPL). See the 13 | # file ../ReadMe.txt for further information. 14 | # 15 | # The University of Maryland (U.M.) and the authors make no 16 | # representations about the suitability or fitness of this software for 17 | # any purpose. It is provided "as is" without express or implied 18 | # warranty. 19 | #----------------------------------------------------------------------------- 20 | # Revision 0.1 03/04/98 21 | # Initial release 22 | # Revision 1.1.1 08/04/06 23 | # Added copyright/license 24 | #----------------------------------------------------------------------------- 25 | # Note: For full performance measurements, it is assumed that the library 26 | # and this program have both been compiled with the -DPERF flag. See the 27 | # Makefile in the ANN base directory for this flag. 28 | #----------------------------------------------------------------------------- 29 | 30 | #----------------------------------------------------------------------------- 31 | # Basic definitions 32 | # BASEDIR where include, src, lib, ... are 33 | # INCDIR include directory 34 | # LIBDIR library directory 35 | # BINDIR bin directory 36 | # LDFLAGS loader flags 37 | # ANNLIBS libraries 38 | #----------------------------------------------------------------------------- 39 | 40 | BASEDIR = .. 41 | INCDIR = $(BASEDIR)/include 42 | LIBDIR = $(BASEDIR)/lib 43 | BINDIR = $(BASEDIR)/bin 44 | LDFLAGS = -L$(LIBDIR) 45 | ANNLIBS = -lANN -lm 46 | 47 | #----------------------------------------------------------------------------- 48 | # Some more definitions 49 | # ANNSAMP name of sample program 50 | #----------------------------------------------------------------------------- 51 | 52 | ANNSAMP = ann_sample 53 | 54 | SAMPSOURCES = ann_sample.cpp 55 | SAMPOBJECTS = $(SAMPSOURCES:.cpp=.o) 56 | 57 | #----------------------------------------------------------------------------- 58 | # Make the program 59 | #----------------------------------------------------------------------------- 60 | 61 | default: 62 | @echo "Specify a target configuration" 63 | 64 | targets: $(BINDIR)/$(ANNSAMP) 65 | 66 | $(BINDIR)/$(ANNSAMP): $(SAMPOBJECTS) $(LIBDIR)/$(ANNLIB) 67 | $(C++) $(SAMPOBJECTS) -o $(ANNSAMP) $(LDFLAGS) $(ANNLIBS) 68 | mv $(ANNSAMP) $(BINDIR) 69 | 70 | #----------------------------------------------------------------------------- 71 | # configuration definitions 72 | #----------------------------------------------------------------------------- 73 | 74 | include ../Make-config 75 | 76 | #----------------------------------------------------------------------------- 77 | # Objects 78 | #----------------------------------------------------------------------------- 79 | 80 | ann_sample.o: ann_sample.cpp 81 | $(C++) -c -I$(INCDIR) $(CFLAGS) ann_sample.cpp 82 | 83 | #----------------------------------------------------------------------------- 84 | # Cleaning 85 | #----------------------------------------------------------------------------- 86 | 87 | clean: 88 | -rm -f *.o *.out core 89 | 90 | realclean: clean 91 | -------------------------------------------------------------------------------- /lib/flann/src/matlab/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #IF(WIN32) 2 | # SET(MEXEXT_CMD cmd /C mexext) 3 | #ELSE(WIN32) 4 | # SET(MEXEXT_CMD mexext) 5 | #ENDIF(WIN32) 6 | 7 | SET(MEX_NAME nearest_neighbors) 8 | 9 | if(WIN32) 10 | find_program(MEX_CMD mex.bat) 11 | find_program(MEXEXT_CMD mexext.bat) 12 | else() 13 | find_program(MEX_CMD mex) 14 | find_program(MEXEXT_CMD mexext) 15 | endif() 16 | 17 | find_program(OCT_CMD mkoctfile) 18 | 19 | get_property(FLANN_LIB_LOCATION TARGET flann_s PROPERTY LOCATION) 20 | get_filename_component(FLANN_LIB_PATH ${FLANN_LIB_LOCATION} PATH) 21 | 22 | if(MEX_CMD AND MEXEXT_CMD) 23 | 24 | get_filename_component(MEX_REAL_CMD ${MEX_CMD} ABSOLUTE) 25 | get_filename_component(MEX_PATH ${MEX_REAL_CMD} PATH) 26 | 27 | get_filename_component(MEXEXT_REAL_CMD ${MEXEXT_CMD} ABSOLUTE) 28 | get_filename_component(MEXEXT_PATH ${MEXEXT_REAL_CMD} PATH) 29 | 30 | if (MEX_PATH STREQUAL MEXEXT_PATH) 31 | message(STATUS "Found MATLAB at: " ${MEX_PATH}) 32 | 33 | EXECUTE_PROCESS(COMMAND ${MEXEXT_REAL_CMD} OUTPUT_VARIABLE MEX_EXTENSION OUTPUT_STRIP_TRAILING_WHITESPACE) 34 | SET(MEX_FILE ${CMAKE_CURRENT_BINARY_DIR}/${MEX_NAME}.${MEX_EXTENSION}) 35 | 36 | 37 | if (WIN32) 38 | if (MSVC_IDE) 39 | set(MEX_BUILD_FLAGS "COMPFLAGS=\"$COMPFLAGS ${OpenMP_CXX_FLAGS}\" LINKFLAGS=\"$LINKFLAGS ${OpenMP_CXX_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}\"") 40 | else() 41 | set(MEX_BUILD_FLAGS "COMPFLAGS=\"$$COMPFLAGS ${OpenMP_CXX_FLAGS}\" LINKFLAGS=\"$$LINKFLAGS ${OpenMP_CXX_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}\"") 42 | endif() 43 | else() 44 | set(MEX_BUILD_FLAGS "CFLAGS='$$CFLAGS ${OpenMP_CXX_FLAGS}' LDFLAGS='$$LDFLAGS ${OpenMP_CXX_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}'") 45 | endif() 46 | separate_arguments(MEX_BUILD_FLAGS) 47 | 48 | ADD_CUSTOM_COMMAND( 49 | OUTPUT ${MEX_FILE} 50 | COMMAND ${MEX_REAL_CMD} 51 | ARGS ${CMAKE_CURRENT_SOURCE_DIR}/${MEX_NAME}.cpp -I${PROJECT_SOURCE_DIR}/src/cpp -L${FLANN_LIB_PATH} -lflann_s ${MEX_BUILD_FLAGS} 52 | DEPENDS flann_s ${CMAKE_CURRENT_SOURCE_DIR}/${MEX_NAME}.cpp 53 | COMMENT "Building MEX extension ${MEX_FILE}" 54 | ) 55 | 56 | ADD_CUSTOM_TARGET(mex_${MEX_NAME} ALL DEPENDS ${MEX_FILE}) 57 | 58 | FILE(GLOB MATLAB_SOURCES *.m) 59 | 60 | INSTALL ( 61 | FILES ${MEX_FILE} ${MATLAB_SOURCES} 62 | DESTINATION share/flann/matlab 63 | ) 64 | else() 65 | message(WARNING "The 'mex' and 'mexext' programs have been found in different locations. It's likely that one of them is not part of the MATLAB instalation. Make sure that the 'bin' directory from the MATLAB instalation is in PATH") 66 | set(BUILD_MATLAB_BINDINGS OFF) 67 | endif() 68 | elseif(OCT_CMD) 69 | SET(MEX_FILE ${CMAKE_CURRENT_BINARY_DIR}/${MEX_NAME}.mex) 70 | ADD_CUSTOM_COMMAND( 71 | OUTPUT ${MEX_FILE} 72 | COMMAND ${OCT_CMD} 73 | ARGS ${CMAKE_CURRENT_SOURCE_DIR}/${MEX_NAME}.cpp -I${PROJECT_SOURCE_DIR}/src/cpp -L${FLANN_LIB_PATH} -DFLANN_STATIC -lflann_s -lgomp --mex 74 | DEPENDS flann_s ${CMAKE_CURRENT_SOURCE_DIR}/${MEX_NAME}.cpp 75 | COMMENT "Building MEX extension ${MEX_FILE}" 76 | ) 77 | 78 | ADD_CUSTOM_TARGET(mex_${MEX_NAME} ALL DEPENDS ${MEX_FILE}) 79 | 80 | FILE(GLOB MATLAB_SOURCES *.m) 81 | 82 | INSTALL ( 83 | FILES ${MEX_FILE} ${MATLAB_SOURCES} 84 | DESTINATION share/flann/octave 85 | ) 86 | else() 87 | message(WARNING "Cannot find MATLAB or Octave instalation. Make sure that the 'bin' directory from the MATLAB instalation or that mkoctfile is in PATH") 88 | set(BUILD_MATLAB_BINDINGS OFF) 89 | endif() 90 | 91 | -------------------------------------------------------------------------------- /maps/var_density.tri: -------------------------------------------------------------------------------- 1 | 2000 2000 2010 2010 -10 2010 2 | 2000 0 2010 -10 2010 2010 3 | 0 0 -10 -10 2010 -10 4 | 0 2000 -10 2010 -10 -10 5 | -10 -10 0 0 0 2000 6 | 2010 2010 2000 2000 2000 0 7 | -10 2010 0 2000 2000 2000 8 | 2010 -10 2000 0 0 0 9 | -140 80 139.333 78.666700000000006 0.66666700000000001 321.33300000000003 10 | 1048.22 525.33299999999997 1327.5599999999999 524 1188.8900000000001 766.66700000000003 11 | 1444 525.33299999999997 1723.3299999999999 524 1584.6700000000001 766.66700000000003 12 | 1839.78 525.33299999999997 2119.1100000000001 524 1980.4400000000001 766.66700000000003 13 | -132.22200000000001 1078 147.11099999999999 1076.6700000000001 8.4444400000000002 1319.3299999999999 14 | 367.77800000000002 1078 647.11099999999999 1076.6700000000001 508.44400000000002 1319.3299999999999 15 | 867.77800000000002 1078 1147.1099999999999 1076.6700000000001 1008.4400000000001 1319.3299999999999 16 | 1367.78 1078 1647.1099999999999 1076.6700000000001 1508.4400000000001 1319.3299999999999 17 | 1867.78 1078 2147.1100000000001 1076.6700000000001 2008.4400000000001 1319.3299999999999 18 | 31.777799999999999 426.22199999999998 172.44399999999999 184.88900000000001 311.11099999999999 427.55599999999998 19 | 371.77800000000002 426.22199999999998 512.44399999999996 184.88900000000001 651.11099999999999 427.55599999999998 20 | 200 80 479.33300000000003 78.666700000000006 340.66699999999997 321.33300000000003 21 | 711.77800000000002 426.22199999999998 852.44399999999996 184.88900000000001 991.11099999999999 427.55599999999998 22 | 1051.78 426.22199999999998 1192.4400000000001 184.88900000000001 1331.1099999999999 427.55599999999998 23 | 1391.78 426.22199999999998 1532.4400000000001 184.88900000000001 1671.1099999999999 427.55599999999998 24 | 1731.78 426.22199999999998 1872.4400000000001 184.88900000000001 2011.1099999999999 427.55599999999998 25 | 53.333300000000001 922 194 680.66700000000003 332.66699999999997 923.33299999999997 26 | 449.11099999999999 922 589.77800000000002 680.66700000000003 728.44399999999996 923.33299999999997 27 | 844.88900000000001 922 985.55600000000004 680.66700000000003 1124.22 923.33299999999997 28 | 1240.6700000000001 922 1381.3299999999999 680.66700000000003 1520 923.33299999999997 29 | 1636.4400000000001 922 1777.1099999999999 680.66700000000003 1915.78 923.33299999999997 30 | -137.11099999999999 1743.3299999999999 142.22200000000001 1742 3.5555599999999998 1984.6700000000001 31 | 540 80 819.33299999999997 78.666700000000006 680.66700000000003 321.33300000000003 32 | 510.22199999999998 1743.3299999999999 789.55600000000004 1742 650.88900000000001 1984.6700000000001 33 | 1157.5599999999999 1743.3299999999999 1436.8900000000001 1742 1298.22 1984.6700000000001 34 | 1804.8900000000001 1743.3299999999999 2084.2199999999998 1742 1945.5599999999999 1984.6700000000001 35 | 116.889 1522 257.55599999999998 1280.6700000000001 396.22199999999998 1523.3299999999999 36 | 616.88900000000001 1522 757.55600000000004 1280.6700000000001 896.22199999999998 1523.3299999999999 37 | 1116.8900000000001 1522 1257.5599999999999 1280.6700000000001 1396.22 1523.3299999999999 38 | 1616.8900000000001 1522 1757.5599999999999 1280.6700000000001 1896.22 1523.3299999999999 39 | 880 80 1159.3299999999999 78.666700000000006 1020.67 321.33300000000003 40 | 1220 80 1499.3299999999999 78.666700000000006 1360.6700000000001 321.33300000000003 41 | 1560 80 1839.3299999999999 78.666700000000006 1700.6700000000001 321.33300000000003 42 | 1900 80 2179.3299999999999 78.666700000000006 2040.6700000000001 321.33300000000003 43 | -139.11099999999999 525.33299999999997 140.22200000000001 524 1.5555600000000001 766.66700000000003 44 | 256.66699999999997 525.33299999999997 536 524 397.33300000000003 766.66700000000003 45 | 652.44399999999996 525.33299999999997 931.77800000000002 524 793.11099999999999 766.66700000000003 46 | -------------------------------------------------------------------------------- /lib/ann/ann/test/Makefile: -------------------------------------------------------------------------------- 1 | #----------------------------------------------------------------------------- 2 | # Makefile for the test and evaluation program 3 | # 4 | # ANN: Approximate Nearest Neighbors 5 | # Version: 1.1.1 08/04/06 6 | #----------------------------------------------------------------------------- 7 | # Copyright (c) 1997-2005 University of Maryland and Sunil Arya and 8 | # David Mount. All Rights Reserved. 9 | # 10 | # This software and related documentation is part of the Approximate 11 | # Nearest Neighbor Library (ANN). This software is provided under 12 | # the provisions of the Lesser GNU Public License (LGPL). See the 13 | # file ../ReadMe.txt for further information. 14 | # 15 | # The University of Maryland (U.M.) and the authors make no 16 | # representations about the suitability or fitness of this software for 17 | # any purpose. It is provided "as is" without express or implied 18 | # warranty. 19 | #----------------------------------------------------------------------------- 20 | # Revision 0.1 03/04/98 21 | # Initial release 22 | # Revision 1.1.1 08/04/06 23 | # Added copyright/license 24 | #----------------------------------------------------------------------------- 25 | # Note: For full performance measurements, it is assumed that the library 26 | # and this program have both been compiled with the -DANN_PERF flag. See 27 | # the Makefile in the ANN base directory for this flag. 28 | #----------------------------------------------------------------------------- 29 | 30 | #----------------------------------------------------------------------------- 31 | # Basic definitions 32 | # BASEDIR where include, src, lib, ... are 33 | # INCDIR include directory 34 | # LIBDIR library directory 35 | # BINDIR bin directory 36 | # LDFLAGS loader flags 37 | # ANNLIBS ANN library 38 | # OTHERLIBS other libraries 39 | #----------------------------------------------------------------------------- 40 | 41 | BASEDIR = .. 42 | INCDIR = $(BASEDIR)/include 43 | LIBDIR = $(BASEDIR)/lib 44 | BINDIR = $(BASEDIR)/bin 45 | LDFLAGS = -L$(LIBDIR) 46 | ANNLIBS = -lANN 47 | OTHERLIBS = -lm 48 | 49 | #----------------------------------------------------------------------------- 50 | # Some more definitions 51 | # ANNTEST name of test program 52 | #----------------------------------------------------------------------------- 53 | 54 | ANNTEST = ann_test 55 | 56 | HEADERS = rand.h 57 | TESTSOURCES = ann_test.cpp rand.cpp 58 | TESTOBJECTS = $(TESTSOURCES:.cpp=.o) 59 | 60 | #----------------------------------------------------------------------------- 61 | # Make the program 62 | #----------------------------------------------------------------------------- 63 | 64 | default: 65 | @echo "Specify a target configuration" 66 | 67 | targets: $(BINDIR)/$(ANNTEST) 68 | 69 | $(BINDIR)/$(ANNTEST): $(TESTOBJECTS) $(LIBDIR)/$(ANNLIB) 70 | $(C++) $(TESTOBJECTS) -o $(ANNTEST) $(LDFLAGS) $(ANNLIBS) $(OTHERLIBS) 71 | mv $(ANNTEST) $(BINDIR) 72 | 73 | #----------------------------------------------------------------------------- 74 | # configuration definitions 75 | #----------------------------------------------------------------------------- 76 | 77 | include ../Make-config 78 | 79 | #----------------------------------------------------------------------------- 80 | # Objects 81 | #----------------------------------------------------------------------------- 82 | 83 | ann_test.o: ann_test.cpp 84 | $(C++) -c -I$(INCDIR) $(CFLAGS) ann_test.cpp 85 | 86 | rand.o: rand.cpp 87 | $(C++) -c -I$(INCDIR) $(CFLAGS) rand.cpp 88 | 89 | #----------------------------------------------------------------------------- 90 | # Cleaning 91 | #----------------------------------------------------------------------------- 92 | 93 | clean: 94 | -rm -f *.o *.out core 95 | 96 | realclean: clean 97 | -------------------------------------------------------------------------------- /lib/flann/src/cpp/flann/nn/ground_truth.h: -------------------------------------------------------------------------------- 1 | /*********************************************************************** 2 | * Software License Agreement (BSD License) 3 | * 4 | * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. 5 | * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. 6 | * 7 | * THE BSD LICENSE 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | *************************************************************************/ 30 | 31 | #ifndef FLANN_GROUND_TRUTH_H_ 32 | #define FLANN_GROUND_TRUTH_H_ 33 | 34 | #include "flann/algorithms/dist.h" 35 | #include "flann/util/matrix.h" 36 | 37 | 38 | namespace flann 39 | { 40 | 41 | template 42 | void find_nearest(const Matrix& dataset, typename Distance::ElementType* query, size_t* matches, size_t nn, 43 | size_t skip = 0, Distance distance = Distance()) 44 | { 45 | //typedef typename Distance::ElementType ElementType; 46 | typedef typename Distance::ResultType DistanceType; 47 | int n = nn + skip; 48 | 49 | int* match = new int[n]; 50 | DistanceType* dists = new DistanceType[n]; 51 | 52 | dists[0] = distance(dataset[0], query, dataset.cols); 53 | match[0] = 0; 54 | int dcnt = 1; 55 | 56 | for (size_t i=1; i=1 && dists[j] 87 | void compute_ground_truth(const Matrix& dataset, const Matrix& testset, Matrix& matches, 88 | int skip=0, Distance d = Distance()) 89 | { 90 | for (size_t i=0; i(dataset, testset[i], matches[i], matches.cols, skip, d); 92 | } 93 | } 94 | 95 | 96 | } 97 | 98 | #endif //FLANN_GROUND_TRUTH_H_ 99 | -------------------------------------------------------------------------------- /lib/flann/src/ruby/Rakefile: -------------------------------------------------------------------------------- 1 | # Copyright 2014 John O. Woods (john.o.woods@gmail.com), West Virginia 2 | # University's Applied Space Exploration Lab, and West Virginia Robotic 3 | # Technology Center. All rights reserved. 4 | # 5 | # THE BSD LICENSE 6 | # 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions 9 | # are met: 10 | # 11 | # 1. Redistributions of source code must retain the above copyright 12 | # notice, this list of conditions and the following disclaimer. 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | 28 | require 'rubygems' 29 | require 'rubygems/package_task' 30 | require 'bundler' 31 | begin 32 | Bundler.setup(:default, :development) 33 | rescue 34 | $stderr.puts e.message 35 | $stderr.puts "Run `bundle install` to install missing gems" 36 | exit e.status_code 37 | end 38 | 39 | require 'rake' 40 | 41 | gemspec = eval(IO.read("flann.gemspec")) 42 | 43 | Gem::PackageTask.new(gemspec).define 44 | 45 | desc "install the gem locally" 46 | task :install => [:package] do 47 | sh %{gem install pkg/flann-#{NMatrix::VERSION}.gem} 48 | end 49 | 50 | 51 | require 'rspec/core/rake_task' 52 | require 'rspec/core' 53 | require 'rspec/core/rake_task' 54 | RSpec::Core::RakeTask.new(:spec) do |spec| 55 | spec.pattern = FileList['spec/**/*_spec.rb'].uniq 56 | end 57 | 58 | task :console do |task| 59 | cmd = [ 'irb', "-r './lib/flann.rb'" ] 60 | run *cmd 61 | end 62 | 63 | task :pry do |task| 64 | cmd = [ 'pry', "-r './lib/flann.rb'" ] 65 | run *cmd 66 | end 67 | 68 | 69 | task :default => :spec 70 | 71 | def run *cmd 72 | sh(cmd.join(" ")) 73 | end 74 | 75 | 76 | desc "Check the manifest for correctness" 77 | task :check_manifest do |task| 78 | manifest_files = File.read("Manifest.txt").split 79 | 80 | git_files = `git ls-files |grep -v 'spec/'`.split 81 | ignore_files = %w{.gitignore .rspec} 82 | 83 | possible_files = git_files - ignore_files 84 | 85 | missing_files = possible_files - manifest_files 86 | extra_files = manifest_files - possible_files 87 | 88 | unless missing_files.empty? 89 | STDERR.puts "The following files are in the git repo but not the Manifest:" 90 | missing_files.each { |f| STDERR.puts " -- #{f}"} 91 | end 92 | 93 | unless extra_files.empty? 94 | STDERR.puts "The following files are in the Manifest but may not be necessary:" 95 | extra_files.each { |f| STDERR.puts " -- #{f}"} 96 | end 97 | 98 | if extra_files.empty? && missing_files.empty? 99 | STDERR.puts "Manifest looks good!" 100 | end 101 | 102 | end 103 | 104 | 105 | require "rdoc/task" 106 | RDoc::Task.new do |rdoc| 107 | rdoc.main = "README.rdoc" 108 | rdoc.rdoc_files.include(%w{README.rdoc History.txt LICENSE.txt lib/flann/**/*.rb}) 109 | end 110 | 111 | # vim: syntax=ruby -------------------------------------------------------------------------------- /lib/flann/src/matlab/flann_search.m: -------------------------------------------------------------------------------- 1 | %Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. 2 | %Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. 3 | % 4 | %THE BSD LICENSE 5 | % 6 | %Redistribution and use in source and binary forms, with or without 7 | %modification, are permitted provided that the following conditions 8 | %are met: 9 | % 10 | %1. Redistributions of source code must retain the above copyright 11 | % notice, this list of conditions and the following disclaimer. 12 | %2. Redistributions in binary form must reproduce the above copyright 13 | % notice, this list of conditions and the following disclaimer in the 14 | % documentation and/or other materials provided with the distribution. 15 | % 16 | %THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17 | %IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 | %OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19 | %IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20 | %INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21 | %NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 | %DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 | %THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | %(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25 | %THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | 27 | function [indices, dists] = flann_search(data, testset, n, search_params) 28 | %NN_SEARCH Fast approximate nearest neighbors search 29 | % 30 | % Performs a fast approximate nearest neighbor search using an 31 | % index constructed using flann_build_index or directly a 32 | % dataset. 33 | 34 | % Marius Muja, January 2008 35 | 36 | 37 | algos = struct( 'linear', 0, 'kdtree', 1, 'kmeans', 2, 'composite', 3, 'lsh', 6, 'saved', 254, 'autotuned', 255 ); 38 | center_algos = struct('random', 0, 'gonzales', 1, 'kmeanspp', 2 ); 39 | log_levels = struct('none', 0, 'fatal', 1, 'error', 2, 'warning', 3, 'info', 4); 40 | 41 | default_params = struct('algorithm', 'kdtree' ,'checks', 32, 'eps', 0.0, 'sorted', 1, 'max_neighbors', -1, 'cores', 1, 'trees', 4, 'branching', 32, 'iterations', 5, 'centers_init', 'random', 'cb_index', 0.4, 'target_precision', 0.9,'build_weight', 0.01, 'memory_weight', 0, 'sample_fraction', 0.1, 'table_number', 12, 'key_size', 20, 'multi_probe_level', 2, 'log_level', 'warning', 'random_seed', 0); 42 | 43 | if ~isstruct(search_params) 44 | error('The "search_params" argument must be a structure'); 45 | end 46 | 47 | params = default_params; 48 | fn = fieldnames(search_params); 49 | for i = [1:length(fn)], 50 | name = cell2mat(fn(i)); 51 | params.(name) = search_params.(name); 52 | end 53 | if ~isnumeric(params.algorithm), 54 | params.algorithm = value2id(algos,params.algorithm); 55 | end 56 | if ~isnumeric(params.centers_init), 57 | params.centers_init = value2id(center_algos,params.centers_init); 58 | end 59 | if ~isnumeric(params.log_level), 60 | params.log_level = value2id(log_levels,params.log_level); 61 | end 62 | 63 | if (size(data,1)==1 && size(data,2)==1) 64 | % we already have an index 65 | [indices,dists] = nearest_neighbors('index_find_nn', data, testset, n, params); 66 | else 67 | % create the index and search 68 | [indices,dists] = nearest_neighbors('find_nn', data, testset, n, params); 69 | end 70 | end 71 | 72 | function value = id2value(map, id) 73 | fields = fieldnames(map); 74 | for i = 1:length(fields), 75 | val = cell2mat(fields(i)); 76 | if map.(val) == id 77 | value = val; 78 | break; 79 | end 80 | end 81 | end 82 | function id = value2id(map,value) 83 | id = map.(value); 84 | end 85 | -------------------------------------------------------------------------------- /lib/flann/bin/uncrustify.cfg: -------------------------------------------------------------------------------- 1 | indent_align_string=false 2 | indent_braces=false 3 | indent_braces_no_func=false 4 | indent_brace_parent=false 5 | indent_namespace=false 6 | indent_extern=false 7 | indent_class=true 8 | indent_class_colon=false 9 | indent_else_if=false 10 | indent_func_call_param=false 11 | indent_func_def_param=false 12 | indent_func_proto_param=false 13 | indent_func_class_param=false 14 | indent_func_ctor_var_param=false 15 | indent_template_param=false 16 | indent_func_param_double=false 17 | indent_relative_single_line_comments=true 18 | indent_col1_comment=true 19 | indent_access_spec_body=false 20 | indent_paren_nl=false 21 | indent_comma_paren=false 22 | indent_bool_paren=false 23 | indent_square_nl=false 24 | indent_preserve_sql=false 25 | indent_align_assign=true 26 | sp_balance_nested_parens=false 27 | align_keep_tabs=false 28 | align_with_tabs=false 29 | align_on_tabstop=false 30 | align_number_left=false 31 | align_func_params=false 32 | align_same_func_call_params=false 33 | align_var_def_colon=false 34 | align_var_def_attribute=false 35 | align_var_def_inline=false 36 | align_right_cmt_mix=false 37 | align_on_operator=false 38 | align_mix_var_proto=false 39 | align_single_line_func=false 40 | align_single_line_brace=false 41 | align_nl_cont=false 42 | align_left_shift=true 43 | nl_collapse_empty_body=false 44 | nl_assign_leave_one_liners=true 45 | nl_class_leave_one_liners=true 46 | nl_enum_leave_one_liners=true 47 | nl_getset_leave_one_liners=true 48 | nl_func_leave_one_liners=true 49 | nl_if_leave_one_liners=true 50 | nl_multi_line_cond=false 51 | nl_multi_line_define=false 52 | nl_before_case=false 53 | nl_after_case=false 54 | nl_after_return=false 55 | nl_after_semicolon=false 56 | nl_after_brace_open=false 57 | nl_after_brace_open_cmt=false 58 | nl_after_vbrace_open=false 59 | nl_after_brace_close=false 60 | nl_define_macro=false 61 | nl_squeeze_ifdef=false 62 | nl_ds_struct_enum_cmt=false 63 | nl_ds_struct_enum_close_brace=false 64 | nl_create_if_one_liner=true 65 | nl_create_for_one_liner=true 66 | nl_create_while_one_liner=true 67 | ls_for_split_full=false 68 | ls_func_split_full=false 69 | nl_after_multiline_comment=false 70 | eat_blanks_after_open_brace=false 71 | eat_blanks_before_close_brace=false 72 | mod_pawn_semicolon=false 73 | mod_full_paren_if_bool=true 74 | mod_remove_extra_semicolon=true 75 | mod_sort_import=false 76 | mod_sort_using=false 77 | mod_sort_include=false 78 | mod_move_case_break=false 79 | mod_remove_empty_return=false 80 | cmt_indent_multi=true 81 | cmt_c_group=false 82 | cmt_c_nl_start=false 83 | cmt_c_nl_end=false 84 | cmt_cpp_group=false 85 | cmt_cpp_nl_start=false 86 | cmt_cpp_nl_end=false 87 | cmt_cpp_to_c=false 88 | cmt_star_cont=false 89 | cmt_multi_check_last=true 90 | cmt_insert_before_preproc=false 91 | pp_indent_at_level=false 92 | pp_region_indent_code=false 93 | pp_if_indent_code=false 94 | pp_define_at_level=false 95 | input_tab_size=4 96 | indent_columns=4 97 | indent_with_tabs=0 98 | sp_before_ptr_star=remove 99 | sp_between_ptr_star=remove 100 | sp_after_ptr_star=add 101 | sp_before_byref=remove 102 | sp_after_byref=add 103 | sp_after_type=ignore 104 | sp_else_brace=add 105 | sp_catch_brace=add 106 | sp_finally_brace=add 107 | sp_try_brace=add 108 | nl_end_of_file=add 109 | nl_fcall_brace=remove 110 | nl_enum_brace=add 111 | nl_struct_brace=add 112 | nl_union_brace=remove 113 | nl_if_brace=remove 114 | nl_brace_else=add 115 | nl_else_brace=remove 116 | nl_else_if=remove 117 | nl_brace_finally=add 118 | nl_finally_brace=remove 119 | nl_try_brace=remove 120 | nl_for_brace=remove 121 | nl_catch_brace=remove 122 | nl_brace_catch=add 123 | nl_while_brace=remove 124 | nl_do_brace=remove 125 | nl_brace_while=remove 126 | nl_switch_brace=remove 127 | nl_namespace_brace=add 128 | nl_template_class=add 129 | nl_class_brace=add 130 | nl_fdef_brace=add 131 | mod_full_brace_function=add 132 | mod_paren_on_return=remove 133 | -------------------------------------------------------------------------------- /lib/flann/test/test_index_save.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | from pyflann import * 4 | from copy import copy 5 | from numpy import * 6 | from numpy.random import * 7 | import unittest 8 | 9 | 10 | class Test_PyFLANN_nn(unittest.TestCase): 11 | 12 | def setUp(self): 13 | self.nn = FLANN() 14 | 15 | 16 | class Test_PyFLANN_nn_index(unittest.TestCase): 17 | 18 | def testnn_index_save_kdtree_1(self): 19 | self.run_nn_index_save_perturbed(64,1000, algorithm="kdtree", trees=1) 20 | 21 | def testnn_index_save_kdtree_4(self): 22 | self.run_nn_index_save_perturbed(64,1000, algorithm="kdtree", trees=4) 23 | 24 | def testnn_index_save_kdtree_10(self): 25 | self.run_nn_index_save_perturbed(64,1000, algorithm="kdtree", trees=10) 26 | 27 | 28 | def testnn_index_save_kmeans_2(self): 29 | self.run_nn_index_save_perturbed(64,1000, algorithm="kmeans", branching=2, iterations=11) 30 | 31 | def testnn_index_save_kmeans_16(self): 32 | self.run_nn_index_save_perturbed(64,1000, algorithm="kmeans", branching=16, iterations=11) 33 | 34 | def testnn_index_save_kmeans_32(self): 35 | self.run_nn_index_save_perturbed(64,1000, algorithm="kmeans", branching=32, iterations=11) 36 | 37 | def testnn_index_save_kmeans_64(self): 38 | self.run_nn_index_save_perturbed(64,1000, algorithm="kmeans", branching=64, iterations=11) 39 | 40 | 41 | def testnn__save_kdtree_1(self): 42 | self.run_nn_index_save_rand(64,10000,1000, algorithm="kdtree", trees=1, checks=128) 43 | 44 | def testnn__save_kdtree_4(self): 45 | self.run_nn_index_save_rand(64,10000,1000, algorithm="kdtree", trees=4, checks=128) 46 | 47 | def testnn__save_kdtree_10(self): 48 | self.run_nn_index_save_rand(64,10000,1000, algorithm="kdtree", trees=10, checks=128) 49 | 50 | def testnn__save_kmeans_2(self): 51 | self.run_nn_index_save_rand(64,1000,1000, algorithm="kmeans", branching=2, iterations=11, checks=64) 52 | 53 | def testnn__save_kmeans_8(self): 54 | self.run_nn_index_save_rand(64,10000,1000, algorithm="kmeans", branching=8, iterations=11, checks=32) 55 | 56 | def testnn__save_kmeans_16(self): 57 | self.run_nn_index_save_rand(64,10000,1000, algorithm="kmeans", branching=16, iterations=11, checks=40) 58 | 59 | def testnn__save_kmeans_32(self): 60 | self.run_nn_index_save_rand(64,10000,1000, algorithm="kmeans", branching=32, iterations=11, checks=56) 61 | 62 | 63 | 64 | 65 | def run_nn_index_save_perturbed(self, dim, N, **kwargs): 66 | 67 | x = rand(N, dim) 68 | 69 | nn = FLANN() 70 | nn.build_index(x, **kwargs) 71 | nn.save_index("index.dat") 72 | nn.delete_index(); 73 | 74 | nn = FLANN() 75 | nn.load_index("index.dat",x) 76 | x_query = x + randn(x.shape[0], x.shape[1])*0.0001/dim 77 | nnidx, nndist = nn.nn_index(x_query) 78 | correct = all(nnidx == arange(N, dtype = index_type)) 79 | 80 | nn.delete_index() 81 | self.assertTrue(correct) 82 | 83 | def run_nn_index_save_rand(self, dim, N, Nq, **kwargs): 84 | 85 | x = rand(N, dim) 86 | x_query = rand(Nq,dim) 87 | 88 | # build index, search and delete it 89 | nn = FLANN() 90 | nn.build_index(x, **kwargs) 91 | nnidx, nndist = nn.nn_index(x_query, checks=kwargs["checks"]) 92 | nn.save_index("index.dat") 93 | del nn 94 | 95 | 96 | # now reload index and search again 97 | nn = FLANN() 98 | nn.load_index("index.dat",x) 99 | nnidx2, nndist2 = nn.nn_index(x_query, checks=kwargs["checks"]) 100 | del nn 101 | 102 | correct = all(nnidx == nnidx2) 103 | self.assertTrue(correct) 104 | 105 | if __name__ == '__main__': 106 | unittest.main() 107 | -------------------------------------------------------------------------------- /lib/flann/examples/flann_example_mpi.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #define IF_RANK0 if (world.rank()==0) 10 | 11 | timeval start_time_; 12 | void start_timer(const std::string& message = "") 13 | { 14 | if (!message.empty()) { 15 | printf("%s", message.c_str()); 16 | fflush(stdout); 17 | } 18 | gettimeofday(&start_time_,NULL); 19 | } 20 | 21 | double stop_timer() 22 | { 23 | timeval end_time; 24 | gettimeofday(&end_time,NULL); 25 | 26 | return double(end_time.tv_sec-start_time_.tv_sec)+ double(end_time.tv_usec-start_time_.tv_usec)/1000000; 27 | } 28 | 29 | float compute_precision(const flann::Matrix& match, const flann::Matrix& indices) 30 | { 31 | int count = 0; 32 | 33 | assert(match.rows == indices.rows); 34 | size_t nn = std::min(match.cols, indices.cols); 35 | 36 | for(size_t i=0; i >* index) 52 | { 53 | boost::mpi::communicator world; 54 | 55 | int nn = 1; 56 | 57 | flann::Matrix query; 58 | flann::Matrix match; 59 | // flann::Matrix gt_dists; 60 | IF_RANK0 { 61 | flann::load_from_file(query, "sift100K.h5","query"); 62 | flann::load_from_file(match, "sift100K.h5","match"); 63 | // flann::load_from_file(gt_dists, "sift100K.h5","dists"); 64 | } 65 | 66 | 67 | boost::mpi::broadcast(world, query, 0); 68 | boost::mpi::broadcast(world, match, 0); 69 | 70 | flann::Matrix indices(new int[query.rows*nn], query.rows, nn); 71 | flann::Matrix dists(new float[query.rows*nn], query.rows, nn); 72 | 73 | IF_RANK0 { 74 | indices = flann::Matrix(new int[query.rows*nn], query.rows, nn); 75 | dists = flann::Matrix(new float[query.rows*nn], query.rows, nn); 76 | } 77 | 78 | // do a knn search, using 128 checks0 79 | IF_RANK0 start_timer("Performing search...\n"); 80 | index->knnSearch(query, indices, dists, nn, flann::SearchParams(128)); 81 | IF_RANK0 { 82 | printf("Search done (%g seconds)\n", stop_timer()); 83 | printf("Indices size: (%d,%d)\n", (int)indices.rows, (int)indices.cols); 84 | printf("Checking results\n"); 85 | float precision = compute_precision(match, indices); 86 | printf("Precision is: %g\n", precision); 87 | } 88 | delete[] query.ptr(); 89 | delete[] match.ptr(); 90 | 91 | IF_RANK0 { 92 | delete[] indices.ptr(); 93 | delete[] dists.ptr(); 94 | } 95 | 96 | } 97 | 98 | 99 | int main(int argc, char** argv) 100 | { 101 | boost::mpi::environment env(argc, argv); 102 | boost::mpi::communicator world; 103 | 104 | //flann::Matrix dataset; 105 | 106 | IF_RANK0 start_timer("Loading data...\n"); 107 | // construct an randomized kd-tree index using 4 kd-trees 108 | flann::mpi::Index > index("sift100K.h5", "dataset", flann::KDTreeIndexParams(4)); 109 | //flann::load_from_file(dataset, "sift100K.h5","dataset"); 110 | //flann::Index > index( dataset, flann::KDTreeIndexParams(4)); 111 | world.barrier(); 112 | IF_RANK0 printf("Loading data done (%g seconds)\n", stop_timer()); 113 | IF_RANK0 printf("Index size: (%d,%d)\n", index.size(), index.veclen()); 114 | 115 | start_timer("Building index...\n"); 116 | index.buildIndex(); 117 | printf("Building index done (%g seconds)\n", stop_timer()); 118 | world.barrier(); 119 | 120 | printf("Searching...\n"); 121 | 122 | 123 | boost::thread t(boost::bind(search, &index)); 124 | t.join(); 125 | boost::thread t2(boost::bind(search, &index)); 126 | 127 | 128 | for(;;){}; 129 | 130 | return 0; 131 | } 132 | -------------------------------------------------------------------------------- /lib/flann/test/flann_lsh_test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | 7 | #include "flann_tests.h" 8 | 9 | using namespace flann; 10 | 11 | 12 | class LshIndex_Brief100K : public FLANNTestFixture 13 | { 14 | protected: 15 | typedef flann::Hamming Distance; 16 | typedef Distance::ElementType ElementType; 17 | typedef Distance::ResultType DistanceType; 18 | flann::Matrix data; 19 | flann::Matrix query; 20 | flann::Matrix gt_indices; 21 | flann::Matrix dists; 22 | flann::Matrix gt_dists; 23 | flann::Matrix indices; 24 | unsigned int k_nn_; 25 | 26 | void SetUp() 27 | { 28 | k_nn_ = 3; 29 | printf("Reading test data..."); 30 | fflush(stdout); 31 | flann::load_from_file(data, "brief100K.h5", "dataset"); 32 | flann::load_from_file(query, "brief100K.h5", "query"); 33 | 34 | dists = flann::Matrix(new DistanceType[query.rows * k_nn_], query.rows, k_nn_); 35 | indices = flann::Matrix(new size_t[query.rows * k_nn_], query.rows, k_nn_); 36 | 37 | printf("done\n"); 38 | 39 | // The matches are bogus so we compute them the hard way 40 | // flann::load_from_file(match,"brief100K.h5","indices"); 41 | 42 | flann::Index index(data, flann::LinearIndexParams()); 43 | index.buildIndex(); 44 | 45 | start_timer("Searching KNN for ground truth..."); 46 | gt_indices = flann::Matrix(new size_t[query.rows * k_nn_], query.rows, k_nn_); 47 | gt_dists = flann::Matrix(new DistanceType[query.rows * k_nn_], query.rows, k_nn_); 48 | index.knnSearch(query, gt_indices, gt_dists, k_nn_, flann::SearchParams(-1)); 49 | printf("done (%g seconds)\n", stop_timer()); 50 | } 51 | 52 | void TearDown() 53 | { 54 | delete[] data.ptr(); 55 | delete[] query.ptr(); 56 | delete[] gt_indices.ptr(); 57 | delete[] gt_dists.ptr(); 58 | delete[] dists.ptr(); 59 | delete[] indices.ptr(); 60 | } 61 | }; 62 | 63 | 64 | TEST_F(LshIndex_Brief100K, TestSearch) 65 | { 66 | TestSearch(data, flann::LshIndexParams(12, 20, 2), 67 | query, indices, dists, k_nn_, flann::SearchParams(-1), 0.9, gt_indices, gt_dists); 68 | } 69 | 70 | TEST_F(LshIndex_Brief100K, TestSearch2) 71 | { 72 | TestSearch2(data, flann::LshIndexParams(12, 20, 2), 73 | query, indices, dists, k_nn_, flann::SearchParams(-1), 0.9, gt_indices, gt_dists); 74 | } 75 | 76 | TEST_F(LshIndex_Brief100K, TestAddIncremental) 77 | { 78 | TestAddIncremental(data, flann::LshIndexParams(12, 20, 2), 79 | query, indices, dists, k_nn_, flann::SearchParams(-1), 0.9, gt_indices, gt_dists); 80 | } 81 | 82 | TEST_F(LshIndex_Brief100K, TestIncremental2) 83 | { 84 | TestAddIncremental2(data, flann::LshIndexParams(12, 20, 2), 85 | query, indices, dists, k_nn_, flann::SearchParams(-1), 0.9, gt_indices, gt_dists); 86 | } 87 | 88 | 89 | TEST_F(LshIndex_Brief100K, TestRemove) 90 | { 91 | TestRemove(data, flann::LshIndexParams(12, 20, 2), 92 | query, indices, dists, k_nn_, flann::SearchParams(-1)); 93 | } 94 | 95 | 96 | TEST_F(LshIndex_Brief100K, TestSave) 97 | { 98 | TestSave(data, flann::LshIndexParams(12, 20, 2), 99 | query, indices, dists, k_nn_, flann::SearchParams(-1), 0.9, gt_indices, gt_dists); 100 | } 101 | 102 | 103 | TEST_F(LshIndex_Brief100K, TestCopy) 104 | { 105 | TestCopy(data, flann::LshIndexParams(12, 20, 2), 106 | query, indices, dists, k_nn_, flann::SearchParams(-1), 0.9, gt_indices, gt_dists); 107 | } 108 | 109 | 110 | TEST_F(LshIndex_Brief100K, TestCopy2) 111 | { 112 | TestCopy2 >(data, flann::LshIndexParams(12, 20, 2), 113 | query, indices, dists, k_nn_, flann::SearchParams(-1), 0.9, gt_indices, gt_dists); 114 | } 115 | 116 | int main(int argc, char** argv) 117 | { 118 | testing::InitGoogleTest(&argc, argv); 119 | return RUN_ALL_TESTS(); 120 | } 121 | -------------------------------------------------------------------------------- /lib/ann/ann/src/kd_split.h: -------------------------------------------------------------------------------- 1 | //---------------------------------------------------------------------- 2 | // File: kd_split.h 3 | // Programmer: Sunil Arya and David Mount 4 | // Description: Methods for splitting kd-trees 5 | // Last modified: 01/04/05 (Version 1.0) 6 | //---------------------------------------------------------------------- 7 | // Copyright (c) 1997-2005 University of Maryland and Sunil Arya and 8 | // David Mount. All Rights Reserved. 9 | // 10 | // This software and related documentation is part of the Approximate 11 | // Nearest Neighbor Library (ANN). This software is provided under 12 | // the provisions of the Lesser GNU Public License (LGPL). See the 13 | // file ../ReadMe.txt for further information. 14 | // 15 | // The University of Maryland (U.M.) and the authors make no 16 | // representations about the suitability or fitness of this software for 17 | // any purpose. It is provided "as is" without express or implied 18 | // warranty. 19 | //---------------------------------------------------------------------- 20 | // History: 21 | // Revision 0.1 03/04/98 22 | // Initial release 23 | //---------------------------------------------------------------------- 24 | 25 | #ifndef ANN_KD_SPLIT_H 26 | #define ANN_KD_SPLIT_H 27 | 28 | #include "../../../ann/ann/src/kd_tree.h" // kd-tree definitions 29 | 30 | //---------------------------------------------------------------------- 31 | // External entry points 32 | // These are all splitting procedures for kd-trees. 33 | //---------------------------------------------------------------------- 34 | 35 | void kd_split( // standard (optimized) kd-splitter 36 | ANNpointArray pa, // point array (unaltered) 37 | ANNidxArray pidx, // point indices (permuted on return) 38 | const ANNorthRect &bnds, // bounding rectangle for cell 39 | int n, // number of points 40 | int dim, // dimension of space 41 | int &cut_dim, // cutting dimension (returned) 42 | ANNcoord &cut_val, // cutting value (returned) 43 | int &n_lo); // num of points on low side (returned) 44 | 45 | void midpt_split( // midpoint kd-splitter 46 | ANNpointArray pa, // point array (unaltered) 47 | ANNidxArray pidx, // point indices (permuted on return) 48 | const ANNorthRect &bnds, // bounding rectangle for cell 49 | int n, // number of points 50 | int dim, // dimension of space 51 | int &cut_dim, // cutting dimension (returned) 52 | ANNcoord &cut_val, // cutting value (returned) 53 | int &n_lo); // num of points on low side (returned) 54 | 55 | void sl_midpt_split( // sliding midpoint kd-splitter 56 | ANNpointArray pa, // point array (unaltered) 57 | ANNidxArray pidx, // point indices (permuted on return) 58 | const ANNorthRect &bnds, // bounding rectangle for cell 59 | int n, // number of points 60 | int dim, // dimension of space 61 | int &cut_dim, // cutting dimension (returned) 62 | ANNcoord &cut_val, // cutting value (returned) 63 | int &n_lo); // num of points on low side (returned) 64 | 65 | void fair_split( // fair-split kd-splitter 66 | ANNpointArray pa, // point array (unaltered) 67 | ANNidxArray pidx, // point indices (permuted on return) 68 | const ANNorthRect &bnds, // bounding rectangle for cell 69 | int n, // number of points 70 | int dim, // dimension of space 71 | int &cut_dim, // cutting dimension (returned) 72 | ANNcoord &cut_val, // cutting value (returned) 73 | int &n_lo); // num of points on low side (returned) 74 | 75 | void sl_fair_split( // sliding fair-split kd-splitter 76 | ANNpointArray pa, // point array (unaltered) 77 | ANNidxArray pidx, // point indices (permuted on return) 78 | const ANNorthRect &bnds, // bounding rectangle for cell 79 | int n, // number of points 80 | int dim, // dimension of space 81 | int &cut_dim, // cutting dimension (returned) 82 | ANNcoord &cut_val, // cutting value (returned) 83 | int &n_lo); // num of points on low side (returned) 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /lib/flann/test/flann_hierarchical_test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | 7 | #include "flann_tests.h" 8 | 9 | using namespace flann; 10 | 11 | 12 | class HierarchicalIndex_Brief100K : public FLANNTestFixture 13 | { 14 | protected: 15 | typedef flann::Hamming Distance; 16 | typedef Distance::ElementType ElementType; 17 | typedef Distance::ResultType DistanceType; 18 | flann::Matrix data; 19 | flann::Matrix query; 20 | flann::Matrix gt_indices; 21 | flann::Matrix dists; 22 | flann::Matrix gt_dists; 23 | flann::Matrix indices; 24 | unsigned int k_nn_; 25 | 26 | void SetUp() 27 | { 28 | k_nn_ = 3; 29 | printf("Reading test data..."); 30 | fflush(stdout); 31 | flann::load_from_file(data, "brief100K.h5", "dataset"); 32 | flann::load_from_file(query, "brief100K.h5", "query"); 33 | printf("done\n"); 34 | 35 | flann::Index index(data, flann::LinearIndexParams()); 36 | index.buildIndex(); 37 | 38 | start_timer("Searching KNN for ground truth..."); 39 | gt_indices = flann::Matrix(new size_t[query.rows * k_nn_], query.rows, k_nn_); 40 | gt_dists = flann::Matrix(new DistanceType[query.rows * k_nn_], query.rows, k_nn_); 41 | index.knnSearch(query, gt_indices, gt_dists, k_nn_, flann::SearchParams(-1)); 42 | printf("done (%g seconds)\n", stop_timer()); 43 | 44 | dists = flann::Matrix(new DistanceType[query.rows * k_nn_], query.rows, k_nn_); 45 | indices = flann::Matrix(new size_t[query.rows * k_nn_], query.rows, k_nn_); 46 | } 47 | 48 | void TearDown() 49 | { 50 | delete[] data.ptr(); 51 | delete[] query.ptr(); 52 | delete[] dists.ptr(); 53 | delete[] indices.ptr(); 54 | delete[] gt_indices.ptr(); 55 | delete[] gt_dists.ptr(); 56 | } 57 | }; 58 | 59 | 60 | TEST_F(HierarchicalIndex_Brief100K, TestSearch) 61 | { 62 | TestSearch(data, flann::HierarchicalClusteringIndexParams(), 63 | query, indices, dists, k_nn_, flann::SearchParams(2000), 0.9, gt_indices, gt_dists); 64 | } 65 | 66 | TEST_F(HierarchicalIndex_Brief100K, TestSearch2) 67 | { 68 | TestSearch2(data, flann::HierarchicalClusteringIndexParams(), 69 | query, indices, dists, k_nn_, flann::SearchParams(2000), 0.9, gt_indices, gt_dists); 70 | } 71 | 72 | 73 | TEST_F(HierarchicalIndex_Brief100K, TestAddIncremental) 74 | { 75 | TestAddIncremental(data, flann::HierarchicalClusteringIndexParams(), 76 | query, indices, dists, k_nn_, flann::SearchParams(2000), 0.87, gt_indices, gt_dists); 77 | } 78 | 79 | TEST_F(HierarchicalIndex_Brief100K, TestAddIncremental2) 80 | { 81 | TestAddIncremental2(data, flann::HierarchicalClusteringIndexParams(), 82 | query, indices, dists, k_nn_, flann::SearchParams(2000), 0.87, gt_indices, gt_dists); 83 | } 84 | 85 | TEST_F(HierarchicalIndex_Brief100K, TestRemove) 86 | { 87 | TestRemove(data, flann::HierarchicalClusteringIndexParams(), 88 | query, indices, dists, k_nn_, flann::SearchParams(2000)); 89 | } 90 | 91 | TEST_F(HierarchicalIndex_Brief100K, TestSave) 92 | { 93 | TestSave(data, flann::HierarchicalClusteringIndexParams(), 94 | query, indices, dists, k_nn_, flann::SearchParams(2000), 0.87, gt_indices, gt_dists); 95 | } 96 | 97 | 98 | TEST_F(HierarchicalIndex_Brief100K, TestCopy) 99 | { 100 | TestCopy(data, flann::HierarchicalClusteringIndexParams(), 101 | query, indices, dists, k_nn_, flann::SearchParams(2000), 0.87, gt_indices, gt_dists); 102 | } 103 | 104 | TEST_F(HierarchicalIndex_Brief100K, TestCopy2) 105 | { 106 | TestCopy2 >(data, flann::HierarchicalClusteringIndexParams(), 107 | query, indices, dists, k_nn_, flann::SearchParams(2000), 0.87, gt_indices, gt_dists); 108 | } 109 | 110 | 111 | 112 | 113 | 114 | int main(int argc, char** argv) 115 | { 116 | testing::InitGoogleTest(&argc, argv); 117 | return RUN_ALL_TESTS(); 118 | } 119 | -------------------------------------------------------------------------------- /lib/rapidxml/rapidxml_utils.hpp: -------------------------------------------------------------------------------- 1 | #ifndef RAPIDXML_UTILS_HPP_INCLUDED 2 | #define RAPIDXML_UTILS_HPP_INCLUDED 3 | 4 | // Copyright (C) 2006, 2009 Marcin Kalicinski 5 | // Version 1.13 6 | // Revision $DateTime: 2009/05/13 01:46:17 $ 7 | //! \file rapidxml_utils.hpp This file contains high-level rapidxml utilities that can be useful 8 | //! in certain simple scenarios. They should probably not be used if maximizing performance is the main objective. 9 | 10 | #include "rapidxml.hpp" 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | namespace rapidxml 17 | { 18 | 19 | //! Represents data loaded from a file 20 | template 21 | class file 22 | { 23 | 24 | public: 25 | 26 | //! Loads file into the memory. Data will be automatically destroyed by the destructor. 27 | //! \param filename Filename to load. 28 | file(const char *filename) 29 | { 30 | using namespace std; 31 | 32 | // Open stream 33 | basic_ifstream stream(filename, ios::binary); 34 | if (!stream) 35 | throw runtime_error(string("cannot open file ") + filename); 36 | stream.unsetf(ios::skipws); 37 | 38 | // Determine stream size 39 | stream.seekg(0, ios::end); 40 | size_t size = stream.tellg(); 41 | stream.seekg(0); 42 | 43 | // Load data and add terminating 0 44 | m_data.resize(size + 1); 45 | stream.read(&m_data.front(), static_cast(size)); 46 | m_data[size] = 0; 47 | } 48 | 49 | //! Loads file into the memory. Data will be automatically destroyed by the destructor 50 | //! \param stream Stream to load from 51 | file(std::basic_istream &stream) 52 | { 53 | using namespace std; 54 | 55 | // Load data and add terminating 0 56 | stream.unsetf(ios::skipws); 57 | m_data.assign(istreambuf_iterator(stream), istreambuf_iterator()); 58 | if (stream.fail() || stream.bad()) 59 | throw runtime_error("error reading stream"); 60 | m_data.push_back(0); 61 | } 62 | 63 | //! Gets file data. 64 | //! \return Pointer to data of file. 65 | Ch *data() 66 | { 67 | return &m_data.front(); 68 | } 69 | 70 | //! Gets file data. 71 | //! \return Pointer to data of file. 72 | const Ch *data() const 73 | { 74 | return &m_data.front(); 75 | } 76 | 77 | //! Gets file data size. 78 | //! \return Size of file data, in characters. 79 | std::size_t size() const 80 | { 81 | return m_data.size(); 82 | } 83 | 84 | private: 85 | 86 | std::vector m_data; // File data 87 | 88 | }; 89 | 90 | //! Counts children of node. Time complexity is O(n). 91 | //! \return Number of children of node 92 | template 93 | inline std::size_t count_children(xml_node *node) 94 | { 95 | xml_node *child = node->first_node(); 96 | std::size_t count = 0; 97 | while (child) 98 | { 99 | ++count; 100 | child = child->next_sibling(); 101 | } 102 | return count; 103 | } 104 | 105 | //! Counts attributes of node. Time complexity is O(n). 106 | //! \return Number of attributes of node 107 | template 108 | inline std::size_t count_attributes(xml_node *node) 109 | { 110 | xml_attribute *attr = node->first_attribute(); 111 | std::size_t count = 0; 112 | while (attr) 113 | { 114 | ++count; 115 | attr = attr->next_attribute(); 116 | } 117 | return count; 118 | } 119 | 120 | } 121 | 122 | #endif 123 | -------------------------------------------------------------------------------- /lib/flann/src/ruby/spec/flann_spec.rb: -------------------------------------------------------------------------------- 1 | # Copyright 2014 John O. Woods (john.o.woods@gmail.com), West Virginia 2 | # University's Applied Space Exploration Lab, and West Virginia Robotic 3 | # Technology Center. All rights reserved. 4 | # 5 | # THE BSD LICENSE 6 | # 7 | # Redistribution and use in source and binary forms, with or without 8 | # modification, are permitted provided that the following conditions 9 | # are met: 10 | # 11 | # 1. Redistributions of source code must retain the above copyright 12 | # notice, this list of conditions and the following disclaimer. 13 | # 2. Redistributions in binary form must reproduce the above copyright 14 | # notice, this list of conditions and the following disclaimer in the 15 | # documentation and/or other materials provided with the distribution. 16 | # 17 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | 28 | require File.dirname(__FILE__) + "/spec_helper.rb" 29 | 30 | describe Flann do 31 | 32 | it "::VERSION::STRING matches #define FLANN_VERSION_ in config.h" do 33 | found = false 34 | File.open(File.dirname(__FILE__) + "/../../cpp/flann/config.h", "r") do |f| 35 | while line = f.gets 36 | next unless line =~ /#[\s]*define[\s]+FLANN_VERSION_[\s]+"\d.\d.\d"/ 37 | fields = line.split 38 | found = true 39 | expect(fields.last[1...-1]).to eq(Flann::VERSION::STRING.split('.')[0...-1].join('.')) 40 | end 41 | end 42 | 43 | raise("could not find version string in config.h") unless found 44 | end 45 | 46 | it "works on the example given in the manual" do 47 | dataset = NMatrix.random([10000,128]) 48 | testset = NMatrix.random([1000,128]) 49 | 50 | index = Flann::Index.new(dataset) do |params| 51 | params[:algorithm] = :kmeans 52 | params[:branching] = 32 53 | params[:iterations] = 7 54 | params[:checks] = 16 55 | end 56 | speedup = index.build! # this is optional 57 | 58 | results, distances = index.nearest_neighbors(testset, 5) 59 | 60 | # Skip saving, as that's tested elsewhere, and I don't feel like cleaning up. 61 | # index.save "my_index.save" 62 | 63 | # Alternatively, without an index: 64 | results, distances = Flann.nearest_neighbors(dataset, testset, 5, 65 | algorithm: :kmeans, branching: 32, 66 | iterations: 7, checks: 16) 67 | end 68 | 69 | context "#set_distance_type!" do 70 | it "sets the distance functor without error" do 71 | Flann.set_distance_type! :euclidean 72 | 73 | # Version check needed before attempting get_distance_type 74 | if Flann.respond_to?(:flann_get_distance_type) 75 | d = Flann.get_distance_type 76 | expect(d).to eq(:euclidean) 77 | end 78 | end 79 | end 80 | 81 | [:byte, :int32, :float32, :float64].each do |dtype| 82 | before :each do 83 | scale = [:byte, :int32, :int64].include?(dtype) ? 255 : 1.0 84 | @dataset = NMatrix.random([1000,128], dtype: dtype, scale: scale) 85 | @testset = NMatrix.random([100,128], dtype: dtype, scale: scale) 86 | end 87 | 88 | context "#nearest_neighbors" do 89 | it "computes the nearest neighbors without an index" do 90 | Flann.nearest_neighbors @dataset, @testset, 5 91 | end 92 | end 93 | 94 | context "#cluster" do 95 | it "calls flann_compute_cluster_centers_... properly" do 96 | Flann.cluster(@dataset, 5) 97 | end 98 | end 99 | 100 | 101 | end 102 | 103 | 104 | end 105 | -------------------------------------------------------------------------------- /lib/flann/test/flann_kdtree_test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | 7 | #include "flann_tests.h" 8 | 9 | using namespace flann; 10 | 11 | /** 12 | * Test fixture for SIFT 10K dataset 13 | */ 14 | class KDTree_SIFT10K : public DatasetTestFixture { 15 | protected: 16 | KDTree_SIFT10K() : DatasetTestFixture("sift10K.h5") {} 17 | }; 18 | 19 | TEST_F(KDTree_SIFT10K, TestSearch) 20 | { 21 | TestSearch >(data, flann::KDTreeIndexParams(4), query, indices, 22 | dists, knn, flann::SearchParams(256), 0.75, gt_indices); 23 | } 24 | 25 | TEST_F(KDTree_SIFT10K, TestSearch2) 26 | { 27 | TestSearch2 >(data, flann::KDTreeIndexParams(4), query, indices, 28 | dists, knn, flann::SearchParams(256), 0.75, gt_indices); 29 | } 30 | 31 | 32 | TEST_F(KDTree_SIFT10K, TestAddIncremental) 33 | { 34 | TestAddIncremental >(data, flann::KDTreeIndexParams(4), query, indices, 35 | dists, knn, flann::SearchParams(256), 0.75, gt_indices); 36 | } 37 | 38 | TEST_F(KDTree_SIFT10K, TestAddIncremental2) 39 | { 40 | TestAddIncremental2 >(data, flann::KDTreeIndexParams(4), query, indices, 41 | dists, knn, flann::SearchParams(256), 0.75, gt_indices); 42 | } 43 | 44 | TEST_F(KDTree_SIFT10K, TestRemove) 45 | { 46 | TestRemove >(data, flann::KDTreeIndexParams(4), query, indices, 47 | dists, knn, flann::SearchParams(256) ); 48 | } 49 | 50 | 51 | TEST_F(KDTree_SIFT10K, TestSave) 52 | { 53 | TestSave >(data, flann::KDTreeIndexParams(4), query, indices, 54 | dists, knn, flann::SearchParams(256), 0.75, gt_indices); 55 | } 56 | 57 | 58 | TEST_F(KDTree_SIFT10K, TestCopy) 59 | { 60 | TestCopy >(data, flann::KDTreeIndexParams(4), query, indices, 61 | dists, knn, flann::SearchParams(256), 0.75, gt_indices); 62 | } 63 | 64 | TEST_F(KDTree_SIFT10K, TestCopy2) 65 | { 66 | TestCopy2 > >(data, flann::KDTreeIndexParams(4), query, indices, 67 | dists, knn, flann::SearchParams(256), 0.75, gt_indices); 68 | } 69 | 70 | /** 71 | * Test fixture for SIFT 100K dataset 72 | */ 73 | class KDTree_SIFT100K : public DatasetTestFixture { 74 | protected: 75 | KDTree_SIFT100K() : DatasetTestFixture("sift100K.h5") {} 76 | }; 77 | 78 | 79 | TEST_F(KDTree_SIFT100K, TestSearch) 80 | { 81 | TestSearch >(data, flann::KDTreeIndexParams(4), query, indices, 82 | dists, knn, flann::SearchParams(128), 0.75, gt_indices); 83 | } 84 | 85 | 86 | TEST_F(KDTree_SIFT100K, TestAddIncremental) 87 | { 88 | TestAddIncremental >(data, flann::KDTreeIndexParams(4), query, indices, 89 | dists, knn, flann::SearchParams(256), 0.75, gt_indices); 90 | } 91 | 92 | 93 | 94 | TEST_F(KDTree_SIFT100K, TestAddIncremental2) 95 | { 96 | TestAddIncremental2 >(data, flann::KDTreeIndexParams(4), query, indices, 97 | dists, knn, flann::SearchParams(256), 0.75, gt_indices); 98 | } 99 | 100 | 101 | TEST_F(KDTree_SIFT100K, TestRemove) 102 | { 103 | TestRemove >(data, flann::KDTreeIndexParams(4), query, indices, 104 | dists, knn, flann::SearchParams(128) ); 105 | } 106 | 107 | 108 | /** 109 | * Test fixture for SIFT 10K dataset with byte feature elements 110 | */ 111 | class KDTree_SIFT10K_byte : public DatasetTestFixture { 112 | protected: 113 | KDTree_SIFT10K_byte() : DatasetTestFixture("sift10K_byte.h5") {} 114 | }; 115 | 116 | 117 | TEST_F(KDTree_SIFT10K_byte, TestSearch) 118 | { 119 | TestSearch >(data, flann::KDTreeIndexParams(4), query, indices, 120 | dists, knn, flann::SearchParams(256), 0.75, gt_indices); 121 | } 122 | 123 | 124 | class KDTree_SIFT100K_byte : public DatasetTestFixture { 125 | protected: 126 | KDTree_SIFT100K_byte() : DatasetTestFixture("sift100K_byte.h5") {} 127 | }; 128 | 129 | 130 | TEST_F(KDTree_SIFT100K_byte, TestSearch) 131 | { 132 | TestSearch >(data, flann::KDTreeIndexParams(4), query, indices, 133 | dists, knn, flann::SearchParams(128), 0.75, gt_indices); 134 | } 135 | 136 | 137 | int main(int argc, char** argv) 138 | { 139 | testing::InitGoogleTest(&argc, argv); 140 | return RUN_ALL_TESTS(); 141 | } 142 | -------------------------------------------------------------------------------- /models/3D/robot_cylinder.obj: -------------------------------------------------------------------------------- 1 | # Blender v2.82 (sub 7) OBJ File: 'models_robot.blend' 2 | # www.blender.org 3 | v 0.000000 -1.000000 -0.500000 4 | v 0.000000 -1.000000 0.500000 5 | v -0.195090 -0.980785 -0.500000 6 | v -0.195090 -0.980785 0.500000 7 | v -0.382683 -0.923880 -0.500000 8 | v -0.382683 -0.923880 0.500000 9 | v -0.555570 -0.831470 -0.500000 10 | v -0.555570 -0.831470 0.500000 11 | v -0.707107 -0.707107 -0.500000 12 | v -0.707107 -0.707107 0.500000 13 | v -0.831470 -0.555570 -0.500000 14 | v -0.831470 -0.555570 0.500000 15 | v -0.923880 -0.382683 -0.500000 16 | v -0.923880 -0.382683 0.500000 17 | v -0.980785 -0.195090 -0.500000 18 | v -0.980785 -0.195090 0.500000 19 | v -1.000000 -0.000000 -0.500000 20 | v -1.000000 -0.000000 0.500000 21 | v -0.980785 0.195090 -0.500000 22 | v -0.980785 0.195090 0.500000 23 | v -0.923880 0.382683 -0.500000 24 | v -0.923880 0.382683 0.500000 25 | v -0.831470 0.555570 -0.500000 26 | v -0.831470 0.555570 0.500000 27 | v -0.707107 0.707107 -0.500000 28 | v -0.707107 0.707107 0.500000 29 | v -0.555570 0.831470 -0.500000 30 | v -0.555570 0.831470 0.500000 31 | v -0.382683 0.923880 -0.500000 32 | v -0.382683 0.923880 0.500000 33 | v -0.195090 0.980785 -0.500000 34 | v -0.195090 0.980785 0.500000 35 | v 0.000000 1.000000 -0.500000 36 | v 0.000000 1.000000 0.500000 37 | v 0.195091 0.980785 -0.500000 38 | v 0.195091 0.980785 0.500000 39 | v 0.382684 0.923879 -0.500000 40 | v 0.382684 0.923879 0.500000 41 | v 0.555571 0.831469 -0.500000 42 | v 0.555571 0.831469 0.500000 43 | v 0.707107 0.707106 -0.500000 44 | v 0.707107 0.707106 0.500000 45 | v 0.831470 0.555570 -0.500000 46 | v 0.831470 0.555570 0.500000 47 | v 0.923880 0.382683 -0.500000 48 | v 0.923880 0.382683 0.500000 49 | v 0.980785 0.195089 -0.500000 50 | v 0.980785 0.195089 0.500000 51 | v 1.000000 -0.000001 -0.500000 52 | v 1.000000 -0.000001 0.500000 53 | v 0.980785 -0.195091 -0.500000 54 | v 0.980785 -0.195091 0.500000 55 | v 0.923879 -0.382684 -0.500000 56 | v 0.923879 -0.382684 0.500000 57 | v 0.831469 -0.555571 -0.500000 58 | v 0.831469 -0.555571 0.500000 59 | v 0.707106 -0.707108 -0.500000 60 | v 0.707106 -0.707108 0.500000 61 | v 0.555569 -0.831470 -0.500000 62 | v 0.555569 -0.831470 0.500000 63 | v 0.382682 -0.923880 -0.500000 64 | v 0.382682 -0.923880 0.500000 65 | v 0.195089 -0.980786 -0.500000 66 | v 0.195089 -0.980786 0.500000 67 | s off 68 | f 2 3 1 69 | f 4 5 3 70 | f 6 7 5 71 | f 8 9 7 72 | f 10 11 9 73 | f 12 13 11 74 | f 14 15 13 75 | f 16 17 15 76 | f 18 19 17 77 | f 20 21 19 78 | f 22 23 21 79 | f 24 25 23 80 | f 26 27 25 81 | f 28 29 27 82 | f 30 31 29 83 | f 32 33 31 84 | f 34 35 33 85 | f 36 37 35 86 | f 38 39 37 87 | f 40 41 39 88 | f 42 43 41 89 | f 44 45 43 90 | f 46 47 45 91 | f 48 49 47 92 | f 50 51 49 93 | f 52 53 51 94 | f 54 55 53 95 | f 56 57 55 96 | f 58 59 57 97 | f 60 61 59 98 | f 54 38 22 99 | f 62 63 61 100 | f 64 1 63 101 | f 15 31 47 102 | f 2 4 3 103 | f 4 6 5 104 | f 6 8 7 105 | f 8 10 9 106 | f 10 12 11 107 | f 12 14 13 108 | f 14 16 15 109 | f 16 18 17 110 | f 18 20 19 111 | f 20 22 21 112 | f 22 24 23 113 | f 24 26 25 114 | f 26 28 27 115 | f 28 30 29 116 | f 30 32 31 117 | f 32 34 33 118 | f 34 36 35 119 | f 36 38 37 120 | f 38 40 39 121 | f 40 42 41 122 | f 42 44 43 123 | f 44 46 45 124 | f 46 48 47 125 | f 48 50 49 126 | f 50 52 51 127 | f 52 54 53 128 | f 54 56 55 129 | f 56 58 57 130 | f 58 60 59 131 | f 60 62 61 132 | f 6 4 2 133 | f 2 64 6 134 | f 64 62 6 135 | f 62 60 58 136 | f 58 56 54 137 | f 54 52 50 138 | f 50 48 54 139 | f 48 46 54 140 | f 46 44 38 141 | f 44 42 38 142 | f 42 40 38 143 | f 38 36 34 144 | f 34 32 30 145 | f 30 28 26 146 | f 26 24 22 147 | f 22 20 18 148 | f 18 16 22 149 | f 16 14 22 150 | f 14 12 10 151 | f 10 8 6 152 | f 62 58 6 153 | f 58 54 6 154 | f 38 34 22 155 | f 34 30 22 156 | f 30 26 22 157 | f 14 10 22 158 | f 10 6 22 159 | f 54 46 38 160 | f 6 54 22 161 | f 62 64 63 162 | f 64 2 1 163 | f 63 1 3 164 | f 3 5 7 165 | f 7 9 11 166 | f 11 13 7 167 | f 13 15 7 168 | f 15 17 19 169 | f 19 21 15 170 | f 21 23 15 171 | f 23 25 31 172 | f 25 27 31 173 | f 27 29 31 174 | f 31 33 35 175 | f 35 37 39 176 | f 39 41 43 177 | f 43 45 47 178 | f 47 49 51 179 | f 51 53 55 180 | f 55 57 63 181 | f 57 59 63 182 | f 59 61 63 183 | f 63 3 7 184 | f 31 35 47 185 | f 35 39 47 186 | f 39 43 47 187 | f 47 51 63 188 | f 51 55 63 189 | f 63 7 15 190 | f 15 23 31 191 | f 63 15 47 192 | -------------------------------------------------------------------------------- /models/3D/robot_cylinder_small.obj: -------------------------------------------------------------------------------- 1 | # Blender v2.82 (sub 7) OBJ File: 'models_robot.blend' 2 | # www.blender.org 3 | o Cylinder 4 | v 0.000000 -0.300000 -0.150000 5 | v 0.000000 -0.300000 0.150000 6 | v -0.058527 -0.294236 -0.150000 7 | v -0.058527 -0.294236 0.150000 8 | v -0.114805 -0.277164 -0.150000 9 | v -0.114805 -0.277164 0.150000 10 | v -0.166671 -0.249441 -0.150000 11 | v -0.166671 -0.249441 0.150000 12 | v -0.212132 -0.212132 -0.150000 13 | v -0.212132 -0.212132 0.150000 14 | v -0.249441 -0.166671 -0.150000 15 | v -0.249441 -0.166671 0.150000 16 | v -0.277164 -0.114805 -0.150000 17 | v -0.277164 -0.114805 0.150000 18 | v -0.294236 -0.058527 -0.150000 19 | v -0.294236 -0.058527 0.150000 20 | v -0.300000 -0.000000 -0.150000 21 | v -0.300000 -0.000000 0.150000 22 | v -0.294236 0.058527 -0.150000 23 | v -0.294236 0.058527 0.150000 24 | v -0.277164 0.114805 -0.150000 25 | v -0.277164 0.114805 0.150000 26 | v -0.249441 0.166671 -0.150000 27 | v -0.249441 0.166671 0.150000 28 | v -0.212132 0.212132 -0.150000 29 | v -0.212132 0.212132 0.150000 30 | v -0.166671 0.249441 -0.150000 31 | v -0.166671 0.249441 0.150000 32 | v -0.114805 0.277164 -0.150000 33 | v -0.114805 0.277164 0.150000 34 | v -0.058527 0.294236 -0.150000 35 | v -0.058527 0.294236 0.150000 36 | v 0.000000 0.300000 -0.150000 37 | v 0.000000 0.300000 0.150000 38 | v 0.058527 0.294236 -0.150000 39 | v 0.058527 0.294236 0.150000 40 | v 0.114805 0.277164 -0.150000 41 | v 0.114805 0.277164 0.150000 42 | v 0.166671 0.249441 -0.150000 43 | v 0.166671 0.249441 0.150000 44 | v 0.212132 0.212132 -0.150000 45 | v 0.212132 0.212132 0.150000 46 | v 0.249441 0.166671 -0.150000 47 | v 0.249441 0.166671 0.150000 48 | v 0.277164 0.114805 -0.150000 49 | v 0.277164 0.114805 0.150000 50 | v 0.294236 0.058527 -0.150000 51 | v 0.294236 0.058527 0.150000 52 | v 0.300000 -0.000000 -0.150000 53 | v 0.300000 -0.000000 0.150000 54 | v 0.294236 -0.058527 -0.150000 55 | v 0.294236 -0.058527 0.150000 56 | v 0.277164 -0.114805 -0.150000 57 | v 0.277164 -0.114805 0.150000 58 | v 0.249441 -0.166671 -0.150000 59 | v 0.249441 -0.166671 0.150000 60 | v 0.212132 -0.212132 -0.150000 61 | v 0.212132 -0.212132 0.150000 62 | v 0.166671 -0.249441 -0.150000 63 | v 0.166671 -0.249441 0.150000 64 | v 0.114805 -0.277164 -0.150000 65 | v 0.114805 -0.277164 0.150000 66 | v 0.058527 -0.294236 -0.150000 67 | v 0.058527 -0.294236 0.150000 68 | s off 69 | f 2 3 1 70 | f 4 5 3 71 | f 6 7 5 72 | f 8 9 7 73 | f 10 11 9 74 | f 12 13 11 75 | f 14 15 13 76 | f 16 17 15 77 | f 18 19 17 78 | f 20 21 19 79 | f 22 23 21 80 | f 24 25 23 81 | f 26 27 25 82 | f 28 29 27 83 | f 30 31 29 84 | f 32 33 31 85 | f 34 35 33 86 | f 36 37 35 87 | f 38 39 37 88 | f 40 41 39 89 | f 42 43 41 90 | f 44 45 43 91 | f 46 47 45 92 | f 48 49 47 93 | f 50 51 49 94 | f 52 53 51 95 | f 54 55 53 96 | f 56 57 55 97 | f 58 59 57 98 | f 60 61 59 99 | f 54 38 22 100 | f 62 63 61 101 | f 64 1 63 102 | f 15 31 47 103 | f 2 4 3 104 | f 4 6 5 105 | f 6 8 7 106 | f 8 10 9 107 | f 10 12 11 108 | f 12 14 13 109 | f 14 16 15 110 | f 16 18 17 111 | f 18 20 19 112 | f 20 22 21 113 | f 22 24 23 114 | f 24 26 25 115 | f 26 28 27 116 | f 28 30 29 117 | f 30 32 31 118 | f 32 34 33 119 | f 34 36 35 120 | f 36 38 37 121 | f 38 40 39 122 | f 40 42 41 123 | f 42 44 43 124 | f 44 46 45 125 | f 46 48 47 126 | f 48 50 49 127 | f 50 52 51 128 | f 52 54 53 129 | f 54 56 55 130 | f 56 58 57 131 | f 58 60 59 132 | f 60 62 61 133 | f 6 4 2 134 | f 2 64 6 135 | f 64 62 6 136 | f 62 60 58 137 | f 58 56 54 138 | f 54 52 50 139 | f 50 48 54 140 | f 48 46 54 141 | f 46 44 38 142 | f 44 42 38 143 | f 42 40 38 144 | f 38 36 34 145 | f 34 32 30 146 | f 30 28 26 147 | f 26 24 22 148 | f 22 20 18 149 | f 18 16 22 150 | f 16 14 22 151 | f 14 12 10 152 | f 10 8 6 153 | f 62 58 6 154 | f 58 54 6 155 | f 38 34 22 156 | f 34 30 22 157 | f 30 26 22 158 | f 14 10 22 159 | f 10 6 22 160 | f 54 46 38 161 | f 6 54 22 162 | f 62 64 63 163 | f 64 2 1 164 | f 63 1 3 165 | f 3 5 7 166 | f 7 9 11 167 | f 11 13 7 168 | f 13 15 7 169 | f 15 17 19 170 | f 19 21 15 171 | f 21 23 15 172 | f 23 25 31 173 | f 25 27 31 174 | f 27 29 31 175 | f 31 33 35 176 | f 35 37 39 177 | f 39 41 43 178 | f 43 45 47 179 | f 47 49 51 180 | f 51 53 55 181 | f 55 57 63 182 | f 57 59 63 183 | f 59 61 63 184 | f 63 3 7 185 | f 31 35 47 186 | f 35 39 47 187 | f 39 43 47 188 | f 47 51 63 189 | f 51 55 63 190 | f 63 7 15 191 | f 15 23 31 192 | f 63 15 47 193 | -------------------------------------------------------------------------------- /src/dijkstra.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file dijkstra.h 3 | * @author Jaroslav Janos (janosjar@fel.cvut.cz) 4 | * @brief Implementation of the Dijkstra algorithm, as proposed by Robert Penicka 5 | * @version 1.0 6 | * @date 23/04/2020 7 | * 8 | * @copyright Copyright (c) 2020 9 | * 10 | */ 11 | 12 | #ifndef __DIJKSTRA_H__ 13 | #define __DIJKSTRA_H__ 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include "primitives.h" 21 | #include "heap.h" 22 | 23 | #define DIJKSTRA_MAX std::numeric_limits::max() 24 | 25 | /** 26 | * @brief Main class for the Dijkstra algorithm 27 | * 28 | * @tparam T Floating type 29 | * @tparam R Point type 30 | */ 31 | template 32 | class Dijkstra { 33 | public: 34 | Dijkstra(){ 35 | } 36 | 37 | std::deque>> findPath(int start, std::vector &goals, 38 | std::deque> &connectedPoints); 39 | 40 | private: 41 | Node *expandBest(std::map *, PathNode> &pathPoints); 42 | std::unique_ptr>> heap; 43 | }; 44 | 45 | /** 46 | * @brief Finds shortest path from the start node to each of the goals nodes 47 | * 48 | * @tparam T Floating type 49 | * @tparam R Point type 50 | * @param start Start node 51 | * @param goals List of goal nodes 52 | * @param connectedPoints List of all nodes to be explored 53 | * @return std::deque> List of all paths from start 54 | */ 55 | template 56 | std::deque>> Dijkstra::findPath(int start, std::vector &goals, 57 | std::deque> &connectedPoints) { 58 | // 1. initialize nodes and heap 59 | std::deque>> retVal; 60 | 61 | heap = std::make_unique>>(connectedPoints, &(connectedPoints[start]), false); 62 | 63 | heap->pathPoints[&(connectedPoints[start])].distanceFromStart = 0; 64 | heap->pathPoints[&(connectedPoints[start])].previousPoint = &(connectedPoints[start]); 65 | heap->sort(); 66 | 67 | std::set unvisitedGoals(goals.begin(), goals.end()); 68 | 69 | // 2. dijkstra 70 | while(true) { 71 | Node *best{expandBest(heap->pathPoints)}; 72 | 73 | if (best == NULL || heap->pathPoints[best].distanceFromStart == DIJKSTRA_MAX) { 74 | break; 75 | } 76 | 77 | // verify goals (goals are only reward points, so...) 78 | if (best->IsRoot()) { 79 | auto goalIter{unvisitedGoals.find(best->GetId())}; 80 | if (goalIter != unvisitedGoals.end()) { 81 | unvisitedGoals.erase(best->GetId()); 82 | if (unvisitedGoals.empty()) { 83 | break; 84 | } 85 | } 86 | } 87 | } 88 | 89 | // 3. create list of plans 90 | for (int goal : goals) { 91 | DistanceHolder> &plan{retVal.emplace_back(&(connectedPoints[start]), &(connectedPoints[goal]))}; 92 | 93 | Node *actNode{&(connectedPoints[goal])}; 94 | if (heap->pathPoints[actNode].previousPoint != NULL) { 95 | plan.distance = heap->pathPoints[actNode].distanceFromStart; 96 | plan.plan.push_front(actNode); 97 | 98 | Node *startNode{&(connectedPoints[start])}; 99 | while (actNode != startNode) { 100 | actNode = heap->pathPoints[actNode].previousPoint; 101 | plan.plan.push_front(actNode); 102 | } 103 | } else { 104 | //empty plan 105 | plan.distance = DIJKSTRA_MAX; 106 | } 107 | } 108 | 109 | return retVal; 110 | } 111 | 112 | /** 113 | * @brief Updates cost info for the actually best node in the heap 114 | * 115 | * @tparam T Floating type 116 | * @tparam R Point type 117 | * @param pathPoints Map containing info about the best neigbouring nodes 118 | * @return Node* The best node, which is expanded 119 | */ 120 | template 121 | Node* Dijkstra::expandBest(std::map *, PathNode> &pathPoints) { 122 | Node *actual{heap->pop()}; 123 | 124 | if (actual != NULL) { 125 | for (auto &nodeDistPair : actual->VisibleNodes) { 126 | T newDist{heap->pathPoints[actual].distanceFromStart + nodeDistPair.second}; 127 | 128 | if (newDist < heap->pathPoints[nodeDistPair.first].distanceFromStart) { 129 | heap->pathPoints[nodeDistPair.first].previousPoint = actual; 130 | heap->updateCost(nodeDistPair.first, newDist); 131 | } 132 | } 133 | } 134 | 135 | return actual; 136 | } 137 | 138 | #endif 139 | -------------------------------------------------------------------------------- /lib/ann/ann/src/Makefile: -------------------------------------------------------------------------------- 1 | #----------------------------------------------------------------------------- 2 | # Makefile for ANN library 3 | #---------------------------------------------------------------------- 4 | # Copyright (c) 1997-2005 University of Maryland and Sunil Arya and 5 | # David Mount. All Rights Reserved. 6 | # 7 | # This software and related documentation is part of the Approximate 8 | # Nearest Neighbor Library (ANN). This software is provided under 9 | # the provisions of the Lesser GNU Public License (LGPL). See the 10 | # file ../ReadMe.txt for further information. 11 | # 12 | # The University of Maryland (U.M.) and the authors make no 13 | # representations about the suitability or fitness of this software for 14 | # any purpose. It is provided "as is" without express or implied 15 | # warranty. 16 | #---------------------------------------------------------------------- 17 | # History: 18 | # Revision 0.1 03/04/98 19 | # Initial release 20 | # Revision 1.0 04/01/05 21 | # Renamed files from .cc to .cpp for Microsoft Visual C++ 22 | # Added kd_dump.cpp 23 | # Revision 1.1 05/03/05 24 | # Added kd_fix_rad_search.cpp and bd_fix_rad_search.cpp 25 | #---------------------------------------------------------------------- 26 | 27 | #----------------------------------------------------------------------------- 28 | # Some basic definitions: 29 | # BASEDIR where include, src, lib, ... are 30 | # INCLIB include directory 31 | # LIBLIB library directory 32 | #----------------------------------------------------------------------------- 33 | BASEDIR = .. 34 | INCDIR = $(BASEDIR)/include 35 | LIBDIR = $(BASEDIR)/lib 36 | 37 | SOURCES = ANN.cpp brute.cpp kd_tree.cpp kd_util.cpp kd_split.cpp \ 38 | kd_dump.cpp kd_search.cpp kd_pr_search.cpp kd_fix_rad_search.cpp \ 39 | bd_tree.cpp bd_search.cpp bd_pr_search.cpp bd_fix_rad_search.cpp \ 40 | perf.cpp 41 | 42 | HEADERS = kd_tree.h kd_split.h kd_util.h kd_search.h \ 43 | kd_pr_search.h kd_fix_rad_search.h perf.h pr_queue.h pr_queue_k.h 44 | 45 | OBJECTS = $(SOURCES:.cpp=.o) 46 | 47 | #----------------------------------------------------------------------------- 48 | # Make the library 49 | #----------------------------------------------------------------------------- 50 | 51 | default: 52 | @echo "Specify a target configuration" 53 | 54 | targets: $(LIBDIR)/$(ANNLIB) 55 | 56 | $(LIBDIR)/$(ANNLIB): $(OBJECTS) 57 | $(MAKELIB) $(ANNLIB) $(OBJECTS) 58 | $(RANLIB) $(ANNLIB) 59 | mv $(ANNLIB) $(LIBDIR) 60 | 61 | #----------------------------------------------------------------------------- 62 | # Make object files 63 | #----------------------------------------------------------------------------- 64 | 65 | ANN.o: ANN.cpp 66 | $(C++) -c -I$(INCDIR) $(CFLAGS) ANN.cpp 67 | 68 | brute.o: brute.cpp 69 | $(C++) -c -I$(INCDIR) $(CFLAGS) brute.cpp 70 | 71 | kd_tree.o: kd_tree.cpp 72 | $(C++) -c -I$(INCDIR) $(CFLAGS) kd_tree.cpp 73 | 74 | kd_util.o: kd_util.cpp 75 | $(C++) -c -I$(INCDIR) $(CFLAGS) kd_util.cpp 76 | 77 | kd_split.o: kd_split.cpp 78 | $(C++) -c -I$(INCDIR) $(CFLAGS) kd_split.cpp 79 | 80 | kd_search.o: kd_search.cpp 81 | $(C++) -c -I$(INCDIR) $(CFLAGS) kd_search.cpp 82 | 83 | kd_pr_search.o: kd_pr_search.cpp 84 | $(C++) -c -I$(INCDIR) $(CFLAGS) kd_pr_search.cpp 85 | 86 | kd_fix_rad_search.o: kd_fix_rad_search.cpp 87 | $(C++) -c -I$(INCDIR) $(CFLAGS) kd_fix_rad_search.cpp 88 | 89 | kd_dump.o: kd_dump.cpp 90 | $(C++) -c -I$(INCDIR) $(CFLAGS) kd_dump.cpp 91 | 92 | bd_tree.o: bd_tree.cpp 93 | $(C++) -c -I$(INCDIR) $(CFLAGS) bd_tree.cpp 94 | 95 | bd_search.o: bd_search.cpp 96 | $(C++) -c -I$(INCDIR) $(CFLAGS) bd_search.cpp 97 | 98 | bd_pr_search.o: bd_pr_search.cpp 99 | $(C++) -c -I$(INCDIR) $(CFLAGS) bd_pr_search.cpp 100 | 101 | bd_fix_rad_search.o: bd_fix_rad_search.cpp 102 | $(C++) -c -I$(INCDIR) $(CFLAGS) bd_fix_rad_search.cpp 103 | 104 | perf.o: perf.cpp 105 | $(C++) -c -I$(INCDIR) $(CFLAGS) perf.cpp 106 | 107 | #----------------------------------------------------------------------------- 108 | # Configuration definitions 109 | #----------------------------------------------------------------------------- 110 | 111 | include ../Make-config 112 | 113 | #----------------------------------------------------------------------------- 114 | # Cleaning 115 | #----------------------------------------------------------------------------- 116 | 117 | clean: 118 | -rm -f *.o core 119 | 120 | realclean: clean 121 | 122 | --------------------------------------------------------------------------------