# sf.ops.Gaussian¶

class Gaussian(V, r=None, decomp=True, tol=1e-06)[source]

Bases: strawberryfields.ops.Preparation, strawberryfields.ops.Decomposition

Prepare the specified modes in a Gaussian state.

This operation uses the Williamson decomposition to prepare quantum modes into a given Gaussian state, specified by a vector of means and a covariance matrix.

The Williamson decomposition decomposes the Gaussian state into a Gaussian transformation (represented by a symplectic matrix) acting on Thermal states. The Gaussian transformation is then further decomposed into an array of beamsplitters and local squeezing and rotation gates, by way of the GaussianTransform and Interferometer decompositions.

Alternatively, the decomposition can be explicitly turned off, and the backend can be explicitly prepared in the Gaussian state provided. This is only supported by backends using the Gaussian representation.

Note

$$V$$ must be a valid quantum state satisfying the uncertainty principle: $$V+\frac{1}{2}i\hbar\Omega\geq 0$$. If this is not the case, the Williamson decomposition will return non-physical thermal states with $$\bar{n}_i<0$$.

Parameters
• V (array[float]) – an $$2N\times 2N$$ (real and positive definite) covariance matrix

• r (array[float] or None) – Length $$2N$$ vector of means, of the form $$(\x_0,\dots,\x_{N-1},\p_0,\dots,\p_{N-1})$$. If None, it is assumed that $$r=0$$.

• decomp (bool) – Should the operation be decomposed into a sequence of elementary gates? If False, the state preparation is performed directly via the backend API.

• tol (float) – the tolerance used when checking if the matrix is symmetric: $$|V-V^T| \leq$$ tol

Definition

For every positive definite real matrix $$V\in\mathbb{R}^{2N\times 2N}$$, there exists a symplectic matrix $$S$$ and diagonal matrix $$D$$ such that

$V = S D S^T$

where $$D=\text{diag}(\nu_1,\dots,\nu_N,\nu_1,\dots,\nu_N)$$, and $$\{\nu_i\}$$ are the eigenvalues of $$|i\Omega V|$$, where $$||$$ represents the element-wise absolute value.

The Williamson decomposition allows an arbitrary Gaussian covariance matrix to be decomposed into a symplectic transformation acting on the state described by the diagonal matrix $$D$$.

The matrix $$D$$ can always be decomposed further into a set of thermal states with mean photon number given by

$\bar{n}_i = \frac{1}{\hbar}\nu_i - \frac{1}{2}, ~~i=1,\dots,N$

Pure states

In the case where $$V$$ represents a pure state ($$|V|-(\hbar/2)^{2N}=0$$), the Williamson decomposition outputs $$D=\frac{1}{2}\hbar I_{2N}$$; that is, a symplectic transformation $$S$$ acting on the vacuum. It follows that the original covariance matrix can therefore be recovered simply via $$V=\frac{\hbar}{2}SS^T$$.

 measurement_deps Extra dependencies due to parameters that depend on measurements. ns
measurement_deps

Extra dependencies due to parameters that depend on measurements.

Returns

dependencies

Return type

set[RegRef]

ns = None
 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.

Parameters

reg (Sequence[RegRef]) – subsystems the operation is acting on

Returns

decomposition as a list of operations acting on specific subsystems

Return type

list[Command]

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