Constructs a "tensor". A tensor is the generalization of vectors and matrices to multi-index arrays.
to.tensor(X,...)
# S3 method for default
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 ,
tensorA, level.tensor
,
diag.tensor
, norm.tensor
drag.tensor
, one.tensor
,
mul.tensor
, %e%
, %r%
, ,
drag.tensor
, , trace.tensor
,
solve.tensor
, svd.tensor
,
mean.tensor
# NOT RUN {
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
# }
Run the code above in your browser using DataCamp Workspace