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

Go to the source code of this file.

Classes

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

Macros

#define NPY_NO_DEPRECATED_API   NPY_1_7_API_VERSION
 
#define PY_SSIZE_T_CLEAN
 

Functions

Generative_Quantum_Machine_Learning_Basecreate_qgd_Generative_Quantum_Machine_Learning_Base (std::vector< int > x_vectors, std::vector< std::vector< int >> x_bitstrings, Matrix_real P_star, Matrix_real sigma, int qbit_num, bool use_lookup_table, std::vector< std::vector< int >> cliques, bool use_exact, std::map< std::string, Config_Element > &config)
 Creates an instance of class Generative_Quantum_Machine_Learning_Base and return with a pointer pointing to the class instance (C++ linking is needed) More...
 
PyMODINIT_FUNC PyInit_qgd_Generative_Quantum_Machine_Learning_Base_Wrapper (void)
 Method called when the Python module is initialized. More...
 
static PyObject * qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_apply_to (qgd_Generative_Quantum_Machine_Learning_Base_Wrapper *self, PyObject *args)
 
static void qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_dealloc (qgd_Generative_Quantum_Machine_Learning_Base_Wrapper *self)
 Method called when a python instance of the class qgd_Generative_Quantum_Machine_Learning_Base_Wrapper is destroyed. More...
 
static PyObject * qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_Generate_Circuit (qgd_Generative_Quantum_Machine_Learning_Base_Wrapper *self, PyObject *args)
 
static PyObject * qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_get_circuit (qgd_Generative_Quantum_Machine_Learning_Base_Wrapper *self)
 Wrapper function to retrieve the circuit (Squander format) incorporated in the instance. More...
 
static PyObject * qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_get_Optimized_Parameters (qgd_Generative_Quantum_Machine_Learning_Base_Wrapper *self)
 Extract the optimized parameters. More...
 
static PyObject * qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_get_Parameter_Num (qgd_Generative_Quantum_Machine_Learning_Base_Wrapper *self)
 Get the number of free parameters in the gate structure used for the decomposition. More...
 
static PyObject * qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_get_Qbit_Num (qgd_Generative_Quantum_Machine_Learning_Base_Wrapper *self)
 Call to retrieve the number of qubits in the circuit. More...
 
static PyObject * qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_get_Second_Renyi_Entropy (qgd_Generative_Quantum_Machine_Learning_Base_Wrapper *self, PyObject *args)
 Wrapper function to evaluate the second Rényi entropy of a quantum circuit at a specific parameter set. More...
 
static int qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_init (qgd_Generative_Quantum_Machine_Learning_Base_Wrapper *self, PyObject *args, PyObject *kwds)
 Method called when a python instance of the class qgd_Generative_Quantum_Machine_Learning_Base_Wrapper is initialized. More...
 
static PyObject * qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_new (PyTypeObject *type, PyObject *args, PyObject *kwds)
 Method called when a python instance of the class qgd_Generative_Quantum_Machine_Learning_Base_Wrapper is allocated. More...
 
static PyObject * qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_Optimization_Problem (qgd_Generative_Quantum_Machine_Learning_Base_Wrapper *self, PyObject *args)
 
static PyObject * qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_set_Ansatz (qgd_Generative_Quantum_Machine_Learning_Base_Wrapper *self, PyObject *args, PyObject *kwds)
 
static PyObject * qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_set_Gate_Structure (qgd_Generative_Quantum_Machine_Learning_Base_Wrapper *self, PyObject *args)
 Wrapper function to set custom gate structure for the decomposition. More...
 
static PyObject * qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_set_Gate_Structure_From_Binary (qgd_Generative_Quantum_Machine_Learning_Base_Wrapper *self, PyObject *args)
 Wrapper function to set custom layers to the gate structure that are intended to be used in the decomposition. More...
 
static PyObject * qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_set_Initial_State (qgd_Generative_Quantum_Machine_Learning_Base_Wrapper *self, PyObject *args)
 Set the initial state used in the VQE process. More...
 
static PyObject * qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_set_Optimization_Tolerance (qgd_Generative_Quantum_Machine_Learning_Base_Wrapper *self, PyObject *args)
 
static PyObject * qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_set_Optimized_Parameters (qgd_Generative_Quantum_Machine_Learning_Base_Wrapper *self, PyObject *args)
 Set parameters for the solver. More...
 
static PyObject * qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_set_Optimizer (qgd_Generative_Quantum_Machine_Learning_Base_Wrapper *self, PyObject *args, PyObject *kwds)
 
static PyObject * qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_set_Project_Name (qgd_Generative_Quantum_Machine_Learning_Base_Wrapper *self, PyObject *args)
 Call to set a project name. More...
 
static PyObject * qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_Start_Optimization (qgd_Generative_Quantum_Machine_Learning_Base_Wrapper *self)
 
void release_Generative_Quantum_Machine_Learning_Base (Generative_Quantum_Machine_Learning_Base *instance)
 Call to deallocate an instance of Generative_Quantum_Machine_Learning_Base class. More...
 

Variables

static PyMemberDef qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_members []
 Structure containing metadata about the members of class qgd_N_Qubit_Decomposition_Wrapper. More...
 
static PyMethodDef qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_methods []
 Structure containing metadata about the methods of class qgd_N_Qubit_Decomposition_Wrapper. More...
 
static PyModuleDef qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_Module
 Structure containing metadata about the module. More...
 
static PyTypeObject qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_Type
 A structure describing the type of the class qgd_N_Qubit_Decomposition_Wrapper. More...
 

Macro Definition Documentation

◆ NPY_NO_DEPRECATED_API

#define NPY_NO_DEPRECATED_API   NPY_1_7_API_VERSION

Definition at line 24 of file qgd_GQML_Base_Wrapper.cpp.

◆ PY_SSIZE_T_CLEAN

#define PY_SSIZE_T_CLEAN

Definition at line 23 of file qgd_GQML_Base_Wrapper.cpp.

Function Documentation

◆ create_qgd_Generative_Quantum_Machine_Learning_Base()

Generative_Quantum_Machine_Learning_Base* create_qgd_Generative_Quantum_Machine_Learning_Base ( std::vector< int x_vectors,
std::vector< std::vector< int >>  x_bitstrings,
Matrix_real  P_star,
Matrix_real  sigma,
int  qbit_num,
bool  use_lookup_table,
std::vector< std::vector< int >>  cliques,
bool  use_exact,
std::map< std::string, Config_Element > &  config 
)

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

Parameters
x_vectorsThe input data indices
x_bitstringsThe input data bitstrings
P_starThe distribution to approximate
sigmaParameter of the gaussian kernels
qbit_numThe number of qubits spanning the unitary Umtx
use_lookupUse lookup table for the Gaussian kernels
cliquesThe cliques in the graph
use_exactUse exact calculation for MMD or just approximation with samples
configA map that can be used to set hyperparameters during the process
Returns
Return with a void pointer pointing to an instance of Generative_Quantum_Machine_Learning_Base class.

Definition at line 76 of file qgd_GQML_Base_Wrapper.cpp.

Here is the caller graph for this function:

◆ PyInit_qgd_Generative_Quantum_Machine_Learning_Base_Wrapper()

PyMODINIT_FUNC PyInit_qgd_Generative_Quantum_Machine_Learning_Base_Wrapper ( void  )

Method called when the Python module is initialized.

Definition at line 1219 of file qgd_GQML_Base_Wrapper.cpp.

◆ qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_apply_to()

static PyObject* qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_apply_to ( qgd_Generative_Quantum_Machine_Learning_Base_Wrapper self,
PyObject *  args 
)
static

Definition at line 559 of file qgd_GQML_Base_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_dealloc()

static void qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_dealloc ( qgd_Generative_Quantum_Machine_Learning_Base_Wrapper self)
static

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

Parameters
selfA pointer pointing to an instance of class qgd_Generative_Quantum_Machine_Learning_Base_Wrapper.

Definition at line 106 of file qgd_GQML_Base_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_Generate_Circuit()

static PyObject* qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_Generate_Circuit ( qgd_Generative_Quantum_Machine_Learning_Base_Wrapper self,
PyObject *  args 
)
static

Definition at line 861 of file qgd_GQML_Base_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_get_circuit()

static PyObject* qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_get_circuit ( qgd_Generative_Quantum_Machine_Learning_Base_Wrapper self)
static

Wrapper function to retrieve the circuit (Squander format) incorporated in the instance.

Parameters
selfA pointer pointing to an instance of the class qgd_N_Qubit_Decomposition_custom_Wrapper.

Definition at line 964 of file qgd_GQML_Base_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_get_Optimized_Parameters()

static PyObject* qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_get_Optimized_Parameters ( qgd_Generative_Quantum_Machine_Learning_Base_Wrapper self)
static

Extract the optimized parameters.

Parameters
start_indexThe index of the first inverse gate

Definition at line 333 of file qgd_GQML_Base_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_get_Parameter_Num()

static PyObject* qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_get_Parameter_Num ( qgd_Generative_Quantum_Machine_Learning_Base_Wrapper self)
static

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

Definition at line 948 of file qgd_GQML_Base_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_get_Qbit_Num()

static PyObject* qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_get_Qbit_Num ( qgd_Generative_Quantum_Machine_Learning_Base_Wrapper self)
static

Call to retrieve the number of qubits in the circuit.

Definition at line 380 of file qgd_GQML_Base_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_get_Second_Renyi_Entropy()

static PyObject* qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_get_Second_Renyi_Entropy ( qgd_Generative_Quantum_Machine_Learning_Base_Wrapper self,
PyObject *  args 
)
static

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

Definition at line 771 of file qgd_GQML_Base_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_init()

static int qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_init ( qgd_Generative_Quantum_Machine_Learning_Base_Wrapper self,
PyObject *  args,
PyObject *  kwds 
)
static

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

Parameters
selfA pointer pointing to an instance of the class qgd_Generative_Quantum_Machine_Learning_Base_Wrapper.
argsA tuple of the input arguments: x_bitsring_data (numpy array), p_star_data (numpy array), sigma (double), qbit_num (integer), cliques (numpy array), use_lookup_table (bool), cliques (list), use_exact (bool)
kwdsA tuple of keywords

Definition at line 157 of file qgd_GQML_Base_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_new()

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

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

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

Definition at line 136 of file qgd_GQML_Base_Wrapper.cpp.

◆ qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_Optimization_Problem()

static PyObject* qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_Optimization_Problem ( qgd_Generative_Quantum_Machine_Learning_Base_Wrapper self,
PyObject *  args 
)
static

Definition at line 891 of file qgd_GQML_Base_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_set_Ansatz()

static PyObject* qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_set_Ansatz ( qgd_Generative_Quantum_Machine_Learning_Base_Wrapper self,
PyObject *  args,
PyObject *  kwds 
)
static

Definition at line 698 of file qgd_GQML_Base_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_set_Gate_Structure()

static PyObject* qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_set_Gate_Structure ( qgd_Generative_Quantum_Machine_Learning_Base_Wrapper self,
PyObject *  args 
)
static

Wrapper function to set custom gate structure for the decomposition.

Parameters
selfA pointer pointing to an instance of the class qgd_N_Qubit_Decomposition_adaptive_Wrapper.
Returns
Returns with zero on success.

Definition at line 1036 of file qgd_GQML_Base_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_set_Gate_Structure_From_Binary()

static PyObject* qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_set_Gate_Structure_From_Binary ( qgd_Generative_Quantum_Machine_Learning_Base_Wrapper self,
PyObject *  args 
)
static

Wrapper function to set custom layers to the gate structure that are intended to be used in the decomposition.

Definition at line 503 of file qgd_GQML_Base_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_set_Initial_State()

static PyObject* qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_set_Initial_State ( qgd_Generative_Quantum_Machine_Learning_Base_Wrapper self,
PyObject *  args 
)
static

Set the initial state used in the VQE process.

Definition at line 455 of file qgd_GQML_Base_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_set_Optimization_Tolerance()

static PyObject* qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_set_Optimization_Tolerance ( qgd_Generative_Quantum_Machine_Learning_Base_Wrapper self,
PyObject *  args 
)
static

Definition at line 540 of file qgd_GQML_Base_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_set_Optimized_Parameters()

static PyObject* qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_set_Optimized_Parameters ( qgd_Generative_Quantum_Machine_Learning_Base_Wrapper self,
PyObject *  args 
)
static

Set parameters for the solver.

Definition at line 409 of file qgd_GQML_Base_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_set_Optimizer()

static PyObject* qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_set_Optimizer ( qgd_Generative_Quantum_Machine_Learning_Base_Wrapper self,
PyObject *  args,
PyObject *  kwds 
)
static

Definition at line 615 of file qgd_GQML_Base_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_set_Project_Name()

static PyObject* qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_set_Project_Name ( qgd_Generative_Quantum_Machine_Learning_Base_Wrapper self,
PyObject *  args 
)
static

Call to set a project name.

Definition at line 1010 of file qgd_GQML_Base_Wrapper.cpp.

Here is the call graph for this function:

◆ qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_Start_Optimization()

static PyObject* qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_Start_Optimization ( qgd_Generative_Quantum_Machine_Learning_Base_Wrapper self)
static

Definition at line 351 of file qgd_GQML_Base_Wrapper.cpp.

Here is the call graph for this function:

◆ release_Generative_Quantum_Machine_Learning_Base()

void release_Generative_Quantum_Machine_Learning_Base ( Generative_Quantum_Machine_Learning_Base instance)

Call to deallocate an instance of Generative_Quantum_Machine_Learning_Base class.

Parameters
ptrA pointer pointing to an instance of Generative_Quantum_Machine_Learning_Base class.

Definition at line 87 of file qgd_GQML_Base_Wrapper.cpp.

Here is the caller graph for this function:

Variable Documentation

◆ qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_members

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

Structure containing metadata about the members of class qgd_N_Qubit_Decomposition_Wrapper.

Definition at line 1070 of file qgd_GQML_Base_Wrapper.cpp.

◆ qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_methods

PyMethodDef qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_methods[]
static

Structure containing metadata about the methods of class qgd_N_Qubit_Decomposition_Wrapper.

Definition at line 1077 of file qgd_GQML_Base_Wrapper.cpp.

◆ qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_Module

PyModuleDef qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_Module
static
Initial value:
= {
PyModuleDef_HEAD_INIT,
"qgd_N_Qubit_Decomposition_Wrapper",
"Python binding for QGD N_Qubit_Decomposition class",
-1,
}

Structure containing metadata about the module.

Definition at line 1207 of file qgd_GQML_Base_Wrapper.cpp.

◆ qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_Type

PyTypeObject qgd_Generative_Quantum_Machine_Learning_Base_Wrapper_Type
static

A structure describing the type of the class qgd_N_Qubit_Decomposition_Wrapper.

Definition at line 1135 of file qgd_GQML_Base_Wrapper.cpp.