I have a vector with shape [2, 2, 2, 2, 2] and I need to get the indexs "from" and "to" for this numpy einsum operation:
np.einsum(vector,[0, 1, 2, 3, 4], np.conj(vector),
[0, 1, 2, 8, 9],[3, 4, 8, 9])
the result is [2, 2, 2, 2] shape.
Can someone unroll this in loops or explain how I can get the indexs from vector that affects indexs from result.
Looking at numpy einsum source code I fopund that is a tensor contraction operation that uses numbers for indexs instead of letters. So Is just a sum of multiplications. I made the a function that constructs the loops receiving the same parameters as einsum. It creates the code in a string an executes it with python exec. In this function I don't get the indexs but they can be easily accessed. Here is the code: