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]
add_feed_forward_config(*args, **kwargs)

Overloaded function.

  1. add_feed_forward_config(self: exqalibur.SLAP, cfg_map: exqalibur.ConfiguratorMap) -> None

Add a feed-forward configurator to use in the SLAP backend. Configurators are applied in the order they are given. This method can also take a tuple (Matrix, int) where the Matrix is one component’s unitary and the int is the first mode of this component in the circuit.

The first unitary must already be set before using this.

Parameters:

cfg_map – A ConfiguratorMap or a tuple (Matrix, int)

  1. add_feed_forward_config(self: exqalibur.SLAP, cfg_map: tuple[typing.Annotated[numpy.typing.ArrayLike, numpy.complex128, “[m, n]”], typing.SupportsInt]) -> None

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_feed_forward(self: exqalibur.SLAP) None

Clears any pre-existing feed-forward information.

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