%TENSORPROD Tensor products between two tensors.
%   C = TENSORPROD(A,B,DIMA,DIMB) computes the tensor product between
%   tensors A and B. DIMA defines the dimensions to contract in A and DIMB
%   defines the dimensions to contract in B. DIMA and DIMB must have the
%   same length and are matched pairwise. The sizes of the contracted
%   dimensions must match, so size(A,DIMA) must equal size(B,DIMB). The
%   size of the output is the size of the uncontracted dimensions of A
%   followed by the uncontracted dimensions of B.
%
%   C = TENSORPROD(A,B,DIM) computes the tensor product between tensors A
%   and B. DIM defines the dimensions to contract in both A and B. The
%   sizes of the contracted dimensions must match, so size(A,DIM) must
%   equal size(B,DIM). The size of the output is the size of the
%   uncontracted dimensions of A followed by the uncontracted dimensions of
%   B.
%
%   C = TENSORPROD(A,B) computes the outer product between tensors A and B.
%   This is equivalent to using the above syntaxes with DIM = [] or DIMA =
%   DIMB = []. The size of the output is [size(A) size(B)].
%
%   C = TENSORPROD(A,B,"all") computes the inner product between tensors A
%   and B. Since all the dimensions are contracted for the inner product,
%   size(A) must equal size(B). The output is a scalar.
%
%   C = TENSORPROD(A,B,...,NumDimensionsA=ndimsA) specifies the number of
%   dimensions in tensor A. Use this option when A has trailing singleton
%   dimensions that are expected to be passed on to the output.
%
%   EXAMPLE: Inner product
%   A = rand(3,4,5);
%   B = rand(3,4,5);
%   C = tensorprod(A,B,"all")
%
%   EXAMPLE: Product along specified dimensions
%   A = rand(3,4,5);
%   B = rand(4,3,2);
%   C = tensorprod(A,B,[2 1],[1 2]);
%   size(C)
%
%   EXAMPLE: Using "NumDimensionsA"
%   A = rand(3,4);
%   B = rand(3,4,5);
%   C1 = tensorprod(A,B,1);
%   size(C1)
%   % Use "NumDimensionsA" to include a trailing singleton dimension of A
%   C2 = tensorprod(A,B,1,NumDimensionsA=3);
%   size(C2)
%
%   See also mtimes, pagemtimes.

%   Copyright 2021-2022 The MathWorks, Inc.
