Learn R Programming

tensr (version 1.0.2)

mat: Unfold a matrix.

Description

mat returns a matrix version of a provided tensor.

Usage

mat(A, k)

Value

A matrix whose rows index the \(k\)th mode and whose columns index every other mode. The ordering of the columns is in lexicographical order of the indices of the array \(A\).

Arguments

A

An array to be unfolded.

k

The mode, or dimension, along which the unfolding is to be applied.

Author

Peter Hoff.

Details

Applies the matrix unfolding operator (also called 'matricization' or 'matrix flattening' operator) on a provided tensor. There are multiple ways one could do this. This function performs the matrix unfolding described in Kolda and Bader (2009).

References

  • Kolda, T. G., & Bader, B. W. (2009). Tensor decompositions and applications. SIAM review, 51(3), 455-500 tools:::Rd_expr_doi("10.1137/07070111X").

Examples

Run this code
A <- array(1:8, dim = c(2,2,2))
mat(A, 1)
mat(A, 2)
mat(A, 3)

Run the code above in your browser using DataLab