Let's say I have 2 one-dimensional (1D) numpy arrays, a
and b
, with lengths n1
and n2
respectively. I also have a function, F(x,y)
, that takes two values. Now I want to apply that function to each pair of values from my two 1D arrays, so the result would be a 2D numpy array with shape n1, n2
. The i, j
element of the two-dimensional array would be F(a[i], b[j])
.
I haven't been able to find a way of doing this without a horrible amount of for-loops, and I'm sure there's a much simpler (and faster!) way of doing this in numpy.
Thanks in advance!