-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathKMCompParallel.m
48 lines (38 loc) · 1.27 KB
/
KMCompParallel.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
function DM = KMCompParallel(X, DistanceIndex, Parameter1, Parameter2)
addpath(genpath('lockstepmeasures/.'));
addpath(genpath('slidingmeasures/.'));
addpath(genpath('elasticmeasures/.'));
addpath(genpath('kernelmeasures/.'));
[m, TSLength] = size(X);
DM = zeros(m,m);
for i=1:m-1
disp(i);
rowi = X(i,:);
tmpVector = zeros(1,m);
parfor j=i+1:m
rowj = X(j,:);
if DistanceIndex==1
tmpVector(j) = SINK(rowi,rowj,Parameter1);
elseif DistanceIndex==2
tmpVector(j) = logGAK(rowi',rowj',Parameter1,0);
elseif DistanceIndex==3
tmpVector(j) = KDTWNorm_mex(rowi,rowj,Parameter1);
end
end
DM(i,:) = tmpVector;
end
for i=1:m-1
for j=i+1:m
DM(j,i) = DM(i,j);
end
end
for i=1:m
if DistanceIndex==1
DM(i,i) = SINK(X(i,:),X(i,:),Parameter1);
elseif DistanceIndex==2
DM(i,i) = logGAK(X(i,:)',X(i,:)',Parameter1,0);
elseif DistanceIndex==3
DM(i,i) = KDTWNorm_mex(X(i,:),X(i,:), Parameter1);
end
end
end