Home > tt2 > core > tt_tuck.m

tt_tuck

PURPOSE ^

Computes Tucker factors and Tucker core of the TT-tensor

SYNOPSIS ^

function [factors,res]=tt_tuck(tt,eps)

DESCRIPTION ^

Computes Tucker factors and Tucker core of the TT-tensor
   [FACTORS,RES]=TT_TUCK(TT) Compute Tucker factors of the TT tensor 
   FACTORS is the cell array of Tucker factors RES is the TT 
   representation for the core, EPS is the allowed accuracy
 

 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 [factors,res]=tt_tuck(tt,eps)
0002 %Computes Tucker factors and Tucker core of the TT-tensor
0003 %   [FACTORS,RES]=TT_TUCK(TT) Compute Tucker factors of the TT tensor
0004 %   FACTORS is the cell array of Tucker factors RES is the TT
0005 %   representation for the core, EPS is the allowed accuracy
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 tt=core(tt);
0018 d=size(tt,1);
0019 
0020 tt1=tt;
0021 mat=tt1{1};
0022 [q,r]=qr(mat,0);
0023 tt1{1}=q; 
0024 r_left=cell(d,1);
0025 r_left{1}=r;
0026 for i=2:d-1
0027     core1=tt1{i};
0028     core1=ten_conv(core1,2,r');
0029     ncur=size(core1,1);
0030     r2=size(core1,2);
0031     r3=size(core1,3);
0032     core1=reshape(core1,[ncur*r2,r3]);
0033     [tt1{i},r]=qr(core1,0);
0034     r_left{i}=r;
0035     rnew=min(ncur*r2,r3);
0036     tt1{i}=reshape(tt1{i},[ncur,r2,rnew]);
0037 end
0038 %Compute right-to-left qr & maxvol
0039 tt1=tt;
0040 mat=tt1{d};
0041 r_right=cell(d,1);
0042 [q,r]=qr(mat,0);
0043 r_right{d}=r;
0044 tt1{d}=q;
0045 for i=(d-1):-1:2
0046     core1=tt1{i};
0047     core1=ten_conv(core1,3,r');
0048     ncur=size(core1,1);
0049     r2=size(core1,2);
0050     r3=size(core1,3);
0051     core1=permute(core1,[1,3,2]);
0052     core1=reshape(core1,[ncur*r3,r2]);
0053     [tt1{i},r]=qr(core1,0);
0054     r_right{i}=r;
0055     rnew=min(r2,ncur*r3);
0056     tt1{i}=reshape(tt1{i},[ncur,r3,rnew]);
0057     tt1{i}=permute(tt1{i},[1,3,2]);
0058 end
0059 %keyboard;
0060 factors=cell(d,1);
0061 res=cell(d,1);
0062 [factors{1},s,res{1}]=svd(tt{1},'econ');
0063 res{1}=s*res{1}';
0064 [factors{d},s,res{d}]=svd(tt{d},'econ');
0065 res{d}=s*res{d}';
0066 %Compute reduced cores & Tucker factors
0067 for i=2:d-1
0068   core1=tt{i};
0069   core1=ten_conv(core1,2,r_left{i-1}');
0070   core1=ten_conv(core1,3,r_right{i+1}');
0071   ncur=size(core1,1); r2=size(core1,2); r3=size(core1,3);
0072   core1=reshape(core1,[ncur,r2*r3]);
0073   [u,s,v]=svd(core1,'econ');
0074   r=my_chop2(diag(s),eps/sqrt(d-1)*norm(diag(s)));
0075  u=u(:,1:r); 
0076  factors{i}=u;
0077   %Compute cores as convolution
0078   res{i}=ten_conv(tt{i},1,u);
0079   %res{i}=s(1:r,1:r)*v(:,1:r)';
0080   %res{i}=reshape(res{i},r,r2,r3);
0081 end
0082 res=tt_tensor(res);
0083 return
0084 end

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