In NumPy:
A = np.array([[1,2,3],[4,5,6]])
array([[1, 3, 5],
       [2, 4, 6]])
B = np.array([[1,2],[3,4],[5,6]])
array([[1, 2],
       [3, 4],
       [5, 6]])
A.dot(B)
array([[35, 44],
       [44, 56]])
I only care about getting A.dot(B).diagonal() = array([35, 56])
Is there a way I can get array([35, 56]) without having to compute the inner products of all the rows and columns? I.e. the inner product of the ith row with ith column?
I ask because the performance difference becomes more significant for larger matrices.