AUTH's THMMY "Parallel and distributed systems" course assignments.
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

5 gün önce
12345678910111213141516171819
  1. function [N, D] = mergeResults(N1, D1, N2, D2, C1, C2, k, ~)
  2. % Merge neighbors from two sources for a specific subset of queries
  3. numQueries = size(N1, 1); % Queries corresponding to N1 (or N2)
  4. N_combined = [N1, N2 + size(C1, 1)]; % Adjust indices for C2
  5. D_combined = [D1, D2];
  6. % Sort distances and select top-k for each query
  7. [D_sorted, idx] = sort(D_combined, 2); % Sort by distance for each query
  8. idx = idx(:, 1:k); % Top-k indices
  9. % Select corresponding neighbors
  10. N = zeros(numQueries, k);
  11. for i = 1:numQueries
  12. N(i, :) = N_combined(i, idx(i, :));
  13. end
  14. % Select corresponding distances
  15. D = D_sorted(:, 1:k);
  16. end