k_fold: k-mode Folding of 2D DelayedArray

k_fold-methodsR Documentation

k-mode Folding of 2D DelayedArray

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(darr, m), m, dim(darr)) will result in the original Tensor.

Usage

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

## S4 method for signature 'DelayedArray'
k_fold(mat, m, modes)

Arguments

mat

DelayedArray object (only 2D)

m

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

modes

the modes of the output DelayedArray

Details

This function is an extension of the k_fold by DelayedArray.

This is a wrapper function to fold.

Value

DelayedArray object with modes given by modes

References

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

See Also

fold, k_unfold

Examples

library("DelayedRandomArray")
darr <- RandomUnifArray(c(2,3,4))
matT2 <- k_unfold(darr, m=2)
identical(
    as.array(k_fold(matT2, m=2, modes=c(2,3,4))),
    as.array(darr))

rikenbit/DelayedTensor documentation built on Jan. 30, 2023, 6:15 p.m.