Files

stabilizer_project.stabilizer

Contains the classes and function to manipulate stabilizer and graph states

API Documentation

stabilizer_project.grapher(edgelist)[source]

Function that can graph a graph state provided an edgelist

Parameters

edgelistlist

A list that denotes all the connections inp a graph state. The edgelist is a nested list, with each inner list containing two elements, the numbers of the qubits that are connected.

Returns

circuitQuantumCircuit

A Qiskit quantum circuit that encodes the circuit that generates that graph

class stabilizer_project.Stabilizer(n=None, stabs=None, edgelist=None)[source]

This is a class that encodes the stabilizer state in terms of its stabilizers. If no input is given, it will initialize a bell state. If only the n is given, it will initialize n qubits in the 0 state

Parameters:
  • n (int, Optional) – Number of qubits

  • stabs (list or string, optional) – The stabilizers, either in a string or a list, in the format ‘XX,-YY’ or ‘[XX,-YY]’ (case sensitive). Optional

  • edgelist (List) – A list of edges for a graph state. Optional

Variables:
  • size – The number of qubits, initial value: n

  • __stabs – The stabilizers of the state, initial value: stabs (note, this is a dunder attribute, can’t be directly called outside the class. There’s a method to do that instead)

  • tab – The tableau of the state

  • signvector – The signvector of the state

  • gauss – A nxn Gaussian matrix (used for empty_column calculations)

build_and_measure()[source]

A circuit to implement the circuit and then to measure the associated stabilizers.

Returns:

A qiskit circuit for measureing stabilizer

Return type:

QuantumCircuit

circuit_builder()[source]

Uses reverse operations to build the stabilizer state

Returns:

A Qiskit circuit that makes the stabilizer

Return type:

QuantumCircuit

clifford(type, q1, q2=None)[source]

Applies a clifford gate to the stabilizer

Parameters:
  • type (string) – The clifford gate to be operated, ‘H’, ‘X’, ‘Y’, ‘Z’, ‘CNOT’, ‘CZ’, or ‘S’

  • q1 (int) – The qubit to operate on, or the control qubit for entangling gates

  • q2 (int) – The qubit to target, defaults to None

commuter()[source]

Tests whether the stabilizers commute with each other

Returns:

Whether or not they commute

Return type:

boolean

draw_circuit(style='mpl', save=None)[source]

Draws a circuit that can generate the given stabilizer state (requires matplotlib and pylatexenc package)

Parameters:
  • style (String, optional. Defaults to 'mpl') – The type of output, ‘mpl’ for matplotlib, ‘text’ for ASCII drawing, ‘latex_source’ for raw latex output

  • save (String) – If you want to save the file to something (optional)

empty_column()[source]

Tests whether there are any empty stabilizers (free qubits)

Returns:

Whether there is an empty column or not

Return type:

boolean

flip()[source]

Flips the tableau over

gaussian()[source]

Generates an array that contains information about where stabilizers are known

graph_state(edgelist=[[0, 1], [1, 2], [2, 3], [3, 4], [4, 0]])[source]

Generates a graph state based on inputed edgelist

Parameters:

edgelist (Nested list) – The list of connections, defaults to [[0,1],[1,2],[2,3],[3,4],[4,0]]

linear_independence()[source]

Checks if the generators are linearly independent

new_stab(size=None, newstabs=None)[source]

Resets the stabilizer and new tableau associated with it

Parameters:
  • size (int (optional)) – The size of the new state

  • newstabs (string or list) – The new stabilizers

num_qubits()[source]

Returns the size of the stabilizer (the number of qubits)

Returns:

The size of the stabilizer

Return type:

int

qiskit_stabilizers()[source]

Asks Qiskit to return the stabilizers

Returns:

A qiskit stabilizer state representation

Return type:

StabilizerState (qiskit)

report()[source]

Prints the tableau and the signvector

row_add(row1, row2)[source]

Multiplies two stabilizers in the tableau together, specifying a new stabilizer, and puts them into the second row

stabilizer_measurement()[source]

A circuit t-o measure the associated stabilizers of this state

Returns:

A qiskit circuit for measureing stabilizer

Return type:

QuantumCircuit

stabilizers()[source]

Returns a list of the stabilizers of the state, as per the tableau

Returns:

A list of operations to take a standard state to the given stabilizer state

Return type:

list

swap(row1, row2)[source]

Swaps two rows in the stabilizer

Parameters:
  • r1 – The first row

  • r2 – The second row

tableau()[source]

Converts the stabilizers to a tableau and signvector

Returns:

A list contained the tableau and the signvector

Return type:

list