tensorprod: Tensor products of k-tensors

tensorprodR Documentation

Tensor products of k-tensors

Description

\loadmathjax

Tensor products of k-tensors

Usage

tensorprod(U, ...)
tensorprod2(U1,U2)

Arguments

U,U1,U2

Object of class ktensor

...

Further arguments, currently ignored

Details

Given a \mjseqnk-tensor \mjseqnS and an \mjseqnl-tensor \mjseqnT, we can form the tensor product \mjeqnS\otimes TS %X% T, defined as

\mjdeqn

S\otimes T\left(v_1,...,v_k,v_k+1,..., v_k+l\right)= S\left(v_1,... v_k\right)\cdot T\left(v_k+1,... v_k+l\right).omitted; see latex

Package idiom for this includes tensorprod(S,T) and S %X% T; note that the tensor product is not commutative. Function tensorprod() can take any number of arguments (the result is well-defined because the tensor product is associative); it uses tensorprod2() as a low-level helper function.

Value

The functions documented here all return a spray object.

Note

The binary form %X% uses uppercase X to avoid clashing with %x% which is the Kronecker product in base R.

Author(s)

Robin K. S. Hankin

References

Spivak 1961

See Also

ktensor

Examples


(A <- ktensor(spray(matrix(c(1,1,2,2,3,3),2,3,byrow=TRUE),1:2)))
(B <- ktensor(spray(10+matrix(4:9,3,2),5:7)))
tensorprod(A,B)

A %X% B - B %X% A


Va <- matrix(rnorm(9),3,3)
Vb <- matrix(rnorm(38),19,2)

LHS <- as.function(A %X% B)(cbind(rbind(Va,matrix(0,19-3,3)),Vb))
RHS <-  as.function(A)(Va) * as.function(B)(Vb)

c(LHS=LHS,RHS=RHS,diff=LHS-RHS)




stokes documentation built on Aug. 19, 2023, 1:07 a.m.