Kronecker product of two TT-matrices in non-standard ordering [TT]=KRON2(TT1,TT2) Computes Kronecker product of two TT-matrices in non-standard ordering: row indices of TT1 and TT2 are "mixed". The ranks are multiplied after this operation. It can be useful for the matrix inversion 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]=kron2(tt1,tt2) 0002 %Kronecker product of two TT-matrices in non-standard ordering 0003 % [TT]=KRON2(TT1,TT2) Computes Kronecker product of two TT-matrices in 0004 % non-standard ordering: row indices of TT1 and TT2 are "mixed". The 0005 % ranks are multiplied after this operation. It can be useful for the 0006 % matrix inversion 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 %Zaglushka! 0020 n1=tt1.n; m1=tt1.m; n2=tt2.n; m2=tt2.m; 0021 t1=tt1.tt; t2=tt2.tt; 0022 cr1=t1.core; cr2=t2.core; r1=t1.r; r2=t2.r; ps1=t1.ps; ps2=t2.ps; 0023 d=t1.d; 0024 r=r1.*r2; 0025 n=n1.*n2; 0026 m=m1.*m2; 0027 sz=dot(n.*r(1:d),r(2:d+1)); 0028 p=n.*m; 0029 pos=cumsum([1;p.*r(1:d).*r(2:d+1)]); 0030 0031 cr=zeros(sz,1); 0032 for i=1:d 0033 core1=cr1(ps1(i):ps1(i+1)-1); 0034 core2=cr2(ps2(i):ps2(i+1)-1); 0035 core1=core1(:); 0036 core2=core2(:); 0037 cr0=core1*core2.'; 0038 cr0=reshape(cr0,[r1(i),n1(i),m1(i),r1(i+1),r2(i),n2(i),m2(i),r2(i+1)]); 0039 cr0=permute(cr0,[1,5,2,6,3,7,4,8]); 0040 cr(pos(i):pos(i+1)-1)=cr0(:); 0041 end 0042 t=tt_tensor; 0043 t.core=cr; 0044 t.ps=pos; 0045 t.r=r; 0046 t.n=p; 0047 t.d=d; 0048 tt=tt_matrix; 0049 tt.tt=t; 0050 tt.n=n; 0051 tt.m=m; 0052 return 0053 end