Diagonal of a matrix or diagonal matrix from a vector in QTT-Tucker [QT]=DIAG(QT) Either makes a diagonal matrix from a vector in QTT_TUCKER, or extracts a diagonal vector from a matrix 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 [qt]=diag(qt) 0002 %Diagonal of a matrix or diagonal matrix from a vector in QTT-Tucker 0003 % [QT]=DIAG(QT) Either makes a diagonal matrix from a vector in 0004 % QTT_TUCKER, or extracts a diagonal vector from a matrix 0005 % 0006 % 0007 % TT-Toolbox 2.2, 2009-2012 0008 % 0009 %This is TT Toolbox, written by Ivan Oseledets et al. 0010 %Institute of Numerical Mathematics, Moscow, Russia 0011 %webpage: http://spring.inm.ras.ru/osel 0012 % 0013 %For all questions, bugs and suggestions please mail 0014 %ivan.oseledets@gmail.com 0015 %--------------------------- 0016 0017 0018 d = qt.dphys; 0019 for i=1:d 0020 qt.tuck{i} = diag(qt.tuck{i}); 0021 end; 0022 0023 end