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

State and StateVector

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

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

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

Return type:

BSDistribution

class perceval.utils.statevector.ProbabilityDistribution

Time-Independent abstract probabilistic distribution of states

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

Mixed state represented as a 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

Return type:

SVDistribution

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

BasicState

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] * …

Return type:

StateVector | BasicState