Sequential Quantum Gate Decomposer  v1.9.6
Powerful decomposition of general unitarias into one- and two-qubit gates gates
Classes | Macros | Functions | Variables
qgd_Circuit_Wrapper.cpp File Reference

Python interface for the Gates_block class (quantum circuit wrapper) More...

#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 "CRX.h"
#include "CRZ.h"
#include "CP.h"
#include "CCX.h"
#include "SWAP.h"
#include "CSWAP.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 "SXdg.h"
#include "SYC.h"
#include "Adaptive.h"
#include "RXX.h"
#include "RYY.h"
#include "RZZ.h"
#include "numpy_interface.h"
Include dependency graph for qgd_Circuit_Wrapper.cpp:

Go to the source code of this file.

Classes

struct  qgd_Circuit_Wrapper
 Type definition for qgd_Circuit_Wrapper. More...
 
struct  qgd_Gate
 Type definition of the qgd_Gate Python class of the qgd_Gate module. More...
 

Macros

#define get_gate_template_one_qubit(GATE_NAME)
 
#define get_gate_template_two_qubit(GATE_NAME)
 
#define PY_SSIZE_T_CLEAN
 
#define qgd_Circuit_Wrapper_add_one_qubit_gate(gate_name, GATE_NAME)
 
#define qgd_Circuit_Wrapper_add_qbit_only_gate(gate_name, GATE_NAME)
 
#define qgd_Circuit_Wrapper_add_two_qubit_gate(gate_name, GATE_NAME)
 

Functions

static void circuit_matrix_float_owner_capsule_destruct (PyObject *cap)
 Capsule destructor: calls delete on a heap-allocated Matrix_float, which correctly decrements the reference counter and then calls scalable_aligned_free. More...
 
static void circuit_matrix_owner_capsule_destruct (PyObject *cap)
 Capsule destructor: calls delete on a heap-allocated Matrix, which correctly decrements the reference counter and then calls scalable_aligned_free. More...
 
Gates_blockcreate_Circuit (int qbit_num)
 Creates an instance of class Gates_block (Circuit) and returns a pointer to the class instance. More...
 
static PyObject * get_gate (Gates_block *circuit, int &idx)
 Call to get the metadata organized into Python dictionary of the idx-th gate. More...
 
 if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O", kwlist, &target_qbits_py)) return Py_BuildValue("i"
 
 if (target_qbits_py !=NULL &&PyList_Check(target_qbits_py))
 
return Py_BuildValue ("i", 0)
 
PyMODINIT_FUNC PyInit_qgd_Circuit_Wrapper (void)
 Method called when the Python module is initialized. More...
 
CR static adaptive PyObject * qgd_Circuit_Wrapper_add_CCX (qgd_Circuit_Wrapper *self, PyObject *args, PyObject *kwds)
 Wrapper function to add a CCX 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_CSWAP (qgd_Circuit_Wrapper *self, PyObject *args, PyObject *kwds)
 Wrapper function to add a CSWAP gate to the front of the gate structure. More...
 
static PyObject * qgd_Circuit_Wrapper_add_GENERAL (qgd_Circuit_Wrapper *self, PyObject *args, PyObject *kwds)
 Wrapper function to add a GENERAL_OPERATION gate from an explicit matrix. More...
 
 qgd_Circuit_Wrapper_add_one_qubit_gate (u1, U1) qgd_Circuit_Wrapper_add_one_qubit_gate(u3
 
U3 qgd_Circuit_Wrapper_add_one_qubit_gate (u2, U2) qgd_Circuit_Wrapper_add_one_qubit_gate(rx
 
U3 RX qgd_Circuit_Wrapper_add_one_qubit_gate (ry, RY) qgd_Circuit_Wrapper_add_one_qubit_gate(rz
 
U3 RX RZ qgd_Circuit_Wrapper_add_one_qubit_gate (r, R) qgd_Circuit_Wrapper_add_one_qubit_gate(h
 
U3 RX RZ H qgd_Circuit_Wrapper_add_one_qubit_gate (x, X) qgd_Circuit_Wrapper_add_one_qubit_gate(y
 
U3 RX RZ H Y qgd_Circuit_Wrapper_add_one_qubit_gate (z, Z) qgd_Circuit_Wrapper_add_one_qubit_gate(sx
 
U3 RX RZ H Y SX qgd_Circuit_Wrapper_add_one_qubit_gate (sxdg, SXdg) qgd_Circuit_Wrapper_add_one_qubit_gate(s
 
U3 RX RZ H Y SX S qgd_Circuit_Wrapper_add_one_qubit_gate (sdg, Sdg) qgd_Circuit_Wrapper_add_one_qubit_gate(t
 
U3 RX RZ H Y SX S T qgd_Circuit_Wrapper_add_one_qubit_gate (tdg, Tdg) qgd_Circuit_Wrapper_add_two_qubit_gate(cnot
 
static PyObject * qgd_Circuit_Wrapper_add_RXX (qgd_Circuit_Wrapper *self, PyObject *args, PyObject *kwds)
 
static PyObject * qgd_Circuit_Wrapper_add_RYY (qgd_Circuit_Wrapper *self, PyObject *args, PyObject *kwds)
 
static PyObject * qgd_Circuit_Wrapper_add_RZZ (qgd_Circuit_Wrapper *self, PyObject *args, PyObject *kwds)
 
U3 RX RZ H Y SX S T CNOT qgd_Circuit_Wrapper_add_two_qubit_gate (cz, CZ) qgd_Circuit_Wrapper_add_two_qubit_gate(ch
 
U3 RX RZ H Y SX S T CNOT CH qgd_Circuit_Wrapper_add_two_qubit_gate (cu, CU) qgd_Circuit_Wrapper_add_two_qubit_gate(syc
 
U3 RX RZ H Y SX S T CNOT CH SYC qgd_Circuit_Wrapper_add_two_qubit_gate (cry, CRY) qgd_Circuit_Wrapper_add_two_qubit_gate(crz
 
U3 RX RZ H Y SX S T CNOT CH SYC CRZ qgd_Circuit_Wrapper_add_two_qubit_gate (crx, CRX) static PyObject *qgd_Circuit_Wrapper_add_SWAP(qgd_Circuit_Wrapper *self
 
 qgd_Circuit_Wrapper_add_two_qubit_gate (cp, CP) qgd_Circuit_Wrapper_add_two_qubit_gate(cr
 
CR qgd_Circuit_Wrapper_add_two_qubit_gate (crot, CROT) qgd_Circuit_Wrapper_add_two_qubit_gate(adaptive
 
static PyObject * qgd_Circuit_Wrapper_apply_derivate_to (qgd_Circuit_Wrapper *self, PyObject *args, PyObject *kwds)
 Evaluate the derivative of the circuit on an input matrix with respect to all free parameters (float64 only). More...
 
static PyObject * qgd_Circuit_Wrapper_apply_from_right (qgd_Circuit_Wrapper *self, PyObject *args, PyObject *kwds)
 Apply the gate circuit from the right on the input matrix with float32/float64 dispatch. More...
 
static PyObject * qgd_Circuit_Wrapper_apply_to (qgd_Circuit_Wrapper *self, PyObject *args, PyObject *kwds)
 Apply the gate circuit operation on the input matrix. More...
 
static PyObject * qgd_Circuit_Wrapper_apply_to_combined (qgd_Circuit_Wrapper *self, PyObject *args, PyObject *kwds)
 Evaluate forward circuit action and all derivatives in one call. More...
 
static PyObject * qgd_Circuit_Wrapper_apply_to_list (qgd_Circuit_Wrapper *self, PyObject *args, PyObject *kwds)
 Apply the circuit to a list of input matrices with float32/float64 dispatch. 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 parameters corresponding to the gate from a parameter array associated with 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 of 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, PyObject *kwds)
 Extract the optimized parameters and return the matrix representation of the gate circuit. 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_Min_Fusion (qgd_Circuit_Wrapper *self, PyObject *args)
 
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 Gates_block class. More...
 

Variables

U3 RX RZ H Y SX S T CNOT CH SYC CRZ PyObject * args
 
U3 RX RZ H Y SX S T CNOT CH SYC CRZ PyObject PyObject * kwds
 
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...
 
PyObject * target_qbits_py = NULL
 

Detailed Description

Python interface for the Gates_block class (quantum circuit wrapper)

Definition in file qgd_Circuit_Wrapper.cpp.

Macro Definition Documentation

◆ get_gate_template_one_qubit

#define get_gate_template_one_qubit (   GATE_NAME)
Value:
else if (gate->get_type() == GATE_NAME##_OPERATION) { \
PyObject* qgd_gate_Dict = PyModule_GetDict( qgd_gate ); \
PyObject* py_gate_class = PyDict_GetItemString( qgd_gate_Dict, #GATE_NAME); \
PyObject* gate_input = Py_BuildValue("(OO)", qbit_num, target_qbit); \
py_gate = PyObject_CallObject(py_gate_class, gate_input); \
qgd_Gate* py_gate_C = reinterpret_cast<qgd_Gate*>( py_gate ); \
delete( py_gate_C->gate ); \
py_gate_C->gate = static_cast<Gate*>( gate->clone() ); \
Py_DECREF( qgd_gate ); \
Py_DECREF( gate_input ); \
}
return Py_BuildValue("i", 0)
Type definition of the qgd_Gate Python class of the qgd_Gate module.
Base class for the representation of general gate operations.
Definition: Gate.h:86

Definition at line 2087 of file qgd_Circuit_Wrapper.cpp.

◆ get_gate_template_two_qubit

#define get_gate_template_two_qubit (   GATE_NAME)
Value:
else if (gate->get_type() == GATE_NAME##_OPERATION) { \
PyObject* qgd_gate_Dict = PyModule_GetDict( qgd_gate ); \
PyObject* py_gate_class = PyDict_GetItemString( qgd_gate_Dict, #GATE_NAME); \
PyObject* gate_input = Py_BuildValue("(OOO)", qbit_num, target_qbit, control_qbit); \
py_gate = PyObject_CallObject(py_gate_class, gate_input); \
qgd_Gate* py_gate_C = reinterpret_cast<qgd_Gate*>( py_gate ); \
delete( py_gate_C->gate ); \
py_gate_C->gate = static_cast<Gate*>( gate->clone() ); \
Py_DECREF( qgd_gate ); \
Py_DECREF( gate_input ); \
}
return Py_BuildValue("i", 0)
Type definition of the qgd_Gate Python class of the qgd_Gate module.
Base class for the representation of general gate operations.
Definition: Gate.h:86

Definition at line 2074 of file qgd_Circuit_Wrapper.cpp.

◆ PY_SSIZE_T_CLEAN

#define PY_SSIZE_T_CLEAN

Definition at line 26 of file qgd_Circuit_Wrapper.cpp.

◆ qgd_Circuit_Wrapper_add_one_qubit_gate

#define qgd_Circuit_Wrapper_add_one_qubit_gate (   gate_name,
  GATE_NAME 
)
Value:
static PyObject * \
qgd_Circuit_Wrapper_add_##GATE_NAME(qgd_Circuit_Wrapper *self, PyObject *args, PyObject *kwds) \
{\
static char *kwlist[] = {(char*)"target_qbit", NULL};\
\
int target_qbit = -1; \
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|i", kwlist,\
&target_qbit))\
return Py_BuildValue("i", -1);\
if (target_qbit != -1 ) {\
self->circuit->add_##gate_name(target_qbit);\
}\
\
return Py_BuildValue("i", 0);\
}
return Py_BuildValue("i", 0)
U3 RX RZ H Y SX S T CNOT CH SYC CRZ PyObject PyObject * kwds
U3 RX RZ H Y SX S T CNOT CH SYC CRZ PyObject * args
if(!PyArg_ParseTupleAndKeywords(args, kwds, "|O", kwlist, &target_qbits_py)) return Py_BuildValue("i"
Type definition for qgd_Circuit_Wrapper.

Definition at line 182 of file qgd_Circuit_Wrapper.cpp.

◆ qgd_Circuit_Wrapper_add_qbit_only_gate

#define qgd_Circuit_Wrapper_add_qbit_only_gate (   gate_name,
  GATE_NAME 
)
Value:
static PyObject * \
qgd_Circuit_Wrapper_add_##GATE_NAME(qgd_Circuit_Wrapper *self, PyObject *args, PyObject *kwds) \
{\
(void)args;\
(void)kwds;\
self->circuit->add_##gate_name();\
return Py_BuildValue("i", 0);\
}
return Py_BuildValue("i", 0)
U3 RX RZ H Y SX S T CNOT CH SYC CRZ PyObject PyObject * kwds
U3 RX RZ H Y SX S T CNOT CH SYC CRZ PyObject * args
Type definition for qgd_Circuit_Wrapper.

Definition at line 201 of file qgd_Circuit_Wrapper.cpp.

◆ qgd_Circuit_Wrapper_add_two_qubit_gate

#define qgd_Circuit_Wrapper_add_two_qubit_gate (   gate_name,
  GATE_NAME 
)
Value:
static PyObject * \
qgd_Circuit_Wrapper_add_##GATE_NAME(qgd_Circuit_Wrapper *self, PyObject *args, PyObject *kwds) \
{\
static char *kwlist[] = {(char*)"target_qbit", (char*)"control_qbit", NULL};\
int target_qbit = -1; \
int control_qbit = -1; \
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|ii", kwlist,\
&target_qbit, &control_qbit))\
return Py_BuildValue("i", -1);\
if (target_qbit != -1 ) {\
self->circuit->add_##gate_name(target_qbit, control_qbit);\
}\
return Py_BuildValue("i", 0);\
}
return Py_BuildValue("i", 0)
U3 RX RZ H Y SX S T CNOT CH SYC CRZ PyObject PyObject * kwds
U3 RX RZ H Y SX S T CNOT CH SYC CRZ PyObject * args
Type definition for qgd_Circuit_Wrapper.

Definition at line 211 of file qgd_Circuit_Wrapper.cpp.

Function Documentation

◆ circuit_matrix_float_owner_capsule_destruct()

static void circuit_matrix_float_owner_capsule_destruct ( PyObject *  cap)
static

Capsule destructor: calls delete on a heap-allocated Matrix_float, which correctly decrements the reference counter and then calls scalable_aligned_free.

Definition at line 1147 of file qgd_Circuit_Wrapper.cpp.

Here is the caller graph for this function:

◆ circuit_matrix_owner_capsule_destruct()

static void circuit_matrix_owner_capsule_destruct ( PyObject *  cap)
static

Capsule destructor: calls delete on a heap-allocated Matrix, which correctly decrements the reference counter and then calls scalable_aligned_free.

Definition at line 1137 of file qgd_Circuit_Wrapper.cpp.

Here is the caller graph for this function:

◆ create_Circuit()

Gates_block* create_Circuit ( int  qbit_num)

Creates an instance of class Gates_block (Circuit) and returns a pointer to the class instance.

Parameters
qbit_numNumber of qubits spanning the circuit
Returns
Returns a pointer to an instance of Gates_block class

Definition at line 93 of file qgd_Circuit_Wrapper.cpp.

Here is the caller graph for this function:

◆ get_gate()

static PyObject* get_gate ( Gates_block circuit,
int idx 
)
static

Call to get the metadata organized into Python dictionary of the idx-th gate.

Parameters
circuitA pointer pointing to an instance of the class Gates_block
idxLabels the idx-th gate (passed by reference, may be modified)
Returns
Returns a Python dictionary containing the metadata of the idx-th gate, or NULL on error

Definition at line 2108 of file qgd_Circuit_Wrapper.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ if() [1/2]

if ( PyArg_ParseTupleAndKeywordsargs, kwds, "|O", kwlist, &target_qbits_py)

◆ if() [2/2]

if ( target_qbits_py = NULL && PyList_Check(target_qbits_py))

Definition at line 288 of file qgd_Circuit_Wrapper.cpp.

Here is the call graph for this function:

◆ Py_BuildValue()

return Py_BuildValue ( "i"  ,
 
)

◆ PyInit_qgd_Circuit_Wrapper()

PyMODINIT_FUNC PyInit_qgd_Circuit_Wrapper ( void  )

Method called when the Python module is initialized.

Definition at line 3384 of file qgd_Circuit_Wrapper.cpp.

◆ qgd_Circuit_Wrapper_add_CCX()

CR static adaptive PyObject* qgd_Circuit_Wrapper_add_CCX ( qgd_Circuit_Wrapper self,
PyObject *  args,
PyObject *  kwds 
)
static

Wrapper function to add a CCX gate to the front of the gate structure.

Parameters
selfA pointer pointing to an instance of the class qgd_Circuit_Wrapper.
argsA tuple of the input arguments: target_qbit (int), control_qbits (list of ints)
kwdsA tuple of keywords

Definition at line 386 of file qgd_Circuit_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Circuit_Wrapper_add_Circuit()

static PyObject* qgd_Circuit_Wrapper_add_Circuit ( qgd_Circuit_Wrapper self,
PyObject *  args 
)
static

Wrapper function to add a block of operations to the front of the gate structure.

Parameters
selfA pointer pointing to an instance of the class qgd_Circuit_Wrapper.
argsA 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 481 of file qgd_Circuit_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Circuit_Wrapper_add_CSWAP()

static PyObject* qgd_Circuit_Wrapper_add_CSWAP ( qgd_Circuit_Wrapper self,
PyObject *  args,
PyObject *  kwds 
)
static

Wrapper function to add a CSWAP gate to the front of the gate structure.

Parameters
selfA pointer pointing to an instance of the class qgd_Circuit_Wrapper.
argsA tuple of the input arguments: target_qbits (list of ints), control_qbits (list of ints)
kwdsA tuple of keywords

Definition at line 428 of file qgd_Circuit_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Circuit_Wrapper_add_GENERAL()

static PyObject* qgd_Circuit_Wrapper_add_GENERAL ( qgd_Circuit_Wrapper self,
PyObject *  args,
PyObject *  kwds 
)
static

Wrapper function to add a GENERAL_OPERATION gate from an explicit matrix.

Parameters
selfA pointer to an instance of qgd_Circuit_Wrapper.
argsPositional args: operation_mtx (numpy.ndarray), optional target_qbits, optional control_qbits.
kwdsKeywords: is_f32 (bool, optional, default False).

Definition at line 511 of file qgd_Circuit_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Circuit_Wrapper_add_one_qubit_gate() [1/9]

qgd_Circuit_Wrapper_add_one_qubit_gate ( u1  ,
U1   
)

◆ qgd_Circuit_Wrapper_add_one_qubit_gate() [2/9]

U3 qgd_Circuit_Wrapper_add_one_qubit_gate ( u2  ,
U2   
)

◆ qgd_Circuit_Wrapper_add_one_qubit_gate() [3/9]

U3 RX qgd_Circuit_Wrapper_add_one_qubit_gate ( ry  ,
RY   
)

◆ qgd_Circuit_Wrapper_add_one_qubit_gate() [4/9]

U3 RX RZ qgd_Circuit_Wrapper_add_one_qubit_gate ( ,
R   
)

◆ qgd_Circuit_Wrapper_add_one_qubit_gate() [5/9]

U3 RX RZ H qgd_Circuit_Wrapper_add_one_qubit_gate ( ,
X   
)

◆ qgd_Circuit_Wrapper_add_one_qubit_gate() [6/9]

U3 RX RZ H Y qgd_Circuit_Wrapper_add_one_qubit_gate ( ,
Z   
)

◆ qgd_Circuit_Wrapper_add_one_qubit_gate() [7/9]

U3 RX RZ H Y SX qgd_Circuit_Wrapper_add_one_qubit_gate ( sxdg  ,
SXdg   
)

◆ qgd_Circuit_Wrapper_add_one_qubit_gate() [8/9]

U3 RX RZ H Y SX S qgd_Circuit_Wrapper_add_one_qubit_gate ( sdg  ,
Sdg   
)

◆ qgd_Circuit_Wrapper_add_one_qubit_gate() [9/9]

U3 RX RZ H Y SX S T qgd_Circuit_Wrapper_add_one_qubit_gate ( tdg  ,
Tdg   
)

◆ qgd_Circuit_Wrapper_add_RXX()

static PyObject* qgd_Circuit_Wrapper_add_RXX ( qgd_Circuit_Wrapper self,
PyObject *  args,
PyObject *  kwds 
)
static

Definition at line 303 of file qgd_Circuit_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Circuit_Wrapper_add_RYY()

static PyObject* qgd_Circuit_Wrapper_add_RYY ( qgd_Circuit_Wrapper self,
PyObject *  args,
PyObject *  kwds 
)
static

Definition at line 326 of file qgd_Circuit_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Circuit_Wrapper_add_RZZ()

static PyObject* qgd_Circuit_Wrapper_add_RZZ ( qgd_Circuit_Wrapper self,
PyObject *  args,
PyObject *  kwds 
)
static

Definition at line 349 of file qgd_Circuit_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Circuit_Wrapper_add_two_qubit_gate() [1/6]

U3 RX RZ H Y SX S T CNOT qgd_Circuit_Wrapper_add_two_qubit_gate ( cz  ,
CZ   
)

◆ qgd_Circuit_Wrapper_add_two_qubit_gate() [2/6]

U3 RX RZ H Y SX S T CNOT CH qgd_Circuit_Wrapper_add_two_qubit_gate ( cu  ,
CU   
)

◆ qgd_Circuit_Wrapper_add_two_qubit_gate() [3/6]

U3 RX RZ H Y SX S T CNOT CH SYC qgd_Circuit_Wrapper_add_two_qubit_gate ( cry  ,
CRY   
)

◆ qgd_Circuit_Wrapper_add_two_qubit_gate() [4/6]

U3 RX RZ H Y SX S T CNOT CH SYC CRZ qgd_Circuit_Wrapper_add_two_qubit_gate ( crx  ,
CRX   
)

◆ qgd_Circuit_Wrapper_add_two_qubit_gate() [5/6]

qgd_Circuit_Wrapper_add_two_qubit_gate ( cp  ,
CP   
)

◆ qgd_Circuit_Wrapper_add_two_qubit_gate() [6/6]

CR qgd_Circuit_Wrapper_add_two_qubit_gate ( crot  ,
CROT   
)

◆ qgd_Circuit_Wrapper_apply_derivate_to()

static PyObject* qgd_Circuit_Wrapper_apply_derivate_to ( qgd_Circuit_Wrapper self,
PyObject *  args,
PyObject *  kwds 
)
static

Evaluate the derivative of the circuit on an input matrix with respect to all free parameters (float64 only).

Parameters
selfA pointer pointing to an instance of the class qgd_Circuit_Wrapper
argsA tuple of the input arguments: parameters_arr (numpy array), unitary_arg (numpy array), parallel (int, optional)
kwdsOptional keyword arguments
Returns
Returns a Python list of numpy arrays, one per free parameter

Definition at line 1358 of file qgd_Circuit_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Circuit_Wrapper_apply_from_right()

static PyObject* qgd_Circuit_Wrapper_apply_from_right ( qgd_Circuit_Wrapper self,
PyObject *  args,
PyObject *  kwds 
)
static

Apply the gate circuit from the right on the input matrix with float32/float64 dispatch.

Parameters
selfA pointer pointing to an instance of the class qgd_Circuit_Wrapper
argsA tuple of the input arguments: parameters_arr (numpy array), unitary_arg (numpy array), parallel (int, optional)
kwdsKeywords: is_f32 (bool, optional, default False)
Returns
Returns 0 on success

Definition at line 1010 of file qgd_Circuit_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Circuit_Wrapper_apply_to()

static PyObject* qgd_Circuit_Wrapper_apply_to ( qgd_Circuit_Wrapper self,
PyObject *  args,
PyObject *  kwds 
)
static

Apply the gate circuit operation on the input matrix.

Parameters
selfA pointer pointing to an instance of the class qgd_Circuit_Wrapper
argsA tuple of the input arguments: parameters_arr (numpy array), unitary_arg (numpy array), parallel (int, optional)
kwdsA tuple of keywords
Returns
Returns 0 on success

Definition at line 861 of file qgd_Circuit_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Circuit_Wrapper_apply_to_combined()

static PyObject* qgd_Circuit_Wrapper_apply_to_combined ( qgd_Circuit_Wrapper self,
PyObject *  args,
PyObject *  kwds 
)
static

Evaluate forward circuit action and all derivatives in one call.

Return format: list where item[0] is apply_to output and item[1:] are derivatives.

Parameters
selfA pointer pointing to an instance of the class qgd_Circuit_Wrapper
argsA tuple of the input arguments: parameters_arr (numpy array), unitary_arg (numpy array), parallel (int, optional)
kwdsOptional keyword arguments
Returns
Returns a Python list of numpy arrays [forward, deriv_0, deriv_1, ...]

Definition at line 1541 of file qgd_Circuit_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Circuit_Wrapper_apply_to_list()

static PyObject* qgd_Circuit_Wrapper_apply_to_list ( qgd_Circuit_Wrapper self,
PyObject *  args,
PyObject *  kwds 
)
static

Apply the circuit to a list of input matrices with float32/float64 dispatch.

Parameters
selfA pointer pointing to an instance of the class qgd_Circuit_Wrapper
argsA tuple of the input arguments: inputs (list of numpy arrays), parameters_arr (numpy array), parallel (int, optional)
kwdsKeywords: is_f32 (bool, optional, default False)
Returns
Returns 0 on success

Definition at line 1161 of file qgd_Circuit_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Circuit_Wrapper_dealloc()

static void qgd_Circuit_Wrapper_dealloc ( qgd_Circuit_Wrapper self)
static

Method called when a python instance of the class qgd_Circuit_Wrapper is destroyed.

Parameters
selfA pointer pointing to an instance of class qgd_Circuit_Wrapper.

Definition at line 119 of file qgd_Circuit_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Circuit_Wrapper_Extract_Parameters()

static PyObject* qgd_Circuit_Wrapper_Extract_Parameters ( qgd_Circuit_Wrapper self,
PyObject *  args 
)
static

Call to extract the parameters corresponding to the gate from a parameter array associated with the circuit in which the gate is embedded.

Parameters
selfA pointer pointing to an instance of the class qgd_Circuit_Wrapper
argsA tuple of the input arguments: parameters_arr (numpy array, optional)
Returns
Returns a numpy array containing the extracted parameters, or -1 on error

Definition at line 2708 of file qgd_Circuit_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Circuit_Wrapper_get_children()

static PyObject* qgd_Circuit_Wrapper_get_children ( qgd_Circuit_Wrapper self,
PyObject *  args 
)
static

Wrapper function to get the indices of children gates.

Parameters
selfA pointer pointing to an instance of the class qgd_Circuit_Wrapper
argsA tuple of the input arguments: idx (integer) - the index of the gate for which we are retrieving the children
Returns
Returns a Python list containing the indices of children gates

Definition at line 2641 of file qgd_Circuit_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Circuit_Wrapper_get_Flat_Circuit()

static PyObject* qgd_Circuit_Wrapper_get_Flat_Circuit ( qgd_Circuit_Wrapper self)
static

Method to generate a flat circuit.

A flat circuit does not contain 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

Parameters
selfA pointer pointing to an instance of the class qgd_Circuit_Wrapper
Returns
Returns a new qgd_Circuit_Wrapper instance representing the flat circuit

Definition at line 2762 of file qgd_Circuit_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Circuit_Wrapper_get_gate()

static PyObject* qgd_Circuit_Wrapper_get_gate ( qgd_Circuit_Wrapper self,
PyObject *  args 
)
static

Wrapper function to get a gate from the circuit.

Parameters
selfA pointer pointing to an instance of the class qgd_Circuit_Wrapper
argsA tuple of the input arguments: idx (integer) - the index of the gate to retrieve
Returns
Returns a Python dictionary containing the gate metadata, or a gate object

Definition at line 2453 of file qgd_Circuit_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Circuit_Wrapper_get_Gate_Nums()

static PyObject* qgd_Circuit_Wrapper_get_Gate_Nums ( qgd_Circuit_Wrapper self)
static

Call to get the counts of individual gates in the circuit.

Parameters
selfA pointer pointing to an instance of the class qgd_Circuit_Wrapper
Returns
Returns a Python dictionary mapping gate type names to their counts in the circuit

Definition at line 2474 of file qgd_Circuit_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Circuit_Wrapper_get_gates()

static PyObject* qgd_Circuit_Wrapper_get_gates ( qgd_Circuit_Wrapper self)
static

Call to get the incorporated gates in a Python list.

Parameters
selfA pointer pointing to an instance of the class qgd_Circuit_Wrapper
Returns
Returns a Python list containing gate objects representing all gates in the circuit

Definition at line 2535 of file qgd_Circuit_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Circuit_Wrapper_get_Matrix()

static PyObject* qgd_Circuit_Wrapper_get_Matrix ( qgd_Circuit_Wrapper self,
PyObject *  args,
PyObject *  kwds 
)
static

Extract the optimized parameters and return the matrix representation of the gate circuit.

Parameters
selfA pointer pointing to an instance of the class qgd_Circuit_Wrapper
argsA tuple of the input arguments: start_index (integer, optional) - the index of the first inverse gate
Returns
Returns a numpy array containing the matrix representation of the circuit

Definition at line 793 of file qgd_Circuit_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Circuit_Wrapper_get_Parameter_Num()

static PyObject* qgd_Circuit_Wrapper_get_Parameter_Num ( qgd_Circuit_Wrapper self)
static

Get the number of free parameters in the gate structure used for the decomposition.

Definition at line 844 of file qgd_Circuit_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Circuit_Wrapper_get_Parameter_Start_Index()

static PyObject* qgd_Circuit_Wrapper_get_Parameter_Start_Index ( qgd_Circuit_Wrapper self)
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.

Parameters
selfA pointer pointing to an instance of the class qgd_Circuit_Wrapper
Returns
Returns the starting index as an integer

Definition at line 3088 of file qgd_Circuit_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Circuit_Wrapper_get_parents()

static PyObject* qgd_Circuit_Wrapper_get_parents ( qgd_Circuit_Wrapper self,
PyObject *  args 
)
static

Wrapper function to get the indices of parent gates.

Parameters
selfA pointer pointing to an instance of the class qgd_Circuit_Wrapper
argsA tuple of the input arguments: idx (integer) - the index of the gate for which we are retrieving the parents
Returns
Returns a Python list containing the indices of parent gates

Definition at line 2573 of file qgd_Circuit_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Circuit_Wrapper_get_Qbit_Num()

static PyObject* qgd_Circuit_Wrapper_get_Qbit_Num ( qgd_Circuit_Wrapper self)
static

Call to retrieve the number of qubits in the circuit.

Parameters
selfA pointer pointing to an instance of the class qgd_Circuit_Wrapper
Returns
Returns the number of qubits as an integer

Definition at line 1821 of file qgd_Circuit_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Circuit_Wrapper_get_Qbits()

static PyObject* qgd_Circuit_Wrapper_get_Qbits ( qgd_Circuit_Wrapper self)
static

Call to retrieve the list of qubits involved in the circuit.

Parameters
selfA pointer pointing to an instance of the class qgd_Circuit_Wrapper
Returns
Returns a Python list containing the qubit indices involved in the circuit

Definition at line 1893 of file qgd_Circuit_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Circuit_Wrapper_get_Second_Renyi_Entropy()

static PyObject* qgd_Circuit_Wrapper_get_Second_Renyi_Entropy ( qgd_Circuit_Wrapper self,
PyObject *  args 
)
static

Wrapper function to evaluate the second Rényi entropy of a quantum circuit at a specific parameter set.

Parameters
selfA pointer pointing to an instance of the class qgd_Circuit_Wrapper
argsA tuple of the input arguments: parameters_arr (numpy array, optional), input_state_arg (numpy array, optional), qubit_list_arg (list, optional)
Returns
Returns the second Rényi entropy value as a double, or -1 on error

Definition at line 1723 of file qgd_Circuit_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Circuit_Wrapper_getstate()

static PyObject* qgd_Circuit_Wrapper_getstate ( qgd_Circuit_Wrapper self)
static

Method to extract the stored quantum circuit in a human-readable data serialized and pickle-able format.

Parameters
selfA pointer pointing to an instance of the class qgd_Circuit_Wrapper
Returns
Returns a Python dictionary containing the serialized circuit state

Definition at line 2815 of file qgd_Circuit_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Circuit_Wrapper_init()

static int qgd_Circuit_Wrapper_init ( qgd_Circuit_Wrapper self,
PyObject *  args,
PyObject *  kwds 
)
static

Method called when a python instance of the class qgd_Circuit_Wrapper is initialized.

Parameters
selfA pointer pointing to an instance of the class qgd_Circuit_Wrapper.
argsA tuple of the input arguments: qbit_num (integer) qbit_num: the number of qubits spanning the operations
kwdsA tuple of keywords

Definition at line 168 of file qgd_Circuit_Wrapper.cpp.

◆ qgd_Circuit_Wrapper_new()

static PyObject* qgd_Circuit_Wrapper_new ( PyTypeObject type,
PyObject *  args,
PyObject *  kwds 
)
static

Method called when a python instance of the class qgd_Circuit_Wrapper is allocated.

Parameters
typeA pointer pointing to a structure describing the type of the class Circuit.

Definition at line 133 of file qgd_Circuit_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Circuit_Wrapper_Remap_Qbits()

static PyObject* qgd_Circuit_Wrapper_Remap_Qbits ( qgd_Circuit_Wrapper self,
PyObject *  args 
)
static

Call to remap the qubits in the circuit.

Parameters
selfA pointer pointing to an instance of the class qgd_Circuit_Wrapper
argsA tuple of the input arguments: qbit_map_arg (dictionary)
Returns
Returns 0 on success, -1 on error

Definition at line 1968 of file qgd_Circuit_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Circuit_Wrapper_set_Min_Fusion()

static PyObject* qgd_Circuit_Wrapper_set_Min_Fusion ( qgd_Circuit_Wrapper self,
PyObject *  args 
)
static

Definition at line 1929 of file qgd_Circuit_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Circuit_Wrapper_set_Qbit_Num()

static PyObject* qgd_Circuit_Wrapper_set_Qbit_Num ( qgd_Circuit_Wrapper self,
PyObject *  args 
)
static

Call to set the number of qubits in the circuit.

Parameters
selfA pointer pointing to an instance of the class qgd_Circuit_Wrapper
argsA tuple of the input arguments: qbit_num (integer, optional)
Returns
Returns None on success

Definition at line 1854 of file qgd_Circuit_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Circuit_Wrapper_setstate()

static PyObject* qgd_Circuit_Wrapper_setstate ( qgd_Circuit_Wrapper self,
PyObject *  args 
)
static

Call to set the state of a quantum circuit from a human-readable data serialized and pickle-able format.

Parameters
selfA pointer pointing to an instance of the class qgd_Circuit_Wrapper
argsA tuple of the input arguments: state (dictionary) - the serialized circuit state
Returns
Returns None on success

Definition at line 2927 of file qgd_Circuit_Wrapper.cpp.

Here is the call graph for this function:

◆ release_Circuit()

void release_Circuit ( Gates_block instance)

Call to deallocate an instance of Gates_block class.

Parameters
ptrA pointer pointing to an instance of Gates_block class

Definition at line 102 of file qgd_Circuit_Wrapper.cpp.

Here is the caller graph for this function:

Variable Documentation

◆ args

U3 RX RZ H Y SX S T CNOT CH SYC CRZ PyObject* args

Definition at line 280 of file qgd_Circuit_Wrapper.cpp.

◆ kwds

U3 RX RZ H Y SX S T CNOT CH SYC CRZ PyObject PyObject* kwds
Initial value:
{
static char *kwlist[] = {(char*)"target_qbits", NULL}

Definition at line 281 of file qgd_Circuit_Wrapper.cpp.

◆ qgd_Circuit_Wrapper_Members

PyMemberDef qgd_Circuit_Wrapper_Members[]
static
Initial value:
= {
{NULL}
}

Structure containing metadata about the members of class qgd_Circuit_Wrapper.

Definition at line 177 of file qgd_Circuit_Wrapper.cpp.

◆ qgd_Circuit_Wrapper_Methods

PyMethodDef qgd_Circuit_Wrapper_Methods[]
static

Definition at line 3097 of file qgd_Circuit_Wrapper.cpp.

◆ qgd_Circuit_Wrapper_Module

PyModuleDef qgd_Circuit_Wrapper_Module
static
Initial value:
= {
PyModuleDef_HEAD_INIT,
"qgd_Circuit_Wrapper",
"Python binding for QGD Circuit class",
-1,
}

Structure containing metadata about the module.

Definition at line 3373 of file qgd_Circuit_Wrapper.cpp.

◆ qgd_Circuit_Wrapper_Type

PyTypeObject qgd_Circuit_Wrapper_Type
static

A structure describing the type of the class Circuit.

Definition at line 3301 of file qgd_Circuit_Wrapper.cpp.

◆ target_qbits_py

PyObject* target_qbits_py = NULL

Definition at line 283 of file qgd_Circuit_Wrapper.cpp.