Sequential Quantum Gate Decomposer  v1.9.7
Powerful decomposition of general unitarias into one- and two-qubit gates gates
N_Qubit_Decomposition_adaptive.h
Go to the documentation of this file.
1 /*
2 Created on Fri Jun 26 14:13:26 2020
3 Copyright 2020 Peter Rakyta, Ph.D.
4 
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8 
9  http://www.apache.org/licenses/LICENSE-2.0
10 
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16 
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see http://www.gnu.org/licenses/.
19 
20 @author: Peter Rakyta, Ph.D.
21 */
26 #ifndef N_Qubit_Decomposition_adaptive_H
27 #define N_Qubit_Decomposition_adaptive_H
28 
29 #include "Optimization_Interface.h"
30 
31 
32 
38 
39 
40 public:
41 
42 protected:
43 
44 
50  std::vector<matrix_base<int>> topology;
53 
54 
55 
56 public:
57 
63 
64 
74 N_Qubit_Decomposition_adaptive( Matrix Umtx_in, int qbit_num_in, int level_limit_in, int level_limit_min_in, std::map<std::string, Config_Element>& config, int accelerator_num=0 );
75 
79 N_Qubit_Decomposition_adaptive( Matrix_float Umtx_in, int qbit_num_in, int level_limit_in, int level_limit_min_in, std::map<std::string, Config_Element>& config, int accelerator_num=0 );
80 
81 
91 N_Qubit_Decomposition_adaptive( Matrix Umtx_in, int qbit_num_in, int level_limit_in, int level_limit_min_in, std::vector<matrix_base<int>> topology_in, std::map<std::string, Config_Element>& config, int accelerator_num=0 );
92 
96 N_Qubit_Decomposition_adaptive( Matrix_float Umtx_in, int qbit_num_in, int level_limit_in, int level_limit_min_in, std::vector<matrix_base<int>> topology_in, std::map<std::string, Config_Element>& config, int accelerator_num=0 );
97 
98 
99 
104 
105 
110 virtual void start_decomposition();
111 
115 virtual void get_initial_circuit();
116 
120 virtual void compress_circuit();
121 
126 virtual void remove_trivial_CRY_gates();
127 
131 virtual void finalize_circuit();
132 
137 Gates_block* optimize_imported_gate_structure(Matrix_real& optimized_parameters_mtx_loc);
138 
139 
145 
146 
147 
152 Gates_block* compress_gate_structure( Gates_block* gate_structure, int uncompressed_iter_num );
153 
162 Gates_block* compress_gate_structure( Gates_block* gate_structure, int layer_idx, Matrix_real& optimized_parameters, double& currnt_minimum_loc, int& iteration_num );
163 
168 
174 virtual unsigned int get_panelty( Gates_block* gate_structure, Matrix_real& optimized_parameters );
175 
176 
183 virtual Gates_block* remove_trivial_CRY_gates( Gates_block* gate_structure, Matrix_real& optimized_parameters, double& currnt_minimum_loc );
184 
191 Matrix_real create_reduced_parameters( Gates_block* gate_structure, Matrix_real& optimized_parameters, int layer_idx );
192 
193 
197 void add_adaptive_layers();
198 
203 
208 
209 
213 void add_finalyzing_layer();
214 
215 
220 
221 
222 
227 void set_adaptive_gate_structure( std::string filename );
228 
229 
230 
235  void set_unitary_from_file( std::string filename );
236 
237 
242  void set_unitary( Matrix& Umtx_new ) ;
243 
244  void set_unitary( Matrix_float& Umtx_new ) ;
245 
250 void add_adaptive_gate_structure( std::string filename );
251 
256 
257 
263 
264 double extract_theta_from_layer( Gates_block* gate_structure, int layer_idx, Matrix_real& optimized_parameters);
265 
266 };
267 
268 
269 
270 
271 
272 
273 #endif
virtual unsigned int get_panelty(Gates_block *gate_structure, Matrix_real &optimized_parameters)
Call to get the panelty derived from the number of CRY and CNOT gates in the circuit.
Gates_block * optimize_imported_gate_structure(Matrix_real &optimized_parameters_mtx_loc)
Call to optimize an imported gate structure.
Gates_block * replace_CRY_gates()
Call to replace CRY gates in the circuit that are close to either an identity or to a CNOT gate...
void add_adaptive_layers()
Call to add adaptive layers to the gate structure stored by the class.
void add_finalyzing_layer()
Call to add finalyzing layer (single qubit rotations on all of the qubits) to the gate structure stor...
virtual void remove_trivial_CRY_gates()
Remove blocks containing a trivial CRY gate from the circuit stored by the class. ...
Gates_block * compress_gate_structure(Gates_block *gate_structure, int uncompressed_iter_num)
Call to run compression iterations on the circuit.
bool randomized_adaptive_layers
Boolean variable to determine whether randomized adaptive layers are used or not. ...
int level_limit
The maximal number of adaptive layers used in the decomposition.
std::vector< matrix_base< int > > topology
A vector of index pairs encoding the connectivity between the qubits.
virtual ~N_Qubit_Decomposition_adaptive()
Destructor of the class.
Matrix_real create_reduced_parameters(Gates_block *gate_structure, Matrix_real &optimized_parameters, int layer_idx)
Call to remove those parameters from the array, which correspond to gates that are about to be remove...
N_Qubit_Decomposition_adaptive()
Nullary constructor of the class.
int accelerator_num
number of utilized accelerators
int level_limit_min
The minimal number of adaptive layers used in the decomposition.
void apply_imported_gate_structure()
Call to apply the imported gate structure on the unitary.
void set_unitary_from_file(std::string filename)
Set unitary matrix from file.
void set_adaptive_gate_structure(std::string filename)
Call to set custom layers to the gate structure that are intended to be used in the decomposition...
A base class to determine the decomposition of an N-qubit unitary into a sequence of CNOT and U3 gate...
virtual void compress_circuit()
Compress the circuit.
void add_adaptive_gate_structure(std::string filename)
Call to append custom layers to the gate structure that are intended to be used in the decomposition...
A base class to determine the decomposition of an N-qubit unitary into a sequence of CNOT and U3 gate...
virtual void get_initial_circuit()
get initial circuit
Gates_block * construct_adaptive_gate_layers()
Call to construct adaptive layers.
Double-precision complex matrix (float64).
Definition: matrix.h:38
A class responsible for grouping two-qubit (CNOT,CZ,CH) and one-qubit gates into layers.
Definition: Gates_block.h:44
virtual void finalize_circuit()
Finalize the circuit.
Single-precision complex matrix (float32).
Definition: matrix_float.h:41
void add_layer_to_imported_gate_structure()
Call to add an adaptive layer to the gate structure previously imported gate structure.
std::map< std::string, Config_Element > config
config metadata utilized during the optimization
double extract_theta_from_layer(Gates_block *gate_structure, int layer_idx, Matrix_real &optimized_parameters)
virtual void start_decomposition()
Start the disentanglig process of the unitary.
void set_unitary(Matrix &Umtx_new)
Set unitary matrix.
Gates_block * determine_initial_gate_structure(Matrix_real &optimized_parameters_mtx)
Call determine the gate structrue of the decomposing circuit.
Matrix_real optimized_parameters_mtx
The optimized parameters for the gates.
Class to store data of complex arrays and its properties.
Definition: matrix_real.h:41