Learn R Programming

tensorBSS (version 0.3.9)

tensorTransform2: Linear Transformations of Tensors from Several Modes

Description

Applies a linear transformation to user selected modes of each individual tensor in an array of tensors. The function is a generalization of tensorTransform which only transforms one specific mode.

Usage

tensorTransform2(x, A, mode, transpose = FALSE)

Value

Array with r+1 dimensions where the dimensions specfied via mode are transformed.

Arguments

x

Array of order r+1 >= 2 where the last dimension corresponds to the sampling units.

A

A list of r matrices to apply linearly to the corresponding mode.

mode

subsetting vector indicating which modes should be linearly transformed by multiplying them with the corresponding matrices from A.

transpose

logical. Should the matrices in A be transposed before the mode wise transformations or not.

Author

Klaus Nordhausen

Details

For the modes \(i_1,\ldots,i_k\), specified via mode, the function applies the linear transformation given by the matrix \(A^{i_j}\) of size \(q_{i_j} \times p_{i_j}\) to the \(i_j\)th mode of each of the \(n\) observed tensors \(X_{i_j}\) in the given \(p_1 \times p_2 \times \ldots \times p_r \times n\)-dimensional array x.

See Also

tensorTransform

Examples

Run this code
n <- 5
x <- array(rnorm(5*6*7), dim = c(7, 6, 5))
A1 <- matrix(runif(14), ncol = 7)
A2 <- matrix(rexp(18), ncol = 6)
A  <- list(A1 = A1, A2 = A2)
At <- list(tA1 = t(A1), tA2 = t(A2))

x1 <- tensorTransform2(x, A, 1)
x2 <- tensorTransform2(x, A, -2)
x3 <- tensorTransform(x, A1, 1)
x1 == x2
x1 == x3
x4 <- tensorTransform2(x,At,-2, TRUE)
x1 == x4
x5 <- tensorTransform2(x, A, 1:2)

Run the code above in your browser using DataLab