NORM Norm of a TT/MPS tensor. norm(X) computes the Frobenius norm of the TT/MPS tensor X. norm(X, SAFE) with SAFE=true computes the Frobenius norm of the TT/MPS tensor X with reorthogonalization to increase the accuracy See also INNERPROD
0001 function res = norm( x, safe ) 0002 %NORM Norm of a TT/MPS tensor. 0003 % norm(X) computes the Frobenius norm of the TT/MPS tensor X. 0004 % 0005 % norm(X, SAFE) with SAFE=true computes the Frobenius norm of the TT/MPS tensor X 0006 % with reorthogonalization to increase the accuracy 0007 % 0008 % See also INNERPROD 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('safe','var') 0016 safe = true; 0017 end 0018 0019 if safe 0020 x = orthogonalize(x, x.order ); 0021 res = norm( x.U{end}(:) ); 0022 else 0023 res = sqrt(innerprod( x, x )); 0024 0025 if res < 1e-7 0026 x = orthogonalize(x, x.order ); 0027 res = norm( x.U{end}(:) ); 0028 end 0029 end 0030 0031 end