simulaqron.toolbox package

Submodules

simulaqron.toolbox.stabilizer_states module

class simulaqron.toolbox.stabilizer_states.StabilizerState(data=None, check_symplectic: bool = True)[source]

Bases: object

This class represent a stabilizer state and allows to be manipulated using Clifford operations and Pauli-measurements.

If check_symplectic=True then a check will be made that all stabilizers commute, by checking That the matrix is symplectic. Otherwise, no check is made.

Examples: A qubit in the state \(|0>\) can be created as StabilizerState([[0, 1]]).

A qubit in the state \(|1>\) can be created as StabilizerState([[0, 1, 1]]).

The entangled state \((|00> + |11>)/\sqrt(2)\) can be created as StabilizerState([[1, 1, 0, 0], [0, 0, 1, 1]]).

The entangled state \((|01> + |10>)/\sqrt(2)\) can be created as StabilizerState([[1, 1, 0, 0, 0], [0, 0, 1, 1, 1]]).

Parameters:
  • data

    Can be one of the following:

    • A binary array of rank 2 representing the generators of the stabilizer group. If the array is n-by-2n a stabilizer state on n qubits will be represented. The n first columns are the X-stabilizers and the n last the Z-stabilizer. If the array is n-by-(2n+1), the last column is seen as the phase for each generator as follows: 0 -> 1 1 -> -1

    • An array of rank 1 containing str: Then each string is assumed to be a generator as for example XXZIY Note that each string in the array should have the same length. If the number of strings is n then a stabilizer state on n qubits is created. If the strings have length n then it is assumed that the phase is +1. An explicit phase can be added to the start of the string as for example: -1XXXY. Creating a Bell-pair: StabilizerState(["XX", "ZZ"])  # The state (|00> + |11>) / sqrt(2)

    • None (default): Then this is seen as a stabilizer state on no qubits, i.e. a complex number. To add a qubit to such a state one can do: s = StabilizerState() s.add_qubit()  # This is now in the state |0>

    • int: Then a stabilizer state on this many qubits are created, all in the state \(|0>\) as: StabilizerState(5)  # This is the then the state |00000>

    • networkx.Graph: Then the graph state corresponding to this graph will be created. This assumes that the nodes are numbered from 0 to n - 1, where n is the number of nodes. For example: StabilizerState(networkx.complete_graph(5))  # Single qubit Clifford equiv. to a GHZ state

  • check_symplectic (bool) – Whether to check if all stabilizers commute or not.

Pauli2bool = {'I': (False, False), 'X': (True, False), 'Y': (True, True), 'Z': (False, True)}
static Pauli_phase_tracking(old_pauli, applied_pauli)[source]
add_qubit()[source]

Appends a qubit in the state |0> to the current state :return: None

apply_CNOT(control, target)[source]

Applies CNOT using qubit ‘control’ as control and ‘target’ as target. :param control: The control qubit :type control: int :param target: The target qubit :type control: int :return: None

apply_CZ(control, target)[source]

Applies CZ using qubit ‘control’ as control and ‘target’ as target. :param control: The control qubit :type control: int :param target: The target qubit :type control: int :return: None

apply_H(position)[source]

Applies the H operator to qubit ‘position’ of the stabilizer state and updates the generators. :param position: The position of the qubit. :type position: int :return: None

apply_K(position)[source]

Applies the K operator to qubit ‘position’ of the stabilizer state and updates the generators. :param position: The position of the qubit. :type position: int :return: None

apply_S(position)[source]

Applies the S operator to qubit ‘position’ of the stabilizer state and updates the generators. :param position: The position of the qubit. :type position: int :return: None

apply_X(position)[source]

Applies the Pauli X operator to qubit ‘position’ of the stabilizer state and updates the generators. :param position: The position of the qubit. :type position: int :return: None

apply_Y(position)[source]

Applies the Pauli Y operator to qubit ‘position’ of the stabilizer state and updates the generators. :param position: The position of the qubit. :type position: int :return: None

apply_Z(position)[source]

Applies the Pauli Z operator to qubit ‘position’ of the stabilizer state and updates the generators. :param position: The position of the qubit. :type position: int :return: None

apply_sqrt_IZ(position)[source]
apply_sqrt_minIX(position)[source]
bool2Pauli = {(False, False): 'I', (False, True): 'Z', (True, False): 'X', (True, True): 'Y'}
bool2phase = {False: '+1', True: '-1'}
static boolean_gaussian_elimination(matrix, return_pivot_columns=False)[source]

Given a boolean matrix returns the matrix in row reduced echelon form where entries are seen as elements of GF(2), i.e. intergers modulus 2.

Parameters:

matrix (numpy.array) – The boolean matrix

Returns:

Return type:

numpy.array

check_symplectic()[source]
contains(stabilizer)[source]

Checks if a given stabilizer is in the stabilizer group.

Args:

stabilizer (str or list): The stabilizer to check if it’s in the group.

Should either be a str of the form “XXX” or “+1XXX” or a boolean list of length 2*n or 2*n + 1 in the same way as the input to the __init__ of the class.

find_SQC_equiv_graph_state(return_operations=False)[source]

Finds a graph state single qubit Clifford equivalent to self. Method is described in quant-ph/0308151.

For example:

EPR_pair = [[1,1,0,0],[0,0,1,1]] S = StabilizerState(EPR_pair) G = find_SQC_equiv_graph_state(S)

Parameters:

self (StabilizerState) – The StabilizerState for which we want to find the corresponding graph state

Returns:

A networkx graph SQC equivalent to S

Return type:

networkx.classes.graph.Graph

measure(position, inplace=False)[source]

Measures qubit ‘position’ of the stabilizer state in the standard basis. If ‘inplace=False’ the qubit is removed from the state, i.e. the number of qubits in the state is reduced by one If ‘inplace=True’ the qubit is not removed and the number of qubits remain the same. :param position: The position of the qubit. :type position: int :param inplace: Whether to measure the qubit in place or not. (I.e. to keep it or not) :type inplace: bool :return: The measurement outcome (0 or 1, where 0 is the +1 eigenvalue and 1 is the -1) :rtype: int

property num_qubits
phase2bool = {'+1': False, '-1': True}
put_in_standard_form()[source]

Puts the generators of the stabilizer group in standard form by performing Gaussiand elemination :return: None

tensor_product(other)[source]

Performs the tensor product with another StabilizerState and returns a new StabilizerState.

This can also be done using ‘*’ as for example:

s1 = StabilizerState([[0, 1]]) # The state |0> s2 = StabilizerState([[0, 1]]) # The state |0>

s3 = s1 * s2 # This is then the state |00>

Parameters:

other (StabilizerState) – The other StabilizerState to perform the tensor product with

Returns:

The tensor product of self and other

Return type:

StabilizerState

to_array(standard_form=False, return_pivot_columns=False)[source]

Returns the numpy array representing the stabilizer group of this state. See doc-string for __init__ how the elements of this numpy array are treated. Since, the __init__ takes an array as input, given a StabilizerState ‘s1’ on can do:

s2 = StabilizerState(to_array(s1))

and ‘s1’ and ‘s2’ will represent the same state.

Returns:

The generators of this stabilizer group as a numpy array

Return type:

numpy.array

to_string()[source]

Module contents