Daniel@0: function D = setDistanceFullMKL(X, W, Ifrom, Ito) Daniel@0: % Daniel@0: % D = setDistanceFullMKL(X, W, Ifrom, Ito) Daniel@0: % Daniel@0: % X = d-by-n-by-m data matrix Daniel@0: % W = d-by-d-by-m 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,m] = size(X); Daniel@0: Daniel@0: D = 0; Daniel@0: for i = 1:m Daniel@0: [vecs,vals] = eig(0.5 * (W(:,:,i) + W(:,:,i)')); Daniel@0: L = real(abs(vals)).^0.5 * vecs'; Daniel@0: Daniel@0: Vfrom = L * X(:,Ifrom,i); Daniel@0: Daniel@0: if nargin == 4 Daniel@0: Vto = L * X(:,Ito,i); Daniel@0: else Daniel@0: Vto = L * X(:,:,i); Daniel@0: Ito = 1:n; Daniel@0: end Daniel@0: Daniel@0: D = D + distToFrom(n, Vto, Vfrom, Ito, Ifrom); Daniel@0: end Daniel@0: end