ttm: Tensor Times Matrix (m-Mode Product)

Description Usage Arguments Details Value Note References See Also Examples

View source: R/rTensor_Misc.R

Description

Contracted (m-Mode) product between a Tensor of arbitrary number of modes and a matrix. The result is folded back into Tensor.

Usage

1
ttm(tnsr, mat, m = NULL, transpose = FALSE)

Arguments

tnsr

Tensor object with K modes

mat

input matrix with same number columns as the mth mode of tnsr

m

the mode to contract on

transpose

if mat should be transposed before multiplication

Details

By definition, rs_unfold(ttm(tnsr,mat),m) = mat%*%rs_unfold(tnsr,m), so the number of columns in mat must match the mth mode of tnsr. For the math on the m-Mode Product, see Kolda and Bader (2009).

Value

a Tensor object with K modes

Note

The mth mode of tnsr must match the number of columns in mat. By default, the returned Tensor does not drop any modes equal to 1.

References

T. Kolda, B. Bader, "Tensor decomposition and applications". SIAM Applied Mathematics and Applications 2009.

See Also

ttl, rs_unfold-methods

Examples

1
2
3
tnsr <- new("Tensor",3L,c(3L,4L,5L),data=runif(60))
mat <- matrix(runif(50),ncol=5)
ttm(tnsr,mat,m=3)

jamesyili/rTensor documentation built on May 18, 2019, 11:22 a.m.