Home > manopt > manifolds > ttfixedrank > TTeMPS_1.1 > trunc_singular.m

trunc_singular

PURPOSE ^

REL_TRUNC_SINGULAR Helper routine to truncate singular values

SYNOPSIS ^

function s = trunc_singular(s, tol, relative, maxrank)

DESCRIPTION ^

 REL_TRUNC_SINGULAR Helper routine to truncate singular values

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function s = trunc_singular(s, tol, relative, maxrank)
0002 % REL_TRUNC_SINGULAR Helper routine to truncate singular values
0003 
0004 %   TTeMPS Toolbox.
0005 %   Michael Steinlechner, 2013-2016
0006 %   Questions and contact: michael.steinlechner@epfl.ch
0007 %   BSD 2-clause license, see LICENSE.txt
0008 
0009     if ~exist('relative','var'),    relative = true;     end
0010     if ~exist('maxrank','var'), maxrank = length(s); end
0011 
0012     summ = cumsum(s.^2,'reverse');
0013 
0014     if relative
0015         s = find(summ > tol^2, 1, 'last');
0016         if isempty(s), s = 1; end
0017     else
0018         s = find(summ > tol^2*summ(1), 1, 'last');
0019         if isempty(s), s = 1; end
0020     end
0021 
0022     s = min([s, maxrank, length(s)]);
0023 
0024 end
0025

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