Public Member Functions

ANNbruteForce Class Reference

#include <ANN.h>

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

List of all members.

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 ()

Detailed Description

Definition at line 544 of file ANN.h.


Constructor & Destructor Documentation

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

Definition at line 44 of file brute.cpp.

{
        dim = dd;  n_pts = n;  pts = pa;
}
ANNbruteForce::~ANNbruteForce (  )

Definition at line 52 of file brute.cpp.

{ }             // 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(), ANNmin_k::insert(), ANNmin_k::ith_smallest_info(), and ANNmin_k::ith_smallest_key().

{
        ANNmin_k mk(k);                                         // construct a k-limited priority queue
        int i;
        int pts_in_range = 0;                           // number of points in query range
                                                                                // run every point through queue
        for (i = 0; i < n_pts; i++) {
                                                                                // compute distance to point
                ANNdist sqDist = annDist(dim, pts[i], q);
                if (sqDist <= sqRad &&                  // within radius bound
                        (ANN_ALLOW_SELF_MATCH || sqDist != 0)) { // ...and no self match
                        mk.insert(sqDist, i);
                        pts_in_range++;
                }
        }
        for (i = 0; i < k; i++) {                       // extract the k closest points
                if (dd != NULL)
                        dd[i] = mk.ith_smallest_key(i);
                if (nn_idx != NULL)
                        nn_idx[i] = mk.ith_smallest_info(i);
        }

        return pts_in_range;
}
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(), ANNmin_k::insert(), ANNmin_k::ith_smallest_info(), and ANNmin_k::ith_smallest_key().

{
        ANNmin_k mk(k);                                         // construct a k-limited priority queue
        int i;

        if (k > n_pts) {                                        // too many near neighbors?
                annError("Requesting more near neighbors than data points", ANNabort);
        }
                                                                                // run every point through queue
        for (i = 0; i < n_pts; i++) {
                                                                                // compute distance to point
                ANNdist sqDist = annDist(dim, pts[i], q);
                if (ANN_ALLOW_SELF_MATCH || sqDist != 0)
                        mk.insert(sqDist, i);
        }
        for (i = 0; i < k; i++) {                       // extract the k closest points
                dd[i] = mk.ith_smallest_key(i);
                nn_idx[i] = mk.ith_smallest_info(i);
        }
}
int ANNbruteForce::nPoints (  ) [inline, virtual]

Implements ANNpointSet.

Definition at line 574 of file ANN.h.

                { return n_pts; }
int ANNbruteForce::theDim (  ) [inline, virtual]

Implements ANNpointSet.

Definition at line 571 of file ANN.h.

                { return dim; }
ANNpointArray ANNbruteForce::thePoints (  ) [inline, virtual]

Implements ANNpointSet.

Definition at line 577 of file ANN.h.

                {  return pts;  }

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines