Last chance! 50% off unlimited learning
Sale ends in
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)
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.
The tensor
The image indices of the linear mapping
The domain indices of the linear mapping
the operation is done in parallel for these dimensions
K. Gerald van den Boogaart
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.
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)))
Run the code above in your browser using DataLab