mm.lab.Gaussian¶
- class mrmustard.lab.Gaussian(num_modes, symplectic=None, eigenvalues=None, symplectic_trainable=False, eigenvalues_trainable=False, eigenvalues_bounds=(None, None), modes=None, cutoffs=None, normalize=False)[source]¶
Bases:
State
The N-mode Gaussian state parametrized by a symplectic matrix and N symplectic eigenvalues.
The (mixed) Gaussian state is equivalent to applying a Gaussian symplectic transformation to a Thermal state:
>>> G = Gaussian(num_modes=1, eigenvalues = np.random.uniform(settings.HBAR/2, 10.0)) >>> G == Thermal(nbar=(G.eigenvalues*2/settings.HBAR - 1)/2) >> Ggate(1, symplectic=G.symplectic) True
Note that the 1st moments are zero unless a Dgate is applied to the Gaussian state:
>>> np.allclose(Gaussian(num_modes=1).means, 0.0) True
- Parameters:
num_modes (int) – the number of modes
eigenvalues (float or List[float]) – the symplectic eigenvalues of the Gaussian state
symplectic (np.ndarray or List[np.ndarray]) – the symplectic matrix of the Gaussian state
eigenvalues_trainable (bool) – whether the eigenvalues are trainable
symplectic_trainable (bool) – whether the symplectic matrix is trainable
eigenvalues_bounds (tuple) – the bounds of the eigenvalues
modes (optional, List[int]) – the modes of the Gaussian state.
cutoffs (Sequence[int], default=None) – set to force the cutoff dimensions of the state
normalize (bool, default False) – whether to normalize the leftover state when projecting onto Gaussian
Attributes
Returns the covariance matrix of the state.
Returns the Hilbert space dimension of each mode.
Returns the Fock representation of the state.
Returns whether the state is mixed.
Returns
True
if the state is pure andFalse
otherwise.Returns the means vector of the state.
Returns the modes of the state.
Returns the norm of the state.
Returns the complete photon number covariance matrix.
Returns the mean photon number for each mode.
Returns the square root of the photon number variances (standard deviation) in each mode.
The set of parameters for this state.
Returns the probability of the state.
Returns the purity of the state.
Returns the shape of the state, accounting for ket/dm representation.
- cov¶
- cutoffs¶
Returns the Hilbert space dimension of each mode.
- fock¶
Returns the Fock representation of the state.
- is_mixed¶
- is_pure¶
Returns
True
if the state is pure andFalse
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.
Methods
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 ontoself
.- bargmann(numpy=False)¶
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)¶
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)¶
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
- indices(modes)¶
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)¶
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)¶
Returns the post-measurement state after
other
is projected ontoself
.other << self
is other projected ontoself
.If
other
is aTransformation
, it returns the dual of the transformation applied toself
:other << self
is likeself >> other^dual
.Note that the returned state is not normalized. To normalize a state you can use
mrmustard.physics.normalize
.- Return type: