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 "CR.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_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_CR (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_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 87 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 1519 of file qgd_Circuit_Wrapper.cpp.
PyMODINIT_FUNC PyInit_qgd_Circuit_Wrapper | ( | void | ) |
Method called when the Python module is initialized.
Definition at line 2815 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 865 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 471 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 898 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 403 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 802 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 833 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 770 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 437 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 539 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 307 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 275 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 339 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 371 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 671 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 505 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 704 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 737 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 184 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 214 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 244 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 572 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 605 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 638 of file qgd_Circuit_Wrapper.cpp.
|
static |
Call to apply the gate operation on the inut matrix.
Definition at line 1115 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 113 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 2263 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 2199 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 2315 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 2030 of file qgd_Circuit_Wrapper.cpp.
|
static |
Call to get the counts on the individual gates in the circuit.
Definition at line 2049 of file qgd_Circuit_Wrapper.cpp.
|
static |
Call to get the incorporated gates in a python list.
Definition at line 2093 of file qgd_Circuit_Wrapper.cpp.
|
static |
Extract the optimized parameters.
start_index | The index of the first inverse gate |
Definition at line 1062 of file qgd_Circuit_Wrapper.cpp.
|
static |
Get the number of free parameters in the gate structure used for the decomposition.
Definition at line 1102 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 2574 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 2131 of file qgd_Circuit_Wrapper.cpp.
|
static |
Call to retrieve the number of qubits in the circuit.
Definition at line 1315 of file qgd_Circuit_Wrapper.cpp.
|
static |
Call to retrieve the list of qubits involved in the circuit.
Definition at line 1382 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 1219 of file qgd_Circuit_Wrapper.cpp.
A structure describing the type of the class Circuit. Definition at line 2732 of file qgd_Circuit_Wrapper.cpp. Generated on Mon Aug 4 2025 08:06:11 for Sequential Quantum Gate Decomposer by ![]() |