|
bufferkdtree (C sources)
C source code for the Python bufferkdtree implementation
|
#include "include/cpu.h"#include "include/base.h"#include "include/util.h"#include "include/global.h"
Functions | |
| void | init_cpu (BRUTE_RECORD *brute_record, BRUTE_PARAMETERS *params) |
| void | fit_cpu (FLOAT_TYPE *Xtrain, int nXtrain, int dXtrain, BRUTE_RECORD *brute_record, BRUTE_PARAMETERS *params) |
| void | free_resources_cpu (BRUTE_RECORD *brute_record, BRUTE_PARAMETERS *params) |
| void | neighbors_cpu (FLOAT_TYPE *Xtest, int nXtest, int dXtest, FLOAT_TYPE *d_mins, int *idx_mins, BRUTE_RECORD *brute_record, BRUTE_PARAMETERS *params) |
| void | compute_neighbors_single_instance_cpu (FLOAT_TYPE *Xtrain, int nXtrain, int dim, FLOAT_TYPE *test_pattern, FLOAT_TYPE *d_min, int *idx_min, int K) |
| FLOAT_TYPE | squared_dist_cpu (FLOAT_TYPE *a, FLOAT_TYPE *b, int dim) |
| void | insert_cpu (FLOAT_TYPE pattern_dist, int pattern_idx, FLOAT_TYPE *nearest_dist, int *nearest_idx, int K) |
| void compute_neighbors_single_instance_cpu | ( | FLOAT_TYPE * | Xtrain, |
| int | nXtrain, | ||
| int | dim, | ||
| FLOAT_TYPE * | test_pattern, | ||
| FLOAT_TYPE * | d_min, | ||
| int * | idx_min, | ||
| int | K | ||
| ) |
Computes nearest neighbors for a single test instance.
| *Xtrain | Training patterns |
| nXtrain | Number of training patterns |
| dim | Dimensionality of training patterns |
| *test_pattern | Test pattern |
| *d_min | Pointer to array that shall be used to store the distances |
| *idx_min | Pointer ot array that shall be used to store the indices |
| K | The number of neighbors |
| void fit_cpu | ( | FLOAT_TYPE * | Xtrain, |
| int | nXtrain, | ||
| int | dXtrain, | ||
| BRUTE_RECORD * | brute_record, | ||
| BRUTE_PARAMETERS * | params | ||
| ) |
Fits a model given the training data (and parameters)
| *Xtrain | Training patterns |
| nXtrain | Number of training patterns |
| dXtrain | Dimensionality of training patterns |
| *brute_record | Pointer to record storing the model |
| *params | Pointer to struct storing the parameters |
| void free_resources_cpu | ( | BRUTE_RECORD * | brute_record, |
| BRUTE_PARAMETERS * | params | ||
| ) |
Does some clean up (before exiting the program).
| *brute_record | Pointer to record storing the model |
| *params | Pointer to struct storing the parameters |
| void init_cpu | ( | BRUTE_RECORD * | brute_record, |
| BRUTE_PARAMETERS * | params | ||
| ) |
Intializes components if needed.
| *brute_record | Pointer to record storing the model |
| *params | Pointer to struct storing the parameters |
| void insert_cpu | ( | FLOAT_TYPE | pattern_dist, |
| int | pattern_idx, | ||
| FLOAT_TYPE * | nearest_dist, | ||
| int * | nearest_idx, | ||
| int | K | ||
| ) |
Inserts the value pattern_dist with index pattern_idx in the list nearest_dist of FLOAT_TYPEs and the list nearest_idx of indices. Both lists contain at most K elements.
| pattern_dist | Distance to the current pattern |
| pattern_idx | Associated index |
| *nearest_dist | Array of distances to be updated |
| *nearest_idx | Arra of indices to be updated |
| K | Number of nearest neighbors |
| void neighbors_cpu | ( | FLOAT_TYPE * | Xtest, |
| int | nXtest, | ||
| int | dXtest, | ||
| FLOAT_TYPE * | d_mins, | ||
| int * | idx_mins, | ||
| BRUTE_RECORD * | brute_record, | ||
| BRUTE_PARAMETERS * | params | ||
| ) |
Computes the neighbors (for test patterns)
| *Xtest | Pointer to the set of query/test points (stored as FLOAT_TYPE) |
| nXtest | The number of query points |
| dXtest | The dimension of each query point |
| *d_mins | The distances array (FLOAT_TYPE) used to store the computed distances |
| *idx_mins | Pointer to arrray storing the indices of the k nearest neighbors for each query point |
| *brute_record | Pointer to struct storing all relevant information for model |
| *params | Pointer to struct containing all relevant parameters |
|
inline |
Computes the distance between point a and b in R^dim
| *a | Pointer to first point |
| *b | Pointer to second point |
| dim | Dimensionality of the points |
1.8.6