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 "CR.h"
#include "CROT.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  CR_Wrapper_Type
 
struct  CROT_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 CR_Wrapper_Type CR_Wrapper_Type_ins
 
static CROT_Wrapper_Type CROT_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 176 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 79 of file gates_Wrapper.cpp.

◆ create_gate()

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

Definition at line 72 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 93 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 648 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 557 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 411 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 228 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 721 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 473 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 502 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 531 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 746 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 209 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 143 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 614 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 584 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 786 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 308 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 109 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 1330 of file gates_Wrapper.cpp.

Variable Documentation

◆ CH_Wrapper_Type_ins

CH_Wrapper_Type CH_Wrapper_Type_ins
static

Definition at line 1285 of file gates_Wrapper.cpp.

◆ CNOT_Wrapper_Type_ins

CNOT_Wrapper_Type CNOT_Wrapper_Type_ins
static

Definition at line 1286 of file gates_Wrapper.cpp.

◆ CR_Wrapper_Type_ins

CR_Wrapper_Type CR_Wrapper_Type_ins
static

Definition at line 1304 of file gates_Wrapper.cpp.

◆ CROT_Wrapper_Type_ins

CROT_Wrapper_Type CROT_Wrapper_Type_ins
static

Definition at line 1305 of file gates_Wrapper.cpp.

◆ CRY_Wrapper_Type_ins

CRY_Wrapper_Type CRY_Wrapper_Type_ins
static

Definition at line 1288 of file gates_Wrapper.cpp.

◆ CZ_Wrapper_Type_ins

CZ_Wrapper_Type CZ_Wrapper_Type_ins
static

Definition at line 1287 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 1040 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 993 of file gates_Wrapper.cpp.

◆ Gate_Wrapper_Type

Gate_Wrapper_Type_tmp Gate_Wrapper_Type
static

Definition at line 1068 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 1318 of file gates_Wrapper.cpp.

◆ H_Wrapper_Type_ins

H_Wrapper_Type H_Wrapper_Type_ins
static

Definition at line 1289 of file gates_Wrapper.cpp.

◆ R_Wrapper_Type_ins

R_Wrapper_Type R_Wrapper_Type_ins
static

Definition at line 1303 of file gates_Wrapper.cpp.

◆ RX_Wrapper_Type_ins

RX_Wrapper_Type RX_Wrapper_Type_ins
static

Definition at line 1290 of file gates_Wrapper.cpp.

◆ RY_Wrapper_Type_ins

RY_Wrapper_Type RY_Wrapper_Type_ins
static

Definition at line 1291 of file gates_Wrapper.cpp.

◆ RZ_Wrapper_Type_ins

RZ_Wrapper_Type RZ_Wrapper_Type_ins
static

Definition at line 1292 of file gates_Wrapper.cpp.

◆ SX_Wrapper_Type_ins

SX_Wrapper_Type SX_Wrapper_Type_ins
static

Definition at line 1293 of file gates_Wrapper.cpp.

◆ SYC_Wrapper_Type_ins

SYC_Wrapper_Type SYC_Wrapper_Type_ins
static

Definition at line 1294 of file gates_Wrapper.cpp.

◆ T_Wrapper_Type_ins

T_Wrapper_Type T_Wrapper_Type_ins
static

Definition at line 1301 of file gates_Wrapper.cpp.

◆ Tdg_Wrapper_Type_ins

Tdg_Wrapper_Type Tdg_Wrapper_Type_ins
static

Definition at line 1302 of file gates_Wrapper.cpp.

◆ U1_Wrapper_Type_ins

U1_Wrapper_Type U1_Wrapper_Type_ins
static

Definition at line 1295 of file gates_Wrapper.cpp.

◆ U2_Wrapper_Type_ins

U2_Wrapper_Type U2_Wrapper_Type_ins
static

Definition at line 1296 of file gates_Wrapper.cpp.

◆ U3_Wrapper_Type_ins

U3_Wrapper_Type U3_Wrapper_Type_ins
static

Definition at line 1297 of file gates_Wrapper.cpp.

◆ X_Wrapper_Type_ins

X_Wrapper_Type X_Wrapper_Type_ins
static

Definition at line 1298 of file gates_Wrapper.cpp.

◆ Y_Wrapper_Type_ins

Y_Wrapper_Type Y_Wrapper_Type_ins
static

Definition at line 1299 of file gates_Wrapper.cpp.

◆ Z_Wrapper_Type_ins

Z_Wrapper_Type Z_Wrapper_Type_ins
static

Definition at line 1300 of file gates_Wrapper.cpp.