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:
• from_array FROM_ARRAY Approximate full array by TTeMPS tensor of prescribed rank
• round ROUND Approximate TTeMPS tensor within a prescribed tolerance.
• splitcore SPLITCORE Merging of two cores of a TT/MPS tensor.
• shift TTeMPS Toolbox.
• amen_eigenvalue AMEN_EIGENVALUE Calculate p smallest eigenvalues of a TTeMPS operator
• block_eigenvalue BLOCK_EIGENVALUE Calculate p smallest eigenvalues of a TTeMPS operator

## 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
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