States

States hold the quantum data. Perceval introduces a formalism to represent all kinds of quantum states.

Basic State

Basic states describe Fock states of \(n\) photons over \(m\) modes where photons can be annotated. If none is annotated, then all photons in the state are indistinguishable. It is represented by |n_1,n_2,...,n_m> notation where n_k is the number of photons in mode k.

Technichally, the BasicState initializer is implemented as a factory able to return any of the following types:

  • FockState: A light-weight object only containing photon positions in mode (e.g. |1,0,1>). Can be used to represent detections. It is an alias of exqalibur FockState.

  • NoisyFockState: A collection of indistinguishable photon groups, that are totally distinguishable. The distinguishability index is an integer and is referred to as the noise tag (e.g. |{0},{1},{0}{2}> contains three groups of indistinguishable photons tagged 0, 1 and 2). It is an alias of exqalibur NoisyFockState.

  • AnnotatedBasicState: Replace the previous FockState by allowing rich annotations, having one or more string types, each having a complex number for value. This enables to accurately encode physical parameters and play with partial distinguishability (e.g. |{P:H,lambda:0.625},{P:V,lambda:0.618}>). Please note that apart from polarisation, Perceval does not provide a generic algorithm to separate rich annotated states, and the user would have to write one. It is an alias of exqalibur AnnotatedFockState (see also: exqalibur.Annotation).

Simple code example with indistinguishable photons:

>>> import perceval as pcvl
>>>
>>> # Create a two-mode FockState with no photon in the 1st mode, and 1 photon in the 2nd mode.
>>> bs = pcvl.BasicState("|0,1>")
>>> print(bs)                          # Prints out the created Fock state
|0,1>
>>> bs.n                               # Displays the number of photons of the created Fock state
1
>>> bs.m                               # Displays the number of modes of the created Fock state
2
>>> bs[0]                              # Displays the number of photons in the first mode of the created Fock state ( note that the counter of the number of modes    starts at 0 and ends at m-1 for an m-mode Fock state)
0
>>> print(pcvl.BasicState([0,1])*pcvl.BasicState([2,3]))  # Tensors the |0,1> and |2,3> Fock states, and prints out the result (the Fock state |0,1,2,3>)
|0,1,2,3>

State Vector

StateVector represents a pure state. It is a (complex) linear combination of any of the FockState types to represent state superposition.

It is an alias of exqalibur StateVector class.

Basic State Samples

The class BSSamples is a container that collects chronologically ordered sampled states. It is, for instance, the object generated by a sampling method, such as samples command.

It is an alias of exqalibur BSSamples class and only stores perfect FockState.

Basic State Count

The class BSCount is also a container but it only counts the states without keeping in track their order. The sample_count command return this data type.

It is an alias of exqalibur BSCount class and only stores perfect FockState.

Basic State Distribution

The class BSDistribution represents a probability distribution of measured states. It maps states with their associated probability. It is the type of object returned by a probs command.

It is an alias of exqalibur BSDistribution class and only stores perfect FockState.

State Vector Distribution

SVDistribution is a recipe for constructing a mixed state using BasicState and/or StateVector as components.

For example, The following SVDistribution

state

probability

|0,1>

1/2

1/sqrt(2)*|1,0>+1/sqrt(2)*|0,1>

1/4

|1,0>

1/4

results in the mixed state \(\frac{1}{2}\ket{0,1}\bra{0,1} + \frac{1}{4}(\frac{1}{\sqrt{2}}\ket{1,0} + \frac{1}{\sqrt{2}}\ket{0,1})(\frac{1}{\sqrt{2}}\bra{1,0} + \frac{1}{\sqrt{2}}\bra{0,1}) + \frac{1}{4}\ket{1,0}\bra{1,0}\)

It is an alias of exqalibur SVDistribution class.

Warning

BSDistribution, SVDistribution and BSCount are NOT ordered data structures and must NOT be indexed with integers.

States generators

perceval.utils.states.allstate_iterator(input_state, mask=None)

Iterator on all possible output states compatible with mask generating StateVector

Parameters:
  • input_state (BasicState | StateVector) – a given input state vector

  • mask (xq.FSMask) – an optional mask

Return type:

Generator[xq.FockState]

Returns:

a single state in the Fock space of the input state. When all the space is covered, the iteration ends.

perceval.utils.states.max_photon_state_iterator(m, n_max)

Iterator on all possible output state on m modes with at most n_max photons

Parameters:
  • m (int) – number of modes

  • n_max (int) – maximum number of photons

Returns:

a single state containing from 0 to n_max photons. When all the space is covered, the iteration ends.