Circuit¶
Here we present all the functions linked to the circuits for qiskit, cirq and quimb
-
circuit.
GHZ_qiskit
(circ)[source]¶ Generates a GHZ state in the quantum circuit circ composed by n qubits. Acts in place.
- Parameters
circ (Quantum Circuit) -- The quantum circuit in the state '00...0' where to build the GHZ
- Returns
None -- Acts in place.
- Return type
None
-
circuit.
MPS_circ
(qc, gates=None, init_state=None, chi=None, verbosity=False)[source]¶ Function to transform a qiskit circuit qc to a quimb MPS circuit, using the gates gates
- Parameters
qc (QuantumCircuit) -- Qiskit quantum circuit to apply to the MPS
gates (dictionary or None, optional) -- dictionary containing the gate used in the circuit in the format qiskit_gate_name: quimb_gate If None a standard set is used
init_state (String, None or quimb.tensor.tensor_1d.MatrixProductState, optional) -- If String containing the state in computational basis, i.e. '000' or '0011' If None starts from empty state '0'x(num_qubits) If MPS in quimb format the initial state is the MPS
chi (int, optional) -- maximum bond dimension. If None it is automatically chosen.
verbosity (bool, optional) -- if True prints when the state is initialized. Default to false.
- Returns
MPS -- quimb MPS where we have applied the quantum circuit qc starting from init_state
- Return type
quimb.tensor.tensor_1d.MatrixProductState
-
class
circuit.
circ_data
(circ)[source]¶ Class to contain the metadata of a qiskit quantum circuit
-
data
¶ data of a quantum circuit
- Type
list
-
gates
¶ names of the gate applied in the correct order
- Type
list of string
-
gates_params
¶ gate parameters. if no parameter is present it returns an empty list []
- Type
list of lists
-
indeces
¶ indeces to which the gates are applyed
- Type
list of tuples of ints
-
n_qub
¶ number of qubits in the circuit
- Type
int
-
-
circuit.
qft_circuit_qiskit
(circuit, n)[source]¶ Apply the QFT to a qiskit quantum circuit circuit in a recursive way
- Parameters
circuit (quantum circuit) -- quantum circuit where we want to apply the QFT
n (int) -- number of qubits in circuit
- Returns
None -- Acts in place
- Return type
None
-
circuit.
qft_circuit_quimb
(mps, n, chi=2)[source]¶ Apply the QFT to the matrix product state mps with a bond dimension of chi in a recursive way
- Parameters
mps (quimb.tensor.tensor_1d.MatrixProductState) -- Matrix product state to which we want to apply the QFT
n (int) -- number of qubits in mps
chi (int, optional) -- Bond dimension of the MPS. Default to 2
- Returns
mps -- Matrix product state to which we have applied the QFT
- Return type
quimb.tensor.tensor_1d.MatrixProductState
-
circuit.
qft_circuit_swap_approx
(state, N, verbosity=False, chi=2)[source]¶ Computes the QFT of a MPS state with N qubits and a bond dimension chi.
- Parameters
state (list of ndarray) -- list of tensors of the MPS
N (int) -- number of qubits in state
verbosity (bool, optional) -- Default to False. If True prints applied gates
chi (int, optional) -- Bond dimension
- Returns
state -- MPS where we have applied the QFT
- Return type
list of ndarray
-
circuit.
qft_circuit_swap_cirq
(qubits, circuit=[])[source]¶ Build a circuit implementing the QFT algorithm on the given qubits. The order of qubits is preserved by SWAP operations. Implemented using only local operations, i.e. gates acting on neighbouring qubits. Adapted from: https://github.com/quantumlib/Cirq/blob/master/examples/quantum_fourier_transform.py and extended to n generic qubits through recursion.
- Parameters
qubits (cirq.LineQubit) -- qubits
circuit (list) -- list of directives to create the quantum circuit
- Returns
circuit -- quantum circuit where we have applied the QFT
- Return type
cirq.Circuit
-
circuit.
qft_circuit_swap_full
(state, N, verbosity=False)[source]¶ Computes the QFT of a MPS state with N qubits.
- Parameters
state (list of ndarray) -- list of tensors of the MPS
N (int) -- number of qubits in state
verbosity (bool, optional) -- Default to False. If True prints applied gates
- Returns
state -- MPS where we have applied the QFT
- Return type
list of ndarray