|
Sequential Quantum Gate Decomposer
v1.9.6
Powerful decomposition of general unitarias into one- and two-qubit gates gates
|
#include <Python.h>#include "structmember.h"#include "Gate.h"#include "CU.h"#include "CH.h"#include "CNOT.h"#include "CZ.h"#include "CRY.h"#include "CRX.h"#include "CRZ.h"#include "CP.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 "S.h"#include "SDG.h"#include "T.h"#include "Tdg.h"#include "R.h"#include "CR.h"#include "CROT.h"#include "CCX.h"#include "SWAP.h"#include "CSWAP.h"#include "numpy_interface.h"#include "RXX.h"#include "RYY.h"#include "RZZ.h"#include "SXdg.h"
Go to the source code of this file.
Classes | |
| struct | CCX_Wrapper_Type |
| struct | CSWAP_Wrapper_Type |
| struct | Gate_Wrapper |
| Type definition of the Gate_Wrapper Python class of the gates module. More... | |
| struct | Gate_Wrapper_Type_tmp |
| struct | RXX_Wrapper_Type |
| struct | RYY_Wrapper_Type |
| struct | RZZ_Wrapper_Type |
| struct | SWAP_Wrapper_Type |
Macros | |
| #define | GATE_WRAPPER_BASE_METHODS |
| Structure containing metadata about the methods of class qgd_U3. More... | |
| #define | gate_wrapper_type_template(gate_name, wrapper_new) |
| #define | Py_INCREF_template(gate_name) |
| #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 > | |
| Gate * | create_controlled_gate (int qbit_num, int target_qbit, int control_qbit) |
| template<typename GateT > | |
| Gate * | create_gate (int qbit_num, int target_qbit) |
| template<typename GateT > | |
| Gate * | create_multi_qubit_gate (int qbit_num, int target_qbit, const std::vector< int > &control_qbits) |
| template<typename GateT > | |
| Gate * | create_multi_target_controlled_gate (int qbit_num, const std::vector< int > &target_qbits, const std::vector< int > &control_qbits) |
| template<typename GateT > | |
| Gate * | create_multi_target_gate (int qbit_num, const std::vector< int > &target_qbits) |
| template<typename GateT > | |
| Gate * | create_qbit_gate (int qbit_num) |
| 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_Control_Qbits (Gate_Wrapper *self) |
| Call to get the control qubits vector. 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_Involved_Qbits (Gate_Wrapper *self) |
| Call to get the target qubits vector. 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_get_Target_Qbits (Gate_Wrapper *self) |
| Call to get the target qubits vector. 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_Control_Qbits (Gate_Wrapper *self, PyObject *args) |
| Call to set the control qubits from a Python list. More... | |
| static PyObject * | Gate_Wrapper_set_Target_Qbit (Gate_Wrapper *self, PyObject *args) |
| Call to set the target qbit. More... | |
| static PyObject * | Gate_Wrapper_set_Target_Qbits (Gate_Wrapper *self, PyObject *args) |
| Call to set the target qubits from a Python list. 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... | |
| gate_wrapper_type_template (CH, controlled_gate_Wrapper_new) | |
| gate_wrapper_type_template (CNOT, controlled_gate_Wrapper_new) | |
| gate_wrapper_type_template (CZ, controlled_gate_Wrapper_new) | |
| gate_wrapper_type_template (CRY, controlled_gate_Wrapper_new) | |
| gate_wrapper_type_template (CRX, controlled_gate_Wrapper_new) | |
| gate_wrapper_type_template (CRZ, controlled_gate_Wrapper_new) | |
| gate_wrapper_type_template (CP, controlled_gate_Wrapper_new) | |
| gate_wrapper_type_template (CU, controlled_gate_Wrapper_new) | |
| gate_wrapper_type_template (CR, controlled_gate_Wrapper_new) | |
| gate_wrapper_type_template (CROT, controlled_gate_Wrapper_new) | |
| gate_wrapper_type_template (SYC, controlled_gate_Wrapper_new) | |
| gate_wrapper_type_template (H, Gate_Wrapper_new) | |
| gate_wrapper_type_template (RX, Gate_Wrapper_new) | |
| gate_wrapper_type_template (RY, Gate_Wrapper_new) | |
| gate_wrapper_type_template (RZ, Gate_Wrapper_new) | |
| gate_wrapper_type_template (U1, Gate_Wrapper_new) | |
| gate_wrapper_type_template (U2, Gate_Wrapper_new) | |
| gate_wrapper_type_template (U3, Gate_Wrapper_new) | |
| gate_wrapper_type_template (X, Gate_Wrapper_new) | |
| gate_wrapper_type_template (Y, Gate_Wrapper_new) | |
| gate_wrapper_type_template (Z, Gate_Wrapper_new) | |
| gate_wrapper_type_template (S, Gate_Wrapper_new) | |
| gate_wrapper_type_template (SDG, Gate_Wrapper_new) | |
| gate_wrapper_type_template (SX, Gate_Wrapper_new) | |
| gate_wrapper_type_template (SXdg, Gate_Wrapper_new) | |
| gate_wrapper_type_template (T, Gate_Wrapper_new) | |
| gate_wrapper_type_template (Tdg, Gate_Wrapper_new) | |
| gate_wrapper_type_template (R, Gate_Wrapper_new) | |
| static PyObject * | Gate_Wrapper_Wrapper_apply_derivate_to (Gate_Wrapper *self, PyObject *args, PyObject *kwds) |
| Call to evaluate derivatives of the gate action on an input state or matrix. More... | |
| static PyObject * | Gate_Wrapper_Wrapper_apply_from_right (Gate_Wrapper *self, PyObject *args, PyObject *kwds) |
| Call to apply the gate operation from the right side on an input state or matrix. 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 * | Gate_Wrapper_Wrapper_apply_to_combined (Gate_Wrapper *self, PyObject *args, PyObject *kwds) |
| Call to evaluate forward gate action and all derivatives in one call. More... | |
| static PyObject * | Gate_Wrapper_Wrapper_apply_to_list (Gate_Wrapper *self, PyObject *args, PyObject *kwds) |
| Call to apply the gate operation on a list of input states or matrices. 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... | |
| static void | matrix_float_owner_capsule_destruct (PyObject *cap) |
| Capsule destructor for heap-allocated Matrix_float. More... | |
| static void | matrix_owner_capsule_destruct (PyObject *cap) |
| Capsule destructor: calls delete on a heap-allocated Matrix, which correctly decrements the reference counter and calls scalable_aligned_free when last owner. More... | |
| template<typename GateT > | |
| static PyObject * | multi_control_gate_Wrapper_new (PyTypeObject *type, PyObject *args, PyObject *kwds) |
| Generic wrapper for single-target multi-control gates (e.g., CCX) More... | |
| template<typename GateT > | |
| static PyObject * | multi_target_controlled_gate_Wrapper_new (PyTypeObject *type, PyObject *args, PyObject *kwds) |
| Generic wrapper for multi-target controlled gates (e.g., CSWAP) More... | |
| template<typename GateT > | |
| static PyObject * | multi_target_gate_Wrapper_new (PyTypeObject *type, PyObject *args, PyObject *kwds) |
| Generic wrapper for multi-target gates without control (e.g., SWAP) More... | |
| PyMODINIT_FUNC | PyInit_gates_Wrapper (void) |
| Method called when the Python module is initialized. More... | |
| template<typename GateT > | |
| static PyObject * | qbit_gate_Wrapper_new (PyTypeObject *type, PyObject *args, PyObject *kwds) |
| Method called when a python instance of a qbit-only gate class is initialized. More... | |
Variables | |
| static CCX_Wrapper_Type | CCX_Wrapper_Type_ins |
| static CSWAP_Wrapper_Type | CSWAP_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 [] |
| static Gate_Wrapper_Type_tmp | Gate_Wrapper_Type |
| static PyModuleDef | gates_Wrapper_Module |
| Structure containing metadata about the module. More... | |
| static RXX_Wrapper_Type | RXX_Wrapper_Type_ins |
| static RYY_Wrapper_Type | RYY_Wrapper_Type_ins |
| static RZZ_Wrapper_Type | RZZ_Wrapper_Type_ins |
| static SWAP_Wrapper_Type | SWAP_Wrapper_Type_ins |
| #define GATE_WRAPPER_BASE_METHODS |
Structure containing metadata about the methods of class qgd_U3.
Definition at line 2803 of file gates_Wrapper.cpp.
| #define gate_wrapper_type_template | ( | gate_name, | |
| wrapper_new | |||
| ) |
Definition at line 2911 of file gates_Wrapper.cpp.
| #define Py_INCREF_template | ( | gate_name | ) |
Definition at line 3065 of file gates_Wrapper.cpp.
| #define PY_SSIZE_T_CLEAN |
Definition at line 27 of file gates_Wrapper.cpp.
|
static |
Method called when a python instance of a controlled gate class is initialized.
| self | A pointer pointing to an instance of the class Gate_Wrapper. |
| args | A tuple of the input arguments: qbit_num (int), target_qbit (int), control_qbit (int) |
| kwds | A tuple of keywords |
Definition at line 264 of file gates_Wrapper.cpp.
| Gate* create_controlled_gate | ( | int | qbit_num, |
| int | target_qbit, | ||
| int | control_qbit | ||
| ) |
Definition at line 97 of file gates_Wrapper.cpp.
Definition at line 84 of file gates_Wrapper.cpp.
| Gate* create_multi_qubit_gate | ( | int | qbit_num, |
| int | target_qbit, | ||
| const std::vector< int > & | control_qbits | ||
| ) |
Definition at line 113 of file gates_Wrapper.cpp.
| Gate* create_multi_target_controlled_gate | ( | int | qbit_num, |
| const std::vector< int > & | target_qbits, | ||
| const std::vector< int > & | control_qbits | ||
| ) |
Definition at line 121 of file gates_Wrapper.cpp.
| Gate* create_multi_target_gate | ( | int | qbit_num, |
| const std::vector< int > & | target_qbits | ||
| ) |
Definition at line 105 of file gates_Wrapper.cpp.
Definition at line 90 of file gates_Wrapper.cpp.
|
static |
Method called when a python instance of the class Gate_Wrapper is destroyed.
| self | A pointer pointing to an instance of class Gate_Wrapper. |
Definition at line 135 of file gates_Wrapper.cpp.

|
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 2197 of file gates_Wrapper.cpp.

|
static |
Call to get the control qbit (returns with -1 if no control qbit is used in the gate)
Definition at line 1923 of file gates_Wrapper.cpp.

|
static |
Call to get the control qubits vector.
Definition at line 2042 of file gates_Wrapper.cpp.

|
static |
Calculate the matrix of a U3 gate gate corresponding to the given parameters acting on a single qbit space.
| ThetaOver2 | Real parameter standing for the parameter theta (optional). |
| Phi | Real parameter standing for the parameter phi (optional). |
| Lambda | Real parameter standing for the parameter lambda (optional). |
Definition at line 1772 of file gates_Wrapper.cpp.

|
static |
Call to get the target qubits vector.
Definition at line 2165 of file gates_Wrapper.cpp.

|
static |
Call te extract t he matric representation of the gate.
| start_index | The index of the first inverse gate |
Definition at line 516 of file gates_Wrapper.cpp.

|
static |
Extract the optimized parameters.
| start_index | The index of the first inverse gate |
Definition at line 2284 of file gates_Wrapper.cpp.
|
static |
Call to get the number of free parameters in the gate.
Definition at line 1839 of file gates_Wrapper.cpp.

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

|
static |
Call to get the target qbit.
Definition at line 1897 of file gates_Wrapper.cpp.

|
static |
Call to get the target qubits vector.
Definition at line 2011 of file gates_Wrapper.cpp.

|
static |
Method to extract the stored quantum gate in a human-readable data serialized and pickle-able format.
Definition at line 2309 of file gates_Wrapper.cpp.

|
static |
Method called when a python instance of a non-controlled gate class is initialized.
| self | A pointer pointing to an instance of the class Gate_Wrapper. |
| args | A tuple of the input arguments: qbit_num (int), target_qbit (int) |
| kwds | A tuple of keywords |
Definition at line 497 of file gates_Wrapper.cpp.

|
static |
Method called when a python instance of a non-controlled gate class is initialized.
| self | A pointer pointing to an instance of the class Gate_Wrapper. |
| args | A tuple of the input arguments: qbit_num (int), target_qbit (int) |
| kwds | A tuple of keywords |
Definition at line 190 of file gates_Wrapper.cpp.
|
static |
Call to set the target qbit.
Definition at line 1978 of file gates_Wrapper.cpp.

|
static |
Call to set the control qubits from a Python list.
Definition at line 2118 of file gates_Wrapper.cpp.

|
static |
Call to set the target qbit.
Definition at line 1948 of file gates_Wrapper.cpp.

|
static |
Call to set the target qubits from a Python list.
Definition at line 2072 of file gates_Wrapper.cpp.

|
static |
Call to set the state of quantum gate from a human-readable data serialized and pickle-able format.
Definition at line 2438 of file gates_Wrapper.cpp.

| gate_wrapper_type_template | ( | CH | , |
| controlled_gate_Wrapper_new | |||
| ) |
| gate_wrapper_type_template | ( | CNOT | , |
| controlled_gate_Wrapper_new | |||
| ) |
| gate_wrapper_type_template | ( | CZ | , |
| controlled_gate_Wrapper_new | |||
| ) |
| gate_wrapper_type_template | ( | CRY | , |
| controlled_gate_Wrapper_new | |||
| ) |
| gate_wrapper_type_template | ( | CRX | , |
| controlled_gate_Wrapper_new | |||
| ) |
| gate_wrapper_type_template | ( | CRZ | , |
| controlled_gate_Wrapper_new | |||
| ) |
| gate_wrapper_type_template | ( | CP | , |
| controlled_gate_Wrapper_new | |||
| ) |
| gate_wrapper_type_template | ( | CU | , |
| controlled_gate_Wrapper_new | |||
| ) |
| gate_wrapper_type_template | ( | CR | , |
| controlled_gate_Wrapper_new | |||
| ) |
| gate_wrapper_type_template | ( | CROT | , |
| controlled_gate_Wrapper_new | |||
| ) |
| gate_wrapper_type_template | ( | SYC | , |
| controlled_gate_Wrapper_new | |||
| ) |
| gate_wrapper_type_template | ( | H | , |
| Gate_Wrapper_new | |||
| ) |
| gate_wrapper_type_template | ( | RX | , |
| Gate_Wrapper_new | |||
| ) |
| gate_wrapper_type_template | ( | RY | , |
| Gate_Wrapper_new | |||
| ) |
| gate_wrapper_type_template | ( | RZ | , |
| Gate_Wrapper_new | |||
| ) |
| gate_wrapper_type_template | ( | U1 | , |
| Gate_Wrapper_new | |||
| ) |
| gate_wrapper_type_template | ( | U2 | , |
| Gate_Wrapper_new | |||
| ) |
| gate_wrapper_type_template | ( | U3 | , |
| Gate_Wrapper_new | |||
| ) |
| gate_wrapper_type_template | ( | X | , |
| Gate_Wrapper_new | |||
| ) |
| gate_wrapper_type_template | ( | Y | , |
| Gate_Wrapper_new | |||
| ) |
| gate_wrapper_type_template | ( | Z | , |
| Gate_Wrapper_new | |||
| ) |
| gate_wrapper_type_template | ( | S | , |
| Gate_Wrapper_new | |||
| ) |
| gate_wrapper_type_template | ( | SDG | , |
| Gate_Wrapper_new | |||
| ) |
| gate_wrapper_type_template | ( | SX | , |
| Gate_Wrapper_new | |||
| ) |
| gate_wrapper_type_template | ( | SXdg | , |
| Gate_Wrapper_new | |||
| ) |
| gate_wrapper_type_template | ( | T | , |
| Gate_Wrapper_new | |||
| ) |
| gate_wrapper_type_template | ( | Tdg | , |
| Gate_Wrapper_new | |||
| ) |
| gate_wrapper_type_template | ( | R | , |
| Gate_Wrapper_new | |||
| ) |
|
static |
Call to evaluate derivatives of the gate action on an input state or matrix.
Definition at line 1291 of file gates_Wrapper.cpp.

|
static |
Call to apply the gate operation from the right side on an input state or matrix.
Definition at line 680 of file gates_Wrapper.cpp.

|
static |
Call to apply the gate operation on an input state or matrix.
Definition at line 1092 of file gates_Wrapper.cpp.

|
static |
Call to evaluate forward gate action and all derivatives in one call.
Return format: list where item[0] is apply_to output, item[1:] are derivatives.
Definition at line 1535 of file gates_Wrapper.cpp.

|
static |
Call to apply the gate operation on a list of input states or matrices.
Definition at line 859 of file gates_Wrapper.cpp.

|
static |
Method called when a python instance of the class qgd_CH_Wrapper is allocated.
| type | A pointer pointing to a structure describing the type of the class qgd_CH_Wrapper. |
Definition at line 151 of file gates_Wrapper.cpp.

|
static |
Capsule destructor for heap-allocated Matrix_float.
Definition at line 1282 of file gates_Wrapper.cpp.

|
static |
Capsule destructor: calls delete on a heap-allocated Matrix, which correctly decrements the reference counter and calls scalable_aligned_free when last owner.
Definition at line 1273 of file gates_Wrapper.cpp.

|
static |
Generic wrapper for single-target multi-control gates (e.g., CCX)
| type | The Python type object |
| args | Positional arguments: qbit_num (int), target_qbit (int), control_qbits (list of ints) |
| kwds | Keyword arguments |
Definition at line 306 of file gates_Wrapper.cpp.
|
static |
Generic wrapper for multi-target controlled gates (e.g., CSWAP)
| type | The Python type object |
| args | Positional arguments: qbit_num (int), target_qbits (list of ints), control_qbits (list of ints) |
| kwds | Keyword arguments |
Definition at line 424 of file gates_Wrapper.cpp.
|
static |
Generic wrapper for multi-target gates without control (e.g., SWAP)
| type | The Python type object |
| args | Positional arguments: qbit_num (int), target_qbits (list of ints) |
| kwds | Keyword arguments |
Definition at line 368 of file gates_Wrapper.cpp.
| PyMODINIT_FUNC PyInit_gates_Wrapper | ( | void | ) |
Method called when the Python module is initialized.
Definition at line 3077 of file gates_Wrapper.cpp.
|
static |
Method called when a python instance of a qbit-only gate class is initialized.
| type | A pointer pointing to an instance of the class Gate_Wrapper. |
| args | A tuple of the input arguments: qbit_num (int) |
| kwds | A tuple of keywords |
Definition at line 230 of file gates_Wrapper.cpp.
|
static |
Definition at line 2978 of file gates_Wrapper.cpp.
|
static |
Definition at line 2989 of file gates_Wrapper.cpp.
|
static |
Structure containing metadata about the members of class qgd_CH_Wrapper.
Definition at line 2881 of file gates_Wrapper.cpp.
|
static |
Definition at line 2865 of file gates_Wrapper.cpp.
|
static |
Definition at line 2908 of file gates_Wrapper.cpp.
|
static |
Structure containing metadata about the module.
Definition at line 3058 of file gates_Wrapper.cpp.
|
static |
Definition at line 2944 of file gates_Wrapper.cpp.
|
static |
Definition at line 2955 of file gates_Wrapper.cpp.
|
static |
Definition at line 2966 of file gates_Wrapper.cpp.
|
static |
Definition at line 2933 of file gates_Wrapper.cpp.
1.8.13