tensor
(Package: tensor) :
Tensor product of arrays
The tensor product of two arrays is notionally an outer product of the arrays collapsed in specific extents by summing along the appropriate diagonals. For example, a matrix product is the tensor product along the second extent of the first matrix and the first extent of the second. Thus A %*% B could also be evaluated as tensor(A, B, 2, 1), likewise A %*% t(B) could be tensor(A, B, 2, 2).