Home > tt2 > misc > linqtt_to_qtttucker.m

linqtt_to_qtttucker

PURPOSE ^

function [qtu] = linqtt_to_qtttucker(tt, dims, eps)

SYNOPSIS ^

function [qtu] = linqtt_to_qtttucker(tt, dims, eps)

DESCRIPTION ^

 function [qtu] = linqtt_to_qtttucker(tt, dims, eps)
 Computes the qtt_tucker representation from the linear (Q)TT with the
 accuracy eps.
 dims specifies, how many dimensions include in each tucker factor

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [qtu] = linqtt_to_qtttucker(tt, dims, eps)
0002 % function [qtu] = linqtt_to_qtttucker(tt, dims, eps)
0003 % Computes the qtt_tucker representation from the linear (Q)TT with the
0004 % accuracy eps.
0005 % dims specifies, how many dimensions include in each tucker factor
0006 
0007 dphys = numel(dims);
0008 dtt = tt.d;
0009 qtu = qtt_tucker;
0010 qtu.dphys = dphys;
0011 tucks = cell(dphys, 1);
0012 sz = cell(dphys, 1);
0013 qtucore = tt_tensor;
0014 qtucore.d = dphys;
0015 qtucore.n = zeros(dphys, 1);
0016 qtucore.r = [1; zeros(dphys-1,1); 1];
0017 qtucore.ps = ones(dphys+1,1);
0018 qtucore.core = 0;
0019 
0020 [tt,nrm]=qr(tt, 'rl');
0021 tt{1} = nrm*tt{1};
0022 
0023 for i=1:dphys
0024     cf = chunk(tt, 1, dims(i));
0025     if (i<dphys)
0026         tt = chunk(tt, dims(i)+1, dtt);
0027     end;
0028     dtt = dtt-dims(i);
0029     
0030     curn = cf.n;
0031     sz{i} = curn;
0032     rc1 = cf.r(1);
0033     rc2 = cf.r(dims(i)+1);
0034     cf = tt_reshape(cf, [rc1; curn; rc2], eps/sqrt(dphys));
0035     cf = move_tt_block(cf, 1, dims(i)+1, eps/sqrt(dphys));
0036     cf = tt_reshape(cf, [curn; rc1*rc2]);
0037     [cf, nrm]=qr(cf, 'lr');
0038     rtuck = cf.r(dims(i)+1);    
0039     curcr = cf{dims(i)+1};
0040     curcr = curcr*nrm;
0041     % Orthogonal tucker factor is ready
0042     tucks{i} = chunk(cf, 1, dims(i));
0043     % Now prepare the core
0044     if (i<dphys)
0045         curcr = reshape(curcr, rtuck*rc1, rc2);
0046         [curcr, rv]=qr(curcr, 0);
0047         % Orthogonal tucker core is ready
0048         % Convolve the RV to the rest of linear TT
0049         cr_in_tt = tt{1};
0050         n2 = size(cr_in_tt, 2);
0051         rtt2 = size(cr_in_tt, 3);
0052         cr_in_tt = reshape(cr_in_tt, rc2, n2*rtt2);
0053         cr_in_tt = rv*cr_in_tt;
0054         rc2 = size(curcr,2);
0055         tt{1} = reshape(cr_in_tt, rc2, n2, rtt2);
0056     end;
0057     curcr = reshape(curcr, rtuck, rc1, rc2);
0058     qtucore{i} = permute(curcr, [2, 1, 3]);
0059 end;
0060 
0061 qtu.core = qtucore;
0062 qtu.tuck = tucks;
0063 qtu.sz = sz;
0064 
0065 end

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