FSMask
- class exqalibur.FSMask
FSMask
handles a list of simple conditions to assert if any given state should be masked or not.- Parameters:
m – Number of modes the mask applies to
n – Number of expected photons in the state
conditions –
Optional list of conditions expressed as strings Each character of a condition represents a mode.
If a character is an integer, it represents the number of expected photon in the mode
If it’s a space “ “ and a star “*”, it means that any value would fit
For instance, “10*” means 1 photon is expected in the 1st mode, 0 in the 2nd mode, and any number is accepted in the 3rd mode. Having several conditions acts as a “or” : the mask matches if any of the conditions match.
- match(self: exqalibur.FSMask, fs: exqalibur.FockState, allow_missing: bool = True) bool
Check a if a given Fock state matches the mask
>>> import exqalibur as xq >>> mask = xq.FSMask(3, 2, ["101"]) >>> print(mask.match(xq.FockState([1, 0, 1])), >>> mask.match(xq.FockState([1, 0, 0]), allow_missing=False), >>> mask.match(xq.FockState([1, 0, 0]))) True False True
- Parameters:
fs – Fock state to check
allow_missing – If
True
, the number of photon in the condition is the maximum allowed photons. The check is otherwise strict. Default isTrue
.
- Returns:
True
if the Fock state matches any of the conditions in the list,False
otherwise.
FSArray
- class exqalibur.FSArray
FsArray
allows to iterate on the Fock space of any given size. It will yield every element only once, in Perceval natural order (some results are returned in this order). When masked, it will only iterate over matching elements; this can be useful in some computations to save some time and memory.>>> import exqalibur as xq >>> mask = xq.FSMask(3, 3, ["1**"]) >>> for state in xq.FSArray(3, 3, mask): >>> print(state) |1,2,0> |1,1,1> |1,0,2>
- Parameters:
m – Number of optical modes in the Fock space
n – Number of photons
mask – Optional
FsMask
to hide part of the Fock space
- count(self: exqalibur.FSArray) int
Return the size of the represented Fock space.
- Returns:
The number of elements in the array
- find(self: exqalibur.FSArray, fs: exqalibur.FockState) int
Find index of a state in Perceval natural order.
- Parameters:
fs – A Fock state
- Returns:
The index of the Fock state
- generate(self: exqalibur.FSArray) None
Create a contiguous buffer containing all Fock states in the represented space.
- norm_coefs(self: exqalibur.FSArray, arg0: Annotated[numpy.typing.NDArray[numpy.complex128], '[m, n]', 'flags.writeable', 'flags.c_contiguous']) None
Normalise a vector of complex values with coefficients being the square root of the product of factorials of the photon count in each mode of represented states.
For instance, if the FsArray iterates over |3,0>, |2,1> and |0,3>, this call would normalise a 3 elements vector with the coefficients sqrt(3!*0!) = sqrt(6), sqrt(2!*1!) = sqrt(2) and sqrt(0!*3!) = sqrt(6).
- size(self: exqalibur.FSArray) int
Return the size in memory the array uses after generating all states.
- Returns:
The size in bytes