[Numpy-discussion] Distance Matrix speed (original) (raw)
Johannes Loehnert a.u.r.e.l.i.a.n at gmx.net
Sat Jun 17 02:47:24 EDT 2006
- Previous message (by thread): [Numpy-discussion] Distance Matrix speed
- Next message (by thread): [Numpy-discussion] Distance Matrix speed
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Previous message (by thread): [Numpy-discussion] Distance Matrix speed
- Next message (by thread): [Numpy-discussion] Distance Matrix speed
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]