Sequential Quantum Gate Decomposer  v1.9.3
Powerful decomposition of general unitarias into one- and two-qubit gates gates
Classes | Macros | Functions | Variables
qgd_R_Wrapper.cpp File Reference
#include <Python.h>
#include "structmember.h"
#include "R.h"
#include "numpy_interface.h"
Include dependency graph for qgd_R_Wrapper.cpp:

Go to the source code of this file.

Classes

struct  qgd_R_Wrapper
 Type definition of the qgd_RX_Wrapper Python class of the qgd_RX_Wrapper module. More...
 

Macros

#define PY_SSIZE_T_CLEAN
 

Functions

Rcreate_R (int qbit_num, int target_qbit)
 Creates an instance of class N_Qubit_Decomposition and return with a pointer pointing to the class instance (C++ linking is needed) More...
 
PyMODINIT_FUNC PyInit_qgd_R_Wrapper (void)
 Method called when the Python module is initialized. More...
 
static PyObject * qgd_R_Wrapper_apply_to (qgd_R_Wrapper *self, PyObject *args)
 Call to apply the gate operation on the inut matrix. More...
 
static void qgd_R_Wrapper_dealloc (qgd_R_Wrapper *self)
 Method called when a python instance of the class qgd_RX_Wrapper is destroyed. More...
 
static PyObject * qgd_R_Wrapper_Extract_Parameters (qgd_R_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_R_Wrapper_get_Control_Qbit (qgd_R_Wrapper *self)
 Call to get the control qbit (returns with -1 if no control qbit is used in the gate) More...
 
static PyObject * qgd_R_Wrapper_get_Gate_Kernel (qgd_R_Wrapper *self, PyObject *args)
 Calculate the matrix of a U3 gate gate corresponding to the given parameters acting on a single qbit space. More...
 
static PyObject * qgd_R_Wrapper_get_Matrix (qgd_R_Wrapper *self, PyObject *args)
 Extract the optimized parameters. More...
 
static PyObject * qgd_R_Wrapper_get_Parameter_Num (qgd_R_Wrapper *self)
 Call to get the number of free parameters in the gate. More...
 
static PyObject * qgd_R_Wrapper_get_Parameter_Start_Index (qgd_R_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_R_Wrapper_get_Target_Qbit (qgd_R_Wrapper *self)
 Call to get the target qbit. More...
 
static int qgd_R_Wrapper_init (qgd_R_Wrapper *self, PyObject *args, PyObject *kwds)
 Method called when a python instance of the class qgd_RX_Wrapper is initialized. More...
 
static PyObject * qgd_R_Wrapper_new (PyTypeObject *type, PyObject *args, PyObject *kwds)
 Method called when a python instance of the class qgd_RX_Wrapper is allocated. More...
 
static PyObject * qgd_R_Wrapper_set_Target_Qbit (qgd_R_Wrapper *self, PyObject *args)
 Call to set the target qbit. More...
 
void release_R (R *instance)
 Call to deallocate an instance of N_Qubit_Decomposition class. More...
 

Variables

static PyMemberDef qgd_R_Wrapper_members []
 Structure containing metadata about the members of class qgd_RX_Wrapper. More...
 
static PyMethodDef qgd_R_Wrapper_methods []
 Structure containing metadata about the methods of class qgd_RX_Wrapper. More...
 
static PyModuleDef qgd_R_Wrapper_Module
 Structure containing metadata about the module. More...
 
static PyTypeObject qgd_R_Wrapper_Type
 A structure describing the type of the class qgd_RX_Wrapper. More...
 

Macro Definition Documentation

◆ PY_SSIZE_T_CLEAN

#define PY_SSIZE_T_CLEAN

Definition at line 27 of file qgd_R_Wrapper.cpp.

Function Documentation

◆ create_R()

R* create_R ( int  qbit_num,
int  target_qbit 
)

Creates an instance of class N_Qubit_Decomposition and return with a pointer pointing to the class instance (C++ linking is needed)

Parameters
qbit_numThe number of qubits spanning the operation.
target_qbitThe 0<=ID<qbit_num of the target qubit.

Definition at line 54 of file qgd_R_Wrapper.cpp.

Here is the caller graph for this function:

◆ PyInit_qgd_R_Wrapper()

PyMODINIT_FUNC PyInit_qgd_R_Wrapper ( void  )

Method called when the Python module is initialized.

Definition at line 514 of file qgd_R_Wrapper.cpp.

◆ qgd_R_Wrapper_apply_to()

static PyObject* qgd_R_Wrapper_apply_to ( qgd_R_Wrapper self,
PyObject *  args 
)
static

Call to apply the gate operation on the inut matrix.

Definition at line 179 of file qgd_R_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_R_Wrapper_dealloc()

static void qgd_R_Wrapper_dealloc ( qgd_R_Wrapper self)
static

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

Parameters
selfA pointer pointing to an instance of class qgd_RX_Wrapper.

Definition at line 83 of file qgd_R_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_R_Wrapper_Extract_Parameters()

static PyObject* qgd_R_Wrapper_Extract_Parameters ( qgd_R_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.

Definition at line 335 of file qgd_R_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_R_Wrapper_get_Control_Qbit()

static PyObject* qgd_R_Wrapper_get_Control_Qbit ( qgd_R_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 309 of file qgd_R_Wrapper.cpp.

◆ qgd_R_Wrapper_get_Gate_Kernel()

static PyObject* qgd_R_Wrapper_get_Gate_Kernel ( qgd_R_Wrapper self,
PyObject *  args 
)
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.
PhiReal parameter standing for the parameter phi.
LambdaReal parameter standing for the parameter lambda.
Returns
Returns with the matrix of the one-qubit matrix.

Definition at line 239 of file qgd_R_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_R_Wrapper_get_Matrix()

static PyObject* qgd_R_Wrapper_get_Matrix ( qgd_R_Wrapper self,
PyObject *  args 
)
static

Extract the optimized parameters.

Parameters
start_indexThe index of the first inverse gate

Definition at line 139 of file qgd_R_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_R_Wrapper_get_Parameter_Num()

static PyObject* qgd_R_Wrapper_get_Parameter_Num ( qgd_R_Wrapper self)
static

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

Returns
Returns with the starting index

Definition at line 268 of file qgd_R_Wrapper.cpp.

◆ qgd_R_Wrapper_get_Parameter_Start_Index()

static PyObject* qgd_R_Wrapper_get_Parameter_Start_Index ( qgd_R_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 281 of file qgd_R_Wrapper.cpp.

◆ qgd_R_Wrapper_get_Target_Qbit()

static PyObject* qgd_R_Wrapper_get_Target_Qbit ( qgd_R_Wrapper self)
static

Call to get the target qbit.

Returns
Returns with the target qbit

Definition at line 296 of file qgd_R_Wrapper.cpp.

◆ qgd_R_Wrapper_init()

static int qgd_R_Wrapper_init ( qgd_R_Wrapper self,
PyObject *  args,
PyObject *  kwds 
)
static

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

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

Definition at line 114 of file qgd_R_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_R_Wrapper_new()

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

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

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

Definition at line 98 of file qgd_R_Wrapper.cpp.

◆ qgd_R_Wrapper_set_Target_Qbit()

static PyObject* qgd_R_Wrapper_set_Target_Qbit ( qgd_R_Wrapper self,
PyObject *  args 
)
static

Call to set the target qbit.

Definition at line 321 of file qgd_R_Wrapper.cpp.

◆ release_R()

void release_R ( R instance)

Call to deallocate an instance of N_Qubit_Decomposition class.

Parameters
ptrA pointer pointing to an instance of N_Qubit_Decomposition class.

Definition at line 65 of file qgd_R_Wrapper.cpp.

Here is the caller graph for this function:

Variable Documentation

◆ qgd_R_Wrapper_members

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

Structure containing metadata about the members of class qgd_RX_Wrapper.

Definition at line 386 of file qgd_R_Wrapper.cpp.

◆ qgd_R_Wrapper_methods

PyMethodDef qgd_R_Wrapper_methods[]
static
Initial value:
= {
{"get_Matrix", (PyCFunction) qgd_R_Wrapper_get_Matrix, METH_VARARGS,
"Method to get the matrix of the operation."
},
{"apply_to", (PyCFunction) qgd_R_Wrapper_apply_to, METH_VARARGS,
"Call to apply the gate on the input matrix."
},
{"get_Gate_Kernel", (PyCFunction) qgd_R_Wrapper_get_Gate_Kernel, METH_VARARGS,
"Call to calculate the gate matrix acting on a single qbit space."
},
{"get_Parameter_Num", (PyCFunction) qgd_R_Wrapper_get_Parameter_Num, METH_NOARGS,
"Call to get the number of free parameters in the gate."
},
{"get_Parameter_Start_Index", (PyCFunction) qgd_R_Wrapper_get_Parameter_Start_Index, METH_NOARGS,
"Call to get the starting index of the parameters in the parameter array corresponding to the circuit in which the current gate is incorporated."
},
{"get_Target_Qbit", (PyCFunction) qgd_R_Wrapper_get_Target_Qbit, METH_NOARGS,
"Call to get the target qbit."
},
{"get_Control_Qbit", (PyCFunction) qgd_R_Wrapper_get_Control_Qbit, METH_NOARGS,
"Call to get the control qbit (returns with -1 if no control qbit is used in the gate)."
},
{"set_Target_Qbit", (PyCFunction) qgd_R_Wrapper_set_Target_Qbit, METH_VARARGS,
"Call to set the target qbit."
},
{"Extract_Parameters", (PyCFunction) qgd_R_Wrapper_Extract_Parameters, METH_VARARGS,
"Call to extract the paramaters corresponding to the gate, from a parameter array associated to the circuit in which the gate is embedded."
},
{NULL}
}
static PyObject * qgd_R_Wrapper_apply_to(qgd_R_Wrapper *self, PyObject *args)
Call to apply the gate operation on the inut matrix.
static PyObject * qgd_R_Wrapper_get_Parameter_Num(qgd_R_Wrapper *self)
Call to get the number of free parameters in the gate.
static PyObject * qgd_R_Wrapper_get_Control_Qbit(qgd_R_Wrapper *self)
Call to get the control qbit (returns with -1 if no control qbit is used in the gate) ...
static PyObject * qgd_R_Wrapper_get_Matrix(qgd_R_Wrapper *self, PyObject *args)
Extract the optimized parameters.
static PyObject * qgd_R_Wrapper_set_Target_Qbit(qgd_R_Wrapper *self, PyObject *args)
Call to set the target qbit.
static PyObject * qgd_R_Wrapper_get_Gate_Kernel(qgd_R_Wrapper *self, PyObject *args)
Calculate the matrix of a U3 gate gate corresponding to the given parameters acting on a single qbit ...
static PyObject * qgd_R_Wrapper_get_Target_Qbit(qgd_R_Wrapper *self)
Call to get the target qbit.
static PyObject * qgd_R_Wrapper_Extract_Parameters(qgd_R_Wrapper *self, PyObject *args)
Call to extract the paramaters corresponding to the gate, from a parameter array associated to the ci...
static PyObject * qgd_R_Wrapper_get_Parameter_Start_Index(qgd_R_Wrapper *self)
Call to get the starting index of the parameters in the parameter array corresponding to the circuit ...

Structure containing metadata about the methods of class qgd_RX_Wrapper.

Definition at line 394 of file qgd_R_Wrapper.cpp.

◆ qgd_R_Wrapper_Module

PyModuleDef qgd_R_Wrapper_Module
static
Initial value:
= {
PyModuleDef_HEAD_INIT,
"qgd_R_Wrapper",
"Python binding for QGD R gate",
-1,
}

Structure containing metadata about the module.

Definition at line 502 of file qgd_R_Wrapper.cpp.

◆ qgd_R_Wrapper_Type

PyTypeObject qgd_R_Wrapper_Type
static

A structure describing the type of the class qgd_RX_Wrapper.

Definition at line 429 of file qgd_R_Wrapper.cpp.