SLAP

SLAP (Simulator of LAttice of Polynomials) is a strong simulation back-end. The exqalibur C++ class is highly optimised and wrapped in a Python class exposing the same API as other strong simulation back-ends (see SLAPBackend)

class exqalibur.SLAP

SLAP is a strong simulation back-end able to compute all probability amplitudes at once efficiently.

Usage example:

>>> import exqalibur as xq
>>> import numpy as np
>>> slap = xq.SLAP()
>>> slap.set_unitary(np.array([[1, 1j], [1j, 1]]) * 0.7071068)
>>> print(slap.all_prob_ampli(xq.FockState([1, 1])))
[0.707106818813453j, 0j, 0.707106818813453j]
all_prob(self: exqalibur.SLAP, input_state: exqalibur.FockState) list[float]

Compute the probabilities for all possible output states

Parameters:

input_state – A perfect input state, which size matches the unitary matrix’s

Returns:

A vector of probabilities (real), ordered in Perceval natural Fock space order (see FSArray)

all_prob_ampli(self: exqalibur.SLAP, input_state: exqalibur.FockState) list[complex]

Compute the probability amplitudes for all possible output states

Parameters:

input_state – A perfect input state, which size matches the unitary matrix’s

Returns:

A vector of amplitudes (complex), ordered in Perceval natural Fock space order (see FSArray)

prob_distribution(self: exqalibur.SLAP, input_state: exqalibur.FockState) BasicStateDistribution

Compute the probability distribution from the unitary circuit and the input state

Parameters:

input_state – A perfect input state, which size matches the unitary matrix’s

Returns:

The output BSDistribution

reset_mask(self: exqalibur.SLAP) None

Clears any pre-existing mask.

set_mask(self: exqalibur.SLAP, mask: exqalibur.FSMask) None

Set a mask to discard part of the Fock space. This saves time and memory during a simulation.

Parameters:

mask – A FSMask instance

set_unitary(self: exqalibur.SLAP, u: Annotated[numpy.typing.ArrayLike, numpy.complex128, '[m, n]']) None

Set the unitary matrix of a linear optics circuit

Parameters:

u – The unitary matrix