sequencing {tensorA} | R Documentation |
In typical tensor notation the indices are not identified by names but by positions. The operators allow to identify names and positions transparently during calculation.
## Methods for class tensor # x $ y # x ^ y # x | y renamefirst.tensor(x,y)
x |
A tensor |
y |
Typically a character vector specifying a sequence of names for the
tensor. The names can be specified in various ways: |
These functions are used to mimic the mathematical notation in tensor analysis. Formulae of the form (with Einstein convention):
E_ijk= A_ihl C_hj C_lk
with defined tensors A_ijk and C_ij can
be given the
simple
form
E <- A$ihl %e% C$hj %e% C$lk |"$ijk"
or alternatively for multi letter names:
E <- A$i.h.l %e% C$h.j %e% C$l.k |"i.j.k"
or more flexible in computation with arguments I,J,K:
E <- A^c(I,"h.l") %e% C^c("h",J) %e% C^c("l",K) | c(I,J,K)
The $
or ^
binds to the tensors with high precedence
and renames the first elements. The |
binds with very low
precedence and reorders the tensor according to the
assumed index sequence of the result afterwards.
A tensor of the same shape as x but with reordered dimensions (for
|
) or renamed dimensions (for the others)
K. Gerald van den Boogaart
reorder.tensor
, names<-.tensor
, [[.tensor
A <- to.tensor(1:20,c(i=5,j=2,k=2)) C <- to.tensor(1:4,c(i=2,j=2)) E <- A$ihl %e% C$hj %e% C$lk |"$ijk" E # Same as: E2 <- reorder.tensor(A[[j=~h,k=~l]] %e% C[[i=~h]] %e% C[[i=~l,j=~k]],c("i","j","k")) E-E2 E <- A$i.h.l %e% C$h.j %e% C$l.k |"i.j.k" E E-E2 E <- A^"i.h.l" %e% C^"h.j" %e% C^"l.k" |"i.j.k" E E-E2