queso-0.53.0
Public Member Functions | Private Attributes | List of all members
ANNbruteForce Class Reference

#include <ANN.h>

Inheritance diagram for ANNbruteForce:
Inheritance graph
[legend]
Collaboration diagram for ANNbruteForce:
Collaboration graph
[legend]

Public Member Functions

 ANNbruteForce (ANNpointArray pa, int n, int dd)
 
 ~ANNbruteForce ()
 
void annkSearch (ANNpoint q, int k, ANNidxArray nn_idx, ANNdistArray dd, double eps=0.0)
 
int annkFRSearch (ANNpoint q, ANNdist sqRad, int k=0, ANNidxArray nn_idx=NULL, ANNdistArray dd=NULL, double eps=0.0)
 
int theDim ()
 
int nPoints ()
 
ANNpointArray thePoints ()
 
- Public Member Functions inherited from ANNpointSet
virtual ~ANNpointSet ()
 

Private Attributes

int dim
 
int n_pts
 
ANNpointArray pts
 

Detailed Description

Definition at line 538 of file ANN.h.

Constructor & Destructor Documentation

ANNbruteForce::ANNbruteForce ( ANNpointArray  pa,
int  n,
int  dd 
)

Definition at line 44 of file brute.cpp.

References dim, n_pts, and pts.

48 {
49  dim = dd; n_pts = n; pts = pa;
50 }
int dim
Definition: ANN.h:539
int n_pts
Definition: ANN.h:540
ANNpointArray pts
Definition: ANN.h:541
ANNbruteForce::~ANNbruteForce ( )

Definition at line 52 of file brute.cpp.

52 { } // destructor (empty)

Member Function Documentation

int ANNbruteForce::annkFRSearch ( ANNpoint  q,
ANNdist  sqRad,
int  k = 0,
ANNidxArray  nn_idx = NULL,
ANNdistArray  dd = NULL,
double  eps = 0.0 
)
virtual

Implements ANNpointSet.

Definition at line 80 of file brute.cpp.

References ANN_ALLOW_SELF_MATCH, annDist(), dim, ANNmin_k::insert(), ANNmin_k::ith_smallest_info(), ANNmin_k::ith_smallest_key(), k, n_pts, and pts.

Referenced by getTrueNN().

87 {
88  ANNmin_k mk(k); // construct a k-limited priority queue
89  int i;
90  int pts_in_range = 0; // number of points in query range
91  // run every point through queue
92  for (i = 0; i < n_pts; i++) {
93  // compute distance to point
94  ANNdist sqDist = annDist(dim, pts[i], q);
95  if (sqDist <= sqRad && // within radius bound
96  (ANN_ALLOW_SELF_MATCH || sqDist != 0)) { // ...and no self match
97  mk.insert(sqDist, i);
98  pts_in_range++;
99  }
100  }
101  for (i = 0; i < k; i++) { // extract the k closest points
102  if (dd != NULL)
103  dd[i] = mk.ith_smallest_key(i);
104  if (nn_idx != NULL)
105  nn_idx[i] = mk.ith_smallest_info(i);
106  }
107 
108  return pts_in_range;
109 }
int dim
Definition: ANN.h:539
int n_pts
Definition: ANN.h:540
ANNpointArray pts
Definition: ANN.h:541
const ANNbool ANN_ALLOW_SELF_MATCH
Definition: ANN.h:235
DLL_API ANNdist annDist(int dim, ANNpoint p, ANNpoint q)
Definition: ANN.cpp:46
double ANNdist
Definition: ANN.h:159
int k
Definition: ann_sample.cpp:53
void ANNbruteForce::annkSearch ( ANNpoint  q,
int  k,
ANNidxArray  nn_idx,
ANNdistArray  dd,
double  eps = 0.0 
)
virtual

Implements ANNpointSet.

Definition at line 54 of file brute.cpp.

References ANN_ALLOW_SELF_MATCH, ANNabort, annDist(), annError(), dim, ANNmin_k::insert(), ANNmin_k::ith_smallest_info(), ANNmin_k::ith_smallest_key(), k, n_pts, and pts.

Referenced by getTrueNN().

60 {
61  ANNmin_k mk(k); // construct a k-limited priority queue
62  int i;
63 
64  if (k > n_pts) { // too many near neighbors?
65  annError("Requesting more near neighbors than data points", ANNabort);
66  }
67  // run every point through queue
68  for (i = 0; i < n_pts; i++) {
69  // compute distance to point
70  ANNdist sqDist = annDist(dim, pts[i], q);
71  if (ANN_ALLOW_SELF_MATCH || sqDist != 0)
72  mk.insert(sqDist, i);
73  }
74  for (i = 0; i < k; i++) { // extract the k closest points
75  dd[i] = mk.ith_smallest_key(i);
76  nn_idx[i] = mk.ith_smallest_info(i);
77  }
78 }
int dim
Definition: ANN.h:539
Definition: ANNx.h:48
int n_pts
Definition: ANN.h:540
ANNpointArray pts
Definition: ANN.h:541
const ANNbool ANN_ALLOW_SELF_MATCH
Definition: ANN.h:235
void annError(const char *msg, ANNerr level)
Definition: ANN.cpp:169
DLL_API ANNdist annDist(int dim, ANNpoint p, ANNpoint q)
Definition: ANN.cpp:46
double ANNdist
Definition: ANN.h:159
int k
Definition: ann_sample.cpp:53
int ANNbruteForce::nPoints ( )
inlinevirtual

Implements ANNpointSet.

Definition at line 568 of file ANN.h.

References n_pts.

569  { return n_pts; }
int n_pts
Definition: ANN.h:540
int ANNbruteForce::theDim ( )
inlinevirtual

Implements ANNpointSet.

Definition at line 565 of file ANN.h.

References dim.

566  { return dim; }
int dim
Definition: ANN.h:539
ANNpointArray ANNbruteForce::thePoints ( )
inlinevirtual

Implements ANNpointSet.

Definition at line 571 of file ANN.h.

References pts.

572  { return pts; }
ANNpointArray pts
Definition: ANN.h:541

Member Data Documentation

int ANNbruteForce::dim
private

Definition at line 539 of file ANN.h.

Referenced by ANNbruteForce(), annkFRSearch(), and annkSearch().

int ANNbruteForce::n_pts
private

Definition at line 540 of file ANN.h.

Referenced by ANNbruteForce(), annkFRSearch(), and annkSearch().

ANNpointArray ANNbruteForce::pts
private

Definition at line 541 of file ANN.h.

Referenced by ANNbruteForce(), annkFRSearch(), and annkSearch().


The documentation for this class was generated from the following files:

Generated on Thu Jun 11 2015 13:52:33 for queso-0.53.0 by  doxygen 1.8.5