Efficiently compute pairwise squared Euclidean distance in Matlab
问题 Given two sets of d -dimensional points. How can I most efficiently compute the pairwise squared euclidean distance matrix in Matlab? Notation: Set one is given by a (numA,d) -matrix A and set two is given by a (numB,d) -matrix B . The resulting distance matrix shall be of the format (numA,numB) . Example points: d = 4; % dimension numA = 100; % number of set 1 points numB = 200; % number of set 2 points A = rand(numA,d); % set 1 given as matrix A B = rand(numB,d); % set 2 given as matrix B