Home > tt2 > core > tt_mvdot.m

tt_mvdot

PURPOSE ^

Fast computation of the bilinear form (Ax,y) in the TT-format

SYNOPSIS ^

function [res] = tt_mvdot(a_tt,x_tt,y_tt)

DESCRIPTION ^

Fast computation of the bilinear form (Ax,y) in the TT-format
   [RES]=TT_MVDOT(A_TT,X_TT,Y_TT) Computes scalar product(AX,Y), where 
   A_TT is a matrix, X_TT is a vector, Y_TT  is a vector


 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
---------------------------

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [res] = tt_mvdot(a_tt,x_tt,y_tt)
0002 %Fast computation of the bilinear form (Ax,y) in the TT-format
0003 %   [RES]=TT_MVDOT(A_TT,X_TT,Y_TT) Computes scalar product(AX,Y), where
0004 %   A_TT is a matrix, X_TT is a vector, Y_TT  is a vector
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 d=size(a_tt,1);
0017 %The c
0018 core=a_tt{1}; matx=x_tt{1}; maty=y_tt{1};
0019 n1=size(core,1); n2=size(core,2);
0020 rc=size(core,3);
0021 rx=size(matx,2); ry=size(maty,2);
0022 core=maty'*reshape(core,[n1,n2*rc]); %core is ryxn2xrc
0023 core=reshape(permute(reshape(core,[ry,n2,rc]),[3,1,2]),[rc*ry,n2]);
0024 phi=permute(reshape(core*matx,[rc,ry,rx]),[1,3,2]); %core is rcxryxrx-> rcxrx*ry
0025 
0026 for i=2:d-1
0027   core=a_tt{i}; core_x = x_tt{i}; core_y=y_tt{i};
0028   %Decipher sizes
0029  n1=size(core,1); n2=size(core,2); rc1=size(core,3); rc2=size(core,4);
0030  rx1=size(core_x,2); rx2=size(core_x,3); ry1=size(core_y,2); ry2=size(core_y,3);
0031  %Convolve phi & core over the first index
0032  %core is n1xn2xrc1xrc2 phi is rc1x rx1 x ry1
0033   core=reshape(permute(core,[3,1,2,4,5]),[rc1,n1*n2*rc2]);
0034   phi=reshape(phi,[rc1,rx1*ry1])'*core; %Is rx1 x ry1 x n1 x n2 x rc2
0035   %Convolve over n2 & rx1
0036   phi=permute(reshape(phi,[rx1,ry1,n1,n2,rc2]),[4,1,2,3,5]); 
0037   %n2 x rx1 x ry1 x n1 x rc2;
0038   phi=reshape(core_x,[n2*rx1,rx2])'*reshape(phi,[n2*rx1,ry1*n1*rc2]);
0039   %phi is now rx2 x ry1 x n1 x rc2
0040   %Convolve over n1 & ry1
0041   phi=reshape(phi,[rx2,ry1*n1,rc2]); phi=permute(phi,[3,1,2]);
0042   %keyboard;
0043   phi=reshape(phi,[rc2*rx2,ry1*n1])*reshape(permute(core_y,[2,1,3]),[ry1*n1,ry2]);
0044   phi=reshape(phi,[rc2,rx2,ry2]);
0045 end
0046   core=a_tt{d}; mat_x=x_tt{d}; mat_y=y_tt{d};
0047   n1=size(core,1); n2=size(core,2); rc=size(core,3);
0048   rx=size(mat_x,2); ry=size(mat_y,2);
0049   %Convolve phi & core over aux index
0050   %core is n1 x n2 x rc
0051   phi=reshape(core,[n1*n2,rc])*reshape(phi,[rc,rx*ry]);
0052   %phi is n1 x n2 x rx x ry
0053   %Convolve over n2 & rx
0054   phi=permute(reshape(phi,[n1,n2*rx,ry]),[1,3,2]);
0055   phi=reshape(phi,[n1*ry,n2*rx])*reshape(mat_x,[n2*rx,1]);
0056   %phi is a column of length
0057   res= phi'*reshape(mat_y,[n1*ry,1]);
0058 
0059 return
0060 
0061 end

Generated on Wed 08-Feb-2012 18:20:24 by m2html © 2005