Sequential Quantum Gate Decomposer  v1.9.3
Powerful decomposition of general unitarias into one- and two-qubit gates gates
Classes | Macros | Functions | Variables
gates_Wrapper.cpp File Reference
#include <Python.h>
#include "structmember.h"
#include "Gate.h"
#include "CH.h"
#include "CNOT.h"
#include "CZ.h"
#include "CRY.h"
#include "H.h"
#include "RX.h"
#include "RY.h"
#include "RZ.h"
#include "SX.h"
#include "SYC.h"
#include "U1.h"
#include "U2.h"
#include "U3.h"
#include "X.h"
#include "Y.h"
#include "Z.h"
#include "T.h"
#include "Tdg.h"
#include "R.h"
#include "numpy_interface.h"
Include dependency graph for gates_Wrapper.cpp:

Go to the source code of this file.

Classes

struct  CH_Wrapper_Type
 
struct  CNOT_Wrapper_Type
 
struct  CRY_Wrapper_Type
 
struct  CZ_Wrapper_Type
 
struct  Gate_Wrapper
 Type definition of the Gate_Wrapper Python class of the gates module. More...
 
struct  Gate_Wrapper_Type_tmp
 
struct  H_Wrapper_Type
 
struct  R_Wrapper_Type
 
struct  RX_Wrapper_Type
 
struct  RY_Wrapper_Type
 
struct  RZ_Wrapper_Type
 
struct  SX_Wrapper_Type
 
struct  SYC_Wrapper_Type
 
struct  T_Wrapper_Type
 
struct  Tdg_Wrapper_Type
 
struct  U1_Wrapper_Type
 
struct  U2_Wrapper_Type
 
struct  U3_Wrapper_Type
 
struct  X_Wrapper_Type
 
struct  Y_Wrapper_Type
 
struct  Z_Wrapper_Type
 

Macros

#define PY_SSIZE_T_CLEAN
 

Functions

template<typename GateT >
static PyObject * controlled_gate_Wrapper_new (PyTypeObject *type, PyObject *args, PyObject *kwds)
 Method called when a python instance of a controlled gate class is initialized. More...
 
template<typename GateT >
Gatecreate_controlled_gate (int qbit_num, int target_qbit, int control_qbit)
 
template<typename GateT >
Gatecreate_gate (int qbit_num, int target_qbit)
 
static void Gate_Wrapper_dealloc (Gate_Wrapper *self)
 Method called when a python instance of the class Gate_Wrapper is destroyed. More...
 
static PyObject * Gate_Wrapper_Extract_Parameters (Gate_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 * Gate_Wrapper_get_Control_Qbit (Gate_Wrapper *self)
 Call to get the control qbit (returns with -1 if no control qbit is used in the gate) More...
 
static PyObject * Gate_Wrapper_get_Gate_Kernel (Gate_Wrapper *self, PyObject *args, PyObject *kwds)
 Calculate the matrix of a U3 gate gate corresponding to the given parameters acting on a single qbit space. More...
 
static PyObject * Gate_Wrapper_get_Matrix (Gate_Wrapper *self, PyObject *args, PyObject *kwds)
 Call te extract t he matric representation of the gate. More...
 
static PyObject * Gate_Wrapper_get_Name (Gate_Wrapper *self)
 Extract the optimized parameters. More...
 
static PyObject * Gate_Wrapper_get_Parameter_Num (Gate_Wrapper *self)
 Call to get the number of free parameters in the gate. More...
 
static PyObject * Gate_Wrapper_get_Parameter_Start_Index (Gate_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 * Gate_Wrapper_get_Target_Qbit (Gate_Wrapper *self)
 Call to get the target qbit. More...
 
static PyObject * Gate_Wrapper_getstate (Gate_Wrapper *self)
 Method to extract the stored quantum gate in a human-readable data serialized and pickle-able format. More...
 
static int Gate_Wrapper_init (Gate_Wrapper *self, PyObject *args, PyObject *kwds)
 Method called when a python instance of a non-controlled gate class is initialized. More...
 
template<typename GateT >
static PyObject * Gate_Wrapper_new (PyTypeObject *type, PyObject *args, PyObject *kwds)
 Method called when a python instance of a non-controlled gate class is initialized. More...
 
static PyObject * Gate_Wrapper_set_Control_Qbit (Gate_Wrapper *self, PyObject *args)
 Call to set the target qbit. More...
 
static PyObject * Gate_Wrapper_set_Target_Qbit (Gate_Wrapper *self, PyObject *args)
 Call to set the target qbit. More...
 
static PyObject * Gate_Wrapper_setstate (Gate_Wrapper *self, PyObject *args)
 Call to set the state of quantum gate from a human-readable data serialized and pickle-able format. More...
 
static PyObject * Gate_Wrapper_Wrapper_apply_to (Gate_Wrapper *self, PyObject *args, PyObject *kwds)
 Call to apply the gate operation on an input state or matrix. More...
 
static PyObject * generic_Gate_Wrapper_new (PyTypeObject *type, PyObject *args, PyObject *kwds)
 Method called when a python instance of the class qgd_CH_Wrapper is allocated. More...
 
PyMODINIT_FUNC PyInit_gates_Wrapper (void)
 Method called when the Python module is initialized. More...
 

Variables

static CH_Wrapper_Type CH_Wrapper_Type_ins
 
static CNOT_Wrapper_Type CNOT_Wrapper_Type_ins
 
static CRY_Wrapper_Type CRY_Wrapper_Type_ins
 
static CZ_Wrapper_Type CZ_Wrapper_Type_ins
 
static PyMemberDef Gate_Wrapper_members []
 Structure containing metadata about the members of class qgd_CH_Wrapper. More...
 
static PyMethodDef Gate_Wrapper_methods []
 Structure containing metadata about the methods of class qgd_U3. More...
 
static Gate_Wrapper_Type_tmp Gate_Wrapper_Type
 
static PyModuleDef gates_Wrapper_Module
 Structure containing metadata about the module. More...
 
static H_Wrapper_Type H_Wrapper_Type_ins
 
static R_Wrapper_Type R_Wrapper_Type_ins
 
static RX_Wrapper_Type RX_Wrapper_Type_ins
 
static RY_Wrapper_Type RY_Wrapper_Type_ins
 
static RZ_Wrapper_Type RZ_Wrapper_Type_ins
 
static SX_Wrapper_Type SX_Wrapper_Type_ins
 
static SYC_Wrapper_Type SYC_Wrapper_Type_ins
 
static T_Wrapper_Type T_Wrapper_Type_ins
 
static Tdg_Wrapper_Type Tdg_Wrapper_Type_ins
 
static U1_Wrapper_Type U1_Wrapper_Type_ins
 
static U2_Wrapper_Type U2_Wrapper_Type_ins
 
static U3_Wrapper_Type U3_Wrapper_Type_ins
 
static X_Wrapper_Type X_Wrapper_Type_ins
 
static Y_Wrapper_Type Y_Wrapper_Type_ins
 
static Z_Wrapper_Type Z_Wrapper_Type_ins
 

Macro Definition Documentation

◆ PY_SSIZE_T_CLEAN

#define PY_SSIZE_T_CLEAN

Definition at line 27 of file gates_Wrapper.cpp.

Function Documentation

◆ controlled_gate_Wrapper_new()

template<typename GateT >
static PyObject* controlled_gate_Wrapper_new ( PyTypeObject type,
PyObject *  args,
PyObject *  kwds 
)
static

Method called when a python instance of a controlled gate class is initialized.

Parameters
selfA pointer pointing to an instance of the class Gate_Wrapper.
argsA tuple of the input arguments: qbit_num (int), target_qbit (int), control_qbit (int)
kwdsA tuple of keywords

Definition at line 174 of file gates_Wrapper.cpp.

◆ create_controlled_gate()

template<typename GateT >
Gate* create_controlled_gate ( int  qbit_num,
int  target_qbit,
int  control_qbit 
)

Definition at line 77 of file gates_Wrapper.cpp.

◆ create_gate()

template<typename GateT >
Gate* create_gate ( int  qbit_num,
int  target_qbit 
)

Definition at line 70 of file gates_Wrapper.cpp.

◆ Gate_Wrapper_dealloc()

static void Gate_Wrapper_dealloc ( Gate_Wrapper self)
static

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

Parameters
selfA pointer pointing to an instance of class Gate_Wrapper.

Definition at line 91 of file gates_Wrapper.cpp.

Here is the caller graph for this function:

◆ Gate_Wrapper_Extract_Parameters()

static PyObject* Gate_Wrapper_Extract_Parameters ( Gate_Wrapper self,
PyObject *  args 
)
static

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

Returns
Returns with he extracted parameters

Definition at line 646 of file gates_Wrapper.cpp.

Here is the call graph for this function:

◆ Gate_Wrapper_get_Control_Qbit()

static PyObject* Gate_Wrapper_get_Control_Qbit ( Gate_Wrapper self)
static

Call to get the control qbit (returns with -1 if no control qbit is used in the gate)

Returns
Returns with the control qbit

Definition at line 555 of file gates_Wrapper.cpp.

◆ Gate_Wrapper_get_Gate_Kernel()

static PyObject* Gate_Wrapper_get_Gate_Kernel ( Gate_Wrapper self,
PyObject *  args,
PyObject *  kwds 
)
static

Calculate the matrix of a U3 gate gate corresponding to the given parameters acting on a single qbit space.

Parameters
ThetaOver2Real parameter standing for the parameter theta (optional).
PhiReal parameter standing for the parameter phi (optional).
LambdaReal parameter standing for the parameter lambda (optional).
Returns
Returns with the matrix of the one-qubit matrix.

Definition at line 409 of file gates_Wrapper.cpp.

Here is the call graph for this function:

◆ Gate_Wrapper_get_Matrix()

static PyObject* Gate_Wrapper_get_Matrix ( Gate_Wrapper self,
PyObject *  args,
PyObject *  kwds 
)
static

Call te extract t he matric representation of the gate.

Parameters
start_indexThe index of the first inverse gate

Definition at line 226 of file gates_Wrapper.cpp.

Here is the call graph for this function:

◆ Gate_Wrapper_get_Name()

static PyObject* Gate_Wrapper_get_Name ( Gate_Wrapper self)
static

Extract the optimized parameters.

Parameters
start_indexThe index of the first inverse gate

Definition at line 719 of file gates_Wrapper.cpp.

◆ Gate_Wrapper_get_Parameter_Num()

static PyObject* Gate_Wrapper_get_Parameter_Num ( Gate_Wrapper self)
static

Call to get the number of free parameters in the gate.

Returns
Returns with the number of parameters

Definition at line 471 of file gates_Wrapper.cpp.

◆ Gate_Wrapper_get_Parameter_Start_Index()

static PyObject* Gate_Wrapper_get_Parameter_Start_Index ( Gate_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.

Returns
Returns with the starting index

Definition at line 500 of file gates_Wrapper.cpp.

◆ Gate_Wrapper_get_Target_Qbit()

static PyObject* Gate_Wrapper_get_Target_Qbit ( Gate_Wrapper self)
static

Call to get the target qbit.

Returns
Returns with the target qbit

Definition at line 529 of file gates_Wrapper.cpp.

◆ Gate_Wrapper_getstate()

static PyObject* Gate_Wrapper_getstate ( Gate_Wrapper self)
static

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

Definition at line 744 of file gates_Wrapper.cpp.

◆ Gate_Wrapper_init()

static int Gate_Wrapper_init ( Gate_Wrapper self,
PyObject *  args,
PyObject *  kwds 
)
static

Method called when a python instance of a non-controlled gate class is initialized.

Parameters
selfA pointer pointing to an instance of the class Gate_Wrapper.
argsA tuple of the input arguments: qbit_num (int), target_qbit (int)
kwdsA tuple of keywords

Definition at line 207 of file gates_Wrapper.cpp.

Here is the caller graph for this function:

◆ Gate_Wrapper_new()

template<typename GateT >
static PyObject* Gate_Wrapper_new ( PyTypeObject type,
PyObject *  args,
PyObject *  kwds 
)
static

Method called when a python instance of a non-controlled gate class is initialized.

Parameters
selfA pointer pointing to an instance of the class Gate_Wrapper.
argsA tuple of the input arguments: qbit_num (int), target_qbit (int)
kwdsA tuple of keywords

Definition at line 141 of file gates_Wrapper.cpp.

◆ Gate_Wrapper_set_Control_Qbit()

static PyObject* Gate_Wrapper_set_Control_Qbit ( Gate_Wrapper self,
PyObject *  args 
)
static

Call to set the target qbit.

Definition at line 612 of file gates_Wrapper.cpp.

◆ Gate_Wrapper_set_Target_Qbit()

static PyObject* Gate_Wrapper_set_Target_Qbit ( Gate_Wrapper self,
PyObject *  args 
)
static

Call to set the target qbit.

Definition at line 582 of file gates_Wrapper.cpp.

◆ Gate_Wrapper_setstate()

static PyObject* Gate_Wrapper_setstate ( Gate_Wrapper self,
PyObject *  args 
)
static

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

Definition at line 784 of file gates_Wrapper.cpp.

◆ Gate_Wrapper_Wrapper_apply_to()

static PyObject* Gate_Wrapper_Wrapper_apply_to ( Gate_Wrapper self,
PyObject *  args,
PyObject *  kwds 
)
static

Call to apply the gate operation on an input state or matrix.

Definition at line 306 of file gates_Wrapper.cpp.

Here is the call graph for this function:

◆ generic_Gate_Wrapper_new()

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

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

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

Definition at line 107 of file gates_Wrapper.cpp.

Here is the caller graph for this function:

◆ PyInit_gates_Wrapper()

PyMODINIT_FUNC PyInit_gates_Wrapper ( void  )

Method called when the Python module is initialized.

Definition at line 1297 of file gates_Wrapper.cpp.

Variable Documentation

◆ CH_Wrapper_Type_ins

CH_Wrapper_Type CH_Wrapper_Type_ins
static

Definition at line 1254 of file gates_Wrapper.cpp.

◆ CNOT_Wrapper_Type_ins

CNOT_Wrapper_Type CNOT_Wrapper_Type_ins
static

Definition at line 1255 of file gates_Wrapper.cpp.

◆ CRY_Wrapper_Type_ins

CRY_Wrapper_Type CRY_Wrapper_Type_ins
static

Definition at line 1257 of file gates_Wrapper.cpp.

◆ CZ_Wrapper_Type_ins

CZ_Wrapper_Type CZ_Wrapper_Type_ins
static

Definition at line 1256 of file gates_Wrapper.cpp.

◆ Gate_Wrapper_members

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

Structure containing metadata about the members of class qgd_CH_Wrapper.

Definition at line 1029 of file gates_Wrapper.cpp.

◆ Gate_Wrapper_methods

PyMethodDef Gate_Wrapper_methods[]
static

Structure containing metadata about the methods of class qgd_U3.

Definition at line 982 of file gates_Wrapper.cpp.

◆ Gate_Wrapper_Type

Gate_Wrapper_Type_tmp Gate_Wrapper_Type
static

Definition at line 1057 of file gates_Wrapper.cpp.

◆ gates_Wrapper_Module

PyModuleDef gates_Wrapper_Module
static
Initial value:
= {
PyModuleDef_HEAD_INIT,
"gates_Wrapper",
"Python binding for gates implemented in Squander C++",
-1,
}

Structure containing metadata about the module.

Definition at line 1285 of file gates_Wrapper.cpp.

◆ H_Wrapper_Type_ins

H_Wrapper_Type H_Wrapper_Type_ins
static

Definition at line 1258 of file gates_Wrapper.cpp.

◆ R_Wrapper_Type_ins

R_Wrapper_Type R_Wrapper_Type_ins
static

Definition at line 1272 of file gates_Wrapper.cpp.

◆ RX_Wrapper_Type_ins

RX_Wrapper_Type RX_Wrapper_Type_ins
static

Definition at line 1259 of file gates_Wrapper.cpp.

◆ RY_Wrapper_Type_ins

RY_Wrapper_Type RY_Wrapper_Type_ins
static

Definition at line 1260 of file gates_Wrapper.cpp.

◆ RZ_Wrapper_Type_ins

RZ_Wrapper_Type RZ_Wrapper_Type_ins
static

Definition at line 1261 of file gates_Wrapper.cpp.

◆ SX_Wrapper_Type_ins

SX_Wrapper_Type SX_Wrapper_Type_ins
static

Definition at line 1262 of file gates_Wrapper.cpp.

◆ SYC_Wrapper_Type_ins

SYC_Wrapper_Type SYC_Wrapper_Type_ins
static

Definition at line 1263 of file gates_Wrapper.cpp.

◆ T_Wrapper_Type_ins

T_Wrapper_Type T_Wrapper_Type_ins
static

Definition at line 1270 of file gates_Wrapper.cpp.

◆ Tdg_Wrapper_Type_ins

Tdg_Wrapper_Type Tdg_Wrapper_Type_ins
static

Definition at line 1271 of file gates_Wrapper.cpp.

◆ U1_Wrapper_Type_ins

U1_Wrapper_Type U1_Wrapper_Type_ins
static

Definition at line 1264 of file gates_Wrapper.cpp.

◆ U2_Wrapper_Type_ins

U2_Wrapper_Type U2_Wrapper_Type_ins
static

Definition at line 1265 of file gates_Wrapper.cpp.

◆ U3_Wrapper_Type_ins

U3_Wrapper_Type U3_Wrapper_Type_ins
static

Definition at line 1266 of file gates_Wrapper.cpp.

◆ X_Wrapper_Type_ins

X_Wrapper_Type X_Wrapper_Type_ins
static

Definition at line 1267 of file gates_Wrapper.cpp.

◆ Y_Wrapper_Type_ins

Y_Wrapper_Type Y_Wrapper_Type_ins
static

Definition at line 1268 of file gates_Wrapper.cpp.

◆ Z_Wrapper_Type_ins

Z_Wrapper_Type Z_Wrapper_Type_ins
static

Definition at line 1269 of file gates_Wrapper.cpp.