Mercurial > hg > camir-aes2014
comparison toolboxes/distance_learning/mlr/distance/setDistanceDODMKL.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 = setDistanceDODMKL(X, W, Ifrom, Ito) | |
2 % | |
3 % D = setDistanceDODMKL(X, W, Ifrom, Ito) | |
4 % | |
5 % X = d-by-n data matrix | |
6 % W = m-by-m-by-n 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 L = W.^0.5; | |
16 | |
17 D = 0; | |
18 for i = 1:m | |
19 for j = i:m | |
20 Vfrom = bsxfun(@times, squeeze(L(i,j)), X(:,Ifrom,i) + X(:,Ifrom,j)); | |
21 | |
22 if nargin == 4 | |
23 Vto = bsxfun(@times, squeeze(L(i,j)), X(:,Ito,i) + X(:,Ito,j)); | |
24 else | |
25 Vto = bsxfun(@times, squeeze(L(i,j)), X(:,:,i) + X(:,:,j)); | |
26 Ito = 1:n; | |
27 end | |
28 | |
29 if i == j | |
30 s = 0.5; | |
31 else | |
32 s = 1; | |
33 end | |
34 | |
35 D = D + s * distToFrom(n, Vto, Vfrom, Ito, Ifrom); | |
36 end | |
37 end | |
38 | |
39 end |