quantum.optics#

This module is an implementation of linear optical circuits as diagrams built from beam splitters, phases and Mach-Zender interferometers.

One may compute the bosonic statistics of these devices using Diagram.indist_prob() and the statistics for distinguishable or partially distinguishable particles using Diagram.dist_prob() and Diagram.pdist_prob(). Amplitudes for pairs of input and output occupation numbers are computed using Diagram.amp() and the full matrix of amplitudes over occupation numbers is obtained using Diagram.eval().

One may also use the QPath calculus as defined in https://arxiv.org/abs/2204.12985. The functor optics2path() decomposes linear optical circuits into QPath diagrams. The functor zx2path() turns instances of zx.Diagram into QPath diagrams via the dual-rail encoding.

Example

>>> from discopy.quantum.optics import zx2path
>>> from discopy.quantum.zx import Z
>>> from discopy import drawing
>>> drawing.equation(Z(2, 1), zx2path(Z(2, 1)), symbol='->',
...                  draw_type_labels=False, figsize=(6, 4),
...                  path='docs/_static/imgs/optics-fusion.png')
../_images/optics-fusion.png

discopy.quantum.optics.Diagram(dom, cod, ...)

Linear optical network seen as a diagram of beam splitters, phase shifters and Mach-Zender interferometers.

discopy.quantum.optics.Box(name, dom, cod, ...)

Box in an optics.Diagram.

discopy.quantum.optics.Id([dom])

Identity for optics.Diagram.

discopy.quantum.optics.BBS(bias)

Beam splitter with a bias.

discopy.quantum.optics.TBS(theta[, _dagger])

Tunable Beam Splitter.

discopy.quantum.optics.BS

Alias for BBS(0).

discopy.quantum.optics.Phase(phi)

Phase shifter.

discopy.quantum.optics.MZI(theta, phi[, _dagger])

Mach-Zender interferometer.

discopy.quantum.optics.Functor(ob, ar)

Can be used for catching lions

discopy.quantum.optics.ansatz(width, depth, x)

Returns a universal interferometer given width, depth and parameters x, based on https://arxiv.org/abs/1603.08788.

discopy.quantum.optics.occupation_numbers(...)

Returns vectors of occupation numbers for n_photons in m_modes.

discopy.quantum.optics.npperm(M)

Numpy code for computing the permanent of a matrix, from scipy/scipy#7151.

discopy.quantum.optics.PathBox(name, dom, ...)

Box in Path category, see https://arxiv.org/abs/2204.12985.

discopy.quantum.optics.Endo(scalar)

Endomorphism PathBox in the Path category.

discopy.quantum.optics.Monoid()

Monoid PathBox in the Path category.

discopy.quantum.optics.Comonoid()

Comonoid PathBox in the Path category.

discopy.quantum.optics.Unit()

Unit PathBox in the Path category.

discopy.quantum.optics.Counit()

Counit PathBox in the Path category.

discopy.quantum.optics.Annil()

Annilation PathBox in the QPath category.

discopy.quantum.optics.Create()

Creation PathBox in the QPath category.