AUTH's THMMY "Parallel and distributed systems" course assignments.
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

20 lines
680 B

  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