diff options
author | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2024-11-20 17:47:16 -0500 |
---|---|---|
committer | Eugeniy E. Mikhailov <evgmik@gmail.com> | 2024-11-20 17:47:16 -0500 |
commit | fa3ed5eaf67bd54e8f1fa4a1bc2c7ffbd1898d6f (patch) | |
tree | 1d311297c6738f8026e8199f26ae8cd02d5b6de1 | |
parent | db7ee776d2a10f50752c23f57b11184cb3347a15 (diff) | |
download | matlab_strawberryfields-fa3ed5eaf67bd54e8f1fa4a1bc2c7ffbd1898d6f.tar.gz matlab_strawberryfields-fa3ed5eaf67bd54e8f1fa4a1bc2c7ffbd1898d6f.zip |
remove rounding of significant figures from takagi and bloch_messiah code
-rw-r--r-- | bloch_messiah.m | 10 | ||||
-rw-r--r-- | takagi.m | 8 |
2 files changed, 5 insertions, 13 deletions
diff --git a/bloch_messiah.m b/bloch_messiah.m index 6724a26..4050102 100644 --- a/bloch_messiah.m +++ b/bloch_messiah.m @@ -1,10 +1,9 @@ -function [ut1, st1, v1] = bloch_messiah(S, tol, rounding) +function [ut1, st1, v1] = bloch_messiah(S, tol) % Bloch-Messiah decomposition of a symplectic matrix. % % Args: % S (matrix): symplectic matrix % tol (double): tolerance for symplectic check (default: 1e-10) - % rounding (int): decimal places for rounding singular values (default: 9) % % Returns: % ut1, st1, v1 (matrices): Decomposition matrices such that S = ut1 * st1 * v1 @@ -12,9 +11,6 @@ function [ut1, st1, v1] = bloch_messiah(S, tol, rounding) if nargin < 2 tol = 1e-10; end - if nargin < 3 - rounding = 9; - end [n, m] = size(S); @@ -35,7 +31,7 @@ function [ut1, st1, v1] = bloch_messiah(S, tol, rounding) if norm(S' * S - eye(2*n)) >= tol [u, sigma] = polardecomp(S, 'left'); - [ss, uss] = takagi(sigma, tol, rounding); + [ss, uss] = takagi(sigma, tol); % Apply permutation matrix perm = [1:n, 2*n:-1:n+1]; @@ -49,7 +45,7 @@ function [ut1, st1, v1] = bloch_messiah(S, tol, rounding) st = pmat * diag(ss) * pmat; % Identify degenerate subspaces - st_diag = round(diag(st), rounding); + st_diag = diag(st); [~, ~, ic] = unique(st_diag(1:n)); stop_is = cumsum(accumarray(ic, 1)); start_is = [0; stop_is(1:end-1)] + 1; @@ -1,10 +1,9 @@ -function [rl, U] = takagi(N, tol, rounding) +function [rl, U] = takagi(N, tol) % Autonne-Takagi decomposition of a complex symmetric (not Hermitian!) matrix. % % Args: % N (complex matrix): square, symmetric matrix N % tol (double): tolerance for symmetry check (default: 1e-13) - % rounding (integer): decimal places for rounding singular values (default: 13) % % Returns: % rl (vector): rounded singular values @@ -13,9 +12,6 @@ function [rl, U] = takagi(N, tol, rounding) if nargin < 2 tol = 1e-13; end - if nargin < 3 - rounding = 13; - end [n, m] = size(N); @@ -55,7 +51,7 @@ function [rl, U] = takagi(N, tol, rounding) [v, l, ws] = svd(N); w = ws'; - rl = round(diag(l), rounding); + rl = diag(l); % Group degenerate singular values [~, ~, ic] = unique(rl); |