108 m_pData =
new float[nDimension * nDataSets];
110 memcpy(
m_pData, pData, nDimension * nDataSets *
sizeof(
float));
114 const int nOverallDimension = nDimension + 2;
117 float **ppValues =
new float*[nDataSets];
120 for (i = 0; i < nDataSets; i++)
122 ppValues[i] =
new float[nOverallDimension];
125 memcpy(ppValues[i], pData + i * nDimension, nDimension *
sizeof(
float));
128 memcpy(&ppValues[i][nDimension], &i,
sizeof(
int));
137 for (i = 0; i < nDataSets; i++)
138 delete [] ppValues[i];
158 printf(
"error: classifier not trained in CNearestNeighbor::Classify\n");
164 printf(
"error: query dimension and trained dimension do not match in CNearestNeighbor::Classify\n");
181 register float v = pQuery[j] - pData[j];
204 memcpy(&nResultIndex, pData +
m_nDimension,
sizeof(
int));
206 fResultError = error;
225 printf(
"error: classifier not trained in CNearestNeighbor::Classify\n");
231 printf(
"error: query dimension and trained dimension do not match in CNearestNeighbor::Classify\n");
237 const float *pQuery = pQueries;
239 for (
int k = 0; k < nQueries; k++)
252 register float v = pQuery[j] - pData[j];
265 pResults[k] = best_i;
266 pResultErrors[k] = min;
275 const float *pQuery = pQueries;
277 for (
int k = 0; k < nQueries; k++)
282 memcpy(pResults + k, pData +
m_nDimension,
sizeof(
int));
283 pResultErrors[k] = error;
#define OPTIMIZED_FUNCTION_HEADER_3(name, p1, p2, p3)
#define OPTIMIZED_FUNCTION_HEADER_4(name, p1, p2, p3, p4)
CNearestNeighbor(ComputationMethod method)
int Classify(const float *pQuery, int nDimension, float &fResultError)
#define OPTIMIZED_FUNCTION_HEADER_0(name)
void NearestNeighborBBF(const float *pfQuery, float &fError, float *&pfNN, int nMaximumLeavesToVisit=-1)
#define OPTIMIZED_FUNCTION_FOOTER
void Build(float **ppfValues, int nLow, int nHigh, int nBucketSize, int nDimensions, int nUserDataSize)
bool Train(const float *pData, int nDimension, int nDataSets)
ComputationMethod m_method
#define OPTIMIZED_FUNCTION_HEADER_5(name, p1, p2, p3, p4, p5)