# Calculations on Fock objects¶

This module contains functions for performing calculations on objects in the Fock representations.

## Functions¶

 U_to_choi(U[, Udual]) Converts a unitary transformation to a Choi tensor. apply_choi_to_dm(choi, dm, choi_in_modes[, ...]) Applies a choi operator to a density matrix. apply_choi_to_ket(choi, ket, choi_in_modes) Applies a choi operator to a ket. apply_kraus_to_dm(kraus, dm, kraus_in_modes) Applies a kraus operator to a density matrix. apply_kraus_to_ket(kraus, ket, kraus_in_modes) Applies a kraus operator to a ket. autocutoffs(cov, means, probability) Returns the cutoffs of a Gaussian state by computing the 1-mode marginals until the probability of the marginal is less than probability. beamsplitter(*args, **kwargs) contract_states(stateA, stateB, a_is_dm, ...) Contracts two states in the specified modes. displacement(*args, **kwargs) Maps a density matrix to a ket if the state is pure. Extracts the diagonals of a density matrix. estimate_dx(cutoff[, period_resolution]) Estimates a suitable quadrature discretization interval dx. estimate_quadrature_axis(cutoff[, minimum, ...]) Generates a suitable quadrature axis. estimate_xmax(cutoff[, minimum]) Estimates a suitable quadrature axis length fidelity(state_a, state_b, a_ket, b_ket) Computes the fidelity between two states in Fock representation. fock_state(n[, cutoffs]) The Fock array of a tensor product of one-mode Number states. Evaluates if a density matrix represents a mixed state. ket_to_dm(ket) Maps a ket to a density matrix. Maps a ket to probabilities. lru_cache([maxsize, typed]) Least-recently-used cache decorator. norm(state, is_dm) Returns the norm of a ket or the trace of the density matrix. normalize(fock, is_dm) Returns the normalized ket state. number_means(tensor, is_dm) Returns the mean of the number operator in each mode. number_variances(tensor, is_dm) Returns the variance of the number operator in each mode. oscillator_eigenstate(q, cutoff) Harmonic oscillator eigenstate wavefunction psi_n(q) = . purity(dm) Returns the purity of a density matrix. quadrature_distribution(state[, ...]) Given the ket or density matrix of a single-mode state, it generates the probability density distribution \(\tr [ \rho |x_\phi> the quadrature eigenvector with angle phi equal to quadrature_angle. sample_homodyne(state[, quadrature_angle]) Given a single-mode state, it generates the pdf of \(\tr [ \rho |x_\phi>

## Variables¶

 ComplexTensor ndarray(shape, dtype=float, buffer=None, offset=0, List A generic version of list. Matrix ndarray(shape, dtype=float, buffer=None, offset=0, Optional Optional[X] is equivalent to Union[X, None]. SQRT ndarray(shape, dtype=float, buffer=None, offset=0, Scalar alias of Union[R, C, Z, N] Sequence A generic version of collections.abc.Sequence. Tensor ndarray(shape, dtype=float, buffer=None, offset=0, Tuple Deprecated alias to builtins.tuple. Union Union type; Union[X, Y] means either X or Y. Vector ndarray(shape, dtype=float, buffer=None, offset=0, math A class to manage the different backends supported by Mr Mustard. settings A class containing various settings that are used by Mr Mustard throughout a session.