names.RdThe names of a tensor are the names of its dimension
the names of the dimensions the tensor
The names of the dimensions of the tensor are very relevant in any tensor arithmetic since they are the principle way to specify the dimensions to be involved in an operation. The dimnames function is here only for convenice to guarantee that the names of the dimnames are always the same as the names of the dimensions and to ensure that always at least a list with the right length and names.
A <- to.tensor(1:20,c(U=2,V=2,W=5))
A
#> , , 1
#>
#> V
#> U [,1] [,2]
#> [1,] 1 3
#> [2,] 2 4
#>
#> , , 2
#>
#> V
#> U [,1] [,2]
#> [1,] 5 7
#> [2,] 6 8
#>
#> , , 3
#>
#> V
#> U [,1] [,2]
#> [1,] 9 11
#> [2,] 10 12
#>
#> , , 4
#>
#> V
#> U [,1] [,2]
#> [1,] 13 15
#> [2,] 14 16
#>
#> , , 5
#>
#> V
#> U [,1] [,2]
#> [1,] 17 19
#> [2,] 18 20
#>
#> attr(,"class")
#> [1] "tensor"
dim(A)
#> U V W
#> 2 2 5
names(A)
#> [1] "U" "V" "W"
names(A) <- c("A","B","C")
A
#> , , 1
#>
#> B
#> A [,1] [,2]
#> [1,] 1 3
#> [2,] 2 4
#>
#> , , 2
#>
#> B
#> A [,1] [,2]
#> [1,] 5 7
#> [2,] 6 8
#>
#> , , 3
#>
#> B
#> A [,1] [,2]
#> [1,] 9 11
#> [2,] 10 12
#>
#> , , 4
#>
#> B
#> A [,1] [,2]
#> [1,] 13 15
#> [2,] 14 16
#>
#> , , 5
#>
#> B
#> A [,1] [,2]
#> [1,] 17 19
#> [2,] 18 20
#>
#> attr(,"class")
#> [1] "tensor"
dim(A)
#> A B C
#> 2 2 5
names(A)
#> [1] "A" "B" "C"