diff options
author | Leo Chan <leochanj@live.unc.edu> | 2020-10-22 01:53:21 -0400 |
---|---|---|
committer | Joshua Bakita <jbakita@cs.unc.edu> | 2020-10-22 01:56:35 -0400 |
commit | d17b33131c14864bd1eae275f49a3f148e21cf29 (patch) | |
tree | 0d8f77922e8d193cb0f6edab83018f057aad64a0 /SD-VBS/common/toolbox/toolbox_basic/textons/dist2.m | |
parent | 601ed25a4c5b66cb75315832c15613a727db2c26 (diff) |
Squashed commit of the sb-vbs branch.
Includes the SD-VBS benchmarks modified to:
- Use libextra to loop as realtime jobs
- Preallocate memory before starting their main computation
- Accept input via stdin instead of via argc
Does not include the SD-VBS matlab code.
Fixes libextra execution in LITMUS^RT.
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 | |||