sf.ops.DensityMatrix¶
-
class
DensityMatrix
(state)[source]¶ Bases:
strawberryfields.ops.Preparation
Prepare mode(s) using the given density matrix in the Fock basis.
The prepared modes are traced out and replaced with the given state (in the Fock basis). As a result, the overall state of system will also have to be described using a density matrix.
The provided density matrices must be of size
[cutoff_dim, cutoff_dim]
, matching the cutoff dimension used in calls toeng.run
.Warning
The Fock basis is non-Gaussian, and thus can only be used in the Fock backends, not the Gaussian backend.
- Parameters
state (array or BaseFockState) –
density matrix in the Fock basis. This can be provided as either:
a single mode two-dimensional matrix \(\rho_{ij}\),
a multimode tensor \(\rho_{ij,kl,\dots,mn}\), with two indices per mode,
a
BaseFockState
state object.
Details and Conventions
When working with an \(N\)-mode density matrix in the Fock basis,
\[\rho = \sum_{n_1}\cdots\sum_{n_N} c_{n_1,\cdots,n_N} \ket{n_1,\cdots,n_N}\bra{n_1,\cdots,n_N}\]we use the convention that every pair of consecutive dimensions corresponds to a subsystem; i.e.,
\[\rho_{\underbrace{ij}_{\text{mode}~0}~\underbrace{kl}_{\text{mode}~1} ~\underbrace{mn}_{\text{mode}~2}}\]Thus, using index notation, we can calculate the reduced density matrix for mode 2 by taking the partial trace over modes 0 and 1:
\[\braketT{n}{\text{Tr}_{01}[\rho]}{m} = \sum_{i}\sum_k \rho_{iikkmn}\]Attributes
Extra dependencies due to parameters that depend on measurements.
-
measurement_deps
¶ Extra dependencies due to parameters that depend on measurements.
- Returns
dependencies
- Return type
set[RegRef]
-
ns
= None¶
Methods
apply
(reg, backend, **kwargs)Ask a local backend to execute the operation on the current register state right away.
decompose
(reg, **kwargs)Decompose the operation into elementary operations supported by the backend API.
merge
(other)Merge the operation with another (acting on the exact same set of subsystems).
-
apply
(reg, backend, **kwargs)¶ Ask a local backend to execute the operation on the current register state right away.
Takes care of parameter evaluations and any pending formal transformations (like dagger) and then calls
Operation._apply()
.- Parameters
reg (Sequence[RegRef]) – subsystem(s) the operation is acting on
backend (BaseBackend) – backend to execute the operation
- Returns
the result of self._apply
- Return type
Any
-
decompose
(reg, **kwargs)¶ Decompose the operation into elementary operations supported by the backend API.
See
strawberryfields.backends.base
.
-
merge
(other)¶ Merge the operation with another (acting on the exact same set of subsystems).
Note
For subclass overrides: merge may return a newly created object, or self, or other, but it must never modify self or other because the same Operation objects may be also used elsewhere.
- Parameters
other (Operation) – operation to merge this one with
- Returns
other * self. The return value None represents the identity gate (doing nothing).
- Return type
Operation, None
- Raises
MergeFailure – if the two operations cannot be merged