You're reading the documentation of the v0.8. For the latest released version, please have a look at v0.11.

State and StateVector

class perceval.utils.statevector.BSCount(d=None)

Container that counts basic state events

class perceval.utils.statevector.BSDistribution(d=None)

Time-Independent probabilistic distribution of Basic States

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

static tensor_product(bsd1, bsd2, merge_modes=False, prob_threshold=0)

Compute the tensor product of two BasicState Distribution

class perceval.utils.statevector.BSSamples(iterable=(), /)

Container that stores samples in a time ordered way

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

static tensor_product(svd1, svd2, prob_threshold=0)

Compute the tensor product of two SVDistribution with an optional probability threshold

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

Iterator on all possible output states compatible with mask generating StateVector

Parameters:
  • input_state (Union[FockState, StateVector]) – a given input state vector

  • mask – an optional mask

Return type:

FockState

Returns:

list of output_state

perceval.utils.statevector.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:

list of BasicState

perceval.utils.statevector.tensorproduct(states)

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