Symplectics

cxgate_symplectic

The symplectic matrix of a controlled X gate.

czgate_symplectic

The symplectic matrix of a controlled Z gate.

interferometer_symplectic

The symplectic matrix of an N-mode interferometer parametrized by an NxN unitary matrix.

mzgate_symplectic

The symplectic matrix of a Mach-Zehnder gate.

pgate_symplectic

The symplectic matrix of a quadratic phase gate.

realinterferometer_symplectic

The symplectic matrix of an N-mode interferometer parametrized by an NxN orthogonal matrix.

cxgate_symplectic

mrmustard.physics.symplectics.cxgate_symplectic(s)[source]

The symplectic matrix of a controlled X gate.

Parameters:

s (float | Sequence[float]) – The control parameter.

Returns:

The symplectic matrix of a CX gate.

Return type:

Matrix

czgate_symplectic

mrmustard.physics.symplectics.czgate_symplectic(s)[source]

The symplectic matrix of a controlled Z gate.

Parameters:

s (float | Sequence[float]) – The control parameter.

Returns:

The symplectic matrix of a CZ gate.

Return type:

Matrix

interferometer_symplectic

mrmustard.physics.symplectics.interferometer_symplectic(unitary)[source]

The symplectic matrix of an N-mode interferometer parametrized by an NxN unitary matrix.

Parameters:

unitary (Matrix) – A unitary matrix. For N modes it must have shape (N,N).

Returns:

The symplectic matrix of an N-mode interferometer.

Return type:

Matrix

mzgate_symplectic

mrmustard.physics.symplectics.mzgate_symplectic(phi_a, phi_b, internal)[source]

The symplectic matrix of a Mach-Zehnder gate.

It supports two conventions:
  1. if internal=True, both phases act inside the interferometer: phi_a on the upper arm, phi_b on the lower arm;

  2. if internal = False, both phases act on the upper arm: phi_a before the first BS, phi_b after the first BS.

Parameters:
  • phi_a (float | Sequence[float]) – The phase in the upper arm of the MZ interferometer

  • phi_b (float | Sequence[float]) – The phase in the lower arm or external of the MZ interferometer

  • internal (bool) – Whether phases are both in the internal arms.

Returns:

The symplectic matrix of a Mach-Zehnder gate.

Return type:

Matrix

pgate_symplectic

mrmustard.physics.symplectics.pgate_symplectic(n_modes, shearing)[source]

The symplectic matrix of a quadratic phase gate.

Parameters:
  • n_modes (int) – The number of modes.

  • shearing (float | Sequence[float]) – The shearing parameter.

Returns:

The symplectic matrix of a phase gate.

Return type:

Matrix

realinterferometer_symplectic

mrmustard.physics.symplectics.realinterferometer_symplectic(orthogonal)[source]

The symplectic matrix of an N-mode interferometer parametrized by an NxN orthogonal matrix.

Parameters:

orthogonal (Matrix) – A real orthogonal matrix. For N modes it must have shape (N,N).

Returns:

The symplectic matrix of an N-mode interferometer.

Return type:

Matrix