summaryrefslogtreecommitdiffstats
path: root/SD-VBS/common/toolbox/toolbox_basic/textons/dist2.m
diff options
context:
space:
mode:
Diffstat (limited to 'SD-VBS/common/toolbox/toolbox_basic/textons/dist2.m')
-rwxr-xr-xSD-VBS/common/toolbox/toolbox_basic/textons/dist2.m27
1 files changed, 27 insertions, 0 deletions
diff --git a/SD-VBS/common/toolbox/toolbox_basic/textons/dist2.m b/SD-VBS/common/toolbox/toolbox_basic/textons/dist2.m
new file mode 100755
index 0000000..f2d93e1
--- /dev/null
+++ b/SD-VBS/common/toolbox/toolbox_basic/textons/dist2.m
@@ -0,0 +1,27 @@
1function n2 = dist2(x, c)
2%DIST2 Calculates squared distance between two sets of points.
3%
4% Description
5% D = DIST2(X, C) takes two matrices of vectors and calculates the
6% squared Euclidean distance between them. Both matrices must be of
7% the same column dimension. If X has M rows and N columns, and C has
8% L rows and N columns, then the result has M rows and L columns. The
9% I, Jth entry is the squared distance from the Ith row of X to the
10% Jth row of C.
11%
12% See also
13% GMMACTIV, KMEANS, RBFFWD
14%
15
16% Copyright (c) Christopher M Bishop, Ian T Nabney (1996, 1997)
17
18[ndata, dimx] = size(x);
19[ncentres, dimc] = size(c);
20if dimx ~= dimc
21 error('Data dimension does not match dimension of centres')
22end
23
24n2 = (ones(ncentres, 1) * sum((x.^2)', 1))' + ...
25 ones(ndata, 1) * sum((c.^2)',1) - ...
26 2.*(x*(c'));
27