Converts a 3d Tucker form tensor to a multiarray. function Xtensor = tucker2multiarray(X) X has fields U1, U2, U3, and G. The matrices U1 (n1-by-r1), U2 (n2-by-r2) and U3 (n3-by-r3) are orthogonal matrices. G (r1-by-r2-by-r3) is a multidimensional array. See also: fixedrankfactory_tucker_preconditioned
0001 function Xtensor = tucker2multiarray(X) 0002 % Converts a 3d Tucker form tensor to a multiarray. 0003 % 0004 % function Xtensor = tucker2multiarray(X) 0005 % 0006 % X has fields U1, U2, U3, and G. 0007 % 0008 % The matrices U1 (n1-by-r1), U2 (n2-by-r2) and U3 (n3-by-r3) are 0009 % orthogonal matrices. 0010 % G (r1-by-r2-by-r3) is a multidimensional array. 0011 % 0012 % See also: fixedrankfactory_tucker_preconditioned 0013 0014 % This file is part of Manopt: www.manopt.org. 0015 % Original authors: Hiroyuki Kasai and Bamdev Mishra, June 05, 2015. 0016 % Contributors: 0017 % Change log: 0018 0019 U1 = X.U1; 0020 U2 = X.U2; 0021 U3 = X.U3; 0022 G = X.G; 0023 0024 % Tensor size 0025 n1 = size(U1, 1); 0026 n2 = size(U2, 1); 0027 n3 = size(U3, 1); 0028 0029 % Core size 0030 [r1, r2, r3] = size(G); 0031 0032 % Multplication by U1 0033 G1 = reshape(G, r1, r2*r3); 0034 GU1 = reshape(U1*G1, n1, r2, r3); 0035 0036 % Further multplication by U2 0037 G2 = reshape(permute(GU1, [2 1 3]), r2, n1*r3); 0038 GU1U2 = permute(reshape(U2*G2, n2, n1, r3), [2 1 3]); 0039 0040 % Further multplication by U3 0041 G3 = reshape(permute(GU1U2, [3 1 2]), r3, n1*n2); 0042 GU1U2U3 = permute(reshape(U3*G3, n3, n1, n2), [2 3 1]); 0043 0044 Xtensor = GU1U2U3;% Full tensor 0045 0046 end