Mercurial > hg > camir-ismir2012
annotate 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 |
rev | line source |
---|---|
Daniel@0 | 1 function D = setDistanceFullMKL(X, W, Ifrom, Ito) |
Daniel@0 | 2 % |
Daniel@0 | 3 % D = setDistanceFullMKL(X, W, Ifrom, Ito) |
Daniel@0 | 4 % |
Daniel@0 | 5 % X = d-by-n-by-m data matrix |
Daniel@0 | 6 % W = d-by-d-by-m PSD matrix |
Daniel@0 | 7 % Ifrom = k-by-1 vector of source points |
Daniel@0 | 8 % Ito = j-by-1 vector of destination points |
Daniel@0 | 9 % |
Daniel@0 | 10 % D = n-by-n matrix of squared euclidean distances from Ifrom to Ito |
Daniel@0 | 11 % D is sparse, and only the rows corresponding to Ifrom and |
Daniel@0 | 12 % columns corresponding to Ito are populated. |
Daniel@0 | 13 |
Daniel@0 | 14 [d,n,m] = size(X); |
Daniel@0 | 15 |
Daniel@0 | 16 D = 0; |
Daniel@0 | 17 for i = 1:m |
Daniel@0 | 18 [vecs,vals] = eig(0.5 * (W(:,:,i) + W(:,:,i)')); |
Daniel@0 | 19 L = real(abs(vals)).^0.5 * vecs'; |
Daniel@0 | 20 |
Daniel@0 | 21 Vfrom = L * X(:,Ifrom,i); |
Daniel@0 | 22 |
Daniel@0 | 23 if nargin == 4 |
Daniel@0 | 24 Vto = L * X(:,Ito,i); |
Daniel@0 | 25 else |
Daniel@0 | 26 Vto = L * X(:,:,i); |
Daniel@0 | 27 Ito = 1:n; |
Daniel@0 | 28 end |
Daniel@0 | 29 |
Daniel@0 | 30 D = D + distToFrom(n, Vto, Vfrom, Ito, Ifrom); |
Daniel@0 | 31 end |
Daniel@0 | 32 end |