You are here: Symbol Reference > MtxForLoop Namespace > Functions > MtxForLoop.ClusteredKNN Function
MtxVec VCL
ContentsIndex
Example
uses MtxExpr, MtxVec, MtxExprInt; var Data, cmpData, nearDistance: Matrix; nearIdx: MatrixInt; begin data := [[1,2,3], [2,3,1], [3,2,1]]; cmpData := [[2,2,3], [2,3,4]]; ClusteredKNN(computeThreads, Data, cmpData, 2, nearIdx, nearDistance); // Results: // nearIdx = [[0, 1], // data rows 0 and 1 are closest vectors to cmpData row 0. // [0, 1]] // data rows 0 and 1 are closest vectors to cmpData row 1. // nearDistance = [[1 5], // [0,0] = sqr(2-1) + sqr(2-2) + sqr(3-3), distance from cmpData row 0 to Data row 0 is 1 // [3, 9]] // [1,0] = sqr(2-1) + sqr(3-2) + sqr(4-3), distance from cmpData row 1 to Data row 0 is 3
Copyright (c) 1999-2025 by Dew Research. All rights reserved.