> I was trying to implement a pairwise distance function between an Nx2
> vector and an Mx2 vector in Python. As this part is quite critical in
> my code, I tried a few different approaches:
numpy may be about as fast as you can do anyway, but.... I fyou're
doing the same number of loops, operations and memeory allocations,
you're not going to do better than numpy (not that I've looked closely
enough at your problem...)
> https://bitbucket.org/FedericoV/numpy-tip-complex-modeling/src/29292a93cbf2/src/simulations
> Any obvious speed ups I'm missing?
it does look about right, but a couple things to consider:
1) have you looked at the annotated source (html) you can find hidden
python code where you think it souold be pure C.
2) you can use an unsigned type for your indexes -- i and j -- that can help.
3) you can replace "**2" with a multiply -- I"m not sure if Cython or
the C complier optimizes that for you.
HTH,
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
phi_1 = a[i,0] should be phi_1 = a[i,1], right?
cheers,
Liu Zhenhai