Symplectic Operations

Module name: thewalrus.symplectic

Contains some Gaussian operations and auxiliary functions.

Auxiliary functions

expand(S, modes, N)

Expands a Symplectic matrix S to act on the entire subsystem.

expand_vector(alpha, mode, N[, hbar])

Returns the phase-space displacement vector associated to a displacement.

reduced_state(mu, cov, modes)

Returns the vector of means and the covariance matrix of the specified modes.

is_symplectic(S[, rtol, atol])

Checks if matrix S is a symplectic matrix

sympmat(N[, dtype])

Returns the matrix \(\Omega_n = \begin{bmatrix}0 & I_n\\ -I_n & 0\end{bmatrix}\)

Gaussian states

vacuum_state(modes[, hbar, dtype])

Returns the vacuum state.

Gates and operations

two_mode_squeezing(r, phi[, dtype])

Two-mode squeezing.

interferometer(U)

Interferometer.

loss(mu, cov, T, mode[, nbar, hbar])

Loss channel acting on a Gaussian state.

mean_photon_number(mu, cov[, hbar])

Calculates the mean photon number for a given one-mode state.

beam_splitter(theta, phi[, dtype])

Beam-splitter.

rotation(theta[, dtype])

Rotation gate.

Code details

autonne(A, rtol=1e-05, atol=1e-08, svd_order=True)[source]

Autonne-Takagi decomposition of a complex symmetric (not Hermitian!) matrix.

Parameters
  • A (array) – square, symmetric matrix

  • rtol (float) – the relative tolerance parameter between A and A.T

  • atol (float) – the absolute tolerance parameter between A and A.T

  • svd_order (boolean) – whether to return result by ordering the singular values of A in descending (True) or asceding (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]

beam_splitter(theta, phi, dtype=<class 'numpy.float64'>)[source]

Beam-splitter.

Parameters
  • theta (float) – transmissivity parameter

  • phi (float) – phase parameter

  • dtype (numpy.dtype) – datatype to represent the Symplectic matrix

Returns

symplectic-orthogonal transformation matrix of an interferometer with angles theta and phi

Return type

array

expand(S, modes, N)[source]

Expands a Symplectic matrix S to act on the entire subsystem.

Parameters
  • S (array) – a \(2M\times 2M\) Symplectic matrix

  • modes (Sequence[int]) – the list of modes S acts on

  • N (int) – full size of the subsystem

Returns

the resulting \(2N\times 2N\) Symplectic matrix

Return type

array

expand_vector(alpha, mode, N, hbar=2.0)[source]

Returns the phase-space displacement vector associated to a displacement.

Parameters
  • alpha (complex) – complex displacement

  • mode (int) – mode index

  • N (int) – number of modes

Returns

phase-space displacement vector of size 2*N

Return type

array

interferometer(U)[source]

Interferometer.

Parameters

U (array) – unitary matrix

Returns

symplectic transformation matrix

Return type

array

is_symplectic(S, rtol=1e-05, atol=1e-08)[source]

Checks if matrix S is a symplectic matrix

Parameters

S (array) – a square matrix

Returns

whether the given matrix is symplectic

Return type

(bool)

loss(mu, cov, T, mode, nbar=0, hbar=2)[source]

Loss channel acting on a Gaussian state.

Parameters
  • mu (array) – means vector

  • cov (array) – covariance matri

  • T (float) – transmission; 1 corresponds to no loss, 0 to full loss.

  • mode (int) – mode to act on

  • nbar (float) – thermal mean population (default 0)

  • hbar (float) – (default 2) the value of \(\hbar\) in the commutation relation \([\x,\p]=i\hbar\)

Returns

the means vector and covariance matrix of the resulting state

Return type

tuple[array]

mean_photon_number(mu, cov, hbar=2)[source]

Calculates the mean photon number for a given one-mode state.

Parameters
  • mu (array) – length-2 vector of means

  • cov (array) – \(2\times 2\) covariance matrix

  • hbar (float) – (default 2) the value of \(\hbar\) in the commutation relation \([\x,\p]=i\hbar\)

Returns

the photon number expectation and variance

Return type

tuple

reduced_state(mu, cov, modes)[source]

Returns the vector of means and the covariance matrix of the specified modes.

Parameters

modes (int of Sequence[int]) – indices of the requested modes

Returns

means is an array containing the vector of means, and cov is a square array containing the covariance matrix. Both use the \(xp\)-ordering.

Return type

tuple (means, cov)

rotation(theta, dtype=<class 'numpy.float64'>)[source]

Rotation gate.

Parameters
  • theta (float) – rotation angle

  • dtype (numpy.dtype) – datatype to represent the Symplectic matrix

Returns

rotation matrix by angle theta

Return type

array

squeezing(r, phi, dtype=<class 'numpy.float64'>)[source]

Squeezing. In fock space this corresponds to exp(tfrac{1}{2}r e^{i phi} (a^2 - a^{dagger 2}) ).

Parameters
  • r (float) – squeezing magnitude

  • phi (float) – rotation parameter

  • dtype (numpy.dtype) – datatype to represent the Symplectic matrix

Returns

symplectic transformation matrix

Return type

array

sympmat(N, dtype=<class 'numpy.float64'>)[source]

Returns the matrix \(\Omega_n = \begin{bmatrix}0 & I_n\\ -I_n & 0\end{bmatrix}\)

Parameters
  • N (int) – positive integer

  • dtype (numpy.dtype) – datatype to represent the Symplectic matrix

Returns

\(2N\times 2N\) array

Return type

array

two_mode_squeezing(r, phi, dtype=<class 'numpy.float64'>)[source]

Two-mode squeezing.

Parameters
  • r (float) – squeezing magnitude

  • phi (float) – rotation parameter

  • dtype (numpy.dtype) – datatype to represent the Symplectic matrix

Returns

symplectic transformation matrix

Return type

array

vacuum_state(modes, hbar=2.0, dtype=<class 'numpy.float64'>)[source]

Returns the vacuum state.

Parameters
  • modes (str) – Returns the vector of means and the covariance matrix

  • hbar (float) – (default 2) the value of \(\hbar\) in the commutation relation \([\x,\p]=i\hbar\)

  • dtype (numpy.dtype) – datatype to represent the covariance matrix and vector of means

Returns

the means vector and covariance matrix of the vacuum state

Return type

list[array]