Sequential Quantum Gate Decomposer  v1.9.3
Powerful decomposition of general unitarias into one- and two-qubit gates gates
GrayCodeHash_base.hpp
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 GRAYCODEHASH_BASE_HPP
27 #define GRAYCODEHASH_BASE_HPP
28 
29 #include "GrayCode_base.hpp"
30 
31 
32 
36 template <typename intType>
38 
39 protected:
40 
41 public:
42 
48 
49 }
50 
56 size_t
58 
59  GrayCode_base<intType> &key_loc = const_cast<GrayCode_base<intType> &>(key);
60  intType *data = key_loc.get_data();
61  size_t hash_val = 0;
62 
63  matrix_base<intType>&& n_ary_limits = key.get_Limits();
64  size_t pow = 1;
65 
66  for (size_t idx=0; idx<key.cols; idx++) {
67  hash_val = hash_val + data[idx]*pow;
68  pow = pow*n_ary_limits[idx];
69  }
70 
71  return hash_val;
72 }
73 
74 
75 }; //GrayCodeHash_base
76 
77 
78 
79 
80 
81 #endif // GRAYCODEHASH_BASE_HPP
matrix_base< intType > get_Limits() const
Call to get the n-ary limits of the Gray code.
Copyright 2021 Budapest Quantum Computing Group.
Class to hash function operator for GrayCode_base keys in unordered maps and unordered sets...
data
load the unitary from file
Definition: example.py:51
intType * get_data() const
Call to get the pointer to the stored data.
int cols
The number of columns.
Definition: matrix_base.hpp:44
GrayCodeHash_base()
Constructor of the class.
size_t operator()(const GrayCode_base< intType > &key) const
Operator to generate hash key for class instance PicState_base<intType>