Quantum Gate Decomposer  v1.3
Powerful decomposition of almost any unitary into U3 and CNOT gates
List of all members | Public Member Functions | Protected Attributes
Operation_block Class Reference

A class responsible for grouping CNOT and U3 operations into layers. More...

#include <Operation_block.h>

Inheritance diagram for Operation_block:
Inheritance graph
[legend]

Public Member Functions

void add_cnot_to_end (int control_qbit, int target_qbit)
 Append a C_NOT gate operation to the list of operations. More...
 
void add_cnot_to_front (int control_qbit, int target_qbit)
 Add a C_NOT gate operation to the front of the list of operations. More...
 
void add_operation_to_end (Operation *operation)
 Append a general operation to the list of operations. More...
 
void add_operation_to_front (Operation *operation)
 Add an operation to the front of the list of operations. More...
 
void add_operations_to_end (std::vector< Operation * > operations_in)
 Append a list of operations to the list of operations. More...
 
void add_operations_to_front (std::vector< Operation * > operations_in)
 Add an array of operations to the front of the list of operations. More...
 
void add_u3_to_end (int target_qbit, bool Theta, bool Phi, bool Lambda)
 Append a U3 gate to the list of operations. More...
 
void add_u3_to_front (int target_qbit, bool Theta, bool Phi, bool Lambda)
 Add a U3 gate to the front of the list of operations. More...
 
Operation_blockclone ()
 Create a clone of the present class. More...
 
void combine (Operation_block *op_block)
 Call to append the operations of an operation block to the current block. More...
 
int extract_operations (Operation_block *op_block)
 Call to extract the operations stored in the class. More...
 
int get_control_qbit ()
 Call to get the index of the control qubit. More...
 
gates_num get_gate_nums ()
 Call to get the number of the individual gate types in the list of operations. More...
 
std::vector< int > get_involved_qubits ()
 Call to get the qubits involved in the operations stored in the block of operations. More...
 
std::vector< Matrixget_matrices (const double *parameters)
 Call to get the list of matrix representation of the operations grouped in the block. More...
 
Matrix get_matrix (const double *parameters)
 Call to retrieve the operation matrix (Which is the product of all the operation matrices stored in the operation block) More...
 
Matrix get_matrix ()
 Call to retrieve the operation matrix. More...
 
int get_operation_num ()
 Call to get the number of operations grouped in the class. More...
 
std::vector< Operation * > get_operations ()
 Call to get the operations stored in the class. 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 unitary. More...
 
int get_target_qbit ()
 Call to get the index of the target qubit. More...
 
operation_type get_type ()
 Call to get the type of the operation. More...
 
void list_operations (const double *parameters, int start_index)
 Call to print the list of operations stored in the block of operations for a specific set of parameters. More...
 
 Operation_block ()
 Deafult constructor of the class. More...
 
 Operation_block (int qbit_num_in)
 Constructor of the class. More...
 
void release_operations ()
 Call to release the stored operations. More...
 
void reorder_qubits (std::vector< int > qbit_list)
 Call to reorder the qubits in the matrix of the operations. More...
 
void set_matrix (Matrix input)
 Call to set the stored matrix in the operation. More...
 
void set_qbit_num (int qbit_num_in)
 Set the number of qubits spanning the matrix of the operations stored in the block of operations. More...
 
virtual ~Operation_block ()
 Destructor of the class. 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 layer_num
 number of operation layers More...
 
int matrix_size
 The size N of the NxN matrix associated with the operations. More...
 
std::vector< Operation * > operations
 The list of stored operations. More...
 
unsigned int parameter_num
 the number of free parameters of the operation 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...
 
operation_type type
 The type of the operation (see enumeration operation_type) More...
 

Detailed Description

A class responsible for grouping CNOT and U3 operations into layers.

Definition at line 36 of file Operation_block.h.

Constructor & Destructor Documentation

◆ Operation_block() [1/2]

Operation_block::Operation_block ( )

Deafult constructor of the class.

Definition at line 34 of file Operation_block (copy).cpp.

Here is the caller graph for this function:

◆ Operation_block() [2/2]

Operation_block::Operation_block ( int  qbit_num_in)

Constructor of the class.

Parameters
qbit_num_inThe number of qubits in the unitaries

Definition at line 48 of file Operation_block (copy).cpp.

◆ ~Operation_block()

Operation_block::~Operation_block ( )
virtual

Destructor of the class.

Definition at line 60 of file Operation_block (copy).cpp.

Here is the call graph for this function:

Member Function Documentation

◆ add_cnot_to_end()

void Operation_block::add_cnot_to_end ( int  control_qbit,
int  target_qbit 
)

Append a C_NOT gate operation to the list of operations.

Parameters
control_qbitThe identification number of the control qubit. (0 <= target_qbit <= qbit_num-1)
target_qbitThe identification number of the target qubit. (0 <= target_qbit <= qbit_num-1)

Definition at line 264 of file Operation_block (copy).cpp.

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

◆ add_cnot_to_front()

void Operation_block::add_cnot_to_front ( int  control_qbit,
int  target_qbit 
)

Add a C_NOT gate operation to the front of the list of operations.

Parameters
control_qbitThe identification number of the control qubit. (0 <= target_qbit <= qbit_num-1)
target_qbitThe identification number of the target qubit. (0 <= target_qbit <= qbit_num-1)

Definition at line 281 of file Operation_block (copy).cpp.

Here is the call graph for this function:

◆ add_operation_to_end()

void Operation_block::add_operation_to_end ( Operation operation)

Append a general operation to the list of operations.

Parameters
operationA pointer to a class Operation describing an operation.

Definition at line 322 of file Operation_block (copy).cpp.

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

◆ add_operation_to_front()

void Operation_block::add_operation_to_front ( Operation operation)

Add an operation to the front of the list of operations.

Parameters
operationA pointer to a class Operation describing an operation.

Definition at line 345 of file Operation_block (copy).cpp.

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

◆ add_operations_to_end()

void Operation_block::add_operations_to_end ( std::vector< Operation * >  operations_in)

Append a list of operations to the list of operations.

Parameters
operations_inA list of operation class instances.

Definition at line 295 of file Operation_block (copy).cpp.

Here is the call graph for this function:

◆ add_operations_to_front()

void Operation_block::add_operations_to_front ( std::vector< Operation * >  operations_in)

Add an array of operations to the front of the list of operations.

Parameters
operations_inA list of operation class instances.

Definition at line 308 of file Operation_block (copy).cpp.

Here is the call graph for this function:

◆ add_u3_to_end()

void Operation_block::add_u3_to_end ( int  target_qbit,
bool  Theta,
bool  Phi,
bool  Lambda 
)

Append a U3 gate to the list of operations.

Parameters
target_qbitThe identification number of the targt qubit. (0 <= target_qbit <= qbit_num-1)
ThetaThe Theta parameter of the U3 operation
PhiThe Phi parameter of the U3 operation
LambdaThe Lambda parameter of the U3 operation

Definition at line 233 of file Operation_block (copy).cpp.

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

◆ add_u3_to_front()

void Operation_block::add_u3_to_front ( int  target_qbit,
bool  Theta,
bool  Phi,
bool  Lambda 
)

Add a U3 gate to the front of the list of operations.

Parameters
target_qbitThe identification number of the targt qubit. (0 <= target_qbit <= qbit_num-1)
ThetaThe Theta parameter of the U3 operation
PhiThe Phi parameter of the U3 operation
LambdaThe Lambda parameter of the U3 operation

Definition at line 249 of file Operation_block (copy).cpp.

Here is the call graph for this function:

◆ clone()

Operation_block * Operation_block::clone ( )

Create a clone of the present class.

Returns
Return with a pointer pointing to the cloned object.

Definition at line 665 of file Operation_block (copy).cpp.

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

◆ combine()

void Operation_block::combine ( Operation_block op_block)

Call to append the operations of an operation block to the current block.

Parameters
op_blockA pointer to an instance of class Operation_block

Definition at line 593 of file Operation_block (copy).cpp.

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

◆ extract_operations()

int Operation_block::extract_operations ( Operation_block op_block)

Call to extract the operations stored in the class.

Parameters
op_blockAn instance of Operation_block class in which the operations will be stored. (The current operations will be erased)
Returns
Return with 0 on success.

Definition at line 686 of file Operation_block (copy).cpp.

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

◆ get_control_qbit()

int Operation::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 157 of file Operation.cpp.

Here is the caller graph for this function:

◆ get_gate_nums()

gates_num Operation_block::get_gate_nums ( )

Call to get the number of the individual gate types in the list of operations.

Returns
Returns with an instance gates_num describing the number of the individual gate types

Definition at line 369 of file Operation_block (copy).cpp.

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

◆ get_involved_qubits()

std::vector< int > Operation_block::get_involved_qubits ( )

Call to get the qubits involved in the operations stored in the block of operations.

Returns
Return with a list of the invovled qubits

Definition at line 552 of file Operation_block (copy).cpp.

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

◆ get_matrices()

std::vector< Matrix > Operation_block::get_matrices ( const double *  parameters)

Call to get the list of matrix representation of the operations grouped in the block.

Parameters
parametersArray of parameters to calculate the matrix of the operation block
Returns
Returns with the list of the operations

Definition at line 174 of file Operation_block (copy).cpp.

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

◆ get_matrix() [1/2]

Matrix Operation_block::get_matrix ( const double *  parameters)

Call to retrieve the operation matrix (Which is the product of all the operation matrices stored in the operation block)

Parameters
parametersAn array pointing to the parameters of the operations
Returns
Returns with the operation matrix

Definition at line 106 of file Operation_block (copy).cpp.

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

◆ get_matrix() [2/2]

Matrix Operation::get_matrix ( )
inherited

Call to retrieve the operation matrix.

Returns
Returns with a matrix of the operation

Definition at line 97 of file Operation.cpp.

Here is the caller graph for this function:

◆ get_operation_num()

int Operation_block::get_operation_num ( )

Call to get the number of operations grouped in the class.

Returns
Return with the number of the operations grouped in the operation block.

Definition at line 418 of file Operation_block (copy).cpp.

Here is the caller graph for this function:

◆ get_operations()

std::vector< Operation * > Operation_block::get_operations ( )

Call to get the operations stored in the class.

Returns
Return with a list of the operations.

Definition at line 584 of file Operation_block (copy).cpp.

Here is the caller graph for this function:

◆ get_parameter_num()

int Operation_block::get_parameter_num ( )

Call to get the number of free parameters.

Returns
Return with the number of parameters of the operations grouped in the operation block.

Definition at line 409 of file Operation_block (copy).cpp.

Here is the caller graph for this function:

◆ get_qbit_num()

int Operation::get_qbit_num ( )
inherited

Call to get the number of qubits composing the unitary.

Returns
Return with the number of qubits composing the unitary

Definition at line 183 of file Operation.cpp.

◆ get_target_qbit()

int Operation::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 149 of file Operation.cpp.

Here is the caller graph for this function:

◆ get_type()

operation_type Operation::get_type ( )
inherited

Call to get the type of the operation.

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

Definition at line 174 of file Operation.cpp.

Here is the caller graph for this function:

◆ list_operations()

void Operation_block::list_operations ( const double *  parameters,
int  start_index 
)

Call to print the list of operations stored in the block of operations for a specific set of parameters.

Parameters
parametersThe parameters of the operations that should be printed.
start_indexThe ordinal number of the first operation.

Definition at line 428 of file Operation_block (copy).cpp.

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

◆ release_operations()

void Operation_block::release_operations ( )

Call to release the stored operations.

Definition at line 68 of file Operation_block (copy).cpp.

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

◆ reorder_qubits()

void Operation_block::reorder_qubits ( std::vector< int >  qbit_list)
virtual

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

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

Parameters
qbit_listThe reordered list of qubits spanning the matrix

Reimplemented from Operation.

Definition at line 522 of file Operation_block (copy).cpp.

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

◆ set_matrix()

void Operation::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 109 of file Operation.cpp.

Here is the caller graph for this function:

◆ set_qbit_num()

void Operation_block::set_qbit_num ( int  qbit_num_in)
virtual

Set the number of qubits spanning the matrix of the operations stored in the block of operations.

Parameters
qbit_num_inThe number of qubits spanning the matrices.

Reimplemented from Operation.

Definition at line 633 of file Operation_block (copy).cpp.

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

Member Data Documentation

◆ control_qbit

int Operation::control_qbit
protectedinherited

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

Definition at line 52 of file Operation.h.

◆ layer_num

int Operation_block::layer_num
protected

number of operation layers

Definition at line 43 of file Operation_block.h.

◆ matrix_size

int Operation::matrix_size
protectedinherited

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

Definition at line 54 of file Operation.h.

◆ operations

std::vector<Operation*> Operation_block::operations
protected

The list of stored operations.

Definition at line 41 of file Operation_block.h.

◆ parameter_num

unsigned int Operation::parameter_num
protectedinherited

the number of free parameters of the operation

Definition at line 56 of file Operation.h.

◆ qbit_num

int Operation::qbit_num
protectedinherited

number of qubits spanning the matrix of the operation

Definition at line 46 of file Operation.h.

◆ target_qbit

int Operation::target_qbit
protectedinherited

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

Definition at line 50 of file Operation.h.

◆ type

operation_type Operation::type
protectedinherited

The type of the operation (see enumeration operation_type)

Definition at line 48 of file Operation.h.


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