3.9. Tensors with a variable number of slots

Sometimes it is desirable to work with tensors with a variable number of slots, and xTensor` supports it. For example, this is important when dealing with tensor harmonics, and actually the special package xAct`Harmonics` makes use of it.
In general, once a tensor has been defined with a number of slots and the symmetry properties of those slots, it is possible to use the tensor with more slots, and the system will assume that there are no additional symmetry properties on the added slots. The problem, however, comes when we want all slots to participate in the symmetry of the tensor. The solution is very simple:
The symmetry of a tensor is given by the function SymmetryGroupOfTensor, which stores the symmetry as an upvalue for the name of the tensor. However, this function tries first to get the symmetry from the whole expression of the tensor (indices included), and only if this is not defined it will use the stored definition. Therefore we can give additional symmetry definitions for the tensor which will overwrite the initial symmetry assignment. From version 0.9.4 we include a special notation to indicate from the beginning the presence of a variable number of slots in vbundle.

Define a tensor with a variable number of indices on a given vbundle:

In[213]:=

DefTensor[Z[AnyIndices @ TangentM3], M3]

** DefTensor: No checks on indices for a variable-rank tensor.

** DefTensor: Defining tensor Z[AnyIndices[TangentM3]] .

The tensor is given no symmetry:

In[214]:=

Catch @ SymmetryGroupOfTensor[Z]

SymmetryGroupOfTensor :: unknown : Unknown tensor Z .

In[215]:=

Catch @ SymmetryGroupOfTensor[Z[]]

SymmetryGroupOfTensor :: unknown : Unknown tensor Z .

Now make it symmetric for any number of indices:

In[216]:=

SymmetryGroupOfTensor[Z[inds___]]^:=Symmetric[Range[Length[{inds}]]]

In[217]:=

SymmetryGroupOfTensor[Z[]]

Out[217]=

StrongGenSet[{}, GenSet[]]

In[218]:=

SymmetryGroupOfTensor[Z[a, b]]

Out[218]=

StrongGenSet[{1}, GenSet[Cycles[{1, 2}]]]

In[219]:=

SymmetryGroupOfTensor[Z[a, b, c, d]]

Out[219]=

StrongGenSet[{1, 2, 3}, GenSet[Cycles[{1, 2}], Cycles[{2, 3}], Cycles[{3, 4}]]]

Note that any call to SymmetryGroupOfTensor must include explicitly the indices of the tensor. This is still undefined:

In[220]:=

Catch @ SymmetryGroupOfTensor[Z]

SymmetryGroupOfTensor :: unknown : Unknown tensor Z .

Clean up:

In[221]:=

UndefTensor[Z]

** UndefTensor: Undefined tensor Z

In case you need symmetries other  than total symmetry or total antisymmetry, you will need to use the general notation for permutation groups (see xPermDoc.nb for a description).


Created by Mathematica  (May 16, 2008) Valid XHTML 1.1!