[Numpy-discussion] "Extended" Outer Product

Geoffrey Zhu zyzhu2000 at gmail.com
Mon Aug 20 17:36:52 EDT 2007


Hi Everyone,

I am wondering if there is an "extended" outer product. Take the
example in "Guide to Numpy." Instead of doing an multiplication, I
want to call a custom function for each pair.

>>> print outer([1,2,3],[10,100,1000])

[[ 10 100 1000]
[ 20 200 2000]
[ 30 300 3000]]


So I want:

[
 [f(1,10), f(1,100), f(1,1000)],
 [f(2,10), f(2, 100), f(2, 1000)],
 [f(3,10), f(3, 100), f(3,1000)]
]

Does anyone know how to do this without using a double loop?

Thanks,
Geoffrey



More information about the NumPy-Discussion mailing list