to.tensor {tensorA}R Documentation

Creates a tensor object

Description

Constructs a "tensor". A tensor is the generalization of vectors and matrices to multi-index arrays.

Usage

to.tensor(X,...)
## Default S3 method:
to.tensor(X,dims=NULL,ndimnames=NULL,what=1,addIndex=FALSE,...)

Arguments

X

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

dims

These dimensions to be added for the new tensor. If the object is to big or addIndex an extra dimension is added.

ndimnames

The new dimnames to be used

what

a numeric or character vector specifying the dimensions to be removed.

addIndex

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

Details

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 ,

Value

a tensor of the specified shape

Note

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

Author(s)

K. Gerald van den Boogaart

See Also

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

Examples

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


[Package tensorA version 0.36.2.1 Index]