mm.lab.State

class mrmustard.lab.State(cov=None, means=None, eigenvalues=None, symplectic=None, ket=None, dm=None, modes=None, cutoffs=None, _norm=1.0)[source]

Bases: object

Base class for quantum states.

cov

Returns the covariance matrix of the state.

cutoffs

Returns the Hilbert space dimension of each mode.

fock

Returns the Fock representation of the state.

is_mixed

Returns whether the state is mixed.

is_pure

Returns True if the state is pure and False otherwise.

means

Returns the means vector of the state.

modes

Returns the modes of the state.

norm

Returns the norm of the state.

number_cov

Returns the complete photon number covariance matrix.

number_means

Returns the mean photon number for each mode.

number_stdev

Returns the square root of the photon number variances (standard deviation) in each mode.

parameter_set

The set of parameters for this state.

probability

Returns the probability of the state.

purity

Returns the purity of the state.

shape

Returns the shape of the state, accounting for ket/dm representation.

cov

Returns the covariance matrix of the state.

cutoffs

Returns the Hilbert space dimension of each mode.

fock

Returns the Fock representation of the state.

is_mixed

Returns whether the state is mixed.

is_pure

Returns True if the state is pure and False otherwise.

means

Returns the means vector of the state.

modes

Returns the modes of the state.

norm

Returns the norm of the state.

number_cov

Returns the complete photon number covariance matrix.

number_means

Returns the mean photon number for each mode.

number_stdev

Returns the square root of the photon number variances (standard deviation) in each mode.

parameter_set

The set of parameters for this state.

probability

Returns the probability of the state.

purity

Returns the purity of the state.

shape

Returns the shape of the state, accounting for ket/dm representation.

If the state is in Gaussian representation, the shape is inferred from the first two moments of the number operator.

bargmann([numpy])

Returns the Bargmann representation of the state.

dm([cutoffs])

Returns the density matrix of the state in Fock representation.

fock_probabilities(cutoffs)

Returns the probabilities in Fock representation.

get_modes(item)

Returns the state on the given modes.

indices(modes)

Returns the indices of the given modes.

ket([cutoffs, max_prob, max_photons])

Returns the ket of the state in Fock representation or None if the state is mixed.

primal(other)

Returns the post-measurement state after other is projected onto self.

bargmann(numpy=False)[source]

Returns the Bargmann representation of the state. If numpy=True, returns the numpy arrays instead of the backend arrays.

Return type:

Optional[tuple[ndarray[Tuple[int, int], TypeVar(C, complex64, complex128)], ndarray[Tuple[int], TypeVar(C, complex64, complex128)], complex]]

dm(cutoffs=None)[source]

Returns the density matrix of the state in Fock representation.

Parameters:

List[int] (cutoffs) – The cutoff dimensions for each mode. If a mode cutoff is None, it’s automatically computed.

Returns:

the density matrix

Return type:

Tensor

fock_probabilities(cutoffs)[source]

Returns the probabilities in Fock representation.

If the state is pure, they are the absolute value squared of the ket amplitudes. If the state is mixed they are the multi-dimensional diagonals of the density matrix.

Parameters:

List[int] (cutoffs) – the cutoff dimensions for each mode

Returns:

the probabilities

Return type:

Tensor

get_modes(item)[source]

Returns the state on the given modes.

Return type:

State

indices(modes)[source]

Returns the indices of the given modes.

Parameters:

modes (Sequence[int] or int) – the modes or mode

Returns:

a tuple of indices of the given modes or the single index of a single mode

Return type:

Tuple[int] or int

ket(cutoffs=None, max_prob=1.0, max_photons=None)[source]

Returns the ket of the state in Fock representation or None if the state is mixed.

Parameters:
  • None] (cutoffs List[int or) – The cutoff dimensions for each mode. If a mode cutoff is None, it’s guessed automatically.

  • max_prob (float) – The maximum probability of the state. Defaults to 1.0. (used to stop the calculation of the amplitudes early)

  • max_photons (int) – The maximum number of photons in the state, summing over all modes (used to stop the calculation of the amplitudes early)

Returns:

the ket

Return type:

Tensor

primal(other)[source]

Returns the post-measurement state after other is projected onto self.

other << self is other projected onto self.

If other is a Transformation, it returns the dual of the transformation applied to self: other << self is like self >> other^dual.

Note that the returned state is not normalized. To normalize a state you can use mrmustard.physics.normalize.

Return type:

State