comparison toolboxes/distance_learning/mlr/distance/setDistanceFull.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e9a9cd732c1e
1 function D = setDistanceFull(X, W, Ifrom, Ito)
2 %
3 % D = setDistanceFull(X, W, Ifrom, Ito)
4 %
5 % X = d-by-n data matrix
6 % W = d-by-d PSD matrix
7 % Ifrom = k-by-1 vector of source points
8 % Ito = j-by-1 vector of destination points
9 %
10 % D = n-by-n matrix of squared euclidean distances from Ifrom to Ito
11 % D is sparse, and only the rows corresponding to Ifrom and
12 % columns corresponding to Ito are populated.
13
14 [d,n] = size(X);
15 [vecs,vals] = eig(0.5 * (W + W'));
16 L = real(abs(vals)).^0.5 * vecs';
17
18 Vfrom = L * X(:,Ifrom);
19
20 if nargin == 4
21 Vto = L * X(:,Ito);
22 else
23 Vto = L * X;
24 Ito = 1:n;
25 end
26
27 D = distToFrom(n, Vto, Vfrom, Ito, Ifrom);
28 end