[Scilab-users] Pairwise distance of a huge amount of points

Dang, Christophe Christophe.Dang at sidel.com
Fri Aug 29 09:29:43 CEST 2014


Hello, 

> De Samuel Gougeon
> Envoyé : jeudi 28 août 2014 23:59
>
> You will need one loop over slices along one of both dimensions.
> Such a slicing algorithm in an identical situation is used inside members.sci.

OK, I just overlooked the file but am lazy to read a 400 lines script and prefered to write from scratch (-:

My script so far looks like

// **********

n = size(X0, "r"); // amount of points

dmax = 0;

for i = 1:n-1
    d = max(sqrt((X0(1:$-i) - X0(i+1:$)).^2 + (Y0(1:$-i) - Y0(i+1:$)).^2 +...
        (Z0(1:$-i) - Z0(i+1:$)).^2));
    if d > dmax then
        dmax = d;
    end
end

// **********

tested on a subset of 1000 data, it gives the same result as the naive n^2 calculation, and is 64 times faster.

Thanks for the help.

-- 
Christophe Dang Ngoc Chan
Mechanical calculation engineer

______________________________________________________________________

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error), please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.
______________________________________________________________________



More information about the users mailing list