Sequential Quantum Gate Decomposer  v1.9.3
Powerful decomposition of general unitarias into one- and two-qubit gates gates
NN.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 @author: Peter Rakyta, Ph.D.
18 */
23 #ifndef NN_H
24 #define NN_H
25 
26 #include "matrix.h"
27 #include "matrix_real.h"
28 
29 #include <time.h>
30 #include <stdlib.h>
31 #include <random>
32 
33 #include "Gates_block.h"
34 #include "CZ.h"
35 #include "CH.h"
36 #include "CNOT.h"
37 #include "U3.h"
38 #include "RX.h"
39 #include "X.h"
40 #include "SX.h"
41 #include "RY.h"
42 #include "CRY.h"
43 #include "RZ.h"
44 #include "SYC.h"
45 #include "UN.h"
46 #include "ON.h"
47 #include "Adaptive.h"
48 #include "Composite.h"
49 #include <map>
50 #include <cstdlib>
51 #include <time.h>
52 #include <ctime>
53 #include <tbb/cache_aligned_allocator.h>
54 
55 
56 
57 
61 class NN {
62 
63 
64 public:
65 
67  int tt;
68 
69 protected:
70 
71 
73  std::random_device rd;
75  std::mt19937 gen;
77  std::vector<matrix_base<int>> topology;
80 
81 
82 
83 
84 public:
85 
90 NN();
91 
92 
97 NN( std::vector<matrix_base<int>> topology_in );
98 
99 
100 
105 void create_randomized_parameters( int num_of_parameters, int qbit_num, int levels, Matrix_real& parameters, matrix_base<int8_t>& nontrivial_adaptive_layers );
106 
107 
112 void get_nn_chanels_from_kernel( Matrix& kernel_up, Matrix& kernel_down, Matrix_real& chanels);
113 
120 void get_nn_chanels( const Matrix& Umtx, const int& target_qbit, Matrix_real& chanels);
121 
127 void get_nn_chanels( int qbit_num, const Matrix& Umtx, Matrix_real& chanels);
128 
136 void get_nn_chanels(int qbit_num, int levels, Matrix_real& chanels, matrix_base<int8_t>& nontrivial_adaptive_layers);
137 
138 
147 void get_nn_chanels(int qbit_num, int levels, int samples_num, Matrix_real& chanels, matrix_base<int8_t>& nontrivial_adaptive_layers);
148 
149 };
150 
151 #endif //NN
NN()
Nullary constructor of the class.
Definition: NN.cpp:34
std::mt19937 gen
Standard mersenne_twister_engine seeded with rd()
Definition: NN.h:75
Header file for a class for a composite gate operation.
Header file for a class representing the X gate.
Header file for a class representing a controlled rotation gate around the Y axis.
Header file for a class representing the SX axis.
int levels
[creating decomp class]
int num_threads
Store the number of OpenMP threads. (During the calculations OpenMP multithreading is turned off...
Definition: NN.h:79
Header file for a class representing a CH operation.
Header file for a class responsible for grouping gates into subcircuits. (Subcircuits can be nested) ...
std::vector< matrix_base< int > > topology
connectivity between the wubits
Definition: NN.h:77
void get_nn_chanels_from_kernel(Matrix &kernel_up, Matrix &kernel_down, Matrix_real &chanels)
call retrieve the channels for the neural network associated with a single 2x2 kernel ...
Definition: NN.cpp:160
Header file for a class representing a CNOT operation.
void create_randomized_parameters(int num_of_parameters, int qbit_num, int levels, Matrix_real &parameters, matrix_base< int8_t > &nontrivial_adaptive_layers)
Call to construct random parameter, with limited number of non-trivial adaptive layers.
Definition: NN.cpp:82
Header file for a class representing a rotation gate around the Z axis.
Umtx
The unitary to be decomposed.
Definition: example.py:53
Header file for a class for the representation of general gate operations on the first qbit_num-1 qub...
Header file of complex array storage array with automatic and thread safe reference counting...
Header file for a class representing a CZ operation.
Class to store data of complex arrays and its properties.
Definition: matrix.h:38
Header file for a class representing a gate used in adaptive decomposition.
Header file for a class representing a U3 gate.
Header file for a class representing a rotation gate around the X axis.
Header file for a class representing a rotation gate around the Y axis.
Header file for a class for the representation of general gate operations on the first qbit_num-1 qub...
A class containing basic methods for the decomposition process.
Definition: NN.h:61
void get_nn_chanels(const Matrix &Umtx, const int &target_qbit, Matrix_real &chanels)
call retrieve the channels for the neural network associated with a single unitary ...
Definition: NN.cpp:222
int tt
number of gate blocks used in one shot of the optimization process
Definition: NN.h:67
std::random_device rd
Will be used to obtain a seed for the random number engine.
Definition: NN.h:73
Class to store data of complex arrays and its properties.
Definition: matrix_real.h:39
Header file for a class representing a Sycamore gate.