Sequential Quantum Gate Decomposer
v1.9.3
Powerful decomposition of general unitarias into one- and two-qubit gates gates
|
#include <Python.h>
#include <numpy/arrayobject.h>
#include "structmember.h"
#include <stdio.h>
#include "N_Qubit_Decomposition.h"
#include "numpy_interface.h"
Go to the source code of this file.
Classes | |
struct | qgd_Circuit_Wrapper |
Type definition of the qgd_Circuit_Wrapper Python class of the qgd_Circuit_Wrapper module. More... | |
struct | qgd_N_Qubit_Decomposition_Wrapper |
Type definition of the qgd_N_Qubit_Decomposition_Wrapper Python class of the qgd_N_Qubit_Decomposition_Wrapper module. More... | |
Macros | |
#define | PY_SSIZE_T_CLEAN |
Functions | |
N_Qubit_Decomposition * | create_N_Qubit_Decomposition (Matrix &Umtx, int qbit_num, bool optimize_layer_num, std::map< std::string, Config_Element > &config, guess_type initial_guess) |
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_N_Qubit_Decomposition_Wrapper (void) |
Method called when the Python module is initialized. More... | |
static void | qgd_N_Qubit_Decomposition_Wrapper_dealloc (qgd_N_Qubit_Decomposition_Wrapper *self) |
Method called when a python instance of the class qgd_N_Qubit_Decomposition_Wrapper is destroyed. More... | |
static PyObject * | qgd_N_Qubit_Decomposition_Wrapper_get_circuit (qgd_N_Qubit_Decomposition_Wrapper *self) |
Wrapper function to retrieve the circuit (Squander format) incorporated in the instance. More... | |
static PyObject * | qgd_N_Qubit_Decomposition_Wrapper_get_gate_num (qgd_N_Qubit_Decomposition_Wrapper *self) |
Wrapper function to get the number of decomposing gates. More... | |
static PyObject * | qgd_N_Qubit_Decomposition_Wrapper_get_Optimized_Parameters (qgd_N_Qubit_Decomposition_Wrapper *self) |
Extract the optimized parameters. More... | |
static int | qgd_N_Qubit_Decomposition_Wrapper_init (qgd_N_Qubit_Decomposition_Wrapper *self, PyObject *args, PyObject *kwds) |
Method called when a python instance of the class qgd_N_Qubit_Decomposition_Wrapper is initialized. More... | |
static PyObject * | qgd_N_Qubit_Decomposition_Wrapper_List_Gates (qgd_N_Qubit_Decomposition_Wrapper *self) |
Lists the gates decomposing the initial unitary. More... | |
static PyObject * | qgd_N_Qubit_Decomposition_Wrapper_new (PyTypeObject *type, PyObject *args, PyObject *kwds) |
Method called when a python instance of the class qgd_N_Qubit_Decomposition_Wrapper is allocated. More... | |
static PyObject * | qgd_N_Qubit_Decomposition_Wrapper_Reorder_Qubits (qgd_N_Qubit_Decomposition_Wrapper *self, PyObject *args) |
Wrapper method to reorder the qubits in the decomposition class. More... | |
static PyObject * | qgd_N_Qubit_Decomposition_Wrapper_set_Convergence_Threshold (qgd_N_Qubit_Decomposition_Wrapper *self, PyObject *args) |
Wrapper method to set the threshold of convergence in the optimization processes. More... | |
static PyObject * | qgd_N_Qubit_Decomposition_Wrapper_set_Debugfile (qgd_N_Qubit_Decomposition_Wrapper *self, PyObject *args) |
Set the debugfile name of the N_Qubit_Decomposition class. More... | |
static PyObject * | qgd_N_Qubit_Decomposition_Wrapper_set_Gate_Structure (qgd_N_Qubit_Decomposition_Wrapper *self, PyObject *args) |
Wrapper function to set custom gate structure for the decomposition. More... | |
static PyObject * | qgd_N_Qubit_Decomposition_Wrapper_set_Identical_Blocks (qgd_N_Qubit_Decomposition_Wrapper *self, PyObject *args) |
Set the number of identical successive blocks during the subdecomposition of the qbit-th qubit. More... | |
static PyObject * | qgd_N_Qubit_Decomposition_Wrapper_set_Iteration_Loops (qgd_N_Qubit_Decomposition_Wrapper *self, PyObject *args) |
Set the number of iteration loops during the subdecomposition of the qbit-th qubit. More... | |
static PyObject * | qgd_N_Qubit_Decomposition_Wrapper_set_Max_Layer_Num (qgd_N_Qubit_Decomposition_Wrapper *self, PyObject *args) |
Set the maximal number of layers used in the subdecomposition of the qbit-th qubit. More... | |
static PyObject * | qgd_N_Qubit_Decomposition_Wrapper_set_Optimization_Blocks (qgd_N_Qubit_Decomposition_Wrapper *self, PyObject *args) |
Wrapper method to to set the number of gate blocks to be optimized in one shot. More... | |
static PyObject * | qgd_N_Qubit_Decomposition_Wrapper_set_Optimization_Tolerance (qgd_N_Qubit_Decomposition_Wrapper *self, PyObject *args) |
Wrapper method to set the optimization tolerance of the optimization process during the decomposition. More... | |
static PyObject * | qgd_N_Qubit_Decomposition_Wrapper_set_Verbose (qgd_N_Qubit_Decomposition_Wrapper *self, PyObject *args) |
Set the verbosity of the N_Qubit_Decomposition class. More... | |
static PyObject * | qgd_N_Qubit_Decomposition_Wrapper_Start_Decomposition (qgd_N_Qubit_Decomposition_Wrapper *self, PyObject *args, PyObject *kwds) |
Wrapper function to call the start_decomposition method of C++ class N_Qubit_Decomposition. More... | |
void | release_N_Qubit_Decomposition (N_Qubit_Decomposition *instance) |
Call to deallocate an instance of N_Qubit_Decomposition class. More... | |
Variables | |
static PyMemberDef | qgd_N_Qubit_Decomposition_Wrapper_members [] |
Structure containing metadata about the members of class qgd_N_Qubit_Decomposition_Wrapper. More... | |
static PyMethodDef | qgd_N_Qubit_Decomposition_Wrapper_methods [] |
Structure containing metadata about the methods of class qgd_N_Qubit_Decomposition_Wrapper. More... | |
static PyModuleDef | qgd_N_Qubit_Decomposition_Wrapper_Module |
Structure containing metadata about the module. More... | |
static PyTypeObject | qgd_N_Qubit_Decomposition_Wrapper_Type |
A structure describing the type of the class qgd_N_Qubit_Decomposition_Wrapper. More... | |
#define PY_SSIZE_T_CLEAN |
Definition at line 27 of file qgd_N_Qubit_Decomposition_Wrapper.cpp.
N_Qubit_Decomposition* create_N_Qubit_Decomposition | ( | Matrix & | Umtx, |
int | qbit_num, | ||
bool | optimize_layer_num, | ||
std::map< std::string, Config_Element > & | config, | ||
guess_type | initial_guess | ||
) |
Creates an instance of class N_Qubit_Decomposition and return with a pointer pointing to the class instance (C++ linking is needed)
Umtx | An instance of class Matrix containing the unitary to be decomposed |
qbit_num | Number of qubits spanning the unitary |
optimize_layer_num | Logical value. Set true to optimize the number of decomposing layers during the decomposition procedure, or false otherwise. |
initial_guess | Type to guess the initial values for the optimization. Possible values: ZEROS=0, RANDOM=1, CLOSE_TO_ZERO=2 |
Definition at line 74 of file qgd_N_Qubit_Decomposition_Wrapper.cpp.
PyMODINIT_FUNC PyInit_qgd_N_Qubit_Decomposition_Wrapper | ( | void | ) |
Method called when the Python module is initialized.
Definition at line 874 of file qgd_N_Qubit_Decomposition_Wrapper.cpp.
|
static |
Method called when a python instance of the class qgd_N_Qubit_Decomposition_Wrapper is destroyed.
self | A pointer pointing to an instance of class qgd_N_Qubit_Decomposition_Wrapper. |
Definition at line 104 of file qgd_N_Qubit_Decomposition_Wrapper.cpp.
|
static |
Wrapper function to retrieve the circuit (Squander format) incorporated in the instance.
self | A pointer pointing to an instance of the class qgd_N_Qubit_Decomposition_custom_Wrapper. |
Definition at line 276 of file qgd_N_Qubit_Decomposition_Wrapper.cpp.
|
static |
Wrapper function to get the number of decomposing gates.
self | A pointer pointing to an instance of the class qgd_N_Qubit_Decomposition_Wrapper. |
Definition at line 257 of file qgd_N_Qubit_Decomposition_Wrapper.cpp.
|
static |
Extract the optimized parameters.
start_index | The index of the first inverse gate |
Definition at line 336 of file qgd_N_Qubit_Decomposition_Wrapper.cpp.
|
static |
Method called when a python instance of the class qgd_N_Qubit_Decomposition_Wrapper is initialized.
self | A pointer pointing to an instance of the class qgd_N_Qubit_Decomposition_Wrapper. |
args | A tuple of the input arguments: Umtx (numpy array), qbit_num (integer), optimize_layer_num (bool), initial_guess (string PyObject |
kwds | A tuple of keywords |
Definition at line 148 of file qgd_N_Qubit_Decomposition_Wrapper.cpp.
|
static |
Lists the gates decomposing the initial unitary.
(These gates are the inverse gates of the gates bringing the intial matrix into unity.)
start_index | The index of the first inverse gate |
Definition at line 321 of file qgd_N_Qubit_Decomposition_Wrapper.cpp.
|
static |
Method called when a python instance of the class qgd_N_Qubit_Decomposition_Wrapper is allocated.
type | A pointer pointing to a structure describing the type of the class qgd_N_Qubit_Decomposition_Wrapper. |
Definition at line 128 of file qgd_N_Qubit_Decomposition_Wrapper.cpp.
|
static |
Wrapper method to reorder the qubits in the decomposition class.
Definition at line 677 of file qgd_N_Qubit_Decomposition_Wrapper.cpp.
|
static |
Wrapper method to set the threshold of convergence in the optimization processes.
self | A pointer pointing to an instance of the class qgd_N_Qubit_Decomposition_Wrapper. |
args | A tuple of the input arguments: tolerance (double) tolerance: The maximal allowed error of the optimization problem |
Definition at line 580 of file qgd_N_Qubit_Decomposition_Wrapper.cpp.
|
static |
Set the debugfile name of the N_Qubit_Decomposition class.
self | A pointer pointing to an instance of the class qgd_N_Qubit_Decomposition_adaptive_Wrapper. |
args | A tuple of the input arguments: debugfile_name (string) debug: Set True to suppress the output messages of the decompostion into a file named debugfile_name, or False (deafult) otherwise. |
Definition at line 522 of file qgd_N_Qubit_Decomposition_Wrapper.cpp.
|
static |
Wrapper function to set custom gate structure for the decomposition.
self | A pointer pointing to an instance of the class qgd_N_Qubit_Decomposition_Wrapper. |
args | A tuple of the input arguments: gate_structure_dict (PyDict) gate_structure_dict: ????????????????????????????? |
Definition at line 629 of file qgd_N_Qubit_Decomposition_Wrapper.cpp.
|
static |
Set the number of identical successive blocks during the subdecomposition of the qbit-th qubit.
identical_blocks | A dictionary {'n': identical_blocks} labeling the number of successive identical layers used in the subdecomposition at the disentangling of the n-th qubit. |
Definition at line 406 of file qgd_N_Qubit_Decomposition_Wrapper.cpp.
|
static |
Set the number of iteration loops during the subdecomposition of the qbit-th qubit.
self | A pointer pointing to an instance of the class qgd_N_Qubit_Decomposition_Wrapper. |
args | A tuple of the input arguments: identical_blocks (PyDict) identical_blocks: A dictionary {'n': iteration_loops} labeling the number of successive identical layers used in the subdecomposition at the disentangling of the n-th qubit. |
Definition at line 454 of file qgd_N_Qubit_Decomposition_Wrapper.cpp.
|
static |
Set the maximal number of layers used in the subdecomposition of the qbit-th qubit.
max_layer_num | A dictionary {'n': max_layer_num} labeling the maximal number of the gate layers used in the subdecomposition. |
Definition at line 361 of file qgd_N_Qubit_Decomposition_Wrapper.cpp.
|
static |
Wrapper method to to set the number of gate blocks to be optimized in one shot.
self | A pointer pointing to an instance of the class qgd_N_Qubit_Decomposition_Wrapper. |
args | A tuple of the input arguments: tolerance (double) optimization_block: number of operators in one sub-layer of the optimization process |
Definition at line 604 of file qgd_N_Qubit_Decomposition_Wrapper.cpp.
|
static |
Wrapper method to set the optimization tolerance of the optimization process during the decomposition.
self | A pointer pointing to an instance of the class qgd_N_Qubit_Decomposition_Wrapper. |
args | A tuple of the input arguments: tolerance (double) tolerance: The maximal allowed error of the optimization problem |
Definition at line 557 of file qgd_N_Qubit_Decomposition_Wrapper.cpp.
|
static |
Set the verbosity of the N_Qubit_Decomposition class.
self | A pointer pointing to an instance of the class qgd_N_Qubit_Decomposition_Wrapper. |
args | A tuple of the input arguments: verbose (int) verbose: Set False to suppress the output messages of the decompostion, or True (deafult) otherwise. |
Definition at line 500 of file qgd_N_Qubit_Decomposition_Wrapper.cpp.
|
static |
Wrapper function to call the start_decomposition method of C++ class N_Qubit_Decomposition.
self | A pointer pointing to an instance of the class qgd_N_Qubit_Decomposition_Wrapper. |
kwds | A tuple of keywords |
Definition at line 227 of file qgd_N_Qubit_Decomposition_Wrapper.cpp.
void release_N_Qubit_Decomposition | ( | N_Qubit_Decomposition * | instance | ) |
Call to deallocate an instance of N_Qubit_Decomposition class.
ptr | A pointer pointing to an instance of N_Qubit_Decomposition class. |
Definition at line 85 of file qgd_N_Qubit_Decomposition_Wrapper.cpp.
|
static |
Structure containing metadata about the members of class qgd_N_Qubit_Decomposition_Wrapper.
Definition at line 731 of file qgd_N_Qubit_Decomposition_Wrapper.cpp.
|
static |
Structure containing metadata about the methods of class qgd_N_Qubit_Decomposition_Wrapper.
Definition at line 738 of file qgd_N_Qubit_Decomposition_Wrapper.cpp.
|
static |
Structure containing metadata about the module.
Definition at line 862 of file qgd_N_Qubit_Decomposition_Wrapper.cpp.
|
static |
A structure describing the type of the class qgd_N_Qubit_Decomposition_Wrapper.
Definition at line 790 of file qgd_N_Qubit_Decomposition_Wrapper.cpp.