>>> x = np.array([['a0', 'a1'],['b0','b1']])
>>> y = np.array([['x0', 'x1'],['y0','y1']])
>>> iterable = [np.outer(x[i],y[i]) for i in xrange(x.shape[0])]
>>> elbareti = np.asarray(iterable)
>>> elbareti
array([[[ 'a0'*'x0', 'a0'*'x1' ],
[ 'a1'*'x0', 'a1'*'x1' ]],
[[ 'b0'*'y0', 'b0'*'y1' ],
[ 'b1'*'y0', 'b1'*'y1' ]]])
Since i'm planning on working with large arrays, is there a more numpy-like version of this? I feel like the answer is right under my nose and I'm thinking it has something to do with reduce
, but numpy's version only works with ufunc
s, not functions. Even a hint would be greatly appreciated.
Thanks in advance.