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

splitcore

PURPOSE ^

SPLITCORE Merging of two cores of a TT/MPS tensor.

SYNOPSIS ^

function res = splitcore( x, idx, nL, nR, tol )

DESCRIPTION ^

SPLITCORE Merging of two cores of a TT/MPS tensor.

   RES = SPLITCORE(X,IDX,NL,NR) splits the core IDX of
   the TT/MPS tensor X into two cores with outer dimensions NL and NR.
   The new outer dimensions NL and NR have to fulfill NL*NR = X.size(idx)

   See also MERGECORE

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function res = splitcore( x, idx, nL, nR, tol )
0002     %SPLITCORE Merging of two cores of a TT/MPS tensor.
0003     %
0004     %   RES = SPLITCORE(X,IDX,NL,NR) splits the core IDX of
0005     %   the TT/MPS tensor X into two cores with outer dimensions NL and NR.
0006     %   The new outer dimensions NL and NR have to fulfill NL*NR = X.size(idx)
0007     %
0008     %   See also MERGECORE
0009 
0010     %   TTeMPS Toolbox.
0011     %   Michael Steinlechner, 2013-2016
0012     %   Questions and contact: michael.steinlechner@epfl.ch
0013     %   BSD 2-clause license, see LICENSE.txt
0014     
0015     if ~exist('tol', 'var')
0016         tol = 1e-8;
0017     end
0018 
0019     if ~isscalar(idx)
0020          error('Index IDX must be a scalar.')
0021     end 
0022     
0023     n = x.size;
0024     r = x.rank;
0025     
0026     if nL*nR ~= n(idx)
0027         error('New sizes must be compatible with old tensor: NL*NR = X.size(idx)')
0028     end
0029     
0030     %x = orthogonalize(x, idx);
0031     [U,S,V] = svd( reshape(x.U{idx}, [r(idx)*nL, nR*r(idx+1)]), 'econ');
0032     s = trunc_singular( diag(S), tol, true );
0033     U = U(:,1:s);
0034     V = V(:,1:s);
0035     S = S(1:s,1:s);
0036     newcoreR = reshape( S*V', [s, nR, r(idx+1)] );
0037     newcoreL = reshape( U, [r(idx), nL, s] );
0038     
0039     C = x.U;
0040     res = TTeMPS( {C{1:idx-1}, newcoreL, newcoreR, C{idx+1:end} } );
0041 end
0042

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