# sf.ops.CZgate¶

class CZgate(s=1)[source]

Bases: strawberryfields.ops.Gate

Controlled phase gate in the position basis.

$\text{CZ}(s) = \iint dx dy \: e^{i sxy/\hbar} \ket{x,y}\bra{x,y} = e^{i s \: \hat{x} \otimes \hat{x}/\hbar}$

In the position basis it maps $$\ket{x_1, x_2} \mapsto e^{i s x_1 x_2/\hbar} \ket{x_1, x_2}$$.

Parameters

s (float) – phase shift multiplier

Definition

$\text{CZ}(s) = \iint dx dy \: e^{i s x_1 x_2/\hbar } \xket{x_1,x_2}\xbra{x_1,x_2} = \exp\left({i s \: \hat{x_1} \otimes \hat{x_2} /\hbar}\right).$

It is related to the addition gate by a phase space rotation in the second mode:

$\text{CZ}(s) = R_{(2)}(\pi/2) \: \text{CX}(s) \: R_{(2)}^\dagger(\pi/2).$

In the position basis $$\text{CZ}(s) \xket{x_1, x_2} = e^{i s x_1 x_2/\hbar} \xket{x_1, x_2}$$.

We can also write the action of the controlled-phase gate on the canonical operators:

$\begin{split}\text{CZ}(s)^\dagger \x_1 \text{CZ}(s) &= \x_1\\ \text{CZ}(s)^\dagger \p_1 \text{CZ}(s) &= \p_1+ s \ \x_2\\ \text{CZ}(s)^\dagger \x_2 \text{CZ}(s) &= \x_2\\ \text{CZ}(s)^\dagger \p_2 \text{CZ}(s) &= \p_2+ s \ \x_1 \\ \text{CZ}(s)^\dagger \hat{a}_1 \text{CZ}(s) &= \a_1+ i\frac{s}{2} (\ad_2 + \a_2)\\ \text{CZ}(s)^\dagger \hat{a}_2 \text{CZ}(s) &= \a_2+ i\frac{s}{2} (\ad_1 + \a_1)\\\end{split}$
 H Returns a copy of the gate with the self.dagger flag flipped. measurement_deps Extra dependencies due to parameters that depend on measurements. ns
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
 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 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