a = np.random.randint(0, 10, (3, 3))
b = np.random.randint(0, 10, (3, 3))
a
b
a.dot(b)
np.diagonal(a.dot(b))
np.einsum('ij,ji->i', a, b)
(Python) How to get diagonal(A*B) without having to perform A*B?