sf.ops.MZgate¶
-
class
MZgate
(phi_in, phi_ex)[source]¶ Bases:
strawberryfields.ops.Gate
Mach-Zehnder interferometer.
\[\mathrm{MZ}(\phi_{in}, \phi_{ex}) = BS\left(\frac{\pi}{4}, \frac{\pi}{2}\right) (R(\phi_{in})\otimes I) BS\left(\frac{\pi}{4}, \frac{\pi}{2}\right) (R(\phi_{ex})\otimes I)\]- Parameters
phi_in (float) – internal phase
phi_ex (float) – external phase
It corresponds to an interferometer operation with unitary matrix
\[\begin{split}U(\phi_{in}, \phi_{ex}) = \frac{1}{2} \left(\begin{array}{cc} \left(-1+e^{i \phi_{in} }\right) e^{i \phi_{ex} } & i \left(1+e^{i \phi_{in} }\right)\\ i \left(1+e^{i \phi_{in} }\right) e^{i \phi_{ex} } & \left(1-e^{i \phi_{in} }\right)\\ \end{array}\right)\end{split}\]with special cases
\[\begin{split}U(\pi, \pi) &= \left( \begin{array}{cc} 1 & 0 \\ 0 & 1\\ \end{array}\right),\\ U(0, 0) &= i \left( \begin{array}{cc} 0 & 1 \\ 1 & 0\\ \end{array}\right),\\ U(\pi/2, \phi_{ex}) &= -\frac{1}{\sqrt{2}} \left( \begin{array}{cc} e^{i (\phi_{ex} -\tfrac{\pi}{4})} & e^{-i \tfrac{\pi}{4}} \\ e^{i (\phi_{ex} -\tfrac{\pi}{4})} & -e^{-i \tfrac{\pi}{4}}\\ \end{array}\right).\end{split}\]The last example corresponds to a 50/50 two-mode interferometer.
Attributes
Returns a copy of the gate with the self.dagger flag flipped.
Extra dependencies due to parameters that depend on measurements.
-
H
¶ Returns a copy of the gate with the self.dagger flag flipped.
H stands for hermitian conjugate.
- Returns
formal inverse of this gate
- Return type
Gate
-
measurement_deps
¶ Extra dependencies due to parameters that depend on measurements.
- Returns
dependencies
- Return type
set[RegRef]
-
ns
= 2¶
Methods
apply
(reg, backend, **kwargs)Ask a 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 backend to execute the operation on the current register state right away.
Like
Operation.apply()
, but takes into account the special nature of p[0] and applies self.dagger.- Returns
Gates do not return anything, return value is None
- Return type
None
-
decompose
(reg, **kwargs)¶ Decompose the operation into elementary operations supported by the backend API.
Like
Operation.decompose()
, but applies self.dagger.
-
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