Home > manopt > manifolds > ttfixedrank > TTeMPS_1.1 > tensorprod.m

tensorprod

PURPOSE ^

TENSORPROD Tensor-times-Matrix product.

SYNOPSIS ^

function res = tensorprod( U, A, mode, apply_inv )

DESCRIPTION ^

TENSORPROD Tensor-times-Matrix product. 
   A = TENSORPROD(U, A, MODE) performs the mode-MODE product between the
   tensor U and matrix A. Higher dimensions than 3 are not supported.

   A = TENSORPROD(U, A, MODE, TRUE) multiplies with A^{-1} instead of A.

   See also MATRICIZE, TENSORIZE, UNFOLD.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function res = tensorprod( U, A, mode, apply_inv )
0002     %TENSORPROD Tensor-times-Matrix product.
0003     %   A = TENSORPROD(U, A, MODE) performs the mode-MODE product between the
0004     %   tensor U and matrix A. Higher dimensions than 3 are not supported.
0005     %
0006     %   A = TENSORPROD(U, A, MODE, TRUE) multiplies with A^{-1} instead of A.
0007     %
0008     %   See also MATRICIZE, TENSORIZE, UNFOLD.
0009     
0010     %   TTeMPS Toolbox.
0011     %   Michael Steinlechner, 2013-2016
0012     %   Questions and contact: michael.steinlechner@epfl.ch
0013     %   BSD 2-clause license, see LICENSE.txt
0014 
0015     if nargin==3
0016         apply_inv = false;
0017     end
0018     
0019     d = size(U);
0020     % pad with 1 for the last dim (annoying)
0021     if length(d) == 2
0022         d = [d, 1];
0023     end
0024     d(mode) = size(A,1);
0025     
0026     if apply_inv
0027         res = A \ matricize( U, mode );
0028         res = tensorize( res, mode, d );
0029     else
0030         res = A * matricize( U, mode );
0031         res = tensorize( res, mode, d );
0032     end
0033 
0034 end

Generated on Sun 05-Sep-2021 17:57:00 by m2html © 2005