FSFunction
- class exqalibur.FSFunction
Fock state function holding measured states (i.e. perfect Fock states), of the same size (number of modes).
The
FSFunctioncan be build via any of the following parameters:- Parameters:
fsf – (optional) build from an existing dictionary or FSFunction. Keys have to be perfect Fock states.
fsa – (optional) a FSArray requiring a same size values vector
probs – (optional) the values vector working with parameter fsa
- items(self: exqalibur.exqalibur.FSFunction) collections.abc.Iterator[tuple[exqalibur.exqalibur.FockState, float]]
Iterate over tuples of (Fock states, probability) contained in the distribution
- keys(self: exqalibur.exqalibur.FSFunction) collections.abc.Iterator[exqalibur.exqalibur.FockState]
Iterate over Fock states contained in the distribution
- static list_tensor_product(distributions: collections.abc.Sequence[exqalibur.exqalibur.FSFunction], merge_modes: bool = False, prob_threshold: SupportsFloat = 0.0) exqalibur.exqalibur.FSFunction
Compute a series of tensor product between distributions
- Parameters:
distributions – List of distributions
merge_modes – If
True, resulting states will merge their modes (both distribution must contain states of the same size). Apply a standard tensor product otherwise (defaults toFalse)prob_threshold – Threshold under which probabilities are discarded during the tensor product (defaults to
0., i.e. no probability is discarded).
- Returns:
The result of the tensor product
- property m
- Returns:
The number of modes of all states in the distribution
- move_to_distribution(self: exqalibur.exqalibur.FSFunction) exqalibur.exqalibur.FSDistribution
transform into a normalized FSDistribution - the current FSDistribution is cleared
- static tensor_product(bsd1: exqalibur.exqalibur.FSFunction, bsd2: exqalibur.exqalibur.FSFunction, merge_modes: bool = False, prob_threshold: SupportsFloat = 0.0) exqalibur.exqalibur.FSFunction
Compute the tensor product of two distributions
- Parameters:
bsd1 – Left hand-side distribution
bsd2 – Right hand-side distribution
merge_modes – If
True, resulting states will merge their modes (both distribution must contain states of the same size). Apply a standard tensor product otherwise (defaults toFalse)prob_threshold – Threshold under which probabilities are discarded during the tensor product (defaults to
0., i.e. no probability is discarded).
- Returns:
The result of the tensor product
- to_distribution(self: exqalibur.exqalibur.FSFunction) exqalibur.exqalibur.FSDistribution
normalize and returns a FSDistribution
- trim(self: exqalibur.exqalibur.FSFunction, threshold: SupportsFloat) None
Remove all entries for which
abs(value)is belowthreshold.- Threshold:
threshold
- values(self: exqalibur.exqalibur.FSFunction) collections.abc.Iterator[float]
Iterate over the probabilities contained in the distribution
FSDistribution
- class exqalibur.FSDistribution
Fock state distribution holding measured states (i.e. perfect Fock states), of the same size (number of modes). Negative values are discarded, then the distribution is normalized. The class is then immutable, it can be moved into a FSFunction to allow modifications.
The
FSDistributioncan be build via any of the following parameters:- Parameters:
fs – (optional) build from a single state which gets a probability of 1.
fsd – (optional) build from an existing dictionary or distribution. Keys have to be perfect Fock states.
fsa – (optional) a FSArray requiring a same size probability vector
probs – (optional) the probability vector working with parameter fsa
- group_modes_simplification(self: exqalibur.exqalibur.FSDistribution, group_size: SupportsInt) exqalibur.exqalibur.FSDistribution
Group modes by merging their contents in shorter states within the whole distribution.
This call can be used to perform coarse grain comparison between two very large distributions
- Parameters:
group_size – Size of mode groups to consider (e.g. if 2, |1,1,3,4> gives |2,7>)
- Returns:
The resulting distribution
- items(self: exqalibur.exqalibur.FSDistribution) collections.abc.Iterator[tuple[exqalibur.exqalibur.FockState, float]]
Iterate over tuples of (Fock states, probability) contained in the distribution
- keys(self: exqalibur.exqalibur.FSDistribution) collections.abc.Iterator[exqalibur.exqalibur.FockState]
Iterate over Fock states contained in the distribution
- static list_tensor_product(distributions: collections.abc.Sequence[exqalibur.exqalibur.FSDistribution], merge_modes: bool = False, prob_threshold: SupportsFloat = 0.0) exqalibur.exqalibur.FSDistribution
Compute a series of tensor product between distributions
- Parameters:
distributions – List of distributions
merge_modes – If
True, resulting states will merge their modes (both distribution must contain states of the same size). Apply a standard tensor product otherwise (defaults toFalse)prob_threshold – Threshold under which probabilities are discarded during the tensor product (defaults to
0., i.e. no probability is discarded).
- Returns:
The result of the tensor product
- property m
- Returns:
The number of modes of all states in the distribution
- move_to_function(self: exqalibur.exqalibur.FSDistribution) FockSpaceFunction
transfer into an editable FSFunction - the current FSDistribution is cleared
- photon_threshold_simplification(self: exqalibur.exqalibur.FSDistribution, photon_threshold: SupportsInt) exqalibur.exqalibur.FSDistribution
Applies a maximum photon per mode threshold to all states in the distribution.
- Parameters:
photon_threshold – Max number of photons allowed per mode. Any bigger value will be changed to
photon_threshold- Returns:
The thresholded distribution
- sample(self: exqalibur.exqalibur.FSDistribution, count: SupportsInt, non_null: bool = True) exqalibur.exqalibur.BSSamples
Generate an ordered list of samples from the distribution.
- Parameters:
count – Number of expected samples
non_null – If
Trueavoids returning in void state (i.e. state containing 0 photon). Defaults toTrue.
- Returns:
A list of samples following the probability distribution
- static tensor_product(bsd1: exqalibur.exqalibur.FSDistribution, bsd2: exqalibur.exqalibur.FSDistribution, merge_modes: bool = False, prob_threshold: SupportsFloat = 0.0) exqalibur.exqalibur.FSDistribution
Compute the tensor product of two distributions
- Parameters:
bsd1 – Left hand-side distribution
bsd2 – Right hand-side distribution
merge_modes – If
True, resulting states will merge their modes (both distribution must contain states of the same size). Apply a standard tensor product otherwise (defaults toFalse)prob_threshold – Threshold under which probabilities are discarded during the tensor product (defaults to
0., i.e. no probability is discarded).
- Returns:
The result of the tensor product
- to_function(self: exqalibur.exqalibur.FSDistribution) FockSpaceFunction
convert to an editable FSFunction
- trim(self: exqalibur.exqalibur.FSDistribution, threshold: SupportsFloat) None
Remove all entries for which
abs(value)is belowthreshold.- Threshold:
threshold
- trim_relative(self: exqalibur.exqalibur.FSDistribution, relative_threshold: SupportsFloat) None
Remove all entries whose value is below
relative_threshold * max_proba, wheremax_probais the current maximal value in the distribution. Then the distribution is normalized again.- Relative_threshold:
threshold
- values(self: exqalibur.exqalibur.FSDistribution) collections.abc.Iterator[float]
Iterate over the probabilities contained in the distribution
BSCount
- class exqalibur.BSCount
Measured sample count data structure. For given states, holds a positive number of occurrence.
- Parameters:
bscount – (optional) can be initialised from another
BSCountor a dictionary in which all keys are of typeFockStateand all values are positive integers
- add(self: exqalibur.exqalibur.BSCount, fs: exqalibur.exqalibur.FockState, value: SupportsInt) None
Increment the count of a given state. Zeroes are discarded.
- Parameters:
fs – Fock state
value – Count to add
- items(self: exqalibur.exqalibur.BSCount) exqalibur.exqalibur.ItemsView
- keys(self: exqalibur.exqalibur.BSCount) exqalibur.exqalibur.KeysView
- total(self: exqalibur.exqalibur.BSCount) int
Compute the total number of samples.
- Returns:
the sum of occurrence of all contained states
- values(self: exqalibur.exqalibur.BSCount) exqalibur.exqalibur.ValuesView
BSSamples
- class exqalibur.BSSamples
Measured samples ordered container, suited to save a sample stream data acquisition.
It basically acts like a list.
- append(self: exqalibur.exqalibur.BSSamples, x: exqalibur.exqalibur.FockState) None
Add an item to the end of the list
- clear(self: exqalibur.exqalibur.BSSamples) None
Clear the contents
- count(self: exqalibur.exqalibur.BSSamples, x: exqalibur.exqalibur.FockState) int
Return the number of times
xappears in the list
- extend(*args, **kwargs)
Overloaded function.
extend(self: exqalibur.exqalibur.BSSamples, L: exqalibur.exqalibur.BSSamples) -> None
Extend the list by appending all the items in the given list
extend(self: exqalibur.exqalibur.BSSamples, L: collections.abc.Iterable) -> None
Extend the list by appending all the items in the given list
- insert(self: exqalibur.exqalibur.BSSamples, i: SupportsInt, x: exqalibur.exqalibur.FockState) None
Insert an item at a given position.
- pop(*args, **kwargs)
Overloaded function.
pop(self: exqalibur.exqalibur.BSSamples) -> exqalibur.exqalibur.FockState
Remove and return the last item
pop(self: exqalibur.exqalibur.BSSamples, i: typing.SupportsInt) -> exqalibur.exqalibur.FockState
Remove and return the item at index
i
- remove(self: exqalibur.exqalibur.BSSamples, x: exqalibur.exqalibur.FockState) None
Remove the first item from the list whose value is x. It is an error if there is no such item.