bufferkdtree (C sources)
C source code for the Python bufferkdtree implementation
 All Classes Files Functions Variables Typedefs Macros
Functions
cpu.c File Reference
#include "include/cpu.h"
#include "include/base.h"
#include "include/util.h"
#include "include/global.h"
Include dependency graph for cpu.c:

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)
 

Function Documentation

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.

Parameters
*XtrainTraining patterns
nXtrainNumber of training patterns
dimDimensionality of training patterns
*test_patternTest pattern
*d_minPointer to array that shall be used to store the distances
*idx_minPointer ot array that shall be used to store the indices
KThe 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)

Parameters
*XtrainTraining patterns
nXtrainNumber of training patterns
dXtrainDimensionality of training patterns
*brute_recordPointer to record storing the model
*paramsPointer to struct storing the parameters
void free_resources_cpu ( BRUTE_RECORD brute_record,
BRUTE_PARAMETERS params 
)

Does some clean up (before exiting the program).

Parameters
*brute_recordPointer to record storing the model
*paramsPointer to struct storing the parameters
void init_cpu ( BRUTE_RECORD brute_record,
BRUTE_PARAMETERS params 
)

Intializes components if needed.

Parameters
*brute_recordPointer to record storing the model
*paramsPointer 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.

Parameters
pattern_distDistance to the current pattern
pattern_idxAssociated index
*nearest_distArray of distances to be updated
*nearest_idxArra of indices to be updated
KNumber 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)

Parameters
*XtestPointer to the set of query/test points (stored as FLOAT_TYPE)
nXtestThe number of query points
dXtestThe dimension of each query point
*d_minsThe distances array (FLOAT_TYPE) used to store the computed distances
*idx_minsPointer to arrray storing the indices of the k nearest neighbors for each query point
*brute_recordPointer to struct storing all relevant information for model
*paramsPointer to struct containing all relevant parameters
FLOAT_TYPE squared_dist_cpu ( FLOAT_TYPE a,
FLOAT_TYPE b,
int  dim 
)
inline

Computes the distance between point a and b in R^dim

Parameters
*aPointer to first point
*bPointer to second point
dimDimensionality of the points