Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

k_fold

k-mode Folding of Matrix


Description

k-mode folding of a matrix into a Tensor. This is the inverse funtion to k_unfold in the m mode. In particular, k_fold(k_unfold(tnsr, m),m,getModes(tnsr)) will result in the original Tensor.

Usage

k_fold(mat, m = NULL, modes = NULL)

Arguments

mat

matrix to be folded into a Tensor

m

the index of the mode that is mapped onto the row indices

modes

the modes of the output Tensor

Details

This is a wrapper function to fold.

Value

Tensor object with modes given by modes

References

T. Kolda, B. Bader, "Tensor decomposition and applications". SIAM Applied Mathematics and Applications 2009.

See Also

Examples

tnsr <- new("Tensor",3L,c(3L,4L,5L),data=runif(60))
matT2<-k_unfold(tnsr,m=2)
identical(k_fold(matT2,m=2,modes=c(3,4,5)),tnsr)

rTensor

Tools for Tensor Analysis and Decomposition

v1.4.8
GPL (>= 2)
Authors
James Li and Jacob Bien and Martin Wells
Initial release
2021-05-14

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.