comparison toolboxes/distance_learning/mlr/distance/setDistanceFullMKL.m @ 0:cc4b1211e677 tip

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:cc4b1211e677
1 function D = setDistanceFullMKL(X, W, Ifrom, Ito)
2 %
3 % D = setDistanceFullMKL(X, W, Ifrom, Ito)
4 %
5 % X = d-by-n-by-m data matrix
6 % W = d-by-d-by-m 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,m] = size(X);
15
16 D = 0;
17 for i = 1:m
18 [vecs,vals] = eig(0.5 * (W(:,:,i) + W(:,:,i)'));
19 L = real(abs(vals)).^0.5 * vecs';
20
21 Vfrom = L * X(:,Ifrom,i);
22
23 if nargin == 4
24 Vto = L * X(:,Ito,i);
25 else
26 Vto = L * X(:,:,i);
27 Ito = 1:n;
28 end
29
30 D = D + distToFrom(n, Vto, Vfrom, Ito, Ifrom);
31 end
32 end