5.2. IndexSet and IndexSetDelayed

The xTensor` functions IndexSet and IndexSetDelayed imitate the behaviour of Set and SetDelayed (which delays the evaluation of the rhs to the moment when the lhs is converted into the rhs).

IndexSet                Set value of an indexed expression, at definition time
IndexSetDelayed            Set value of an indexed expression, at evaluation time

Set functions for indexed expressions.

Example of use of IndexSet:

In[337]:=

IndexSet[w[a_], S[a, b] v[-b]]

Out[337]=

S_  ^ab v_b^

In[338]:=

? w

Global`w

Dagger[w]^=w
DependenciesOfTensor[w]^={M3}
Info[w]^={tensor,}
PrintAs[w]^=w
SlotsOfTensor[w]^={TangentM3}
SymmetryGroupOfTensor[w]^=StrongGenSet[{},GenSet[]]
TensorID[w]^={}
xTensorQ[w]^=True
w_ ^Underscript[a, _] := Module[{b}, S_  ^ab v_b^ ]

In[339]:=

w[b]

Out[339]=

S_  ^ba v_a^

In this case the code finds the conflicting dummies, and then replaces the offending dummy on the right hand side:

In[340]:=

IndexSet[S[a_, b_, -b_], T[a, b, -b, c, -c]]

Out[340]=

T_ (  b c)^(ab c )

In[341]:=

? S

Global`S

Dagger[S]^=S
DependenciesOfTensor[S]^={M3}
Info[S]^={tensor,}
PrintAs[S]^=S
SlotsOfTensor[S]^={TangentM3,TangentM3}
SymmetryGroupOfTensor[S]^=StrongGenSet[{1},GenSet[Cycles[{1,2}]]]
TensorID[S]^={}
xTensorQ[S]^=True

In[342]:=

S[a, c, -c]

Out[342]=

T_ (  c b)^(ac b )

Example of use of IndexSetDelayed. Note that we only use a pattern in the first index of U and that w is still not evaluated:

In[343]:=

IndexSetDelayed[U[-a_, -b, -c], w[-a] w[-b] w[-c]]

In[344]:=

? U

Global`U

Dagger[U]^=U
DependenciesOfTensor[U]^={M3}
Info[U]^={tensor,}
PrintAs[U]^=U
SlotsOfTensor[U]^={-TangentM3,-TangentM3,-TangentM3}
SymmetryGroupOfTensor[U]^=StrongGenSet[{1,2},GenSet[-Cycles[{1,2}],-Cycles[{2,3}]]]
TensorID[U]^={}
xTensorQ[U]^=True
U_ (Underscript[a, _] bc)^    := Module[{}, w_a^  w_b^  w_c^ ]

In[345]:=

U[-a, -b, -c]

Out[345]=

S_a ^( d) S_b ^( e) S_c ^( f) v_d^  v_e^  v_f^

We can change the definition of w and the conversion from U to w will be still valid:

In[346]:=

IndexSet[w[a_], S[a, b] S[-b, -c] v[c]]

Out[346]=

S_  ^ab S_bc^   v_ ^c

In[347]:=

U[-a, -b, -c]

Out[347]=

S_a ^( d) S_b ^( e) S_c ^( f) S_dg^   S_eh^   S_fh1^    v_ ^g v_ ^h v_  ^h1

Clean up:

In[348]:=

U[-a_, -b, -c] =.


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