Skip to content

Commit

Permalink
added pylint: disable=too-many-return-statements.
Browse files Browse the repository at this point in the history
fixed the ordering of the matrix in takagi with diagonal matrix
  • Loading branch information
RyosukeNORO committed Jul 5, 2024
1 parent 7f1a795 commit cf82481
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
8 changes: 5 additions & 3 deletions thewalrus/decompositions.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ def blochmessiah(S):


def takagi(A, svd_order=True):
# pylint: disable=too-many-return-statements
r"""Autonne-Takagi decomposition of a complex symmetric (not Hermitian!) matrix.
Note that the input matrix is internally symmetrized by taking its upper triangular part.
If the input matrix is indeed symmetric this leaves it unchanged.
Expand Down Expand Up @@ -207,10 +208,11 @@ def takagi(A, svd_order=True):
d = np.diag(A)
U = np.diag(np.exp(1j * 0.5 * np.angle(d)))
l = np.abs(d)
l = np.sort(l)
U = U[np.argsort(l)]
idx = np.argsort(l)
l = l[idx]
U = U[idx]
if svd_order:
return l[::-1], U[:, ::-1]
return l[::-1], U[::-1, :]
return l, U

u, d, v = np.linalg.svd(A)
Expand Down
8 changes: 1 addition & 7 deletions thewalrus/tests/test_decompositions.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,7 @@

from thewalrus.random import random_interferometer as haar_measure
from thewalrus.random import random_symplectic
from thewalrus.decompositions import (
williamson,
blochmessiah,
takagi,
pre_iwasawa,
iwasawa,
)
from thewalrus.decompositions import williamson, blochmessiah, takagi, pre_iwasawa, iwasawa
from thewalrus.symplectic import sympmat as omega
from thewalrus.quantum.gaussian_checks import is_symplectic

Expand Down

0 comments on commit cf82481

Please sign in to comment.