AnyonicCircuit Class

class tqsim.AnyonicCircuit(nb_qudits: int = 1, nb_anyons_per_qudit: int = 3)[source]

This class represents an anyon-based topological quantum circuit. Such a circuit is described by the number of qudits it contains, and the number of anyons each qudit contains.

Parameters:
  • nb_qudits (int, optional) – Number of qudits in the circuit. The default is 1.

  • nb_anyons_per_qudit (int, optional) – Number of anyons in each qudit. The default is 3.

Examples

Here is an example of how to create a circuit with 2 qudits and 3 anyons per qudits. The circuit has a total of 6 anyons (2 * 3).

>>> circuit = AnyonicCircuit(nb_qudits=2, nb_anyons_per_qudit=3)
property basis

Returns a list of all the basis states for the circuit.

Returns:

List of all the basis states.

Return type:

List

braid(n: int, m: int)[source]

Braids the two anyons at positions ‘n’ and ‘m’. If n < m, they are braided in a clockwise direction, if n > m, they are braided in a counterclockwise direction.

Parameters:
  • n (int) – The 1st anyon’s position.

  • m (int) – The 2nd anyon’s position.

Raises:
  • Exception – Exceptions are raised if a braiding is attempted after a measurement, or if trying to braid two non-adjacent anyons.

  • ValueError – Is raised if the parameters are not strictly positive integers, or if incorrect positions are passed.

Returns:

A reference to the same circuit.

Return type:

AnyonicCircuit

braid_sequence(braid: Sequence[Sequence[int]])[source]

Takes a sequence of [index of the sigma operator, power], and applies the successive operators to the ‘power’. The first operator in the sequence is the first to be applied.

Parameters:

braid (Sequence[Sequence[int]]) – A sequence of pairs of integers representing a braiding operator and an exponent.

Raises:

ValueError – Is raised if one of the operators’ indices is not an integer greater or equal to 1, or is an incorrect index.

Returns:

A reference to the same circuit.

Return type:

AnyonicCircuit

property braiding_operators

Returns a list of all the braiding operators.

Returns:

List of all the braiding operators.

Return type:

List

property dim: int

Returns the dimension of the fusion space.

Returns:

Dimension of the fusion space.

Return type:

int

draw() Figure[source]

Draws the topological quantum circuit.

Returns:

The braid describing the topological quantum circuit.

Return type:

Figure

property drawer: Drawer

Returns the drawer object for the circuit.

Returns:

The circuit’s drawer object.

Return type:

Drawer

history(output: str = 'raw')[source]

Returns the history of all braiding operations that were performed in the circuit. Its output can either be the raw braiding operations (n, m), a list of braiding operators (sigmas), or a LaTeX string containing the product of all the braiding operators.

Parameters:

output (str, optional) – Can either be “raw”, “sigmas”, or “latex”. The default is “raw”.

Raises:

ValueError – Is raised if an incorrect output format is chosen.

Returns:

Either a list of (n, m) operations, a list of braiding operators, or a LaTeX string.

Return type:

List or String

initialize(input_state: ndarray)[source]

Initializes the circuit in the state input_state.

Parameters:

input_state (np.ndarray) – A normalized quantum state with the same dimensions as the fusion space.

Raises:
  • Exception – Will be raised if an initialization is attempted after performing braiding operations.

  • ValueError – Will be raised if the input state has the wrong dimension or is not normalized.

Returns:

A reference to the same circuit.

Return type:

AnyonicCircuit

measure()[source]

Performs a measurement on the whole circuit.

Raises:

Exception – Is raised if a measurement has already been carried.

Returns:

A reference to the same circuit.

Return type:

AnyonicCircuit

property nb_anyons_per_qudits: int

Returns the number of anyons for each qudit in the circuit.

Returns:

Number of anyons per qudit.

Return type:

int

property nb_qudits: int

Returns the number of qudits in the circuit.

Returns:

Number of qudits.

Return type:

int

run(shots: int = 1000)[source]

Simulates the quantum circuit for ‘shots’ number of times and returns the measurement results.

Parameters:

shots (int, optional) – Number of times the circuit is simulated. The default is 1000.

Raises:

Exception – Is raised if the circuit is run without a measurement.

Returns:

Contains the number of measurements for each measured state.

Return type:

dict

statevector() ndarray[source]

Computes and returns the current state vector of the circuit.

Returns:

The state vector of the circuit.

Return type:

ndarray

unitary() ndarray[source]

Returns the unitary representation of the quantum circuit.

Returns:

The unitary matrix for the circuit.

Return type:

ndarray