Tensor of all ones [TT]=TT_ONES(N,D), computes the d-dimensional TT-tensor of all ones with mode size equal to N [TT]=TT_ONES(N), computes the TT-tensor of all ones with mode size given in the vector N TT-Toolbox 2.2, 2009-2012 This is TT Toolbox, written by Ivan Oseledets et al. Institute of Numerical Mathematics, Moscow, Russia webpage: http://spring.inm.ras.ru/osel For all questions, bugs and suggestions please mail ivan.oseledets@gmail.com ---------------------------
0001 function [tt] = tt_ones(n,varargin) 0002 %Tensor of all ones 0003 % [TT]=TT_ONES(N,D), computes the d-dimensional TT-tensor of all ones 0004 % with mode size equal to N 0005 % 0006 % [TT]=TT_ONES(N), computes the TT-tensor of all ones with mode size 0007 % given in the vector N 0008 % 0009 % 0010 % TT-Toolbox 2.2, 2009-2012 0011 % 0012 %This is TT Toolbox, written by Ivan Oseledets et al. 0013 %Institute of Numerical Mathematics, Moscow, Russia 0014 %webpage: http://spring.inm.ras.ru/osel 0015 % 0016 %For all questions, bugs and suggestions please mail 0017 %ivan.oseledets@gmail.com 0018 %--------------------------- 0019 0020 if (numel(n) == 1) 0021 d=varargin{1}; 0022 n=n*ones(1,d); 0023 else 0024 d=numel(n); 0025 end 0026 0027 tt=cell(d,1); 0028 for k=1:d 0029 tt{k} = ones(n(k),1); %sqrt(n); 0030 end 0031 tt=tt_tensor(tt); %Bydlocode @ 0032 return 0033 end