Learn R Programming

tensorBSS (version 0.3.9)

tensorTransform: Linear Transformation of Tensors from mth Mode

Description

Applies a linear transformation to the mth mode of each individual tensor in an array of tensors.

Usage

tensorTransform(x, A, m)

Value

Array of size \(p_1 \times p_2 \times \ldots \times p_{m-1} \times q_m \times p_{m+1} \times \ldots \times p_r \times n\)

Arguments

x

Array of an order at least two with the last dimension corresponding to the sampling units.

A

Matrix corresponding to the desired linear transformation with the number of columns equal to the size of the mth dimension of x.

m

The mode from which the linear transform is to be applied.

Author

Joni Virta

Details

Applies the linear transformation given by the matrix \(A\) of size \(q_m \times p_m\) to the \(m\)th mode of each of the \(n\) observed tensors \(X_i\) in the given \(p_1 \times p_2 \times \ldots \times p_r \times n\)-dimensional array x. This is equivalent to separately applying the linear transformation given by \(A\) to each \(m\)-mode vector of each \(X_i\).

Examples

Run this code
# Generate sample data.
n <- 10
x <- t(cbind(rnorm(n, mean = 0),
             rnorm(n, mean = 1),
             rnorm(n, mean = 2),
             rnorm(n, mean = 3),
             rnorm(n, mean = 4),
             rnorm(n, mean = 5)))

dim(x) <- c(3, 2, n)

# Transform from the second mode
A <- matrix(c(2, 1, 0, 3), 2, 2)
z <- tensorTransform(x, A, 2)

# Compare
z[, , 1]
x[, , 1]%*%t(A)

Run the code above in your browser using DataLab