fold-methods | R Documentation |
General folding of a 2D DelayedArray into a higher-order DelayedArray(Tensor).
This is designed to be the inverse function to
unfold
, with the same ordering of the indices.
This amounts to following: if we were to unfold a Tensor using a set of
row_idx
and col_idx
, then we can fold the resulting matrix
back into the original Tensor using the same row_idx
and col_idx
.
fold(mat, row_idx = NULL, col_idx = NULL, modes = NULL)
## S4 method for signature 'DelayedArray'
fold(mat, row_idx, col_idx, modes)
mat |
DelayedArray object (only 2D) |
row_idx |
the indices of the modes that are mapped onto the row space |
col_idx |
the indices of the modes that are mapped onto the column space |
modes |
the modes of the output DelayedArray |
This function is an extension of the fold
by DelayedArray.
DelayedArray object with modes given by modes
T. Kolda, B. Bader, "Tensor decomposition and applications". SIAM Applied Mathematics and Applications 2009.
unfold
, k_fold
,
unmatvec
,
rs_fold
, cs_fold
library("DelayedRandomArray")
darr <- RandomUnifArray(c(2,3,4))
matT3 <- DelayedTensor::unfold(darr, row_idx=2, col_idx=c(3,1))
identical(
as.array(DelayedTensor::fold(matT3, row_idx=2,col_idx=c(3,1),
modes=c(2,3,4))),
as.array(darr))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.