3
$\begingroup$

Suppose I have a rank 4 tensor $T_{abcd}$, I can build a SparseArray to input some initial values like $T_{1435}=1$ (a huge amounts of elements are equal to 1) etc. Now I want to antisymmetrize this tensor, then automatically diagonal terms are all 0, and $T_{4135}=T_{1453}=T_{1345}=T_{3415}=T_{5431}=T_{1534}=-1$ and $T_{4153}=1$ etc. How can I achieve this?

PS: I have tried SymmetrizedArray, but it can not do something like {{1,2,3,4},{2,1,4,2}} -> 1.

$\endgroup$

1 Answer 1

5
$\begingroup$

You're almost there. You just need to add Antisymmetric[{1, 2, 3, 4}]:

sa = SymmetrizedArray[
  {{1, 4, 3, 5} -> 1},
  {5, 5, 5, 5}, 
  Antisymmetric[{1, 2, 3, 4}]
]

Then you can simply visually check with

Normal[sa] // MatrixForm

that by specifying just $T_{1435} = 1$ above, you automatically get $T_{4135}=T_{1453}=T_{1345}=T_{3415}=T_{5431}=T_{1534}=-1$ and $T_{4153}=1$ etc.

$\endgroup$
2
  • $\begingroup$ Thank you for your answer. One problem I am having with this method is that I have created a huge amount of list contains the position of 1s. But SymmetrizedArray does not allow operation like list->1, and I am not sure how to assign each element in the list to 1 in this case (because there are too many). $\endgroup$
    – lol
    Aug 26, 2017 at 3:17
  • $\begingroup$ @lol Suppose your list is list = {{1,2,3,4},{2,1,4,2}}. Use the following as the first argument of SymmetrizedArray: # -> 1 & /@ list. $\endgroup$
    – Taiki
    Aug 26, 2017 at 3:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.