sf.ops.Pgate

class Pgate(s)[source]

Bases: strawberryfields.ops.Gate

Quadratic phase gate.

\[P(s) = e^{i \frac{s}{2} \hat{x}^2/\hbar}\]
Parameters

s (float) – parameter

Definition

\[P(s) = \exp\left(i \frac{s}{2 \hbar} \x^2\right), \quad P^\dagger(s) \a P(s) = \a +i\frac{s}{2}(\a +\ad)\]

It shears the phase space, preserving position:

\[\begin{split}P^\dagger(s) \x P(s) &= \x,\\ P^\dagger(s) \p P(s) &= \p +s\x.\end{split}\]

This gate can be decomposed as

\[P(s) = R(\theta) S(r e^{i \phi})\]

where \(\cosh(r) = \sqrt{1+(\frac{s}{2})^2}, \quad \tan(\theta) = \frac{s}{2}, \quad \phi = -\sign(s)\frac{\pi}{2} -\theta\).

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 = 1

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