Sequential Quantum Gate Decomposer  v1.8.8
Powerful decomposition of general unitarias into one- and two-qubit gates gates
List of all members | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes
ON Class Reference

Base class for the representation of general gate operations. More...

#include <ON.h>

Inheritance diagram for ON:
Inheritance graph
[legend]

Public Member Functions

void apply_from_right (Matrix_real &parameters, Matrix &input)
 Call to apply the gate on the input array/matrix by input*Gate. More...
 
virtual void apply_from_right (Matrix &input)
 Call to apply the gate on the input array/matrix by input*Gate. More...
 
void apply_to (Matrix_real &parameters, Matrix &input, bool parallel=false)
 Call to apply the gate on the input array/matrix. More...
 
virtual void apply_to (Matrix &input, bool parallel=false)
 Call to apply the gate on the input array/matrix. More...
 
void apply_to_list (std::vector< Matrix > &input)
 Call to apply the gate on the input array/matrix by U3*input. More...
 
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...
 
ONclone ()
 Call to create a clone of the present class. More...
 
int get_control_qbit ()
 Call to get the index of the control qubit. More...
 
Matrix get_matrix (Matrix_real &parameters)
 Call to retrieve the operation matrix. More...
 
Matrix get_matrix (Matrix_real &parameters, bool parallel=false)
 Call to retrieve the operation matrix. More...
 
Matrix get_matrix ()
 Call to retrieve the operation matrix. More...
 
Matrix_real get_optimized_parameters ()
 Call to get the final optimized parameters of the gate. More...
 
int get_parameter_num ()
 Call to get the number of free parameters. More...
 
int get_qbit_num ()
 Call to get the number of qubits composing the ONitary. More...
 
Matrix get_submatrix (Matrix_real &parameters)
 Call to retrieve the qbut_num-1 kernel of the operation. 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...
 
 ON ()
 Default constructor of the class. More...
 
 ON (int qbit_num_in)
 Constructor of the class. 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_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_optimized_parameters (Matrix_real parameters_)
 Call to set the final optimized parameters of the 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 ~ON ()
 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, bool parallel=false)
 Call to apply the gate kernel on the input state or unitary with optional AVX support. More...
 

Protected Attributes

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...
 
int parameter_num
 the number of free parameters of the operation More...
 
Matrix_real parameters
 Parameters after the decomposition of the ONitary is done. 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...
 

Detailed Description

Base class for the representation of general gate operations.

Definition at line 35 of file ON.h.

Constructor & Destructor Documentation

◆ ON() [1/2]

ON::ON ( )

Default constructor of the class.

Deafult constructor of the class.

Returns
An instance of the class

Definition at line 35 of file ON.cpp.

Here is the caller graph for this function:

◆ ~ON()

ON::~ON ( )
virtual

Destructor of the class.

Definition at line 78 of file ON.cpp.

◆ ON() [2/2]

ON::ON ( int  qbit_num_in)

Constructor of the class.

Parameters
qbit_num_inThe number of qubits spanning the ONitaries
Returns
An instance of the class

Definition at line 58 of file ON.cpp.

Here is the call graph for this function:

Member Function Documentation

◆ apply_from_right() [1/2]

void ON::apply_from_right ( Matrix_real parameters,
Matrix input 
)

Call to apply the gate on the input array/matrix by input*Gate.

Parameters
inputThe input array on which the gate is applied

Definition at line 186 of file ON.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ apply_from_right() [2/2]

void Gate::apply_from_right ( Matrix input)
virtualinherited

Call to apply the gate on the input array/matrix by input*Gate.

Parameters
inputThe input array on which the gate is applied

Reimplemented in SX, X, Y, Z, SYC, CH, CNOT, and CZ.

Definition at line 156 of file Gate.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ apply_kernel_from_right()

void Gate::apply_kernel_from_right ( Matrix u3_1qbit,
Matrix input 
)
protectedinherited

Call to apply the gate kernel on the input state or unitary from right (no AVX support)

Parameters
u3_1qbitThe 2x2 kernel of the gate operation
inputThe input matrix on which the transformation is applied
derivSet true to apply derivate transformation, false otherwise

Definition at line 359 of file Gate.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ apply_kernel_to()

void Gate::apply_kernel_to ( Matrix u3_1qbit,
Matrix input,
bool  deriv = false,
bool  parallel = false 
)
protectedinherited

Call to apply the gate kernel on the input state or unitary with optional AVX support.

Parameters
u3_1qbitThe 2x2 kernel of the gate operation
inputThe input matrix on which the transformation is applied
derivSet true to apply derivate transformation, false otherwise (optional)
parallelSet true to apply parallel kernels, false otherwise (optional)
u3_1qbitThe 2x2 kernel of the gate operation
inputThe input matrix on which the transformation is applied
derivSet true to apply derivate transformation, false otherwise (optional)
derivSet true to apply parallel kernels, false otherwise (optional)

Definition at line 292 of file Gate.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ apply_to() [1/2]

void ON::apply_to ( Matrix_real parameters,
Matrix input,
bool  parallel = false 
)

Call to apply the gate on the input array/matrix.

Parameters
inputThe input array on which the gate is applied
parallelSet true to apply parallel kernels, false otherwise (optional)

Definition at line 146 of file ON.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ apply_to() [2/2]

void Gate::apply_to ( Matrix input,
bool  parallel = false 
)
virtualinherited

Call to apply the gate on the input array/matrix.

Parameters
inputThe input array on which the gate is applied
parallelSet true to apply parallel kernels, false otherwise (optional)

Reimplemented in SX, X, Y, Z, CH, CZ, SYC, and CNOT.

Definition at line 143 of file Gate.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ apply_to_list()

void Gate::apply_to_list ( std::vector< Matrix > &  input)
inherited

Call to apply the gate on the input array/matrix by U3*input.

Parameters
parametersAn array of parameters to calculate the matrix of the U3 gate.
inputThe input array on which the gate is applied

Definition at line 127 of file Gate.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ calc_one_qubit_u3() [1/2]

Matrix Gate::calc_one_qubit_u3 ( double  ThetaOver2,
double  Phi,
double  Lambda 
)
inherited

Calculate the matrix of a U3 gate gate corresponding to the given parameters acting on a single qbit space.

Parameters
ThetaReal 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.
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 439 of file Gate.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ calc_one_qubit_u3() [2/2]

Matrix Gate::calc_one_qubit_u3 ( )
virtualinherited

Calculate the matrix of the constans gates.

Returns
Returns with the matrix of the one-qubit matrix.

Reimplemented in SX, X, Y, Z, CH, CNOT, and CZ.

Definition at line 494 of file Gate.cpp.

Here is the caller graph for this function:

◆ clone()

ON * ON::clone ( )
virtual

Call to create a clone of the present class.

Returns
Return with a pointer pointing to the cloned object

Reimplemented from Gate.

Definition at line 326 of file ON.cpp.

Here is the call graph for this function:

◆ get_control_qbit()

int Gate::get_control_qbit ( )
inherited

Call to get the index of the control qubit.

Returns
Return with the index of the control qubit (return with -1 if control qubit was not set)

Definition at line 238 of file Gate.cpp.

Here is the caller graph for this function:

◆ get_matrix() [1/3]

Matrix ON::get_matrix ( Matrix_real parameters)

Call to retrieve the operation matrix.

Parameters
parallelSet true to apply parallel kernels, false otherwise
Returns
Returns with a matrix of the operation
Parameters
parametersAn array of parameters to calculate the matrix of the ON gate.
Returns
Returns with a matrix of the operation

Definition at line 106 of file ON.cpp.

Here is the call graph for this function:

◆ get_matrix() [2/3]

Matrix ON::get_matrix ( Matrix_real parameters,
bool  parallel = false 
)

Call to retrieve the operation matrix.

Parameters
parallelSet true to apply parallel kernels, false otherwise (optional)
Returns
Returns with a matrix of the operation
Parameters
parametersAn array of parameters to calculate the matrix of the ON gate.
parallelSet true to apply parallel kernels, false otherwise
Returns
Returns with a matrix of the operation

Definition at line 122 of file ON.cpp.

Here is the call graph for this function:

◆ get_matrix() [3/3]

Matrix Gate::get_matrix ( )
inherited

Call to retrieve the operation matrix.

Returns
Returns with a matrix of the operation

Definition at line 116 of file Gate.cpp.

Here is the caller graph for this function:

◆ get_optimized_parameters()

Matrix_real ON::get_optimized_parameters ( )

Call to get the final optimized parameters of the gate.

Definition at line 288 of file ON.cpp.

Here is the call graph for this function:

◆ get_parameter_num()

int ON::get_parameter_num ( )

Call to get the number of free parameters.

Returns
Return with the number of the free parameters

Definition at line 299 of file ON.cpp.

Here is the caller graph for this function:

◆ get_qbit_num()

int ON::get_qbit_num ( )

Call to get the number of qubits composing the ONitary.

Returns
Return with the number of qubits composing the ONitary

Definition at line 317 of file ON.cpp.

◆ get_submatrix()

Matrix ON::get_submatrix ( Matrix_real parameters)

Call to retrieve the qbut_num-1 kernel of the operation.

?????

Definition at line 227 of file ON.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_target_qbit()

int Gate::get_target_qbit ( )
inherited

Call to get the index of the target qubit.

Returns
Return with the index of the target qubit (return with -1 if target qubit was not set)

Definition at line 230 of file Gate.cpp.

Here is the caller graph for this function:

◆ get_type()

gate_type ON::get_type ( )

Call to get the type of the operation.

Returns
Return with the type of the operation (see gate_type for details)

Definition at line 308 of file ON.cpp.

◆ parameters_for_calc_one_qubit()

void Gate::parameters_for_calc_one_qubit ( double &  ThetaOver2,
double &  Phi,
double &  Lambda 
)
virtualinherited

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.

Parameters
ThetaReal 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.
Parameters
ThetaOver2Real parameter standing for the parameter theta.
PhiReal parameter standing for the parameter phi.
LambdaReal parameter standing for the parameter lambda.

Reimplemented in RY, RX, RZ, and RZ_P.

Definition at line 508 of file Gate.cpp.

◆ print()

void logging::print ( const std::stringstream &  sstream,
int  verbose_level = 1 
) const
inherited

Call to print output messages in the function of the verbosity level.

Parameters
sstreamThe stringstream input to store the output messages.
verbose_levelInteger 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.

◆ reorder_qubits()

void ON::reorder_qubits ( std::vector< int qbit_list)
virtual

Call to reorder the qubits in the matrix of the operation.

Parameters
qbit_listThe reordered list of qubits spanning the matrix

Reimplemented from Gate.

Definition at line 244 of file ON.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_control_qbit()

void Gate::set_control_qbit ( int  control_qbit_in)
inherited

Call to set the control qubit for the gate operation.

Parameters
control_qbit_inThe control qubit. Should be: 0 <= control_qbit_in < qbit_num

Definition at line 179 of file Gate.cpp.

Here is the caller graph for this function:

◆ set_debugfile()

void logging::set_debugfile ( std::string  debugfile)
inherited

Call to set the debugfile name.

Parameters
debugfileString variable. Set the debugfile name.

Definition at line 95 of file logging.cpp.

Here is the caller graph for this function:

◆ set_matrix()

void Gate::set_matrix ( Matrix  input)
inherited

Call to set the stored matrix in the operation.

Parameters
inputThe operation matrix to be stored. The matrix is stored by attribute matrix_alloc.
Returns
Returns with 0 on success.

Definition at line 170 of file Gate.cpp.

Here is the caller graph for this function:

◆ set_optimized_parameters()

void ON::set_optimized_parameters ( Matrix_real  parameters_)

Call to set the final optimized parameters of the gate.

Parameters
parameters_Real array of the optimized parameters

Definition at line 278 of file ON.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_qbit_num()

void ON::set_qbit_num ( int  qbit_num_in)
virtual

Set the number of qubits spanning the matrix of the operation.

Parameters
qbit_num_inThe number of qubits spanning the matrix

Reimplemented from Gate.

Definition at line 85 of file ON.cpp.

Here is the call graph for this function:

◆ set_target_qbit()

void Gate::set_target_qbit ( int  target_qbit_in)
inherited

Call to set the target qubit for the gate operation.

Parameters
target_qbit_inThe target qubit on which the gate is applied. Should be: 0 <= target_qbit_in < qbit_num

Definition at line 188 of file Gate.cpp.

Here is the caller graph for this function:

◆ set_verbose()

void logging::set_verbose ( int  verbose_in)
inherited

Call to set the verbose attribute.

Parameters
verbose_inInteger variable. Set the number to specify the verbosity level for output messages.

Definition at line 85 of file logging.cpp.

Here is the caller graph for this function:

Member Data Documentation

◆ control_qbit

int Gate::control_qbit
protectedinherited

The index of the qubit which acts as a control qubit (control_qbit >= 0) in controlled operations.

Definition at line 53 of file Gate.h.

◆ debug

bool logging::debug
inherited

Logical variable. Set true to write output messages to the 'debug.txt' file.

Definition at line 53 of file logging.h.

◆ debugfile_name

std::string logging::debugfile_name
inherited

String variable. Set the debug file name.

Definition at line 56 of file logging.h.

◆ matrix_size

int Gate::matrix_size
protectedinherited

The size N of the NxN matrix associated with the operations.

Definition at line 55 of file Gate.h.

◆ parameter_num

int Gate::parameter_num
protectedinherited

the number of free parameters of the operation

Definition at line 57 of file Gate.h.

◆ parameters

Matrix_real ON::parameters
protected

Parameters after the decomposition of the ONitary is done.

Definition at line 41 of file ON.h.

◆ qbit_num

int Gate::qbit_num
protectedinherited

number of qubits spanning the matrix of the operation

Definition at line 47 of file Gate.h.

◆ target_qbit

int Gate::target_qbit
protectedinherited

The index of the qubit on which the operation acts (target_qbit >= 0)

Definition at line 51 of file Gate.h.

◆ type

gate_type Gate::type
protectedinherited

The type of the operation (see enumeration gate_type)

Definition at line 49 of file Gate.h.

◆ verbose

int logging::verbose
inherited

Set the verbosity level of the output messages.

Definition at line 50 of file logging.h.


The documentation for this class was generated from the following files: