tracetensor: Collapse a tensor

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Collapses the tensor over dimensions i and j. This is like a trace for matrices or like an inner product of the dimensions i and j.

Usage

1
trace.tensor(X,i,j)

Arguments

X

the tensor

i

a numeric or character vector of dimensions of X, used for the inner product.

j

a numeric or character vector of dimensions of X with the same length but other elements than i.

Details

Let be

X_{i_1...i_n j_1...j_n k_1...k_d}

the tensor. Then the result is given by

E_{k_1...k_d}=sum_{i_1...i_n} X_{i_1...i_n i_1...i_n k_1...k_d}

With the Einstein summing convention we would write:

E_{k_1 … k_d}=X_{i_1… i_n j_1… j_n k_1 … k_d}δ_{i_1j_1}… δ_{i_nj_n}{ E_{k_1...k_d}=X_{i_1...i_n j_1...j_n k_1 ... k_d}δ_{i_1j_1} ... δ_{i_nj_n } }

Value

A tensor like X with the i and j dimensions removed.

Author(s)

K. Gerald van den Boogaart

See Also

mul.tensor, to.tensor

Examples

1
2
3
A <- to.tensor(1:20,c(i=2,j=2,k=5))
A
trace.tensor(A,"i","j")

Example output

Attaching package: 'tensorA'

The following object is masked from 'package:base':

    norm

, , 1

      j
i      [,1] [,2]
  [1,]    1    3
  [2,]    2    4

, , 2

      j
i      [,1] [,2]
  [1,]    5    7
  [2,]    6    8

, , 3

      j
i      [,1] [,2]
  [1,]    9   11
  [2,]   10   12

, , 4

      j
i      [,1] [,2]
  [1,]   13   15
  [2,]   14   16

, , 5

      j
i      [,1] [,2]
  [1,]   17   19
  [2,]   18   20

attr(,"class")
[1] "tensor"
[1]  5 13 21 29 37
attr(,"class")
[1] "tensor"

tensorA documentation built on Nov. 20, 2020, 9:07 a.m.

Related to tracetensor in tensorA...