[Numpy-discussion] Distance Matrix speed
Johannes Loehnert
a.u.r.e.l.i.a.n at gmx.net
Sat Jun 17 02:47:24 EDT 2006
Hi,
> def d4():
> d = zeros([4, 1000], dtype=float)
> for i in range(4):
> xy = A[i] - B
> d[i] = sqrt( sum(xy**2, axis=1) )
> return d
>
> Maybe there's another alternative to d4?
> Thanks again,
I think this is the fastest you can get. Maybe it would be nicer to use
the .sum() method instead of sum function, but that is just my personal
opinion.
I am curious how this compares to the matlab version. :)
Johannes
More information about the NumPy-Discussion
mailing list