@Override public int[][] assign(long[][] data) { int [][] indices = new int [data.length][numNeighbours]; double [][] distances = new double [data.length][numNeighbours]; nn.searchKNN(data, numNeighbours, indices, distances); return indices; }
@Override public void assignWeighted(long[][] data, int[][] assignments, double[][] weights) { nn.searchKNN(data, numNeighbours, assignments, weights); }
@Override public IndependentPair<int[], double[]> assignWeighted(long[] data) { int [][] indices = new int [data.length][numNeighbours]; double [][] distances = new double [data.length][numNeighbours]; nn.searchKNN(new long[][] { data }, numNeighbours, indices, distances); return new IndependentPair<int[], double[]>(indices[0], distances[0]); }
final int[][] idx = new int[1][K]; final double[][] dst = new double[1][K]; nn.searchKNN(qus, K, idx, dst);
final int[][] idx = new int[1][K]; final double[][] dst = new double[1][K]; nn.searchKNN(qus, K, idx, dst);
protected void computeDistances(long[] fullQuery, BoundedPriorityQueue<IntDoublePair> queue, IntDoublePair wp) { final double[][] distances = new double[pq.assigners.length][]; for (int j = 0, from = 0; j < this.pq.assigners.length; j++) { final LongNearestNeighbours nn = this.pq.assigners[j]; final int to = nn.numDimensions(); final int K = nn.size(); final long[][] qus = { Arrays.copyOfRange(fullQuery, from, from + to) }; final int[][] idx = new int[1][K]; final double[][] dst = new double[1][K]; nn.searchKNN(qus, K, idx, dst); distances[j] = new double[K]; for (int k = 0; k < K; k++) { distances[j][idx[0][k]] = dst[0][k]; } from += to; } for (int i = 0; i < data.length; i++) { wp.first = i; wp.second = 0; for (int j = 0; j < this.pq.assigners.length; j++) { final int centroid = this.data[i][j] + 128; wp.second += distances[j][centroid]; } wp = queue.offerItem(wp); } }
protected void computeDistances(long[] fullQuery, BoundedPriorityQueue<IntDoublePair> queue, IntDoublePair wp) { final double[][] distances = new double[pq.assigners.length][]; for (int j = 0, from = 0; j < this.pq.assigners.length; j++) { final LongNearestNeighbours nn = this.pq.assigners[j]; final int to = nn.numDimensions(); final int K = nn.size(); final long[][] qus = { Arrays.copyOfRange(fullQuery, from, from + to) }; final int[][] idx = new int[1][K]; final double[][] dst = new double[1][K]; nn.searchKNN(qus, K, idx, dst); distances[j] = new double[K]; for (int k = 0; k < K; k++) { distances[j][idx[0][k]] = dst[0][k]; } from += to; } for (int i = 0; i < data.length; i++) { wp.first = i; wp.second = 0; for (int j = 0; j < this.pq.assigners.length; j++) { final int centroid = this.data[i][j] + 128; wp.second += distances[j][centroid]; } wp = queue.offerItem(wp); } }