Data Structures | Functions

src/nnsearch.h File Reference

STATUS: work in progress Fast Nearest-Neighbour searching. More...

#include "mathadd.h"
#include "distances.h"
#include "definitions.h"
#include "optarg.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  SearchTree

Functions

SearchTreenn_prepare (const double **X, int m, int N, OptArgList *optargs)
void nn_search_k (const SearchTree *S, const double *x, int k, int *nn_idx, double *nn_dist)
void nn_searck_k_slow (const double **X, int N, int m, const double *x, int k, int *nn_idx, double *nn_dist, OptArgList *optargs)

Detailed Description

STATUS: work in progress Fast Nearest-Neighbour searching.

see

Merkwirth et al. Fast nearest-neighbor searching for nonlinear signal processing. Physical review E, Statistical physics, plasmas, fluids, and related interdisciplinary topics (2000) vol. 62 (2 Pt A) pp. 2089-97

Definition in file nnsearch.h.


Function Documentation

SearchTree* nn_prepare ( const double **  X,
int  N,
int  m,
OptArgList optargs 
)

Initialize the search tree for fast-nearest-neighbour searching.

Parameters:
data matrix of m variables with N measurements each
m dimensionality
N number of measurements
optargs may contain:

  • 'metric=void*' the distance metric used (default=euclidean)
  • 'max_numel_terminal_node=int' the maximum number of elements in a terminal node (default=50)
  • optional arguments for the called function (e.g. metric)
Returns:
the searchtree-struct used to look for nearest neighbours

Definition at line 38 of file nnsearch.c.

void nn_search_k ( const SearchTree S,
const double *  x,
int  k,
int *  nn_idx,
double *  nn_dist 
)

Searching the k nearest neighbour of vector x in searchtree. This implementation uses a searchtree-based method.

Parameters:
S the searchtree, previously initialized by nn_prepare
x query point; must be of dimension m in searchtree S
k number of neighbours to look for
nn_idx memory for holding the indices for the k NN's
nn_dist memory for holding distances for k NN's

Definition at line 147 of file nnsearch.c.

void nn_searck_k_slow ( const double **  X,
int  N,
int  m,
const double *  x,
int  k,
int *  nn_idx,
double *  nn_dist,
OptArgList optargs 
)