Quantum Gate Decomposer  v1.3
Powerful decomposition of almost any unitary into U3 and CNOT gates
Operation_block.h
Go to the documentation of this file.
1 /*
2 Created on Fri Jun 26 14:13:26 2020
3 Copyright (C) 2020 Peter Rakyta, Ph.D.
4 
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see http://www.gnu.org/licenses/.
17 
18 @author: Peter Rakyta, Ph.D.
19 */
24 #ifndef OPERATION_BLOCK_H
25 #define OPERATION_BLOCK_H
26 
27 #include <vector>
28 #include "qgd/common.h"
29 #include "qgd/Operation.h"
30 
31 
32 
36 class Operation_block : public Operation {
37 
38 
39 protected:
41  std::vector<Operation*> operations;
43  int layer_num;
44 
45 public:
46 
51 
56 Operation_block(int qbit_num_in);
57 
58 
62 virtual ~Operation_block();
63 
67 void release_operations();
68 
74 Matrix get_matrix( const double* parameters );
75 
81 std::vector<Matrix> get_matrices(const double* parameters );
82 
90 void add_u3_to_end(int target_qbit, bool Theta, bool Phi, bool Lambda);
91 
99 void add_u3_to_front(int target_qbit, bool Theta, bool Phi, bool Lambda);
100 
107 
108 
109 
116 
121 void add_operations_to_end( std::vector<Operation*> operations_in );
122 
123 
128 void add_operations_to_front( std::vector<Operation*> operations_in );
129 
130 
135 void add_operation_to_end( Operation* operation );
136 
141 void add_operation_to_front( Operation* operation );
142 
143 
144 
150 
151 
156 int get_parameter_num();
157 
158 
163 int get_operation_num();
164 
165 
171 void list_operations( const double* parameters, int start_index );
172 
173 
178 void reorder_qubits( std::vector<int> qbit_list );
179 
180 
185 std::vector<int> get_involved_qubits();
186 
191 std::vector<Operation*> get_operations();
192 
197 void combine(Operation_block* op_block);
198 
199 
204 void set_qbit_num( int qbit_num_in );
205 
206 
212 
218 int extract_operations( Operation_block* op_block );
219 
220 
221 };
222 
223 #endif //OPERATION_BLOCK
224 
void reorder_qubits(std::vector< int > qbit_list)
Call to reorder the qubits in the matrix of the operations.
void add_operations_to_end(std::vector< Operation * > operations_in)
Append a list of operations to the list of operations.
std::vector< Operation * > get_operations()
Call to get the operations stored in the class.
int extract_operations(Operation_block *op_block)
Call to extract the operations stored in the class.
Base class for the representation of one- and two-qubit operations.
Definition: Operation.h:40
int target_qbit
The index of the qubit on which the operation acts (target_qbit >= 0)
Definition: Operation.h:50
int control_qbit
The index of the qubit which acts as a control qubit (control_qbit >= 0) in controlled operations.
Definition: Operation.h:52
int get_parameter_num()
Call to get the number of free parameters.
Operation_block * clone()
Create a clone of the present class.
std::vector< Matrix > get_matrices(const double *parameters)
Call to get the list of matrix representation of the operations grouped in the block.
Header file for a class for the representation of one- and two-qubit operations.
Structure type conatining numbers of gates.
Definition: QGDTypes.h:47
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 paramete...
void combine(Operation_block *op_block)
Call to append the operations of an operation block to the current block.
std::vector< int > get_involved_qubits()
Call to get the qubits involved in the operations stored in the block of operations.
void release_operations()
Call to release the stored operations.
A class responsible for grouping CNOT and U3 operations into layers.
Operation_block()
Deafult constructor of the class.
virtual ~Operation_block()
Destructor of the class.
gates_num get_gate_nums()
Call to get the number of the individual gate types in the list of operations.
int layer_num
number of operation layers
Matrix get_matrix()
Call to retrieve the operation matrix.
Definition: Operation.cpp:97
Class to store data of complex arrays and its properties.
Definition: matrix.h:12
std::vector< Operation * > operations
The list of stored operations.
void add_u3_to_end(int target_qbit, bool Theta, bool Phi, bool Lambda)
Append a U3 gate to the list of operations.
void add_operation_to_end(Operation *operation)
Append a general operation to the list of operations.
void add_operation_to_front(Operation *operation)
Add an operation to the front of the list of operations.
Header file for commonly used functions and wrappers to CBLAS functions.
int get_operation_num()
Call to get the number of operations grouped in the class.
void add_cnot_to_end(int control_qbit, int target_qbit)
Append a C_NOT gate operation to the list of operations.
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.
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.
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.
void add_operations_to_front(std::vector< Operation * > operations_in)
Add an array of operations to the front of the list of operations.