3
$\begingroup$

Using Symmetrize I want to transform a tensor to be symmetric under all index permutations for all original entries $\ne 0$. However each entry is normalized by the number of index permutations. How to tell MMA to consider for symmetrizing only values $\ne0$?

a = ConstantArray[0, {3, 3, 3}];
a[[1, 1, 1]] = 1; (* 1 index permutation *)
a[[1, 1, 2]] = 2; (* 3 index permutations *)
a[[1, 2, 3]] = 5; (* 6 index permutations *)
asym = Normal[Symmetrize[a, Symmetric[All]]];
MatrixForm[asym]

enter image description here

To get the desired symmetrized tensor I have to multiply each entry by the number of its index permutations:

Table[asym[[i1,i2,i3]] *= Length[Permutations[{i1,i2,i3}]],{i1,1,3},{i2,1,3},{i3,1,3}];
MatrixForm[asym]

enter image description here

The same I would achieve if I define the symmetric tensor from scratch.

Normal[SymmetrizedArray[{{1,1,1}->1,{1,1,2}->2,{1,2,3}->5},{3,3,3},Symmetric[All]]]

However this method does not apply as there is already a tensor given where only nonzero values shall be symmetrized.

MMA 13

$\endgroup$
1
  • $\begingroup$ Did you try to apply Ceiling[]? $\endgroup$ Commented Oct 10, 2022 at 16:13

2 Answers 2

0
$\begingroup$

I think what you want is to specify a symmetric array giving only its independent components:

SymmetrizedArray[{{1, 1, 1} -> 1, {1, 1, 2} -> 2, {1, 2, 3} -> 5}, {3, 3, 3}, Symmetric[All]] // Normal
(* {{{1, 2, 0}, {2, 0, 5}, {0, 5, 0}}, {{2, 0, 5}, {0, 0, 0}, {5, 0, 0}}, {{0, 5, 0}, {5, 0, 0}, {0, 0, 0}}} *)
$\endgroup$
2
  • $\begingroup$ Given is a tensor with a few entries and I want to symmetrize the tensor. For demonstration I filled in my small example an empty tensor with some values, but in practice I start from a tensor that has already some vales. Your method is only useful if I construct a tensor from zero. My method of multiplication with permutation numbers is more suitable. But I thought there is an option to avoid the normalization by the number of permutations. Why at all this normalization happens? $\endgroup$ Commented Oct 11, 2022 at 10:18
  • 1
    $\begingroup$ With the normalization by the number of permutations we guarantee that Symmetrize[A] is equal to A for an array A that is already symmetric. Note that if you already have an array then you can extract its non-zero values with ArrayRules for example. $\endgroup$
    – jose
    Commented Oct 11, 2022 at 14:59
0
$\begingroup$

The answer from the comments is to define the tensor by ArrayRules. The correct coding is then:

a = ConstantArray[0, {3, 3, 3}];
a[[1, 1, 1]] = 1; 
a[[1, 1, 2]] = 2; 
a[[1, 2, 3]] = 5; 
asym = Normal[SymmetrizedArray[ArrayRules[a],{3,3,3},Symmetric[All]]];
MatrixForm[asym]

enter image description here

$\endgroup$

Your Answer

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

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