Sequential Quantum Gate Decomposer
v1.9.3
Powerful decomposition of general unitarias into one- and two-qubit gates gates
|
#include <Python.h>
#include "structmember.h"
#include "Gates_block.h"
#include "CZ.h"
#include "CH.h"
#include "CNOT.h"
#include "U1.h"
#include "U2.h"
#include "U3.h"
#include "RX.h"
#include "R.h"
#include "RY.h"
#include "CRY.h"
#include "CROT.h"
#include "RZ.h"
#include "H.h"
#include "X.h"
#include "Y.h"
#include "Z.h"
#include "SX.h"
#include "SYC.h"
#include "UN.h"
#include "ON.h"
#include "Adaptive.h"
#include "Composite.h"
#include "numpy_interface.h"
Go to the source code of this file.
Classes | |
struct | qgd_Circuit_Wrapper |
Type definition of the qgd_Circuit_Wrapper Python class of the qgd_Circuit_Wrapper module. More... | |
struct | qgd_CROT_Wrapper |
Type definition of the qgd_CROT Python class of the qgd_CROT module. More... | |
struct | qgd_Gate |
Type definition of the qgd_Gate Python class of the qgd_Gate module. More... | |
Macros | |
#define | PY_SSIZE_T_CLEAN |
Functions | |
Gates_block * | create_Circuit (int qbit_num) |
Creates an instance of class N_Qubit_Decomposition and return with a pointer pointing to the class instance (C++ linking is needed) More... | |
static PyObject * | get_gate (Gates_block *circuit, int &idx) |
Call to get the metadata organised into Python dictionary of the idx-th gate. More... | |
PyMODINIT_FUNC | PyInit_qgd_Circuit_Wrapper (void) |
Method called when the Python module is initialized. More... | |
static PyObject * | qgd_Circuit_Wrapper_add_adaptive (qgd_Circuit_Wrapper *self, PyObject *args, PyObject *kwds) |
Wrapper function to add an adaptive gate to the front of the gate structure. More... | |
static PyObject * | qgd_Circuit_Wrapper_add_CH (qgd_Circuit_Wrapper *self, PyObject *args, PyObject *kwds) |
Wrapper function to add a CH gate to the front of the gate structure. More... | |
static PyObject * | qgd_Circuit_Wrapper_add_Circuit (qgd_Circuit_Wrapper *self, PyObject *args) |
Wrapper function to add a block of operations to the front of the gate structure. More... | |
static PyObject * | qgd_Circuit_Wrapper_add_CNOT (qgd_Circuit_Wrapper *self, PyObject *args, PyObject *kwds) |
Wrapper function to add a CNOT gate to the front of the gate structure. More... | |
static PyObject * | qgd_Circuit_Wrapper_add_CROT (qgd_Circuit_Wrapper *self, PyObject *args, PyObject *kwds) |
Wrapper function to add an adaptive gate to the front of the gate structure. More... | |
static PyObject * | qgd_Circuit_Wrapper_add_CRY (qgd_Circuit_Wrapper *self, PyObject *args, PyObject *kwds) |
Wrapper function to add an adaptive gate to the front of the gate structure. More... | |
static PyObject * | qgd_Circuit_Wrapper_add_CZ (qgd_Circuit_Wrapper *self, PyObject *args, PyObject *kwds) |
Wrapper function to add a CZ gate to the front of the gate structure. More... | |
static PyObject * | qgd_Circuit_Wrapper_add_H (qgd_Circuit_Wrapper *self, PyObject *args, PyObject *kwds) |
Wrapper function to add a Hadamard gate to the front of the gate structure. More... | |
static PyObject * | qgd_Circuit_Wrapper_add_R (qgd_Circuit_Wrapper *self, PyObject *args, PyObject *kwds) |
Wrapper function to add a R gate to the front of the gate structure. More... | |
static PyObject * | qgd_Circuit_Wrapper_add_RX (qgd_Circuit_Wrapper *self, PyObject *args, PyObject *kwds) |
Wrapper function to add a RX gate to the front of the gate structure. More... | |
static PyObject * | qgd_Circuit_Wrapper_add_RY (qgd_Circuit_Wrapper *self, PyObject *args, PyObject *kwds) |
Wrapper function to add a RY gate to the front of the gate structure. More... | |
static PyObject * | qgd_Circuit_Wrapper_add_RZ (qgd_Circuit_Wrapper *self, PyObject *args, PyObject *kwds) |
Wrapper function to add a RZ gate to the front of the gate structure. More... | |
static PyObject * | qgd_Circuit_Wrapper_add_SX (qgd_Circuit_Wrapper *self, PyObject *args, PyObject *kwds) |
Wrapper function to add a SX gate to the front of the gate structure. More... | |
static PyObject * | qgd_Circuit_Wrapper_add_SYC (qgd_Circuit_Wrapper *self, PyObject *args, PyObject *kwds) |
Wrapper function to add a Sycamore gate to the front of the gate structure. More... | |
static PyObject * | qgd_Circuit_Wrapper_add_T (qgd_Circuit_Wrapper *self, PyObject *args, PyObject *kwds) |
Wrapper function to add a T gate to the front of the gate structure. More... | |
static PyObject * | qgd_Circuit_Wrapper_add_Tdg (qgd_Circuit_Wrapper *self, PyObject *args, PyObject *kwds) |
Wrapper function to add a Tdg gate to the front of the gate structure. More... | |
static PyObject * | qgd_Circuit_Wrapper_add_U1 (qgd_Circuit_Wrapper *self, PyObject *args, PyObject *kwds) |
Wrapper function to add a U1 gate to the front of the gate structure. More... | |
static PyObject * | qgd_Circuit_Wrapper_add_U2 (qgd_Circuit_Wrapper *self, PyObject *args, PyObject *kwds) |
Wrapper function to add a U2 gate to the front of the gate structure. More... | |
static PyObject * | qgd_Circuit_Wrapper_add_U3 (qgd_Circuit_Wrapper *self, PyObject *args, PyObject *kwds) |
Wrapper function to add a U3 gate to the front of the gate structure. More... | |
static PyObject * | qgd_Circuit_Wrapper_add_X (qgd_Circuit_Wrapper *self, PyObject *args, PyObject *kwds) |
Wrapper function to add a X gate to the front of the gate structure. More... | |
static PyObject * | qgd_Circuit_Wrapper_add_Y (qgd_Circuit_Wrapper *self, PyObject *args, PyObject *kwds) |
Wrapper function to add a X gate to the front of the gate structure. More... | |
static PyObject * | qgd_Circuit_Wrapper_add_Z (qgd_Circuit_Wrapper *self, PyObject *args, PyObject *kwds) |
Wrapper function to add a X gate to the front of the gate structure. More... | |
static PyObject * | qgd_Circuit_Wrapper_apply_to (qgd_Circuit_Wrapper *self, PyObject *args, PyObject *kwds) |
Call to apply the gate operation on the inut matrix. More... | |
static void | qgd_Circuit_Wrapper_dealloc (qgd_Circuit_Wrapper *self) |
Method called when a python instance of the class qgd_Circuit_Wrapper is destroyed. More... | |
static PyObject * | qgd_Circuit_Wrapper_Extract_Parameters (qgd_Circuit_Wrapper *self, PyObject *args) |
Call to extract the paramaters corresponding to the gate, from a parameter array associated to the circuit in which the gate is embedded. More... | |
static PyObject * | qgd_Circuit_Wrapper_get_children (qgd_Circuit_Wrapper *self, PyObject *args) |
Wrapper function to get the indices of children gates. More... | |
static PyObject * | qgd_Circuit_Wrapper_get_Flat_Circuit (qgd_Circuit_Wrapper *self) |
Method to generate a flat circuit. More... | |
static PyObject * | qgd_Circuit_Wrapper_get_gate (qgd_Circuit_Wrapper *self, PyObject *args) |
Wrapper function to get a gate from the circuit. More... | |
static PyObject * | qgd_Circuit_Wrapper_get_Gate_Nums (qgd_Circuit_Wrapper *self) |
Call to get the counts on the individual gates in the circuit. More... | |
static PyObject * | qgd_Circuit_Wrapper_get_gates (qgd_Circuit_Wrapper *self) |
Call to get the incorporated gates in a python list. More... | |
static PyObject * | qgd_Circuit_Wrapper_get_Matrix (qgd_Circuit_Wrapper *self, PyObject *args) |
Extract the optimized parameters. More... | |
static PyObject * | qgd_Circuit_Wrapper_get_Parameter_Num (qgd_Circuit_Wrapper *self) |
Get the number of free parameters in the gate structure used for the decomposition. More... | |
static PyObject * | qgd_Circuit_Wrapper_get_Parameter_Start_Index (qgd_Circuit_Wrapper *self) |
Call to get the starting index of the parameters in the parameter array corresponding to the circuit in which the current gate is incorporated. More... | |
static PyObject * | qgd_Circuit_Wrapper_get_parents (qgd_Circuit_Wrapper *self, PyObject *args) |
Wrapper function to get the indices of parent gates. More... | |
static PyObject * | qgd_Circuit_Wrapper_get_Qbit_Num (qgd_Circuit_Wrapper *self) |
Call to retrieve the number of qubits in the circuit. More... | |
static PyObject * | qgd_Circuit_Wrapper_get_Qbits (qgd_Circuit_Wrapper *self) |
Call to retrieve the list of qubits involved in the circuit. More... | |
static PyObject * | qgd_Circuit_Wrapper_get_Second_Renyi_Entropy (qgd_Circuit_Wrapper *self, PyObject *args) |
Wrapper function to evaluate the second Rényi entropy of a quantum circuit at a specific parameter set. More... | |
static PyObject * | qgd_Circuit_Wrapper_getstate (qgd_Circuit_Wrapper *self) |
Method to extract the stored quantum circuit in a human-readable data serialized and pickle-able format. More... | |
static int | qgd_Circuit_Wrapper_init (qgd_Circuit_Wrapper *self, PyObject *args, PyObject *kwds) |
Method called when a python instance of the class qgd_Circuit_Wrapper is initialized. More... | |
static PyObject * | qgd_Circuit_Wrapper_new (PyTypeObject *type, PyObject *args, PyObject *kwds) |
Method called when a python instance of the class qgd_Circuit_Wrapper is allocated. More... | |
static PyObject * | qgd_Circuit_Wrapper_Remap_Qbits (qgd_Circuit_Wrapper *self, PyObject *args) |
Call to remap the qubits in the circuit. More... | |
static PyObject * | qgd_Circuit_Wrapper_set_Qbit_Num (qgd_Circuit_Wrapper *self, PyObject *args) |
Call to set the number of qubits in the circuit. More... | |
static PyObject * | qgd_Circuit_Wrapper_setstate (qgd_Circuit_Wrapper *self, PyObject *args) |
Call to set the state of a quantum circuit from a human-readable data serialized and pickle-able format. More... | |
void | release_Circuit (Gates_block *instance) |
Call to deallocate an instance of N_Qubit_Decomposition class. More... | |
Variables | |
static PyMemberDef | qgd_Circuit_Wrapper_Members [] |
Structure containing metadata about the members of class qgd_Circuit_Wrapper. More... | |
static PyMethodDef | qgd_Circuit_Wrapper_Methods [] |
static PyModuleDef | qgd_Circuit_Wrapper_Module |
Structure containing metadata about the module. More... | |
static PyTypeObject | qgd_Circuit_Wrapper_Type |
A structure describing the type of the class Circuit. More... | |
#define PY_SSIZE_T_CLEAN |
Definition at line 27 of file qgd_Circuit_Wrapper.cpp.
Gates_block* create_Circuit | ( | int | qbit_num | ) |
Creates an instance of class N_Qubit_Decomposition and return with a pointer pointing to the class instance (C++ linking is needed)
qbit_num | Number of qubits spanning the unitary |
Definition at line 95 of file qgd_Circuit_Wrapper.cpp.
|
static |
Call to get the metadata organised into Python dictionary of the idx-th gate.
circuit | A pointer pointing to an instance of the class Gates_block. |
idx | Labels the idx-th gate. |
Definition at line 1509 of file qgd_Circuit_Wrapper.cpp.
PyMODINIT_FUNC PyInit_qgd_Circuit_Wrapper | ( | void | ) |
Method called when the Python module is initialized.
Definition at line 2795 of file qgd_Circuit_Wrapper.cpp.
|
static |
Wrapper function to add an adaptive gate to the front of the gate structure.
self | A pointer pointing to an instance of the class qgd_Circuit_Wrapper. |
args | A tuple of the input arguments: target_qbit (int) |
kwds | A tuple of keywords |
Definition at line 855 of file qgd_Circuit_Wrapper.cpp.
|
static |
Wrapper function to add a CH gate to the front of the gate structure.
self | A pointer pointing to an instance of the class qgd_Circuit_Wrapper. |
args | A tuple of the input arguments: control_qbit (int), target_qbit (int) |
kwds | A tuple of keywords |
Definition at line 479 of file qgd_Circuit_Wrapper.cpp.
|
static |
Wrapper function to add a block of operations to the front of the gate structure.
self | A pointer pointing to an instance of the class qgd_Circuit_Wrapper. |
args | A tuple of the input arguments: Py_qgd_Circuit_Wrapper (PyObject) Py_qgd_Circuit_Wrapper: an instance of qgd_Circuit_Wrapper containing the custom gate structure |
Definition at line 888 of file qgd_Circuit_Wrapper.cpp.
|
static |
Wrapper function to add a CNOT gate to the front of the gate structure.
self | A pointer pointing to an instance of the class qgd_Circuit_Wrapper. |
args | A tuple of the input arguments: control_qbit (int), target_qbit (int) |
kwds | A tuple of keywords |
Definition at line 411 of file qgd_Circuit_Wrapper.cpp.
|
static |
Wrapper function to add an adaptive gate to the front of the gate structure.
self | A pointer pointing to an instance of the class qgd_Circuit_Wrapper. |
args | A tuple of the input arguments: target_qbit (int) |
kwds | A tuple of keywords |
Definition at line 810 of file qgd_Circuit_Wrapper.cpp.
|
static |
Wrapper function to add an adaptive gate to the front of the gate structure.
self | A pointer pointing to an instance of the class qgd_Circuit_Wrapper. |
args | A tuple of the input arguments: target_qbit (int) |
kwds | A tuple of keywords |
Definition at line 778 of file qgd_Circuit_Wrapper.cpp.
|
static |
Wrapper function to add a CZ gate to the front of the gate structure.
self | A pointer pointing to an instance of the class qgd_Circuit_Wrapper. |
args | A tuple of the input arguments: control_qbit (int), target_qbit (int) |
kwds | A tuple of keywords |
Definition at line 445 of file qgd_Circuit_Wrapper.cpp.
|
static |
Wrapper function to add a Hadamard gate to the front of the gate structure.
self | A pointer pointing to an instance of the class Circuit. |
args | A tuple of the input arguments: target_qbit (int) |
kwds | A tuple of keywords |
Definition at line 547 of file qgd_Circuit_Wrapper.cpp.
|
static |
Wrapper function to add a R gate to the front of the gate structure.
self | A pointer pointing to an instance of the class qgd_Circuit_Wrapper. |
args | A tuple of the input arguments: target_qbit (int) |
kwds | A tuple of keywords |
Definition at line 315 of file qgd_Circuit_Wrapper.cpp.
|
static |
Wrapper function to add a RX gate to the front of the gate structure.
self | A pointer pointing to an instance of the class qgd_Circuit_Wrapper. |
args | A tuple of the input arguments: target_qbit (int) |
kwds | A tuple of keywords |
Definition at line 283 of file qgd_Circuit_Wrapper.cpp.
|
static |
Wrapper function to add a RY gate to the front of the gate structure.
self | A pointer pointing to an instance of the class qgd_Circuit_Wrapper. |
args | A tuple of the input arguments: target_qbit (int) |
kwds | A tuple of keywords |
Definition at line 347 of file qgd_Circuit_Wrapper.cpp.
|
static |
Wrapper function to add a RZ gate to the front of the gate structure.
self | A pointer pointing to an instance of the class qgd_Circuit_Wrapper. |
args | A tuple of the input arguments: target_qbit (int) |
kwds | A tuple of keywords |
Definition at line 379 of file qgd_Circuit_Wrapper.cpp.
|
static |
Wrapper function to add a SX gate to the front of the gate structure.
self | A pointer pointing to an instance of the class Circuit. |
args | A tuple of the input arguments: target_qbit (int) |
kwds | A tuple of keywords |
Definition at line 679 of file qgd_Circuit_Wrapper.cpp.
|
static |
Wrapper function to add a Sycamore gate to the front of the gate structure.
self | A pointer pointing to an instance of the class qgd_Circuit_Wrapper. |
args | A tuple of the input arguments: control_qbit (int), target_qbit (int) |
kwds | A tuple of keywords |
Definition at line 513 of file qgd_Circuit_Wrapper.cpp.
|
static |
Wrapper function to add a T gate to the front of the gate structure.
self | A pointer pointing to an instance of the class Circuit. |
args | A tuple of the input arguments: target_qbit (int) |
kwds | A tuple of keywords |
Definition at line 712 of file qgd_Circuit_Wrapper.cpp.
|
static |
Wrapper function to add a Tdg gate to the front of the gate structure.
self | A pointer pointing to an instance of the class Circuit. |
args | A tuple of the input arguments: target_qbit (int) |
kwds | A tuple of keywords |
Definition at line 745 of file qgd_Circuit_Wrapper.cpp.
|
static |
Wrapper function to add a U1 gate to the front of the gate structure.
self | A pointer pointing to an instance of the class qgd_Circuit. |
args | A tuple of the input arguments: target_qbit (int) |
kwds | A tuple of keywords |
Definition at line 192 of file qgd_Circuit_Wrapper.cpp.
|
static |
Wrapper function to add a U2 gate to the front of the gate structure.
self | A pointer pointing to an instance of the class qgd_Circuit. |
args | A tuple of the input arguments: target_qbit (int) |
kwds | A tuple of keywords |
Definition at line 222 of file qgd_Circuit_Wrapper.cpp.
|
static |
Wrapper function to add a U3 gate to the front of the gate structure.
self | A pointer pointing to an instance of the class qgd_Circuit. |
args | A tuple of the input arguments: target_qbit (int) |
kwds | A tuple of keywords |
Definition at line 252 of file qgd_Circuit_Wrapper.cpp.
|
static |
Wrapper function to add a X gate to the front of the gate structure.
self | A pointer pointing to an instance of the class Circuit. |
args | A tuple of the input arguments: target_qbit (int) |
kwds | A tuple of keywords |
Definition at line 580 of file qgd_Circuit_Wrapper.cpp.
|
static |
Wrapper function to add a X gate to the front of the gate structure.
self | A pointer pointing to an instance of the class Circuit. |
args | A tuple of the input arguments: target_qbit (int) |
kwds | A tuple of keywords |
Definition at line 613 of file qgd_Circuit_Wrapper.cpp.
|
static |
Wrapper function to add a X gate to the front of the gate structure.
self | A pointer pointing to an instance of the class Circuit. |
args | A tuple of the input arguments: target_qbit (int) |
kwds | A tuple of keywords |
Definition at line 646 of file qgd_Circuit_Wrapper.cpp.
|
static |
Call to apply the gate operation on the inut matrix.
Definition at line 1105 of file qgd_Circuit_Wrapper.cpp.
|
static |
Method called when a python instance of the class qgd_Circuit_Wrapper is destroyed.
self | A pointer pointing to an instance of class qgd_Circuit_Wrapper. |
Definition at line 121 of file qgd_Circuit_Wrapper.cpp.
|
static |
Call to extract the paramaters corresponding to the gate, from a parameter array associated to the circuit in which the gate is embedded.
Definition at line 2246 of file qgd_Circuit_Wrapper.cpp.
|
static |
Wrapper function to get the indices of children gates.
self | A pointer pointing to an instance of the class qgd_Circuit_Wrapper. |
args | A tuple of the input arguments: gate: the gate for which we are retriving the children |
Definition at line 2182 of file qgd_Circuit_Wrapper.cpp.
|
static |
Method to generate a flat circuit.
A flat circuit is a circuit does not containing subcircuits: there are no Gates_block instances (containing subcircuits) in the resulting circuit. If the original circuit contains subcircuits, the gates in the subcircuits are directly incorporated in the resulting flat circuit.
Definition at line 2298 of file qgd_Circuit_Wrapper.cpp.
|
static |
Wrapper function to get a gate from the circuit.
self | A pointer pointing to an instance of the class qgd_Circuit_Wrapper. |
args | A tuple of the input arguments: idx (int) idx: labels the idx-th gate. |
Definition at line 2013 of file qgd_Circuit_Wrapper.cpp.
|
static |
Call to get the counts on the individual gates in the circuit.
Definition at line 2032 of file qgd_Circuit_Wrapper.cpp.
|
static |
Call to get the incorporated gates in a python list.
Definition at line 2076 of file qgd_Circuit_Wrapper.cpp.
|
static |
Extract the optimized parameters.
start_index | The index of the first inverse gate |
Definition at line 1052 of file qgd_Circuit_Wrapper.cpp.
|
static |
Get the number of free parameters in the gate structure used for the decomposition.
Definition at line 1092 of file qgd_Circuit_Wrapper.cpp.
|
static |
Call to get the starting index of the parameters in the parameter array corresponding to the circuit in which the current gate is incorporated.
Definition at line 2557 of file qgd_Circuit_Wrapper.cpp.
|
static |
Wrapper function to get the indices of parent gates.
self | A pointer pointing to an instance of the class qgd_Circuit_Wrapper. |
args | A tuple of the input arguments: gate: the gate for which we are retriving the parents |
Definition at line 2114 of file qgd_Circuit_Wrapper.cpp.
|
static |
Call to retrieve the number of qubits in the circuit.
Definition at line 1305 of file qgd_Circuit_Wrapper.cpp.
|
static |
Call to retrieve the list of qubits involved in the circuit.
Definition at line 1372 of file qgd_Circuit_Wrapper.cpp.
|
static |
Wrapper function to evaluate the second Rényi entropy of a quantum circuit at a specific parameter set.
Definition at line 1209 of file qgd_Circuit_Wrapper.cpp.
|
static |
Method to extract the stored quantum circuit in a human-readable data serialized and pickle-able format.
Definition at line 2338 of file qgd_Circuit_Wrapper.cpp.
|
static |
Method called when a python instance of the class qgd_Circuit_Wrapper is initialized.
self | A pointer pointing to an instance of the class qgd_Circuit_Wrapper. |
args | A tuple of the input arguments: qbit_num (integer) qbit_num: the number of qubits spanning the operations |
kwds | A tuple of keywords |
Definition at line 170 of file qgd_Circuit_Wrapper.cpp.
|
static |
Method called when a python instance of the class qgd_Circuit_Wrapper is allocated.
type | A pointer pointing to a structure describing the type of the class Circuit. |
Definition at line 135 of file qgd_Circuit_Wrapper.cpp.
|
static |
Call to remap the qubits in the circuit.
Definition at line 1405 of file qgd_Circuit_Wrapper.cpp.
|
static |
Call to set the number of qubits in the circuit.
Definition at line 1335 of file qgd_Circuit_Wrapper.cpp.
|
static |
Call to set the state of a quantum circuit from a human-readable data serialized and pickle-able format.
Definition at line 2416 of file qgd_Circuit_Wrapper.cpp.
void release_Circuit | ( | Gates_block * | instance | ) |
Call to deallocate an instance of N_Qubit_Decomposition class.
ptr | A pointer pointing to an instance of N_Qubit_Decomposition class. |
Definition at line 104 of file qgd_Circuit_Wrapper.cpp.
|
static |
Structure containing metadata about the members of class qgd_Circuit_Wrapper.
Definition at line 179 of file qgd_Circuit_Wrapper.cpp.
|
static |
Definition at line 2568 of file qgd_Circuit_Wrapper.cpp.
|
static |
Structure containing metadata about the module.
Definition at line 2784 of file qgd_Circuit_Wrapper.cpp.
|
static |
A structure describing the type of the class Circuit.
Definition at line 2712 of file qgd_Circuit_Wrapper.cpp.