view the array aandb
a = np.array([
[-1, 1, 5],
[-2, 3, 0]
])
b = np.array([
[1, 1, 0],
[0, 2, 3],
])
Looking at
d = a.T.dot(b)
d
array([[-1, -5, -6],
[ 1, 7, 9],
[ 5, 5, 0]])
d[0, 0]- -1. and is the sum a[:, 0] * b[:, 0]. I need an array of 2x2 vectors where the position [0, 0]will be a[:, 0] * b[:, 0].
with the above aand b, I would expect
d = np.array([[a[:, i] * b[:, j] for j in range(a.shape[1])] for i in range(b.shape[1])])
d
array([[[-1, 0],
[-1, -4],
[ 0, -6]],
[[ 1, 0],
[ 1, 6],
[ 0, 9]],
[[ 5, 0],
[ 5, 0],
[ 0, 0]]])
The sum dalong axis==2should be a point producta.T.dot(b)
d.sum(2)
array([[-1, -5, -6],
[ 1, 7, 9],
[ 5, 5, 0]])
Question
What is the most effective way to obtain d?