Scalar product of two TT-tensors in the TT1.0 format [RES]=TT_DOT(TT1,TT2) Scalar product of two TT-tensors in the TT1.0 format. Please avoid its usage, use dot function from the object-oriented version 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 [res] = tt_dot(tt1,tt2) 0002 %Scalar product of two TT-tensors in the TT1.0 format 0003 % [RES]=TT_DOT(TT1,TT2) Scalar product of two TT-tensors in the TT1.0 0004 % format. Please avoid its usage, use dot function from the 0005 % object-oriented version 0006 % 0007 % 0008 % TT-Toolbox 2.2, 2009-2012 0009 % 0010 %This is TT Toolbox, written by Ivan Oseledets et al. 0011 %Institute of Numerical Mathematics, Moscow, Russia 0012 %webpage: http://spring.inm.ras.ru/osel 0013 % 0014 %For all questions, bugs and suggestions please mail 0015 %ivan.oseledets@gmail.com 0016 %--------------------------- 0017 d=size(tt1,1); 0018 g0=(tt1{1})'*(tt2{1}); 0019 gd=(tt1{d})'*(tt2{d}); 0020 r1=size(gd,1); r2=size(gd,2); 0021 gd=reshape(gd,1,r1*r2); 0022 for i=2:d-1 0023 core1=tt1{i}; 0024 core2=tt2{i}; 0025 core1=ten_conv(core1,2,g0); 0026 ncur=size(core1,1); r21=size(core1,2); r31=size(core1,3); 0027 r22=size(core2,2); r32=size(core2,3); 0028 core1=reshape(core1,[ncur*r21,r31]); 0029 core2=reshape(core2,[ncur*r22,r32]); 0030 g0=core1'*core2; 0031 end 0032 r1=size(g0,1); r2=size(g0,2); 0033 g0=reshape(g0,1,r1*r2); 0034 res=g0*gd'; 0035 return 0036 0037 end