sf.ops.BipartiteGraphEmbed

class BipartiteGraphEmbed(A, mean_photon_per_mode=1.0, edges=False, drop_identity=True, tol=1e-06)[source]

Bases: strawberryfields.ops.Decomposition

Embed a bipartite graph into an interferometer setup.

A bipartite graph is a graph that consists of two vertex sets \(U\) and \(V\), such that every edge in the graph connects a vertex between \(U\) and \(V\). That is, there are no edges between vertices in the same vertex set.

The adjacency matrix of an \(N\) vertex undirected bipartite graph is a \(N\times N\) symmetric matrix of the form

\[\begin{split}A = \begin{bmatrix}0 & B \\ B^T & 0\end{bmatrix}\end{split}\]

where \(B\) is a :math:N/2times N/2` matrix representing the (weighted) edges between the vertex set.

This operation decomposes an adjacency matrix into a sequence of two mode squeezers, beamsplitters, and rotation gates.

Parameters
  • A (array) – Either an \(N\times N\) complex or real symmetric adjacency matrix \(A\), or an \(N/2\times N/2\) complex or real matrix \(B\) representing the edges between the vertex sets if edges=True.

  • mean_photon_per_mode (float) – guarantees that the mean photon number in the pure Gaussian state representing the graph satisfies \(\frac{1}{N}\sum_{i=1}^N sinh(r_{i})^2 ==\) :code:mean_photon

  • edges (bool) – set to True if argument A represents the edges \(B\) between the vertex sets rather than the full adjacency matrix

  • drop_identity (bool) – If True, decomposed gates with trivial parameters, such that they correspond to an identity operation, are removed.

  • tol (float) – the tolerance used when checking if the input matrix is symmetric: \(|A-A^T| <\) tol

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