Sequential Quantum Gate Decomposer  v1.9.3
Powerful decomposition of general unitarias into one- and two-qubit gates gates
qgd_R.py
Go to the documentation of this file.
1 
3 """
4 Created on Tue Jun 30 15:44:26 2020
5 Copyright 2020 Peter Rakyta, Ph.D.
6 
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
10 
11  http://www.apache.org/licenses/LICENSE-2.0
12 
13 Unless required by applicable law or agreed to in writing, software
14 distributed under the License is distributed on an "AS IS" BASIS,
15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 See the License for the specific language governing permissions and
17 limitations under the License.
18 
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see http://www.gnu.org/licenses/.
21 
22 @author: Peter Rakyta, Ph.D.
23 """
24 
25 
27 
28 
29 import numpy as np
30 from os import path
31 from .qgd_R_Wrapper import qgd_R_Wrapper
32 
33 
34 
35 
37 class qgd_R(qgd_R_Wrapper):
38 
39 
40 
47 
48  def __init__( self, qbit_num, target_qbit ):
49  self.type = "R"
50  # call the constructor of the wrapper class
51  super().__init__(qbit_num, target_qbit)
52 
53 #@brief Call to retrieve the gate matrix
54 #@param self A pointer pointing to an instance of the class qgd_R.
55 #@param parameters_mtx An array of parameters to calculate the matrix.
56 
57  def get_Matrix( self, parameters_mtx ):
58 
59  # call the C wrapper function
60  return super().get_Matrix( parameters_mtx )
61 
62 #@brief Call to get the parameters of the matrices.
63 #@param self A pointer pointing to an instance of the class qgd_R.
64 
65  def get_Gate_Kernel( self, ThetaOver2, Phi):
66 
67  # call the C wrapper function
68  return super().calc_one_qubit_u3(ThetaOver2, Phi)
69 
70 #@brief Call to apply the gate operation on the input matrix
71 #@param self A pointer pointing to an instance of the class qgd_R.
72 #@param Input arguments: parameters_mtx, unitary_mtx.
73 
74  def apply_to( self, parameters_mtx, unitary_mtx):
75 
76  # call the C wrapper function
77  super().apply_to( parameters_mtx, unitary_mtx )
78 
79 
80 
81 #@brief Call to get the number of free parameters in the gate.
82  def get_Parameter_Num( self):
83 
84  # call the C wrapper function
85  return super().get_Parameter_Num()
86 
87 
88 #@brief Call to get the starting index of the parameters in the parameter array corresponding to the circuit in which the current gate is incorporated.
90 
91  # call the C wrapper function
92  return super().get_Parameter_Start_Index()
93 
94 
95 #@brief Call to get the target qbit.
96  def get_Target_Qbit( self ):
97 
98  # call the C wrapper function
99  return super().get_Target_Qbit()
100 
101 
102 #@brief Call to get the control qbit (returns with -1 if no control qbit is used in the gate).
103  def get_Control_Qbit( self ):
104 
105  # call the C wrapper function
106  return super().get_Control_Qbit()
107 
108 #@brief Call to set the target qbit.
109  def set_Target_Qbit( self, target_qbit_in ):
110 
111  # call the C wrapper function
112  super().set_Target_Qbit(target_qbit_in)
113 
114 
115 #@brief Call to set the control qbit (does nothing if no control qbit is used in the gate).
116  def set_Control_Qbit( self, control_qbit_in ):
117 
118  # call the C wrapper function
119  return
120 
121 #@brief Call to extract the paramaters corresponding to the gate, from a parameter array associated to the circuit in which the gate is embedded.
122  def Extract_Parameters( self, parameters_circuit ):
123 
124  # call the C wrapper function
125  parameters_gate = super().Extract_Parameters( parameters_circuit )
126 
127  parameters_gate = np.reshape( parameters_gate, (parameters_gate.size,) )
128 
129  return parameters_gate
def __init__(self, qbit_num, target_qbit)
Constructor of the class.
Definition: qgd_R.py:48
def Extract_Parameters(self, parameters_circuit)
Definition: qgd_R.py:122
def apply_to(self, parameters_mtx, unitary_mtx)
Definition: qgd_R.py:74
def set_Control_Qbit(self, control_qbit_in)
Definition: qgd_R.py:116
def get_Parameter_Start_Index(self)
Definition: qgd_R.py:89
def get_Gate_Kernel(self, ThetaOver2, Phi)
Definition: qgd_R.py:65
def get_Matrix(self, parameters_mtx)
Definition: qgd_R.py:57
def get_Parameter_Num(self)
Definition: qgd_R.py:82
A QGD Python interface class for the qgd_R.
Definition: qgd_R.py:37
def get_Target_Qbit(self)
Definition: qgd_R.py:96
def get_Control_Qbit(self)
Definition: qgd_R.py:103
def set_Target_Qbit(self, target_qbit_in)
Definition: qgd_R.py:109