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 dependency graph for test-cuik-kdtree.c:

Go to the source code of this file.

Macros

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

Functions

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

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.

Macro Definition 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 82 of file test-cuik-kdtree.c.

Referenced by main().

#define N_POINTS   50000

Number of points used by default.

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

Referenced by main().

#define DIM   8

Dimension of the points used by default.

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

Referenced by main().

#define TOPOLOGY   TOPOLOGY_S

Topology of the points used by default.

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

Referenced by main().

#define POINTS_IN_LEAF   25

Maximum number of points in a leaf.

Definition at line 110 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 119 of file test-cuik-kdtree.c.

Referenced by main().

#define R   2.0

Search radius.

Definition at line 126 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 134 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 142 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
aPointer to the first unsigned int to compare.
bPointer 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 170 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 175 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
argcNumber of elements in the command line that starts the application (i.e., the cuikatlas command itself and its arguments).
argStrings with the arguments.
Returns
EXIT_SUCCESS (0) if the execution worked out fine and EXIT_FAILURE if not.

Definition at line 208 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, PlotKDtree(), POINTS_IN_LEAF, POINTS_ON_SPHERE, 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: