Home > tt2 > core > tt_mv.m

tt_mv

PURPOSE ^

Matrix-by-vector product in the TT1.0 format

SYNOPSIS ^

function [res]=tt_mv(mat,vec)

DESCRIPTION ^

Matrix-by-vector product in the TT1.0 format
   [RES]=TT_MV(MAT,VEC) matrix MAT by vector VEC product in TT1.0 format
   Please avoid its usage: it will be removed in
   future releases. Use * operator 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
---------------------------
ZAGLUSHKA TMP
res=tt_mvk2(mat,vec,1e-4);

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [res]=tt_mv(mat,vec)
0002 %Matrix-by-vector product in the TT1.0 format
0003 %   [RES]=TT_MV(MAT,VEC) matrix MAT by vector VEC product in TT1.0 format
0004 %   Please avoid its usage: it will be removed in
0005 %   future releases. Use * operator from the 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 %ZAGLUSHKA TMP
0018 %res=tt_mvk2(mat,vec,1e-4);
0019 d=size(mat,1);
0020 res=cell(d,1);
0021 n=size(mat{1},1);
0022 m=size(mat{1},2);
0023 rm1=size(mat{1},3);
0024 rv1=size(vec{1},2);
0025 %mat{1} is (n x m x rm1 , vec{1} is mxrv1)
0026 %            n x rm1 x rv1
0027 res{1}=reshape(permute(mat{1},[1,3,2]),[n*rm1,m])*vec{1};
0028 res{1}=reshape(permute(reshape(res{1},[n,rm1,rv1]),[1,3,2]),[n,rv1*rm1]);
0029 n=size(mat{d},1);
0030 m=size(mat{d},2);
0031 rm1=size(mat{d},3);
0032 rv1=size(vec{d},2);
0033 %mat{1} is (n x rm1 x rv1 , vec{1} is mxrv1)
0034 res{d}=reshape(permute(mat{d},[1,3,2]),[n*rm1,m])*vec{d};
0035 res{d}=reshape(permute(reshape(res{d},[n,rm1,rv1]),[1,3,2]),[n,rv1*rm1]);
0036 for i=2:d-1
0037     n=size(mat{i},1);
0038     m=size(mat{i},2);
0039     rm1=size(mat{i},3);
0040     rm2=size(mat{i},4);
0041     rv1=size(vec{i},2);
0042     rv2=size(vec{i},3);
0043     %mat{i} is n x m x rm1 x rm2, vec{i} is m x rv1 x rv2
0044     %n x (rv1*rv2)*rm1*rm2
0045     %n x rm2 x rm1 x m, n x rm2 x rm1 x (rv1*rv2)
0046     %n x rm2 x rmx1 x rv1 x rv2
0047     %want: n x rv1*rm1 x rv2*rm2
0048     res{i}=reshape(permute(mat{i},[1,4,3,2]),[n*rm2*rm1,m])*reshape(vec{i},[m,rv1*rv2]);
0049     res{i}=reshape(res{i},[n,rm2,rm1,rv1,rv2]);
0050     res{i}=permute(res{i},[1,4,3,5,2]);
0051     res{i}=reshape(res{i},[n,rv1*rm1,rv2*rm2]);
0052     %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]);
0053 end 
0054 return
0055 end

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