# [Numpy-discussion] efficient function calculation between two matrices

John [H2O] washakie@gmail....
Tue Feb 17 04:09:12 CST 2009

```hello,

I am trying to calculate the results of a function between two matrices:

>>> F.shape
(170, 2)
>>> T.shape
(170, 481, 2)

Where F contains lat/lon pairs and T contains 481 lat/lon pairs for 170
trajectories of length 481

I want a new array of shape
(170,481)

containing the results of my distance function:

gcd(x1,y1,x2,y3):
""" returns great circle distance"""
...
return dist

Is there a way to do this without the use of loops?

I'm thinking something along the lines of:

distances = [[gcd(f[0],f[1],t[0],t[1]]) for f in F] for t in T]

But obviously this doesn't work...

Thank you,
john
--
View this message in context: http://www.nabble.com/efficient-function-calculation-between-two-matrices-tp22054148p22054148.html
Sent from the Numpy-discussion mailing list archive at Nabble.com.

```

More information about the Numpy-discussion mailing list