I'm using einsum, and I'm having an issue creating an inner product of two 5x2 matrices such that the resulting array has a size of (5,). I was able to use the code: print(np.einsum('ij,kj->ik', A, B)) to create the cross product of the two matrices resulting in a (5,5), and I used the code: print(np.einsum('ij,ik->ik', A, B)) to create a (5,2).
I'm not sure what else I can do to create the inner product of these two matrices to create a 1D array of size (5,). I think I'm on the right track, but I'm not sure what else to do.
My code and output are as follows:
import numpy as np
A = np.array([[4, 2],[-3, 3],[-3, -5],[1, -4], [1, 4]])
B = np.array([[-5, 0],[1, 5],[0, 1],[1, -2],[-1, -1]])
print(np.einsum('ij,kj->ik', A, B))
[[-20 14 2 0 -6]
[ 15 12 3 -9 0]
[ 15 -28 -5 7 8]
[ -5 -19 -4 9 3]
[ -5 21 4 -7 -5]]
print(np.einsum('ij,ik->ik', A, B))
[[-30 0]
[ 0 0]
[ 0 -8]
[ -3 6]
[ -5 -5]]