-
Notifications
You must be signed in to change notification settings - Fork 2.4k
/
__init__.py
142 lines (128 loc) · 3.87 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# This code is part of Qiskit.
#
# (C) Copyright IBM 2017, 2020.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
# of this source tree or at http://www.apache.org/licenses/LICENSE-2.0.
#
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
"""
Standard gates
"""
from .h import HGate, CHGate
from .i import IGate
from .p import PhaseGate, CPhaseGate, MCPhaseGate
from .r import RGate
from .rx import RXGate, CRXGate
from .rxx import RXXGate
from .ry import RYGate, CRYGate
from .ryy import RYYGate
from .rz import RZGate, CRZGate
from .rzz import RZZGate
from .rzx import RZXGate
from .xx_minus_yy import XXMinusYYGate
from .xx_plus_yy import XXPlusYYGate
from .ecr import ECRGate
from .s import SGate, SdgGate, CSGate, CSdgGate
from .swap import SwapGate, CSwapGate
from .iswap import iSwapGate
from .sx import SXGate, SXdgGate, CSXGate
from .dcx import DCXGate
from .t import TGate, TdgGate
from .u import UGate, CUGate
from .u1 import U1Gate, CU1Gate, MCU1Gate
from .u2 import U2Gate
from .u3 import U3Gate, CU3Gate
from .x import XGate, CXGate, CCXGate, C3XGate, C3SXGate, C4XGate, RCCXGate, RC3XGate
from .x import MCXGate, MCXGrayCode, MCXRecursive, MCXVChain
from .y import YGate, CYGate
from .z import ZGate, CZGate, CCZGate
from .global_phase import GlobalPhaseGate
from .multi_control_rotation_gates import mcrx, mcry, mcrz
def get_standard_gate_name_mapping():
"""Return a dictionary mapping the name of standard gates and instructions to an object for
that name.
Examples:
.. code-block:: python
from qiskit.circuit.library import get_standard_gate_name_mapping
gate_name_map = get_standard_gate_name_mapping()
cx_object = gate_name_map["cx"]
print(cx_object)
print(type(cx_object))
.. code-block:: text
Instruction(name='cx', num_qubits=2, num_clbits=0, params=[])
_SingletonCXGate
"""
from qiskit.circuit.parameter import Parameter
from qiskit.circuit.measure import Measure
from qiskit.circuit.delay import Delay
from qiskit.circuit.reset import Reset
lambda_ = Parameter("λ")
theta = Parameter("ϴ")
phi = Parameter("φ")
gamma = Parameter("γ")
beta = Parameter("β")
time = Parameter("t")
# Standard gates library mapping, multicontrolled gates not included since they're
# variable width
gates = [
IGate(),
SXGate(),
XGate(),
CXGate(),
RZGate(lambda_),
RGate(theta, phi),
C3SXGate(),
CCXGate(),
DCXGate(),
CHGate(),
CPhaseGate(theta),
CRXGate(theta),
CRYGate(theta),
CRZGate(theta),
CSwapGate(),
CSXGate(),
CUGate(theta, phi, lambda_, gamma),
CU1Gate(lambda_),
CU3Gate(theta, phi, lambda_),
CYGate(),
CZGate(),
CCZGate(),
GlobalPhaseGate(theta),
HGate(),
PhaseGate(theta),
RCCXGate(),
RC3XGate(),
RXGate(theta),
RXXGate(theta),
RYGate(theta),
RYYGate(theta),
RZZGate(theta),
RZXGate(theta),
XXMinusYYGate(theta, beta),
XXPlusYYGate(theta, beta),
ECRGate(),
SGate(),
SdgGate(),
CSGate(),
CSdgGate(),
SwapGate(),
iSwapGate(),
SXdgGate(),
TGate(),
TdgGate(),
UGate(theta, phi, lambda_),
U1Gate(lambda_),
U2Gate(phi, lambda_),
U3Gate(theta, phi, lambda_),
YGate(),
ZGate(),
Delay(time),
Reset(),
Measure(),
]
name_mapping = {gate.name: gate for gate in gates}
return name_mapping