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
- group_modes_simplification(group_size)
Simplify this BSDistribution by grouping modes (ex: |1,3,0,0> -> |4,0> if group_size=2) These “coarse grain” simplification methods can be used to decrease the number of components of a given distribution.
- Parameters:
group_size (
int
) – the size of the groups of modes- Return type:
- Returns:
the simplified distribution
- static list_tensor_product(distributions, merge_modes=False, prob_threshold=0)
- Return type:
- Efficient tensor product for a list of BasicState Distribution.
Can modify the distributions in place if merge_modes is False by adding empty modes. Performs len(distributions) - 1 tensor products
- photon_threshold_simplification(photon_threshold)
Simplify this BSDistribution with a photon threshold for each mode (ex: |0,3,0,0> -> |0,1,0,0> if photon_threshold=1) These “coarse grain” simplification methods can be used to decrease the number of components of a given distribution.
- Parameters:
photon_threshold (
int
) – the maximum number of photons per mode- Return type:
- Returns:
the simplified distribution
- sample(count, non_null=True)
Samples basic states from the BSDistribution
- Parameters:
count (
int
) – number of samples to drawnon_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:
- 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
- static list_tensor_product(distributions, prob_threshold=0)
Efficient tensor product for a list of distributions
- Return type:
- sample(count, non_null=True)
Generate a sample StateVector from the SVDistribution
- Parameters:
non_null (
bool
) – excludes null states from the sample generationcount (
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:
- 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.filter_distribution_photon_count(bsd, min_photons_filter)
Filter the states of a BSDistribution to keep only those having state.n >= min_photons_filter
- Parameters:
bsd (
BSDistribution
) – the BSDistribution to filter outmin_photons_filter (
int
) – the minimum number of photons required to keep a state
- Return type:
tuple
[BSDistribution
,float
]- Returns:
a tuple containing the normalized filtered BSDistribution and the probability that the state is kept
- 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 modesn_max (
int
) – maximum number of photons
- Returns:
list of BasicState
- perceval.utils.statevector.tensorproduct(states)
Computes states[0] * states[1] * …
- Return type:
StateVector | BasicState