amprod: k-mode product.

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

amprod returns the k-mode product of an array with a matrix.

Usage

1
amprod(A, M, k)

Arguments

A

A real valued array.

M

A real matrix.

k

An integer. The mode along which M is to be multiplied to A.

Details

The k-mode product of a tensor A with a matrix M results in a tensor whose k-mode unfolding is M times the k-mode unfolding of A. That is mat(amprod(A,M,k)) = M %*% mat(A,k). More details of the k-mode product can be found in Kolda and Bader (2009).

Value

An array whose k-mode unfolding is M %*% mat(A,k).

Author(s)

Peter Hoff.

References

Kolda, T. G., & Bader, B. W. (2009). Tensor decompositions and applications. SIAM review, 51(3), 455-500.

See Also

atrans for applying multiple k-mode products.

Examples

1
2
3
4
5
A <- array(1:8, dim = c(2,2,2))
M <- matrix(1:4, nrow = 2, ncol = 2)
Y <- amprod(A, M, 2)
Y
identical(M %*% mat(A,2), mat(Y,2))

Example output

, , 1

     [,1] [,2]
[1,]   10   14
[2,]   14   20

, , 2

     [,1] [,2]
[1,]   26   38
[2,]   30   44

[1] TRUE

tensr documentation built on May 2, 2019, 2:32 p.m.