I am currently doing some studies on computing a 4th order tensor in numpy with the einsum function.
The tensor I am computing is written in Einstein notation and the function einsun does the work perfectly! But I would like to know what it is doing in the following case:
import numpy as np a=np.array(((2,0,3),(0,1,0),(0, 0, 4))) b= np.eye(3) r1=np.einsum("ij,kl->ijkl", a, b) r2=np.einsum("ik,jl->ijkl", a, b)
r1 I am basically doing the standard tensor product (equivalent to
What about in
I know I can get the value by doing
a(:,None,:,None)*b(None,:,None,:) but I do not know what the indexing is doing. Does this operation have a name?
How can I handle this swap in the indices?
Sorry if this is too basic!