The SDL Component Suite is an industry leading collection of components supporting scientific and engineering computing. Please visit the SDL Web site for more information.... 
Home MathPack Math2 Procedures and Functions FindNearestNeighbors  
See also: FindCenters, MeanDistanceKNN, EstimateByKNN, kMeansClustering  
FindNearestNeighbors 

This routine calculates the k nearest neighbors of the vector DatVec in the matrix InMat. The rows are considered to be objects, the columns are the variables. The user has to ensure that both the xdimension of InMat and the length of DatVec are equal to each other. The result is returned as an ordered list in the matrix KNNList (size 2 x k), the first row specifying the nearest neighbor. The first column of KNNList holds the indices into the data matrix InMat, the second column holds the distances to these neighbors. The parameters FirstObj and LastObj define the index of the first and the last object of matrix Inmat to be included in the kNN search. The function pointer CalcDist may be used to perform a user defined calculation of the distances between the elements of the data matrix and the data vector (see TCalcDistFunc for more details). If CalcDist is set to nil the Euclidean distance is calculated by default.
