diff options
author | leochanj105 <leochanj@live.unc.edu> | 2020-10-19 23:09:30 -0400 |
---|---|---|
committer | leochanj105 <leochanj@live.unc.edu> | 2020-10-20 02:40:39 -0400 |
commit | f618466c25d43f3bae9e40920273bf77de1e1149 (patch) | |
tree | 460e739e2165b8a9c37a9c7ab1b60f5874903543 /SD-VBS/common/toolbox/toolbox_basic/textons/dist2.m | |
parent | 47ced4e96bbb782b9e780e8f2cfc637b2c21ff44 (diff) |
initial sd-vbs
initial sd-vbs
add sd-vbs
sd-vbs
Diffstat (limited to 'SD-VBS/common/toolbox/toolbox_basic/textons/dist2.m')
-rwxr-xr-x | SD-VBS/common/toolbox/toolbox_basic/textons/dist2.m | 27 |
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 @@ | |||
1 | function 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); | ||
20 | if dimx ~= dimc | ||
21 | error('Data dimension does not match dimension of centres') | ||
22 | end | ||
23 | |||
24 | n2 = (ones(ncentres, 1) * sum((x.^2)', 1))' + ... | ||
25 | ones(ndata, 1) * sum((c.^2)',1) - ... | ||
26 | 2.*(x*(c')); | ||
27 | |||