mex_sepsq
by Ben Mitch
16 Sep 2003
(Updated 22 Nov 2010)
Fast, dedicated, code to compute Euclidean separation between sets of points in N-dimensional space.
|
Watch this File
|
| File Information |
| Description |
To compute the Euclidean separation (L2 norm) between two sets of points in MATLAB can be slow and/or memory-hungry. In some cases (most particularly, if you are working with 2D, 3D or 4D data), this function will do it 2-4 times faster than the fastest m-code I've seen (due to Germano Gomes) and hundreds of times faster than a typical memory-efficient nested loop.
NB: for D much greater than 10-15, performance is better using GG's m-script. See the screenshot for a performance plot - green is GG, blue is mex_sepsq.
>> mex_sepsq_demo
A = randn(4, 5000);
B = randn(4, 5000);
C1 = mex_sepsq(A, B);
Elapsed time is 0.201335 seconds.
C2 = sepsq_gg(A, B);
Elapsed time is 0.517755 seconds.
Relative time per implementation: 1.00 2.57 |
| MATLAB release |
MATLAB 7.10 (2010a)
|
| Other requirements |
Must be compiled from source - run "mex_sepsq compile" to do this, usually. |
|
Tags for This File
|
| Everyone's Tags |
|
| Tags I've Applied |
|
| Add New Tags |
Please login to tag files.
|
| Updates |
| 30 Aug 2010 |
Provided a demo and an auto-compile script. |
| 20 Nov 2010 |
Improved performance, added benchmarking. |
| 22 Nov 2010 |
whoops, broke the linux implementation - fixed, now. |
|
Contact us at files@mathworks.com