Fock Utilities

c_in_PS

Transforms the c matrix of a DM object from bargmann to phase-space.

c_ps_matrix

Helper function for c_in_PS.

estimate_dx

Estimates a suitable quadrature discretization interval dx.

estimate_quadrature_axis

Generates a suitable quadrature axis.

estimate_xmax

Estimates a suitable quadrature axis length.

fidelity

Computes the fidelity between two states in Fock representation.

fock_state

The Fock array of a batchable single-mode Number state.

gamma_matrix

Helper function for c_in_PS.

oscillator_eigenstate

Harmonic oscillator eigenstate wavefunction psi_n(q) = <n|q>.

quadrature_basis

Given the Fock basis representation return the quadrature basis representation.

quadrature_distribution

Given the ket or density matrix of a single-mode state, it generates the probability density distribution \(\tr [ \rho |x_\phi><x_\phi| ]\) where \rho is the density matrix of the state and |x_\phi> the quadrature eigenvector with angle \phi equal to quadrature_angle.

c_in_PS

mrmustard.physics.fock_utils.c_in_PS(c)[source]

Transforms the c matrix of a DM object from bargmann to phase-space.

Parameters:

c (Tensor) – the 2-dimensional c matrix of the DM object

c_ps_matrix

mrmustard.physics.fock_utils.c_ps_matrix(m, n, alpha)[source]

Helper function for c_in_PS.

estimate_dx

mrmustard.physics.fock_utils.estimate_dx(cutoff, period_resolution=20)[source]

Estimates a suitable quadrature discretization interval dx. Uses the fact that Fock state n oscillates with angular frequency \(\sqrt{2(n + 1)}\), which follows from the relation.

\[\psi^{[n]}'(q) = q - sqrt(2*(n + 1))*\psi^{[n+1]}(q)\]

by setting q = 0, and approximating the oscillation amplitude by psi^{[n+1]}(0).

Ref: https://en.wikipedia.org/wiki/Hermite_polynomials#Hermite_functions

Parameters:
  • cutoff (int) – Fock cutoff

  • period_resolution (int) – Number of points used to sample one Fock wavefunction oscillation. Larger values yields better approximations and thus smaller dx.

Returns:

discretization value of quadrature

Return type:

(float)

estimate_quadrature_axis

mrmustard.physics.fock_utils.estimate_quadrature_axis(cutoff, minimum=5, period_resolution=20)[source]

Generates a suitable quadrature axis.

Parameters:
  • cutoff (int) – Fock cutoff

  • minimum (float) – Minimum value of the returned xmax

  • period_resolution (int) – Number of points used to sample one Fock wavefunction oscillation. Larger values yields better approximations and thus smaller dx.

Returns:

quadrature axis

Return type:

(array)

estimate_xmax

mrmustard.physics.fock_utils.estimate_xmax(cutoff, minimum=5)[source]

Estimates a suitable quadrature axis length.

Parameters:
  • cutoff (int) – Fock cutoff

  • minimum (float) – Minimum value of the returned xmax

Returns:

maximum quadrature value

Return type:

(float)

fidelity

mrmustard.physics.fock_utils.fidelity(dm_a, dm_b)[source]

Computes the fidelity between two states in Fock representation.

Return type:

Scalar

fock_state

mrmustard.physics.fock_utils.fock_state(n, cutoff=None)[source]

The Fock array of a batchable single-mode Number state.

Parameters:
  • n (int | Sequence[int]) – The photon number of the number state. Can be a single integer or a batch of integers.

  • cutoff (int | None) – The cutoff of the Fock array.

Returns:

The Fock array of a batchable single-mode Number state.

Return type:

Tensor

gamma_matrix

mrmustard.physics.fock_utils.gamma_matrix(c)[source]

Helper function for c_in_PS. constructs the matrix transformation that helps transforming c. c here must be 2-dimensional.

oscillator_eigenstate

mrmustard.physics.fock_utils.oscillator_eigenstate(q, cutoff)[source]

Harmonic oscillator eigenstate wavefunction psi_n(q) = <n|q>.

Parameters:
  • q (Vector) – array of q points at which the function is evaluated (units of sqrt{hbar}). Can have any shape; the result has shape (cutoff, *q.shape).

  • cutoff (int) – Fock space dimension (shape). Note: despite the parameter name, this is the shape (cutoff + 1), not the max photon number. Callers pass shape values here.

Returns:

shape (cutoff, *q.shape). Entry [n, ...] is \(\psi_n\) evaluated

at the corresponding points of q.

Return type:

Tensor

Definition

The q-quadrature eigenstates are defined as

\[\psi_n(x) = 1/sqrt[2^n n!](\frac{\omega}{\pi \hbar})^{1/4} \exp{-\frac{\omega}{2\hbar} x^2} H_n(\sqrt{\frac{\omega}{\pi}} x)\]

where \(H_n(x)\) is the (physicists) n-th Hermite polynomial.

quadrature_basis

mrmustard.physics.fock_utils.quadrature_basis(fock_array, quad, conjugates=False, phi=0.0)[source]

Given the Fock basis representation return the quadrature basis representation.

Parameters:
  • fock_array (Tensor) – fock tensor amplitudes

  • quad (Batch[Vector]) – points at which the quadrature basis is evaluated

  • conjugates (list[bool]) – which dimensions of the array to conjugate based on whether it is a bra or a ket

  • phi (float) – angle of the quadrature basis vector

Returns:

quadrature basis representation at the points in quad

Return type:

tuple(Tensor)

quadrature_distribution

mrmustard.physics.fock_utils.quadrature_distribution(state, quadrature_angle=0.0, x=None)[source]

Given the ket or density matrix of a single-mode state, it generates the probability density distribution \(\tr [ \rho |x_\phi><x_\phi| ]\) where \rho is the density matrix of the state and |x_\phi> the quadrature eigenvector with angle \phi equal to quadrature_angle.

Parameters:
  • state (Tensor) – A single mode state ket or density matrix.

  • quadrature_angle (float) – The angle of the quadrature basis vector.

  • x (Vector | None) – The points at which the quadrature distribution is evaluated.

Returns:

The coordinates at which the pdf is evaluated and the probability distribution.