Home > tt2 > core > tt_mat_full_vec.m

tt_mat_full_vec

PURPOSE ^

Multiplication of the TT-matrix by full vector in TT1.0 format

SYNOPSIS ^

function [y]=tt_mat_full_vec(tt,x)

DESCRIPTION ^

Multiplication of the TT-matrix by full vector in TT1.0 format
   [Y]=TT_MAT_FULL_VEC(TT,X) Multiplies full TT-matrix TT  by full 
   vector X. Please avoid the usage: use "*" operator from the
   object-oriented TT2 format. Will be removed in future releases.


 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 [y]=tt_mat_full_vec(tt,x)
0002 %Multiplication of the TT-matrix by full vector in TT1.0 format
0003 %   [Y]=TT_MAT_FULL_VEC(TT,X) Multiplies full TT-matrix TT  by full
0004 %   vector X. Please avoid the usage: use "*" operator from the
0005 %   object-oriented TT2 format. Will be removed in future releases.
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(tt,1);
0018 n=size(x,1);
0019 sz=zeros(1,d);
0020 for i=1:d
0021     sz(i)=size(tt{i},1);
0022 end
0023 x=reshape(x,sz); 
0024 %Convolve x over  mode-1 with tt{1}
0025 n1=sz(1);
0026 n2=n/n1;
0027 core=tt{1};
0028 ns1=size(core,1);
0029 ns2=size(core,2);
0030 r1=size(core,3);
0031 core=permute(core,[1,3,2]); %core is i_1 \alpha_1 j_1
0032 core=reshape(core,[ns1*r1,ns2]);
0033 x=(core)*reshape(x,[n1,n2]); %x is i_1 \alpha_1,j_2,...,j_d
0034 x=reshape(x, [n1, n2*r1]);
0035 x=x.'; % x is \alpha_1,j_2, ...., j_d, i_1
0036 msize=(n2*n1)/sz(2);
0037 %msize=n2/sz(2);
0038 %keyboard;
0039 for k=2:d-1
0040     % x is alpha_{k-1},j_k,...,j_d,i_1,...,i_{k-1} convolve over alpha_{j-1} j_k
0041     core=tt{k}; %core is i_k j_k \alpha_{k-1} \alpha_k
0042     is=size(core,1); js=size(core,2); r1=size(core,3); r2=size(core,4);
0043     core=permute(core,[3,2,1,4]); %core is \alpha_{k-1} j_k i_k \alpha_k
0044     core=reshape(core,[js*r1,is*r2]);
0045     x=reshape(x,[js*r1,msize]); 
0046     %keyboard;
0047     x=core.'*x; %x is i_k \alpha_k j_{k+1} ... j_d i_1,i_2,...,i_{k-1}
0048     x=reshape(x,[is,msize*r2]);
0049     x=x.';
0050     msize=(is*msize)/js;
0051     %keyboard;
0052     %msize=
0053 end
0054 %x is \alpha_{d-1} j_d i_1 .... i_{d-1}
0055 core=tt{d}; ns1=size(core,1); ns2=size(core,2); r=size(core,3);
0056 core=permute(core,[3,2,1]); %core is \alpha_{d-1} j_d i_d
0057 core=reshape(core,[ns2*r,ns1]); 
0058 x=reshape(x,[r*ns2,msize]);
0059 x=core.'*x; %x is i_d i_1 ... i_{d-1}
0060 x=reshape(x,[ns1,msize]);
0061 x=x.';
0062 y=reshape(x,[n,1]);
0063 
0064 return
0065 end

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