ttt: Matrix product of two tensors

Description Usage Arguments Details Value Examples

View source: R/ttt.R

Description

Matrix product of two tensors unfolded on the specified modes.

Usage

1
ttt(x, y, ms)

Arguments

x

A tensor instance.

y

A tensor instance.

ms

The indices of the modes to compute on. A single value or a vector.

Details

Suppose x is a s-way tensor with dimension p_1 \times … \times p_s and y is a t-way tensor with dimension r_1 \times … \times r_t. ms specifies the indices on which the tensors x and y are unfolded as columns. Thus, ms must be a subset of 1:min{s,t}. Meanwhile, the sizes of the dimensions specified by ms must match, e.g., if ms = 1:k where k <= min{s,t}, then p_1\times … p_k = s_1\times … s_k. Let X_0 and Y_0 denote the unfolded matrices, the matrix X_0 \times Y_0^T is returned. See Examples for a better illustration.

Value

Return the matrix product of tensors x and y.

Examples

1
2
3
x <- rTensor::as.tensor(array(runif(24), c(3, 4, 2)))
y <- rTensor::as.tensor(array(runif(24), c(3, 4, 2)))
z <- ttt(x, y, 1:2)

TRES documentation built on Oct. 20, 2021, 9:06 a.m.