Calculation of permutation in tensor of rank 4 I am trying to compute the symmetric part of a 4th order tensor $A_{ijkl}$
From a previous post (Symmetric Part of Product of 2 tank 2 tensors), I saw that I need to compute the permutations of $A_{ijkl}$ (4!=24 permutations).
I would like to know if anyone can give some hints on how to compute these permutations.
If $$A_{ij}=\begin{bmatrix} 1 &0 &0 \\ 0 &1 &0 \\ 0 & 0 &1 \end{bmatrix}\quad\text{and}\quad A_{kl}=\begin{bmatrix} 1 &0 &0 \\ 0 &1 &0 \\ 0 & 0 &1 \end{bmatrix}$$
Then
$$A_{ijkl}=\begin{bmatrix} 
1 &0 &0 \\
0 &1 &0 \\
0 & 0 &1 
\end{bmatrix}
 \begin{bmatrix} 
1 &0 &0 \\
0 &1 &0 \\
0 & 0 &1 \end{bmatrix} \\
= \begin{bmatrix} 
1.& 0.& 0.& 0.& 1.& 0.& 0.& 0.& 1. \\
 0.& 0.& 0.& 0.& 0.& 0.& 0.& 0.& 0.\\
 0.& 0.& 0.& 0.& 0.& 0.& 0.& 0.& 0.\\ 
0.& 0.& 0.& 0.& 0.& 0.& 0.& 0.& 0.\\ 
1.& 0.& 0.& 0.& 1.& 0.& 0.& 0.& 1.\\ 
0.& 0.& 0.& 0.& 0.& 0.& 0.& 0.& 0.\\ 
0.& 0.& 0.& 0.& 0.& 0.& 0.& 0.& 0.\\
 0.& 0.& 0.& 0.& 0.& 0.& 0.& 0.& 0.\\
 1.& 0.& 0.& 0.& 1.& 0.& 0.& 0.& 1.\\ 
\end{bmatrix}
$$
How can I compute the remainder, e.g., $A_{ikjl},A_{jikl}, A_{lkij}, \ldots$
Kind Regards!
 A: Solved in python with:
import numpy as np
from itertools import permutations
# create a 2nd order tensor
a=np.eye(3)
a[0][0]=2
a[0][-1]=3
a[-1][-1]=4
# create a 2nd order tensor
b=np.eye(3)

# Function that will permutate the indices 
def permutation(str1,tmp):
    store=np.zeros([3,3,3,3]) # variable to store the results
    
    #function to split the string with the indices
    def split(word): 
       return [char for char in word]
                
    
    a,b,c,d=split(str1) # gets indices from string

    
    for i in [0,1,2]:
        for j in [0,1,2]:
            for k in [0,1,2]:
                for l in [0,1,2]:
                    store[i,j,k,l]=tmp[vars()[a],vars()[b],vars()[c],vars()[d]]
    return store
                
                
result=np.einsum('ij,kl->ijkl',a,b) # gets the result of A_ij*B_kl = P_ijkl 




permutation_set=[''.join(p) for p in permutations('ijkl')] # generate a list of permutations with the indices ijkl

for p in permutation_set:

    permutation_wanted=np.einsum(p,result) # permutates the result for the with the intended permutation with the funciton einsum
    
    check=permutation(p,result) # gets the permutation with the permutation function defined above
    print("Current permutation is: %s" %(p))
    if(np.count_nonzero(check-permutation_wanted)==0):
        # if the difference between check and permutation_wanted is 0 (all the elements are equal)
        print("Script is working")
    else:
        print("Script is not working!")

