AUTH's THMMY "Parallel and distributed systems" course assignments.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

123456789101112131415161718
  1. function [D2] = dist2(X, Y)
  2. % Calculates the squares of the distances of X and Y
  3. %
  4. % X: A mxd array with m d-dimentional points
  5. % Y: A nxd array with n d-dimentional points
  6. % d: Must be the same
  7. [~, d1] = size(X);
  8. [~, d2] = size(Y);
  9. if d1 ~= d2
  10. error('X,Y column dimensions must match');
  11. end
  12. %D2 = sqrt((X.^2)*ones(d,m) -2*X*Y' + ones(n,d)*(Y.^2)');
  13. D2 = max(sum(X.^2, 2) - 2 * X*Y' + sum(Y.^2, 2)', 0);
  14. D2 = sqrt(D2);
  15. end