Decompositions¶
Module name: thewalrus.decompositions
This module implements common shared matrix decompositions that are used to perform gate decompositions.
For mathematical details of these decompositions see
Houde et al. Matrix decompositions in Quantum Optics: Takagi/Autonne, Bloch-Messiah/Euler, Iwasawa, and Williamson [42] Summary ——-
|
Williamson decomposition of positive-definite (real) symmetric matrix. |
|
Returns the symplectic eigenvalues of a covariance matrix. |
|
Returns the Bloch-Messiah decomposition of a symplectic matrix S = O @ D @ Q |
|
Autonne-Takagi decomposition of a complex symmetric (not Hermitian!) matrix. |
|
Pre-Iwasawa decomposition of a symplectic matrix. |
|
Iwasawa decomposition of a symplectic matrix. |
Code details¶
- blochmessiah(S)[source]¶
- Returns the Bloch-Messiah decomposition of a symplectic matrix S = O @ D @ Q
where O and Q are orthogonal symplectic matrices and D is a positive-definite diagonal matrix of the form diag(d1,d2,…,dn,d1^-1, d2^-1,…,dn^-1).
- Parameters:
S (array[float]) – 2N x 2N real symplectic matrix
- Returns:
- orthogonal symplectic matrix O
array[float], : diagonal matrix D array[float]) : orthogonal symplectic matrix Q
- Return type:
tuple(array[float],
- iwasawa(S)[source]¶
Iwasawa decomposition of a symplectic matrix. See Arvind et al. The Real Symplectic Groups in Quantum Mechanics and Optics and Houde et al. Matrix decompositions in Quantum Optics: Takagi/Autonne, Bloch-Messiah/Euler, Iwasawa, and Williamson
- Parameters:
S (array) – the symplectic matrix
- Returns:
(E,D,F) symplectic matrices such that E @ D @ F = S, EE = np.block([[AA, np.zeros(N,N)],[CC, np.linalg.inv(A.T)]]) with A.T @ C == C.T @ A, and AA upper trinagular with ones in the diagonal DD is diagonal and symplectic, FF is symplectic orthogonal.
- Return type:
tuple[array, array, array]
- pre_iwasawa(S)[source]¶
Pre-Iwasawa decomposition of a symplectic matrix. See Arvind et al. The Real Symplectic Groups in Quantum Mechanics and Optics and Houde et al. Matrix decompositions in Quantum Optics: Takagi/Autonne, Bloch-Messiah/Euler, Iwasawa, and Williamson
- Parameters:
S (array) – the symplectic matrix
- Returns:
(E,D,F) symplectic matrices such that E @ D @ F = S and, E = np.block([[np.eye(N), np.zeros(N,N)],[X, np.eye(N)]]) with X == X.T, D is block diagonal with the top left block being the inverse of the bottom right block, F is symplectic orthogonal.
- Return type:
tuple[array, array, array]
- symplectic_eigenvals(cov)[source]¶
Returns the symplectic eigenvalues of a covariance matrix.
- Parameters:
cov (array) – a covariance matrix
- Returns:
symplectic eigenvalues
- Return type:
(array)
- takagi(A, svd_order=True)[source]¶
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.
- Parameters:
A (array) – square, symmetric matrix
svd_order (boolean) – whether to return result by ordering the singular values of
A
in descending (True
) or ascending (False
) order.
- Returns:
(r, U), where r are the singular values, and U is the Autonne-Takagi unitary, such that \(A = U \diag(r) U^T\).
- Return type:
tuple[array, array]
- williamson(V, rtol=1e-05, atol=1e-08)[source]¶
Williamson decomposition of positive-definite (real) symmetric matrix.
- Parameters:
V (array[float]) – positive definite symmetric (real) matrix
rtol (float) – the relative tolerance parameter used in
np.allclose
atol (float) – the absolute tolerance parameter used in
np.allclose
- Returns:
(Db, S)
whereDb
is a diagonal matrixand
S
is a symplectic matrix such that \(V = S Db S^T\)
- Return type:
tuple[array,array]