Gates Class

The gate class is the main interaction class for users of EQSN. From this class, qubits can be created, measured, and gates can be applied.

class eqsn.gates.EQSN

Main object of EQSN, with this object, all of the Qubits can be controlled. All functions are threadsafe, but at the moment, only one instance should be used.

H_gate(q_id)

Applies the Hadamard gate to the Qubit with q_id.

Parameters

q_id (String) – ID of the Qubit to apply the gate to.

K_gate(q_id)

Applies the K gate to the Qubit with q_id.

Parameters

q_id (String) – ID of the Qubit to apply the gate to.

RX_gate(q_id, rad)

Applies a rotational X gate to the Qubit with q_id.

Parameters
  • q_id (String) – ID of the Qubit to apply the gate to.

  • rad (int) – Rotational degrees in rad.

RY_gate(q_id, rad)

Applies a rotational Y gate to the Qubit with q_id.

Parameters
  • q_id (String) – ID of the Qubit to apply the gate to.

  • rad (int) – Rotational degrees in rad.

RZ_gate(q_id, rad)

Applies a rotational Z gate to the Qubit with q_id.

Parameters
  • q_id (String) – ID of the Qubit to apply the gate to.

  • rad (int) – Rotational degrees in rad.

S_gate(q_id)

Applies the S gate to the Qubit with q_id.

Parameters

q_id (String) – ID of the Qubit to apply the gate to.

T_gate(q_id)

Applies the T gate to the Qubit with q_id.

Parameters

q_id (String) – ID of the Qubit to apply the gate to.

X_gate(q_id)

Applies the Pauli X gate to the Qubit with q_id.

Parameters

q_id (String) – ID of the Qubit to apply the gate to.

Y_gate(q_id)

Applies the Pauli Y gate to the Qubit with q_id.

Parameters

q_id (String) – ID of the Qubit to apply the gate to.

Z_gate(q_id)

Applies the Pauli Z gate to the Qubit with q_id.

Parameters

q_id (String) – ID of the Qubit to apply the gate to.

cnot_gate(applied_to_id, controlled_by_id)

Applies a controlled X gate, where the gate is applied to q_id1 and controlled by q_id2.

Parameters
  • applied_to_id (String) – Id of the Qubit on which the X gate is applied.

  • controlled_by_id (String) – Id of the Qubit which controls the gate.

cphase_gate(applied_to_id, controlled_by_id)

Applies a controlled Z gate, where the gate is applied to q_id1 and controlled by q_id2.

Parameters
  • applied_to_id (String) – Id of the Qubit on which the X gate is applied.

  • controlled_by_id (String) – Id of the Qubit which controls the gate.

custom_controlled_gate(applied_to_id, controlled_by_id, gate)

Applies a custom controlled gate to a Qubit.

Parameters
  • applied_to_id (String) – ID of the qubit to apply the gate to.

  • controlled_by_id (String) – ID of the qubit which controls the gate.

  • gate (np.ndarray) – Unitary 2x2 matrix which should be applied.

custom_gate(q_id, gate)

Applies a custom gate to the qubit with q_id.

Parameters
  • q_id (String) – Id of the Qubit to apply the gate on.

  • gate (np.ndarray) – unitary 2x2 matrix, of the gate.

custom_two_qubit_gate(q_id1, q_id2, gate)

Applies a two Qubit gate to two Qubits.

Parameters
  • q_id1 (String) – ID of the first Qubit of the gate.

  • q_id2 (String) – ID of the second Qubit of the gate.

  • gate (np.ndarray) – 4x4 unitary matrix gate.

give_statevector_for(q_id)

Gives the statevector and Qubits of a Qubit and all other Qubits with which the qubit is entangled.

Parameters

q_id (String) – Qubit id of the Qubit to get the statevector from.

Returns

Tuple. Tuple of a lists and vector, where the first list are the qubits of the statevector and the second list is the statevector.

measure(q_id, non_destructive=False)

Measures a qubit with an id. If non_destructive is False, the qubit is removed from the system, otherwise, the qubit stays in the system after measurement, but its wavefunction collapses.

Parameters
  • id (String) – Id of the Qubit which should be measured.

  • non_destructive (bool) – If a qubit should not be removed from the system after measurement.

merge_qubits(q_id1, q_id2)

Merges two qubits to one process, if they are not already running in the same process.

Parameters
  • q_id1 (String) – Id of the Qubit merged into q_id2.

  • q_id2 (String) – Id of the Qubit merged with q_id1.

new_qubit(q_id)

Creates a new qubit with an id.

Parameters

q_id (String) – Id of the new qubit.

stop_all()

Stops the simulator from running.