Sequential Quantum Gate Decomposer
v1.9.3
Powerful decomposition of general unitarias into one- and two-qubit gates gates
|
Base class for the representation of general gate operations. More...
#include <Gate.h>
Public Member Functions | |
void | add_child (Gate *child) |
Call to add a child gate to the current gate. More... | |
void | add_parent (Gate *parent) |
Call to add a parent gate to the current gate. More... | |
virtual std::vector< Matrix > | apply_derivate_to (Matrix_real ¶meters_mtx_in, Matrix &input, int parallel) |
Call to evaluate the derivate of the circuit on an inout with respect to all of the free parameters. More... | |
virtual void | apply_from_right (Matrix &input) |
Call to apply the gate on the input array/matrix by input*Gate. More... | |
virtual void | apply_to (Matrix &input, int parallel) |
Call to apply the gate on the input array/matrix. More... | |
virtual void | apply_to (Matrix_real ¶meter_mtx, Matrix &input, int parallel) |
Abstract function to be overriden in derived classes to be used to transform an input upon a parametric gate operation. More... | |
virtual void | apply_to_list (std::vector< Matrix > &inputs, int parallel) |
Call to apply the gate on a list of inputs. More... | |
virtual void | apply_to_list (Matrix_real ¶meters_mtx, std::vector< Matrix > &inputs, int parallel) |
Abstract function to be overriden in derived classes to be used to transform a list of inputs upon a parametric gate operation. More... | |
virtual Matrix | calc_one_qubit_u3 (double Theta, double Phi, double Lambda) |
Calculate the matrix of a U3 gate gate corresponding to the given parameters acting on a single qbit space. More... | |
virtual Matrix | calc_one_qubit_u3 () |
Calculate the matrix of the constans gates. More... | |
void | clear_children () |
Call to erase data on children. More... | |
void | clear_parents () |
Call to erase data on parents. More... | |
virtual Gate * | clone () |
Call to create a clone of the present class. More... | |
virtual Matrix_real | extract_parameters (Matrix_real ¶meters) |
Call to extract parameters from the parameter array corresponding to the circuit, in which the gate is embedded. More... | |
Gate () | |
Default constructor of the class. More... | |
Gate (int qbit_num_in) | |
Constructor of the class. More... | |
std::vector< Gate * > | get_children () |
Call to get the children of the current gate. More... | |
int | get_control_qbit () |
Call to get the index of the control qubit. More... | |
virtual std::vector< int > | get_involved_qubits () |
Call to get the qubits involved in the gate operation. More... | |
virtual Matrix | get_matrix () |
Call to retrieve the operation matrix. More... | |
virtual Matrix | get_matrix (int parallel) |
Call to retrieve the operation matrix. More... | |
virtual Matrix | get_matrix (Matrix_real ¶meters) |
Call to retrieve the gate matrix. More... | |
virtual Matrix | get_matrix (Matrix_real ¶meters, int parallel) |
Call to retrieve the gate matrix. More... | |
std::string | get_name () |
Call to get the name label of the gate. More... | |
int | get_parameter_num () |
Call to get the number of free parameters. More... | |
int | get_parameter_start_idx () |
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... | |
std::vector< Gate * > | get_parents () |
Call to get the parents of the current gate. More... | |
int | get_qbit_num () |
Call to get the number of qubits composing the unitary. More... | |
int | get_target_qbit () |
Call to get the index of the target qubit. More... | |
gate_type | get_type () |
Call to get the type of the operation. More... | |
virtual void | parameters_for_calc_one_qubit (double &ThetaOver2, double &Phi, double &Lambda) |
Calculate the matrix of a U3 gate gate corresponding to the given parameters acting on a single qbit space. More... | |
void | print (const std::stringstream &sstream, int verbose_level=1) const |
Call to print output messages in the function of the verbosity level. More... | |
virtual void | reorder_qubits (std::vector< int > qbit_list) |
Call to reorder the qubits in the matrix of the operation. More... | |
void | set_children (std::vector< Gate *> &children_) |
Call to set the children of the current gate. More... | |
void | set_control_qbit (int control_qbit_in) |
Call to set the control qubit for the gate operation. More... | |
void | set_debugfile (std::string debugfile) |
Call to set the debugfile name. More... | |
void | set_matrix (Matrix input) |
Call to set the stored matrix in the operation. More... | |
void | set_parameter_start_idx (int start_idx) |
Call to set the starting index of the parameters in the parameter array corresponding to the circuit in which the current gate is incorporated. More... | |
void | set_parents (std::vector< Gate *> &parents_) |
Call to set the parents of the current gate. More... | |
virtual void | set_qbit_num (int qbit_num_in) |
Set the number of qubits spanning the matrix of the operation. More... | |
void | set_target_qbit (int target_qbit_in) |
Call to set the target qubit for the gate operation. More... | |
void | set_verbose (int verbose_in) |
Call to set the verbose attribute. More... | |
virtual | ~Gate () |
Destructor of the class. More... | |
Public Attributes | |
bool | debug |
Logical variable. Set true to write output messages to the 'debug.txt' file. More... | |
std::string | debugfile_name |
String variable. Set the debug file name. More... | |
int | verbose |
Set the verbosity level of the output messages. More... | |
Protected Member Functions | |
void | apply_kernel_from_right (Matrix &u3_1qbit, Matrix &input) |
Call to apply the gate kernel on the input state or unitary from right (no AVX support) More... | |
void | apply_kernel_to (Matrix &u3_1qbit, Matrix &input, bool deriv=false, int parallel=0) |
Call to apply the gate kernel on the input state or unitary with optional AVX support. More... | |
Protected Attributes | |
std::vector< Gate * > | children |
list of child gates to be applied after this current gate More... | |
int | control_qbit |
The index of the qubit which acts as a control qubit (control_qbit >= 0) in controlled operations. More... | |
int | matrix_size |
The size N of the NxN matrix associated with the operations. More... | |
std::string | name |
A string labeling the gate operation. More... | |
int | parameter_num |
the number of free parameters of the operation More... | |
int | parameter_start_idx |
the index in the parameter array (corrensponding to the encapsulated circuit) where the gate parameters begin (if gates are placed into a circuit a single parameter array is used to execute the whole circuit) More... | |
std::vector< Gate * > | parents |
list of parent gates to be applied in the circuit prior to this current gate More... | |
int | qbit_num |
number of qubits spanning the matrix of the operation More... | |
int | target_qbit |
The index of the qubit on which the operation acts (target_qbit >= 0) More... | |
gate_type | type |
The type of the operation (see enumeration gate_type) More... | |
Private Attributes | |
Matrix | matrix_alloc |
Matrix of the operation. More... | |
Gate::Gate | ( | ) |
Gate::Gate | ( | int | qbit_num_in | ) |
void Gate::add_child | ( | Gate * | child | ) |
void Gate::add_parent | ( | Gate * | parent | ) |
|
virtual |
Call to evaluate the derivate of the circuit on an inout with respect to all of the free parameters.
parameters | An array of the input parameters. |
input | The input array on which the gate is applied |
parallel | Set 0 for sequential execution, 1 for parallel execution with OpenMP (NOT IMPLEMENTED YET) and 2 for parallel with TBB (optional) |
Reimplemented in Gates_block, CZ_NU, U3, RY, Adaptive, R, RX, RZ_P, RZ, U1, U2, CRY, and CROT.
Definition at line 271 of file Gate.cpp.
|
virtual |
Call to apply the gate on the input array/matrix by input*Gate.
input | The input array on which the gate is applied |
Reimplemented in SX, H, X, Y, Z, T, Tdg, SYC, CH, CNOT, and CZ.
Definition at line 285 of file Gate.cpp.
Call to apply the gate kernel on the input state or unitary from right (no AVX support)
u3_1qbit | The 2x2 kernel of the gate operation |
input | The input matrix on which the transformation is applied |
deriv | Set true to apply derivate transformation, false otherwise |
Definition at line 613 of file Gate.cpp.
|
protected |
Call to apply the gate kernel on the input state or unitary with optional AVX support.
u3_1qbit | The 2x2 kernel of the gate operation |
input | The input matrix on which the transformation is applied |
deriv | Set true to apply derivate transformation, false otherwise (optional) |
parallel | Set true to apply parallel kernels, false otherwise (optional) |
parallel | Set 0 for sequential execution (default), 1 for parallel execution with OpenMP and 2 for parallel with TBB (optional) |
u3_1qbit | The 2x2 kernel of the gate operation |
input | The input matrix on which the transformation is applied |
deriv | Set true to apply derivate transformation, false otherwise (optional) |
deriv | Set true to apply parallel kernels, false otherwise (optional) |
parallel | Set 0 for sequential execution (default), 1 for parallel execution with OpenMP and 2 for parallel with TBB (optional) |
Definition at line 537 of file Gate.cpp.
Call to apply the gate on the input array/matrix.
input | The input array on which the gate is applied |
parallel | Set 0 for sequential execution, 1 for parallel execution with OpenMP and 2 for parallel with TBB (optional) |
Reimplemented in SX, H, X, Y, Z, T, Tdg, CH, CZ, SYC, and CNOT.
Definition at line 237 of file Gate.cpp.
|
virtual |
Abstract function to be overriden in derived classes to be used to transform an input upon a parametric gate operation.
parameter_mtx | An array conatining the parameters |
input | The input array on which the gate is applied |
parallel | Set 0 for sequential execution, 1 for parallel execution with OpenMP and 2 for parallel with TBB (optional) |
Reimplemented in Gates_block, Composite, Adaptive, U3, CZ_NU, ON, UN, RY, R, RX, RZ, RZ_P, CRY, U1, U2, and CROT.
Call to apply the gate on a list of inputs.
inputs | The input array on which the gate is applied |
parallel | Set 0 for sequential execution, 1 for parallel execution with OpenMP and 2 for parallel with TBB (optional) |
Definition at line 187 of file Gate.cpp.
|
virtual |
Abstract function to be overriden in derived classes to be used to transform a list of inputs upon a parametric gate operation.
parameter_mtx | An array conatining the parameters of the gate |
inputs | The input array on which the gate is applied |
parallel | Set 0 for sequential execution, 1 for parallel execution with OpenMP and 2 for parallel with TBB (optional) |
Reimplemented in Gates_block, CZ_NU, U3, and CROT.
|
virtual |
Calculate the matrix of a U3 gate gate corresponding to the given parameters acting on a single qbit space.
Theta | Real parameter standing for the parameter theta. |
Phi | Real parameter standing for the parameter phi. |
Lambda | Real parameter standing for the parameter lambda. |
ThetaOver2 | Real parameter standing for the parameter theta. |
Phi | Real parameter standing for the parameter phi. |
Lambda | Real parameter standing for the parameter lambda. |
Definition at line 695 of file Gate.cpp.
|
virtual |
void Gate::clear_children | ( | ) |
void Gate::clear_parents | ( | ) |
|
virtual |
Call to create a clone of the present class.
Reimplemented in Gates_block, Sub_Matrix_Decomposition, CZ_NU, ON, UN, Composite, U3, Adaptive, CH, CNOT, CZ, RY, SYC, SX, RX, U1, U2, H, RZ, RZ_P, X, Y, Z, T, Tdg, R, CRY, custom_kernel_1qubit_gate, and CROT.
Definition at line 513 of file Gate.cpp.
|
virtual |
Call to extract parameters from the parameter array corresponding to the circuit, in which the gate is embedded.
Call to extract parameters from the parameter array corresponding to the circuit, in which the gate is incorporated in.
parameters | The parameter array corresponding to the circuit in which the gate is embedded |
Reimplemented in Gates_block, U3, Adaptive, RY, RZ, U1, U2, RX, R, CRY, and CROT.
std::vector< Gate * > Gate::get_children | ( | ) |
int Gate::get_control_qbit | ( | ) |
|
virtual |
Call to get the qubits involved in the gate operation.
Reimplemented in Gates_block.
Definition at line 386 of file Gate.cpp.
|
virtual |
|
virtual |
|
virtual |
Call to retrieve the gate matrix.
parameters | An array of parameters to calculate the matrix of the U3 gate. |
parallel | Set 0 for sequential execution, 1 for parallel execution with OpenMP and 2 for parallel with TBB (optional) |
Reimplemented in Gates_block, Composite, CZ_NU, ON, UN, and U3.
std::string Gate::get_name | ( | ) |
int Gate::get_parameter_num | ( | ) |
int Gate::get_parameter_start_idx | ( | ) |
std::vector< Gate * > Gate::get_parents | ( | ) |
int Gate::get_qbit_num | ( | ) |
int Gate::get_target_qbit | ( | ) |
gate_type Gate::get_type | ( | ) |
|
virtual |
Calculate the matrix of a U3 gate gate corresponding to the given parameters acting on a single qbit space.
Set static values for the angles and constans parameters for calculating the matrix of the gates.
Theta | Real parameter standing for the parameter theta. |
Phi | Real parameter standing for the parameter phi. |
Lambda | Real parameter standing for the parameter lambda. |
ThetaOver2 | Real parameter standing for the parameter theta. |
Phi | Real parameter standing for the parameter phi. |
Lambda | Real parameter standing for the parameter lambda. |
|
inherited |
Call to print output messages in the function of the verbosity level.
sstream | The stringstream input to store the output messages. |
verbose_level | Integer input. High level means write more to the standart output, 0 means write nothing. The default value is set to 1. |
Definition at line 55 of file logging.cpp.
|
virtual |
Call to reorder the qubits in the matrix of the operation.
qbit_list | The reordered list of qubits spanning the matrix |
Reimplemented in Gates_block, Decomposition_Base, CZ_NU, U3, Composite, SX, H, X, Y, Z, T, Tdg, ON, UN, SYC, CH, CNOT, CZ, and CROT.
Definition at line 339 of file Gate.cpp.
void Gate::set_children | ( | std::vector< Gate *> & | children_ | ) |
void Gate::set_control_qbit | ( | int | control_qbit_in | ) |
|
inherited |
Call to set the debugfile name.
debugfile | String variable. Set the debugfile name. |
Definition at line 95 of file logging.cpp.
void Gate::set_matrix | ( | Matrix | input | ) |
void Gate::set_parameter_start_idx | ( | int | start_idx | ) |
void Gate::set_parents | ( | std::vector< Gate *> & | parents_ | ) |
|
virtual |
Set the number of qubits spanning the matrix of the operation.
qbit_num_in | The number of qubits spanning the matrix |
Reimplemented in Gates_block, Decomposition_Base, CZ_NU, U3, Composite, SX, H, X, Y, ON, UN, Z, T, Tdg, SYC, CNOT, CH, CZ, and CROT.
Definition at line 102 of file Gate.cpp.
void Gate::set_target_qbit | ( | int | target_qbit_in | ) |
|
inherited |
Call to set the verbose attribute.
verbose_in | Integer variable. Set the number to specify the verbosity level for output messages. |
Definition at line 85 of file logging.cpp.
|
protected |
|
protected |
|
inherited |
|
inherited |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
inherited |