I have a list of 3D points p stored in an ndarray with shape (N, 3). I want to compute the outer product for each 3d point with itself:
N = int(1e4)
p = np.random.random((N, 3))
result = np.zeros((N, 3, 3))
for i in range(N):
result[i, :, :] = np.outer(p[i, :], p[i, :])
Is there a way to compute this outer product without any python-level loops? The problem is that np.outer
does not support anything like an axis
argument.