to.matrix.tensor | R Documentation |
A tensor can be seen as a linear mapping of a tensor to a tensor. This function gives the corresponding matrix of the mapping.
to.matrix.tensor(X,i,j,by=NULL)
X |
The tensor |
i |
The image indices of the linear mapping |
j |
The domain indices of the linear mapping |
by |
the operation is done in parallel for these dimensions |
A tensor can be seen as a linear mapping of a tensor to a tensor. This function computes the corresponding matrix, mapping the entries of the domain tensor to the entries of the image tensor.
if no by
is given a matrix. Otherwise a tensor of level
2+length(dim(X))[by]
giving matrices for each specification of the by dimensions.
K. Gerald van den Boogaart
to.tensor
, solve.tensor
,
inv.tensor
, svd.tensor
A <- reorder.tensor(to.tensor(1:30,c(a=2,b=3,c=5)),c("c","a","b"))
to.matrix.tensor(A,"a",c("b","c")) # matrix(1:30,nrow=2)
to.matrix.tensor(A,c("a","b"),c("c")) # matrix(1:30,nrow=6)
to.matrix.tensor(A,c("a","b"),by=c("c")) # structure(1:30,dim=c(6,1,5)))
to.matrix.tensor(A,c("a"),by=c("c")) # structure(1:30,dim=c(2,3,5)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.