Daniel@0: function D = setDistanceFull(X, W, Ifrom, Ito) Daniel@0: % Daniel@0: % D = setDistanceFull(X, W, Ifrom, Ito) Daniel@0: % Daniel@0: % X = d-by-n data matrix Daniel@0: % W = d-by-d PSD matrix Daniel@0: % Ifrom = k-by-1 vector of source points Daniel@0: % Ito = j-by-1 vector of destination points Daniel@0: % Daniel@0: % D = n-by-n matrix of squared euclidean distances from Ifrom to Ito Daniel@0: % D is sparse, and only the rows corresponding to Ifrom and Daniel@0: % columns corresponding to Ito are populated. Daniel@0: Daniel@0: [d,n] = size(X); Daniel@0: [vecs,vals] = eig(0.5 * (W + W')); Daniel@0: L = real(abs(vals)).^0.5 * vecs'; Daniel@0: Daniel@0: Vfrom = L * X(:,Ifrom); Daniel@0: Daniel@0: if nargin == 4 Daniel@0: Vto = L * X(:,Ito); Daniel@0: else Daniel@0: Vto = L * X; Daniel@0: Ito = 1:n; Daniel@0: end Daniel@0: Daniel@0: D = distToFrom(n, Vto, Vfrom, Ito, Ifrom); Daniel@0: end