Decompositions

Module name: thewalrus.decompositions

This module implements common shared matrix decompositions that are used to perform gate decompositions.

Summary

williamson(V[, rtol, atol])

Williamson decomposition of positive-definite (real) symmetric matrix.

symplectic_eigenvals(cov)

Returns the symplectic eigenvalues of a covariance matrix.

blochmessiah(S)

Returns the Bloch-Messiah decomposition of a symplectic matrix S = uff @ dff @ vff

Code details

blochmessiah(S)[source]
Returns the Bloch-Messiah decomposition of a symplectic matrix S = uff @ dff @ vff

where uff and vff are orthogonal symplectic matrices and dff is a 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 uff

array[float], : diagional matrix dff array[float]) : orthogonal symplectic matrix vff

Return type

tupple(array[float],

symplectic_eigenvals(cov)[source]

Returns the symplectic eigenvalues of a covariance matrix.

Parameters

cov (array) – a covariance matrix

Returns

symplectic eigenvalues

Return type

(array)

williamson(V, rtol=1e-05, atol=1e-08)[source]

Williamson decomposition of positive-definite (real) symmetric matrix.

See this thread and the Williamson decomposition documentation

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) where Db is a diagonal matrix

and S is a symplectic matrix such that \(V = S^T Db S\)

Return type

tuple[array,array]