The Cuik KD-Tree Library


test-cuik-kdtree.c File Reference

Test program for the cuik-kdtree library. More...

#include "cuik-kdtree.h"
#include "random.h"
#include "definitions.h"
#include "vector.h"
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <sys/resource.h>
#include <DNN/ANN_C.h>
Include dependency graph for test-cuik-kdtree.c:

Go to the source code of this file.

Defines

#define POINTS_ON_SPHERE   0
 Method to generate the random points.
#define N_POINTS   50000
 Number of points.
#define DIM   8
 Dimension.
#define TOPOLOGY   TOPOLOGY_S
 Topology.
#define POINTS_IN_LEAF   25
#define SAMPLING_EXPANSION   1.0
 Sampling area expansion.
#define R   2.0
#define REP   1000
 Number of queries.
#define N_OPTIONS   9
 Number of command line options.

Functions

int CmpUInt (const void *a, const void *b)
 Compares two unsigned integers.
double getTime ()
 Gets the time in miliseconds.
int main (int argc, char **arg)
 Main body of the test program for the cuik-kdtree library.

Detailed Description

Test program for the cuik-kdtree library. We evaluate the correctness and the peformance of the kd-tree search and compare it with alternative approaches.

Definition in file test-cuik-kdtree.c.


Define Documentation

#define POINTS_ON_SPHERE   0

If set to 1, the random points are generated on a k-dimensional sphere. Otherwise, the points are generated with uniform distribution in the [-1,1] range.

This is used to simulate the search of nearest-neighbours on a manifold

Definition at line 33 of file test-cuik-kdtree.c.

#define N_POINTS   50000

Number of points used by default.

Definition at line 40 of file test-cuik-kdtree.c.

Referenced by main().

#define DIM   8

Dimension of the points used by default.

Definition at line 47 of file test-cuik-kdtree.c.

Referenced by main().

#define TOPOLOGY   TOPOLOGY_S

Topology of the points used by default.

Definition at line 54 of file test-cuik-kdtree.c.

Referenced by main().

#define POINTS_IN_LEAF   25

Maximum number of points in a leaf.

Definition at line 61 of file test-cuik-kdtree.c.

Referenced by main().

#define SAMPLING_EXPANSION   1.0

Expansion of the area covered by the kd-tree used for sampling.

Currently not used.

Definition at line 70 of file test-cuik-kdtree.c.

Referenced by main().

#define R   2.0

Search radius.

Definition at line 77 of file test-cuik-kdtree.c.

Referenced by main().

#define REP   1000

Number of queries used when evaluating the efficiency of the methods.

Definition at line 85 of file test-cuik-kdtree.c.

Referenced by main().

#define N_OPTIONS   9

Number of command line options available to the test program.

Definition at line 93 of file test-cuik-kdtree.c.

Referenced by main().


Function Documentation

int CmpUInt ( const void *  a,
const void *  b 
)

Compares two unsigned integres. Used for the (quick)sort of the resuts of the proximity queries.

Parameters:
a Pointer to the first unsigned int to compare.
b Pointer to the second unsigned int to compare.
Returns:
Negative if 'b' is larger than 'a', zero if they are equal and possitive if 'a' is larger than 'b'.

Definition at line 121 of file test-cuik-kdtree.c.

Referenced by main().

Here is the caller graph for this function:

double getTime (  ) 

Gets the time in miliseconds used by the program so far.

Returns:
The used time in miliseconds.

Definition at line 126 of file test-cuik-kdtree.c.

Referenced by main().

Here is the caller graph for this function:

int main ( int  argc,
char **  arg 
)

Main body of the test program for the cuik-kdtree library.

Use:

  • test-cuik-kdtree

or

  • test-cuik-kdtree -h

to get a help message about the possible commands for this test application.

Parameters:
argc Number of elements in the command line that starts the application (i.e., the cuikatlas command itself and its arguments).
arg Strings with the arguments.
Returns:
EXIT_SUCCESS (0) if the execution worked out fine and EXIT_FAILURE if not.

Definition at line 159 of file test-cuik-kdtree.c.

References AddPoint2KDtree(), CmpUInt(), DeleteKDtree(), DeleteRectangle(), DIM, FALSE, getTime(), INF, InitKDTree(), InitRectangle(), M_PI, MEM_DUP, N_OPTIONS, N_POINTS, NearestNeighbour(), NeighboursInBall(), NEW, POINTS_IN_LEAF, R, randomNormal(), RandomPointInRectangle(), randomSet(), REP, SAMPLING_EXPANSION, SetRectangleLowerLimit(), SetRectangleUpperLimit(), TOPOLOGY, TOPOLOGY_R, TOPOLOGY_S, TRUE, VectorNormalize(), and VectorSquaredDistanceTopologyMin().

Here is the call graph for this function: