# sf.ops.CXgate¶

class CXgate(s=1)[source]

Bases: strawberryfields.ops.Gate

Controlled addition or sum gate in the position basis.

$\text{CX}(s) = \int dx \ket{x}\bra{x} \otimes D\left({\frac{1}{\sqrt{2\hbar}}}s x\right) = e^{-i s \: \hat{x} \otimes \hat{p}/\hbar}$

In the position basis it maps $$\ket{x_1, x_2} \mapsto \ket{x_1, s x_1 +x_2}$$.

Parameters

Definition

The controlled-X gate, also known as the addition gate or the sum gate, is a controlled displacement in position. It is given by

$\text{CX}(s) = \int dx \xket{x}\xbra{x} \otimes D\left(\frac{s x}{\sqrt{2\hbar}}\right) = \exp\left({-i \frac{s}{\hbar} \: \x_1 \otimes \p_2}\right).$

It is called addition because in the position basis $$\text{CX}(s) \xket{x_1, x_2} = \xket{x_1, x_2+s x_1}$$.

We can also write the action of the addition gate on the canonical operators:

$\begin{split}\text{CX}(s)^\dagger \x_1 \text{CX}(s) &= \x_1\\ \text{CX}(s)^\dagger \p_1 \text{CX}(s) &= \p_1- s \ \p_2\\ \text{CX}(s)^\dagger \x_2 \text{CX}(s) &= \x_2+ s \ \x_1\\ \text{CX}(s)^\dagger \p_2 \text{CX}(s) &= \p_2 \\ \text{CX}(s)^\dagger \hat{a}_1 \text{CX}(s) &= \a_1+ \frac{s}{2} (\ad_2 - \a_2)\\ \text{CX}(s)^\dagger \hat{a}_2 \text{CX}(s) &= \a_2+ \frac{s}{2} (\ad_1 + \a_1)\\\end{split}$

The addition gate can be decomposed in terms of single mode squeezers and beamsplitters as follows:

$\text{CX}(s) = B(\frac{\pi}{2}+\theta,0) \left(S(r,0) \otimes S(-r,0) \right) B(\theta,0),$

where

$\sin(2 \theta) = \frac{-1}{\cosh r}, \ \cos(2 \theta)=-\tanh(r), \ \sinh(r) = -\frac{ s}{2}.$
 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[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