$x$ is an $N \times M$ matrix.
$y$ is a $1 \times L$ vector.
I want to return "outer product" between $x$ and $y$, let's call it $z$.
z[n,m,l] = x[n,m] * y[l]
I could probably do this using einsum
.
np.einsum("ij,k->ijk", x[:, :, k], y[:, k])
or reshape
afterwards.
np.outer(x[:, :, k], y).reshape((x.shape[0],x.shape[1],y.shape[0]))
But I'm thinking of doing this in np.outer
only or something seems simpler, memory efficient.
Is there a way?
k
variable contain in your code examples? $\endgroup$ – Federico Poloni Jul 15 '19 at 7:52