Identity matrix in the TT-format [E]=TT_EYE(N,D) Computes N^D x N^d identity matrix in the TT-format [E]=TT_EYE(N) Computes identity matrix, row/col mode sizes are specified by 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 [e]=tt_eye(n,varargin) 0002 %Identity matrix in the TT-format 0003 % [E]=TT_EYE(N,D) Computes N^D x N^d identity matrix in the TT-format 0004 % 0005 % [E]=TT_EYE(N) Computes identity matrix, row/col mode sizes are 0006 % specified by the vector N 0007 % 0008 % 0009 % TT-Toolbox 2.2, 2009-2012 0010 % 0011 %This is TT Toolbox, written by Ivan Oseledets et al. 0012 %Institute of Numerical Mathematics, Moscow, Russia 0013 %webpage: http://spring.inm.ras.ru/osel 0014 % 0015 %For all questions, bugs and suggestions please mail 0016 %ivan.oseledets@gmail.com 0017 %--------------------------- 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 e=cell(d,1); 0027 for i=1:d 0028 e{i}=eye(n(i)); 0029 end 0030 e=tt_matrix(e); %We did it 0031 return 0032 end