Home > manopt > manifolds > ttfixedrank > TTeMPS_1.1 > @TTeMPS > truncate.m

truncate

PURPOSE ^

TRUNCATE Truncate TTeMPS tensor to prescribed rank.

SYNOPSIS ^

function x = truncate( x, r )

DESCRIPTION ^

TRUNCATE Truncate TTeMPS tensor to prescribed rank.
   X = TRUNCATE( X, R ) truncates the given TTeMPS tensor X to rank R. 
 The result is a right orthogonal TTeMPS.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function x = truncate( x, r )
0002     %TRUNCATE Truncate TTeMPS tensor to prescribed rank.
0003     %   X = TRUNCATE( X, R ) truncates the given TTeMPS tensor X to rank R.
0004     % The result is a right orthogonal TTeMPS.
0005 
0006     %   TTeMPS Toolbox.
0007     %   Michael Steinlechner, 2013-2016
0008     %   Questions and contact: michael.steinlechner@epfl.ch
0009     %   BSD 2-clause license, see LICENSE.txt
0010     
0011 
0012     % Left-right procedure
0013     x = x.orthogonalize( x.order );
0014 
0015     for i = x.order:-1:2
0016         [U,S,V] = svd( unfold( x.U{i}, 'right'), 'econ');
0017         s = min( r(i), length(S));
0018         U = U(:,1:s);
0019         V = V(:,1:s);
0020         S = S(1:s,1:s);
0021         x.U{i} = reshape( V', [s, x.size(i), x.rank(i+1)] );
0022         x.U{i-1} = tensorprod_ttemps( x.U{i-1}, (U*S)', 3 );
0023     end
0024 
0025 end

Generated on Fri 30-Sep-2022 13:18:25 by m2html © 2005