States¶
In Strawberry Fields, the statevector simulator backends return state
objects,
which provide useful information and processing of the quantum state of
the system. For example, consider the following program:
prog = sf.Program(3)
with prog.context as q:
ops.Sgate(0.54) | q[0]
ops.Sgate(0.54) | q[1]
ops.Sgate(0.54) | q[2]
ops.BSgate(0.43, 0.1) | (q[0], q[2])
ops.BSgate(0.43, 0.1) | (q[1], q[2])
eng = sf.Engine("fock", backend_options={"cutoff_dim": 10})
result = eng.run(prog)
state = result.state
By executing this program on a local simulator backend, we can use the state object to determine the trace, return the density matrix, and calculate particular Fock basis state probabilities:
>>> state.trace()
0.9989783190545866
>>> rho = state.dm()
>>> state.fock_prob([0, 0, 2])
0.07933909728557098
These methods may differ depending on the backend, but there are a few that are implemented for all backends.
Common methods and attributes¶
Returns the underlying numerical (or symbolic) representation of the state. Returns the value of \(\hbar\) used in the generation of the state. Checks whether the state is a pure state. Gets the number of modes that the state represents. Returns a dictionary mapping the mode index to mode names. Returns a dictionary mapping the mode names to mode indices. The numerical state vector for the quantum state in the Fock basis. The numerical density matrix for the quantum state in the Fock basis. Returns a reduced density matrix in the Fock basis. Probability of a particular Fock basis state. Probabilities of all possible Fock basis states for the current circuit state. Returns the mean photon number of a particular mode. Fidelity of the reduced state in the specified mode with a user supplied state. The fidelity of the state with the vacuum state. The fidelity of the state with a product of coherent states. Calculates the discretized Wigner function of the specified mode. The \(\x_{\phi}\) operator expectation values and variance for the specified mode. The multi-mode expectation values and variance of arbitrary 2nd order polynomials of quadrature operators. Calculates the expectation value of the product of the number operators of the modes. Calculates the expectation value of a product of parity operators acting on given modes Calculates the discretized p-quadrature probability distribution of the specified mode. Calculates the discretized x-quadrature probability distribution of the specified mode.
ket
(**kwargs)dm
(**kwargs)reduced_dm
(modes, **kwargs)fock_prob
(n, **kwargs)all_fock_probs
(**kwargs)mean_photon
(mode, **kwargs)fidelity
(other_state, mode, **kwargs)fidelity_vacuum
(**kwargs)fidelity_coherent
(alpha_list, **kwargs)wigner
(mode, xvec, pvec)quad_expectation
(mode[, phi])poly_quad_expectation
(A[, d, k, phi])number_expectation
(modes)parity_expectation
(modes)p_quad_values
(mode, xvec, pvec)x_quad_values
(mode, xvec, pvec)
Gaussian states¶
Backend that represent the quantum state using the Gaussian formalism
(such as the gaussian
backend) will return a GaussianState
object,
with the following methods and attributes.
The vector of means describing the Gaussian state. The covariance matrix describing the Gaussian state. Returns the vector of means and the covariance matrix of the specified modes. Returns True if the Gaussian state of a particular mode is a coherent state. Returns True if the Gaussian state of a particular mode is a squeezed state. Returns the displacement parameter \(\alpha\) of the modes specified. Returns the squeezing parameters \((r,\phi)\) of the modes specified.
means
()cov
()reduced_gaussian
(modes)is_coherent
(mode[, tol])is_squeezed
(mode[, tol])displacement
([modes])squeezing
([modes])