GithubHelp home page GithubHelp logo

johnelvis / kdtree Goto Github PK

View Code? Open in Web Editor NEW

This project forked from taiya/kdtree

0.0 1.0 0.0 598 KB

Automatically exported from code.google.com/p/kdtree-matlab

Makefile 5.07% C++ 77.34% C 2.35% MATLAB 15.24%

kdtree's Introduction

kdtree

(Automatically exported from code.google.com/p/kdtree-matlab)

This library provides a minimalist implementation of a kd-tree data structure. The implementation can be used either inside MATLAB by means of MEX calls, or as a standalone tool, directly using its C/C++ interface. The image on the side has been created within matlab from "fulltest.m".

Basic API

  • kdtree_build: k-d tree construction O( n log^2(n) )
  • kdtree_delete: frees memory allocated by kdtree
  • kdtree_nearest_neighbor: nearest neighbor query (for one or more points)
  • kdtree_k_nearest_neighbors: kNN for a single query point
  • kdtree_range_query: rectangular range query
  • kdtree_ball_query: queries samples within distance delta from a point

File Structure

Everyone of the scripts/functions is complete of the following:

  • *.cpp: the mex implementation of the sources
  • *.mexmaci: the compiled version of the mex (intel mac)
  • *.m: the comments that you can browse with the "help" command
  • *_demo.m: demo file to illustrate the behavior

Matlab Class Wrapper

I am in the process of building a MATLAB class wrapper for the library. These are the advantages:

  • the memory will be freed automatically
  • ability to load/save kdtree structures to/from a .mat file
  • better organization

How to compile/install in Matlab

Compiling can be done in two ways. The first is directly inside MATLAB. You can compile manually each of the files by calling the command mex within the kdtree folder from the MATLAB command line. For example:

>> mex kdtree_build.cpp 

Alternatively, if you are in a unix environment, you might also be able to use the provided makefile. In order to do this you need to change some of the environment variables in order to make them point to your local MATLAB installation.

NOTE: Correctly setup I assumed you have a correctly configured MEX environment.

Hacking and development

The *.cpp files contain a MEX interface for MATLAB. At the same time, a rich set of examples which run as standalone C++ applications is provided. In order to compile them independetly from the MEX environment, a preprocessor condition -D CPPONLY is required. The makefile uses this flags and compiles sources in both environments: C++ and MEX.

kdtree's People

Contributors

taiya avatar bertholet avatar skoch9 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.