State and StateVector

class perceval.utils.statevector.AnnotatedBasicState(*args, **kwargs)

Deprecated in version 0.7.0. Use BasicState instead.

class perceval.utils.statevector.BSCount(d=None)
class perceval.utils.statevector.BSDistribution(d=None)
sample(count, non_null=True)

Samples basic states from the BSDistribution

Parameters

count (int) – number of samples to draw

Return type

BSSamples

Returns

a list of \(count\) samples

class perceval.utils.statevector.BSSamples(iterable=(), /)
class perceval.utils.statevector.BasicState(*args, **kwargs)

Basic states

partition(distribution_photons)

Given a distribution of photon, find all possible partition of the BasicState - disregard possible annotation

Parameters

distribution_photons (List[int]) –

Returns

separate_state(self: quandelibc.FockState) List[quandelibc.FockState]

separate a state into a list of states with indistinguishable photons

set_slice(self: quandelibc.FockState, arg0: slice, arg1: quandelibc.FockState) quandelibc.FockState
class perceval.utils.statevector.ProbabilityDistribution

Time-Independent abstract probabilistic distribution of states

class perceval.utils.statevector.SVDistribution(sv=None)

Time-Independent Probabilistic distribution of StateVectors

sample(count, non_null=True)

Generate a sample StateVector from the SVDistribution

Parameters
  • non_null (bool) – excludes null states from the sample generation

  • count (int) – number of samples to draw

Return type

List[StateVector]

Returns

a list of \(count\) samples

class perceval.utils.statevector.StateVector(bs=None, photon_annotations=None)

A StateVector is a (complex) linear combination of Basic States

measure(modes)

perform a measure on one or multiple modes and collapse the remaining statevector

Parameters

modes (Union[int, List[int]]) – the mode to measure

Return type

Dict[BasicState, Tuple[float, StateVector]]

Returns

a dictionary - key is the possible measures, values are pairs (probability, BasicState vector)

property n

list the possible values of n in the different states

normalize()

Normalize a non-normalized BasicState

sample()

Sample a single BasicState from the statevector. It does not perform a measure - so do not change the value of the statevector

Return type

BasicState

Returns

a BasicState

samples(shots)

Generate a list of samples. It does not perform a measure - so do not change the value of statevector. This function is more efficient than run :math:$shots$ times :method:sample

Parameters

shots (int) – the number of samples

Return type

List[BasicState]

Returns

a list of BasicState

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

Iterator on all possible output states compatible with mask generating StateVector

Parameters
Return type

BasicState

Returns

list of output_state

perceval.utils.statevector.convert_polarized_state(state, use_symbolic=False, inverse=False)

Convert a polarized BasicState into an expanded BasicState vector

Parameters
  • inverse (bool) –

  • use_symbolic (bool) –

  • state (BasicState) –

Return type

Tuple[BasicState, Matrix]

Returns

perceval.utils.statevector.tensorproduct(states)

Computes states[0] * states[1] * …