FLATTEN_ADJ - mode-k folding of a matrix X into a tensor Syntax function X=flatten_adj(X,sz,k) See also FLATTEN Reference "On the extension of trace norm to tensors" Ryota Tomioka, Kohei Hayashi, and Hisashi Kashima arXiv:1010.0789 http://arxiv.org/abs/1010.0789 Copyright(c) 2010 Ryota Tomioka This software is distributed under the MIT license. See license.txt
0001 % FLATTEN_ADJ - mode-k folding of a matrix X into a tensor 0002 % 0003 % Syntax 0004 % function X=flatten_adj(X,sz,k) 0005 % 0006 % See also 0007 % FLATTEN 0008 % 0009 % Reference 0010 % "On the extension of trace norm to tensors" 0011 % Ryota Tomioka, Kohei Hayashi, and Hisashi Kashima 0012 % arXiv:1010.0789 0013 % http://arxiv.org/abs/1010.0789 0014 % 0015 % Copyright(c) 2010 Ryota Tomioka 0016 % This software is distributed under the MIT license. See license.txt 0017 0018 0019 function X=flatten_adj(X,sz,jj) 0020 nd=length(sz); 0021 sz=sz([jj:nd, 1:jj-1]); 0022 X=reshape(X,sz); 0023 if jj~=1 0024 X=permute(X,[nd-jj+2:nd 1:nd-jj+1]); 0025 end