Sequential Quantum Gate Decomposer  v1.9.3
Powerful decomposition of general unitarias into one- and two-qubit gates gates
qgd_CROT.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_CROT_Wrapper import qgd_CROT_Wrapper
32 
33 
34 
35 
37 class qgd_CROT(qgd_CROT_Wrapper):
38 
39 
40 
47 
48  def __init__( self, qbit_num, target_qbit, control_qbit, subtype_in):
49  self.type = "CROT"
50  self.subtype = subtype_in
51  # call the constructor of the wrapper class
52  super().__init__(qbit_num, target_qbit, control_qbit, subtype_in)
53 
54 
55 #@brief Call to apply the gate operation on the input matrix
56 #@param self A pointer pointing to an instance of the class qgd_CROT.
57 #@param Input arguments: parameters_mtx, unitary_mtx.
58 
59  def apply_to( self, parameters_mtx, unitary_mtx):
60 
61  # call the C wrapper function
62  super().apply_to( parameters_mtx, unitary_mtx )
63 
64 
65 #@brief Call to get the number of free parameters in the gate.
66  def get_Parameter_Num( self):
67 
68  # call the C wrapper function
69  return super().get_Parameter_Num()
70 
71 
72 #@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.
74 
75  # call the C wrapper function
76  return super().get_Parameter_Start_Index()
77 
78 
79 #@brief Call to get the target qbit.
80  def get_Target_Qbit( self ):
81 
82  # call the C wrapper function
83  return super().get_Target_Qbit()
84 
85 
86 #@brief Call to get the control qbit (returns with -1 if no control qbit is used in the gate).
87  def get_Control_Qbit( self ):
88 
89  # call the C wrapper function
90  return super().get_Control_Qbit()
91 
92 #@brief Call to set the target qbit.
93  def set_Target_Qbit( self, target_qbit_in ):
94 
95  # call the C wrapper function
96  super().set_Target_Qbit(target_qbit_in)
97 
98 
99 #@brief Call to set the control qbit (does nothing if no control qbit is used in the gate).
100  def set_Control_Qbit( self, control_qbit_in ):
101 
102  # call the C wrapper function
103  super().set_Control_Qbit(control_qbit_in)
104 
105 
106 #@brief Call to extract the paramaters corresponding to the gate, from a parameter array associated to the circuit in which the gate is embedded.
107  def Extract_Parameters( self, parameters_circuit ):
108 
109  # call the C wrapper function
110  parameters_gate = super().Extract_Parameters( parameters_circuit )
111 
112  parameters_gate = np.reshape( parameters_gate, (parameters_gate.size,) )
113 
114  return parameters_gate
115 
def __init__(self, qbit_num, target_qbit, control_qbit, subtype_in)
Constructor of the class.
Definition: qgd_CROT.py:48
def set_Target_Qbit(self, target_qbit_in)
Definition: qgd_CROT.py:93
def apply_to(self, parameters_mtx, unitary_mtx)
Definition: qgd_CROT.py:59
def Extract_Parameters(self, parameters_circuit)
Definition: qgd_CROT.py:107
def get_Parameter_Start_Index(self)
Definition: qgd_CROT.py:73
def set_Control_Qbit(self, control_qbit_in)
Definition: qgd_CROT.py:100
def get_Parameter_Num(self)
Definition: qgd_CROT.py:66
A QGD Python interface class for the qgd_CROT.
Definition: qgd_CROT.py:37
def get_Control_Qbit(self)
Definition: qgd_CROT.py:87
def get_Target_Qbit(self)
Definition: qgd_CROT.py:80