FLATTEN - mode-k unfolding of a tensor Syntax function Z=flatten(X,k) See also FLATTEN_ADJ 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 - mode-k unfolding of a tensor 0002 % 0003 % Syntax 0004 % function Z=flatten(X,k) 0005 % 0006 % See also 0007 % FLATTEN_ADJ 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 Z=flatten(X,jj) 0020 0021 nd=ndims(X); 0022 0023 if jj~=1 0024 X=permute(X,[jj:nd, 1:jj-1]); 0025 end 0026 0027 Z=X(:,:);