tangelo.linq.helpers.circuits package

Subpackages

Submodules

tangelo.linq.helpers.circuits.clifford_circuits module

tangelo.linq.helpers.circuits.clifford_circuits.decompose_gate_to_cliffords(gate, abs_tol=0.0001)

Decomposes a single qubit parameterized gate into Clifford gates.

Parameters:
  • gate (Gate) – The gate to be decomposed.

  • abs_tol (float) – Optional, absolute tolerance for value comparison (default: 1e-4).

Returns:

list – A list of Clifford gates representing the decomposition.

Raises:

ValueError – If parameterized gate cannot be decomposed into Clifford gates.

tangelo.linq.helpers.circuits.measurement_basis module

Helper function: pauli word rotations.

tangelo.linq.helpers.circuits.measurement_basis.get_compatible_bases(op, basis_list)

Return a list of measurement bases compatible with the given operator.

Parameters:
  • op (str) – Pauli string representing the operator to be measured

  • basis_list (list) – List of Pauli strings for the measurement bases to be checked

Returns:

list – List of measurement bases compatible with the operator

tangelo.linq.helpers.circuits.measurement_basis.measurement_basis_gates(term)

Generate the rotation gates to perform change of basis before measurement.

Parameters:

term – Openfermion-style term. Essentially a list of (int, str) tuples.

Returns:

list of Gate – A list containing the rotation gates.

tangelo.linq.helpers.circuits.measurement_basis.pauli_of_to_string(pauli_op, n_qubits)

Converts an Openfermion-style Pauli word to a string representation. The user must specify the total number of qubits.

tangelo.linq.helpers.circuits.measurement_basis.pauli_string_to_of(pauli_string)

Converts a string of I,X,Y,Z Pauli operators to an Openfermion-style representation.

tangelo.linq.helpers.circuits.statevector module

This module defines a class that can be used to generate the circuit that returns or uncomputes a given statevector (takes the given statevector to the zero state).

class tangelo.linq.helpers.circuits.statevector.StateVector(coefficients, order='msq_first')

Bases: object

This class provides functions to either compute a statevector (of 2**n_qubits) from the zero state or take that state to the zero state

Parameters:

coefficients – The list or array of coefficients defining a state. Must have length 2**n_qubits where n_qubits is an integer.

initializing_circuit(return_phase=False, set_n_qubits=False)

Calculate a circuit that implements the initialization of a given statevector from the zero state Implements a recursive initialization algorithm, including optimizations, from “Synthesis of Quantum Logic Circuits” Shende, Bullock, Markov https://arxiv.org/abs/quant-ph/0406176v5 Additionally implements some extra optimizations: remove zero rotations and double cnots.

Parameters:
  • return_phase (bool) – Return the global phase that is not captured by the circuit Default False

  • set_n_qubits (bool) – Set n_qubits in Circuit to qubits needed for the length of the coefficients array.

Returns:
  • Circuit – The circuit that generates the statevector defined in coeffs

  • float – Optional, If return_phase=True, the global phase angle not captured by the Circuit

uncomputing_circuit(return_phase=False, set_n_qubits=False)

Generate a circuit that takes the desired state to the zero state.

Parameters:
  • return_phase (bool) – Flag to return global_phase

  • set_n_qubits (bool) – Set n_qubits in Circuit to qubits needed for the length of the coefficients array.

Returns:
  • Circuit – circuit to take self.coeffs vector to |{00\ldots0}\rangle

  • float – (if return_phase=True) The angle that defines the global phase not captured by the circuit

Module contents