({{, (RefLink[SymmetrizedArray, paclet:ref/SymmetrizedArray])[{(Subscript[pos, 1])->(Subscript[val, 1]),(Subscript[pos, 2])->(Subscript[val, 2]),…},dims,sym]
yields an array of dimensions dims whose entries are given by those in the rules (Subscript[pos, i])->(Subscript[val, i]) or through the symmetry sym.}, {, (RefLink[SymmetrizedArray, paclet:ref/SymmetrizedArray])[list]
yields a symmetrized array version of list.}})

OpenersNotesSection(Spacer1)Details

(RefLink[SymmetrizedArray, paclet:ref/SymmetrizedArray]) takes unspecified elements to be 0.

(RefLink[SymmetrizedArray, paclet:ref/SymmetrizedArray])[data,…] is converted to an expression of the form (RefLink[StructuredArray, paclet:ref/StructuredArray])[SymmetrizedArray,dims,structureddata], where structureddata contains the symmetry and independent component rules corresponding to the input.

(RefLink[Normal, paclet:ref/Normal])[SymmetrizedArray[…]] gives the ordinary array corresponding to a symmetrized array object.

(RefLink[SymmetrizedArrayRules, paclet:ref/SymmetrizedArrayRules])[SymmetrizedArray[…]] gives the list of independent rules {(Subscript[pos, 1])->(Subscript[val, 1]),(Subscript[pos, 2])->(Subscript[val, 2]),…}.

(RefLink[ArrayRules, paclet:ref/ArrayRules])[SymmetrizedArray[…]] gives the list of both dependent and independent rules {(Subscript[pos, 1])->(Subscript[val, 1]),(Subscript[pos, 2])->(Subscript[val, 2]),…}.

The elements in a (RefLink[SymmetrizedArray, paclet:ref/SymmetrizedArray]) object need not be numeric.

The position specifications (Subscript[pos, i]) can contain patterns.

With rules (Subscript[pos, i]):>(Subscript[val, i]), the (Subscript[val, i]) are evaluated separately for each independent component that matches (Subscript[pos, i]).

(RefLink[SymmetrizedArray, paclet:ref/SymmetrizedArray])[list] requires that list be a full array, with all parts at a particular level being lists of the same length.

The individual elements of a symmetrized array cannot themselves be lists.

(RefLink[SymmetrizedArray, paclet:ref/SymmetrizedArray])[rules] yields a symmetrized array, with dimensions exactly large enough to include elements whose positions have been explicitly specified.

(RefLink[StructuredArray, paclet:ref/StructuredArray])[SymmetrizedArray,…] is treated as a raw object by functions like (RefLink[AtomQ, paclet:ref/AtomQ]) and for purposes of pattern matching.

OpenersPrimaryExamplesSection(Spacer1)Examples  (20)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Construct an antisymmetric array:

SymmetrizedArray[{{1,2}->a,{2,3}->b},{3,3},Antisymmetric[{1,2}]]

Convert it to an ordinary matrix:

Normal[%]

Convert an array with symmetry into its symmetrized form:

SymmetrizedArray[{{a,b},{b,c}}]

These are its independent components:

SymmetrizedArrayRules[%]

OpenersExampleSection1(Spacer1)Scope  (7)

Construct a symmetrized array from rules:

SymmetrizedArray[{{1,2}->a,{2,3}->b},{3,3},Antisymmetric[{1,2}]]

Normal[%]

(RefLink[SymmetrizedArray, paclet:ref/SymmetrizedArray]) form of an array with symmetry:

SymmetrizedArray[{{{a,b},{b,c}},{{b,c},{c,d}}}]

(RefLink[SymmetrizedArray, paclet:ref/SymmetrizedArray]) form of an array with antisymmetry:

SymmetrizedArray[{{{0,0,0},{0,0,a},{0,-a,0}},{{0,0,-a},{0,0,0},{a,0,0}},{{0,a,0},{-a,0,0},{0,0,0}}}]

Construct a symmetrized array of larger dimensions:

SymmetrizedArray[{{{a,b},{b,c}},{{b,c},{c,d}}},{10,10,10}]

Let the Wolfram Language choose the minimal dimensions:

SymmetrizedArray[{{{a,b},{b,c}},{{b,c},{c,d}}},Automatic]

Construct a random skew-symmetric array:

SymmetrizedArray[pos_:>RandomInteger[10],{4,4,4},Antisymmetric[{1,2,3}]]

SymmetrizedArrayRules[%]

Specify an arbitrary symmetry using generators:

SymmetrizedArray[pos_:>a@@pos,{2,2,2,2},{{Cycles[{{1,2}}],-1},{Cycles[{{3,4}}],1}}]

Normal[%]

An empty list of generators represents no symmetry:

SymmetrizedArray[{{1,2}->a},{3,2},{}]

Normal[%]

Use generators with any root of unity:

sym={{{2,1,4,3},1},{{1,3,4,2},Exp[2 I Pi/3]}}

SymmetrizedArray[{{1,1,2,2}->a},{2,2,2,2},sym]

Normal[%]

OpenersExampleSection3(Spacer1)Applications  (5)

Construct an antisymmetric array:

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

Only the independent components are stored:

sa//InputForm

Extract any component of the array:

sa[[2,3,4,1]]

Extract a subarray:

sa[[2,1]]

Normal[%]

Construct an antisymmetric matrix:

am=SymmetrizedArray[{{1,2}->a,{1,3}->b,{2,3}->c},{3,3},Antisymmetric[All]]

Multiple tensor product of the matrix with itself:

am4=am⊗am⊗am⊗am

The result contains only 15 independent components, all with different values:

SymmetrizedArrayRules[am4]

The sparse and normal representations are larger:

SparseArray[am4]

Normal[am4]//Flatten//Length

Antisymmetric arrays of ranks 4 and 10 in dimension 15:

SeedRandom[0];
sa4=SymmetrizedArray[pos_:>RandomInteger[10],ConstantArray[15,4],Antisymmetric[All]];
sa10=SymmetrizedArray[pos_:>RandomInteger[10],ConstantArray[15,10],Antisymmetric[All]];

The wedge product of those antisymmetric arrays can be computed efficiently:

sa14=sa4\[TensorWedge]sa10

The result can be presented in a shorter form through its Hodge dual:

HodgeDual[sa14]

Normal[%]

Construct the array of all sixth-order partial derivatives of a function of four variables:

vars={x,y,z,t};

d6=D[f[x,y,z,t],{vars,6}];

It is a depth-6 array in dimension 4, and therefore it has 4096 entries:

Dimensions[d6]

Apply[Times,%]

It is also a fully symmetric array, due to commutation of the partial derivatives:

TensorSymmetry[d6]

Most entries are repeated multiple times and therefore the array is large:

ByteCount[d6]

The (RefLink[SymmetrizedArray, paclet:ref/SymmetrizedArray]) representation stores each of the independent entries only once:

sd6=Symmetrize[d6]

ByteCount[sd6]

The normal form of the array can be recovered using (RefLink[Normal, paclet:ref/Normal]):

Normal[sd6]===d6

Construct a 4-variate distribution, using a symmetric matrix Σ:

dim=4;
Σ=Normal@SymmetrizedArray[{i_,j_}:>(Subscript[σ, i,j]),{dim,dim},Symmetric[{1,2}]]

dist=MultivariateTDistribution[Σ,10];

Define a function that computes a moment of that distribution for given variable indices:

vars=Array[x,dim];
moment[inds__]:=Expectation[Times@@Part[vars,{inds}],vars\[Distributed]dist]

Check a particular case:

moment[1,2,1,2,1,4]

%==Moment[dist,{3,2,0,1}]//Simplify

Construct the array of moments of order 6:

order=6;

AbsoluteTiming[marray=Array[moment,Table[dim,order]];]

Moment and cumulant arrays for a multivariate distribution are fully symmetric:

TensorSymmetry[marray]

Use (RefLink[SymmetrizedArray, paclet:ref/SymmetrizedArray]) to compute each independent moment only once:

AbsoluteTiming[smarray=SymmetrizedArray[{inds__}:>moment[inds],Table[dim,order],Symmetric[All]]]

Both representations are equivalent:

smarray==marray

Compare sizes:

{ByteCount[marray],ByteCount[smarray]}

OpenersExampleSection4(Spacer1)Properties & Relations  (4)

If the same entry is specified several times, the average of those values is used:

SymmetrizedArray[{{1,2}->a,{1,2}->b,{2,1}->c},{2,2},Symmetric[{1,2}]]

SymmetrizedArrayRules[%]

For a nonsymmetric array, the result is a projected symmetrized part:

SymmetrizedArray[{{a,b},{c,d}},{2,2},Antisymmetric[{1,2}]]

Normal[%]//MatrixForm

(RefLink[SymmetrizedArray, paclet:ref/SymmetrizedArray]) offers a very compact representation of antisymmetric arrays:

d=7;

a=SymmetrizedArray[Range[d]->1,ConstantArray[d,d],Antisymmetric[Range[d]]]

spa=SparseArray[a]

ByteCount/@{a,spa,Normal[a]}

(RefLink[SymmetrizedArray, paclet:ref/SymmetrizedArray]) allows a compact representation of symmetric arrays:

CrossMatrix[{2,2,2}]

SymmetrizedArray[%]

ByteCount[cross=CrossMatrix[{10,10,10,10}]]

ByteCount[SymmetrizedArray[cross]]

OpenersExampleSection5(Spacer1)Possible Issues  (1)

Some symmetry specifications are only compatible with the array having only vanishing entries:

SymmetrizedArray[pos_:>a@@pos,{3,3,3},{{{2,1,3},1},{{1,3,2},-1}}]

OpenersExampleSection6(Spacer1)Neat Examples  (1)

Antisymmetric rank-4 array projected down to a symmetric matrix in different dimensions:

matrix[d_]:=ArrayFlatten@
Normal@
Block[{c=1},
SymmetrizedArray[_:>c++,{d,d,d,d},Antisymmetric[All]]
];
TensorSymmetry[matrix[12]]

Equal elements correspond to the same color. White elements are zeros:

MatrixPlot[matrix[6]]

MatrixPlot[matrix[12]]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[StructuredArray, paclet:ref/StructuredArray])  ▪  (RefLink[Symmetrize, paclet:ref/Symmetrize])  ▪  (RefLink[Symmetric, paclet:ref/Symmetric])  ▪  (RefLink[Antisymmetric, paclet:ref/Antisymmetric])  ▪  (RefLink[TensorSymmetry, paclet:ref/TensorSymmetry])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Symbolic Tensors, paclet:tutorial/SymbolicTensors])}, {▪(RefLinkPlain[Tensor Symmetries, paclet:tutorial/TensorSymmetries])}, {▪(RefLinkPlain[Symmetrized Arrays, paclet:tutorial/SymmetrizedArrays])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Symbolic Tensors, paclet:guide/SymbolicTensors])}})}})