I have one matrix, like
a = np.array([[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6]])
and I want to get a new matrix, where each element is the matrix product of the row of a with itself:
np.array([
np.dot(np.array([a[0]]).T, np.array([a[0]])),
np.dot(np.array([a[1]]).T, np.array([a[1]])),
np.dot(np.array([a[2]]).T, np.array([a[2]])),
np.dot(np.array([a[3]]).T, np.array([a[3]])),
])
which will be a 4x4 matrix with each element a 3x3 matrix. After this I can sum over the 0 axis to get a new 3x3 matrix.
Is there any more elegant way to implement this except using loop?