C = tensorprod(A, B)
C = tensorprod(A, B, dimA, dimB)
C = tensorprod(A, B, 'all')
C = tensorprod(___, 'NumDimensionsA', value)
| Parameter | Description |
|---|---|
| A, B | numeric arrays. |
| dimA, dimB | vectors listing the dimensions of A and B to contract. size(A, dimA(k)) must equal size(B, dimB(k)). |
| value | number of dimensions of A, used to account for trailing singleton dimensions. |
| Parameter | Description |
|---|---|
| C | tensor product. Its dimensions are the uncontracted dimensions of A followed by the uncontracted dimensions of B. |
tensorprod(A, B) returns the outer product of A and B, an array of size [size(A) size(B)].
tensorprod(A, B, dimA, dimB) contracts (sums the products over) the dimensions dimA of A with the dimensions dimB of B. For matrices, tensorprod(A, B, 2, 1) is the matrix product A*B.
tensorprod(A, B, 'all') contracts every dimension and returns the full inner product; A and B must have the same size.
'NumDimensionsA' specifies how many dimensions A has so that trailing singleton dimensions can be contracted.
A = [1 2; 3 4];
B = [5 6; 7 8];
C = tensorprod(A, B, 2, 1)
| Version | Description |
|---|---|
| 2.0.0 | initial version |