Home > tt2 > exp > tt_smv.m

tt_smv

PURPOSE ^

function [res]=tt_smv(sttm, vec)

SYNOPSIS ^

function [res]=tt_smv(sttm, vec)

DESCRIPTION ^

 function [res]=tt_smv(sttm, vec)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % function [res]=tt_smv(sttm, vec)
0002 
0003 function [res]=tt_smv(sttm, vec)
0004 %TT-matrix with sparse factors by TT-vector multiplication
0005 %   [res]=TT_SMV(STTM,VEC) Multiplies the TT-matrix stored in the TT1.0
0006 %   format but with "sparse" cores by a vector VEC
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 d=size(vec,1);
0021 res=cell(d,1);
0022 
0023 n=sttm{d+2}(1);
0024 % m=size(vec{1},1);
0025 rm1=sttm{d+1}(1);
0026 rv1=size(vec{1},2);
0027 %mat{1} is (n x m x rm1 , vec{1} is mxrv1)
0028 %            n x rm1 x rv1
0029 res{1}=sttm{1}*vec{1};
0030 res{1}=reshape(permute(reshape(res{1},[n,rm1,rv1]),[1,3,2]),[n,rv1*rm1]);
0031 
0032 n=sttm{d+2}(d);
0033 % m=size(mat{d},2);
0034 rm1=sttm{d+1}(d-1);
0035 rv1=size(vec{d},2);
0036 %mat{1} is (n x rm1 x rv1 , vec{1} is mxrv1)
0037 res{d}=sttm{d}*vec{d};
0038 res{d}=reshape(permute(reshape(res{d},[n,rm1,rv1]),[1,3,2]),[n,rv1*rm1]);
0039 for i=2:d-1
0040     n=sttm{d+2}(i);
0041     m=size(vec{i},1);
0042     rm1=sttm{d+1}(i-1);
0043     rm2=sttm{d+1}(i);
0044     rv1=size(vec{i},2);
0045     rv2=size(vec{i},3);
0046     %mat{i} is n x m x rm1 x rm2, vec{i} is m x rv1 x rv2
0047     %n x (rv1*rv2)*rm1*rm2
0048     %n x rm2 x rm1 x m, n x rm2 x rm1 x (rv1*rv2)
0049     %n x rm2 x rmx1 x rv1 x rv2
0050     %want: n x rv1*rm1 x rv2*rm2
0051     res{i}=sttm{i}*reshape(vec{i},[m,rv1*rv2]);
0052     res{i}=reshape(res{i},[n,rm2,rm1,rv1,rv2]);
0053     res{i}=permute(res{i},[1,4,3,5,2]);
0054     res{i}=reshape(res{i},[n,rv1*rm1,rv2*rm2]);
0055     %res{i}=permute(reshape(permute(mat{i},[1,3,4,2])*reshape(vec{i},[m,rv1*rv2]),[n,rv1,rv2,rm1,rm2]),[1,2,4,3,5]);
0056 end 
0057 
0058 end

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