totensor.RdConstructs a "tensor". A tensor is the generalization of vectors and matrices to multi-index arrays.
to.tensor(X,...)
# Default S3 method
to.tensor(X,dims=NULL,ndimnames=NULL,what=1,addIndex=FALSE,...)the numeric data with the entries of the tensor. If the
object is already a tensor only the subtensors given by the dimension
what are converted
These dimensions to be added for the new tensor.
If the object is to big or addIndex an extra dimension is
added.
The new dimnames to be used
a numeric or character vector specifying the dimensions to be removed.
boolean or character, FALSE says no additional dimension, or string to give the name of the dimension
further arguments to other instances of the generic function
a tensor of the specified shape
This package provides a class "tensor"
allowing easy computation regarding tensorial computation in the
Einstein convention and allows an easier control of the computation
than aperm and tensor. The package is made to work with things like
matrices of matrices and linear mapping of matrices to matrices, etc.
A tensor is a multidimensional array, with specific mathematical
meaning, generalizing vectors and matrices. Tensors can be added,
subtracted and
multiplied and used in linear equations. While two matrices A,B are
commonly only multiplied in two ways A%*%B or B%*%A
and have some more t(A)%*%B,
B%*%t(A), sum(A*B),
sum(A*t(B)),kronecker(A,B)
the tensor calculus brings all of them into a organized system.
An important aspect for that is the name of its dimensions. Thus we
are not bound to work with rows and columns, but can name the
dimensions to be multiplied. This leads to much more organized
computation of linear mappings of matrices or datasets of matrices or
other genuine tensor arithmetic gets involved.
The package provides a full linear algebra support of tensors
including tensor addition, tensor multiplication, norms, deltatensors,
binding,
inversion, normalization,
Einstein summing
convention, trace, , dimension renaming, smart display of tensors,
renaming and reshaping, solving
equation system and giving decompositions and parallelized data
processing ,
This constructor is not called tensor() according to the general
convention of constructors to avoid conflicts with the tensor
multiplication routine
in the tensor package
A <- to.tensor(1:20,c(U=2,V=2,W=5))
B <- to.tensor(1:20,c(U=2,VV=2,WW=5))
A %e% B
#> , , 1, 1
#>
#> W
#> V [,1] [,2] [,3] [,4] [,5]
#> [1,] 5 17 29 41 53
#> [2,] 11 23 35 47 59
#>
#> , , 2, 1
#>
#> W
#> V [,1] [,2] [,3] [,4] [,5]
#> [1,] 11 39 67 95 123
#> [2,] 25 53 81 109 137
#>
#> , , 1, 2
#>
#> W
#> V [,1] [,2] [,3] [,4] [,5]
#> [1,] 17 61 105 149 193
#> [2,] 39 83 127 171 215
#>
#> , , 2, 2
#>
#> W
#> V [,1] [,2] [,3] [,4] [,5]
#> [1,] 23 83 143 203 263
#> [2,] 53 113 173 233 293
#>
#> , , 1, 3
#>
#> W
#> V [,1] [,2] [,3] [,4] [,5]
#> [1,] 29 105 181 257 333
#> [2,] 67 143 219 295 371
#>
#> , , 2, 3
#>
#> W
#> V [,1] [,2] [,3] [,4] [,5]
#> [1,] 35 127 219 311 403
#> [2,] 81 173 265 357 449
#>
#> , , 1, 4
#>
#> W
#> V [,1] [,2] [,3] [,4] [,5]
#> [1,] 41 149 257 365 473
#> [2,] 95 203 311 419 527
#>
#> , , 2, 4
#>
#> W
#> V [,1] [,2] [,3] [,4] [,5]
#> [1,] 47 171 295 419 543
#> [2,] 109 233 357 481 605
#>
#> , , 1, 5
#>
#> W
#> V [,1] [,2] [,3] [,4] [,5]
#> [1,] 53 193 333 473 613
#> [2,] 123 263 403 543 683
#>
#> , , 2, 5
#>
#> W
#> V [,1] [,2] [,3] [,4] [,5]
#> [1,] 59 215 371 527 683
#> [2,] 137 293 449 605 761
#>
#> attr(,"class")
#> [1] "tensor"