shor package¶
Subpackages¶
Submodules¶
shor.errors module¶
-
exception
shor.errors.
CircuitError
[source]¶ Bases:
shor.errors.ShorError
-
exception
shor.errors.
ProviderError
[source]¶ Bases:
shor.errors.ShorError
shor.gates module¶
-
class
shor.gates.
CCNOT
(*qbits, **kwargs)[source]¶ Bases:
shor.gates._Gate
Apply the CCNOT or CCX gate to three qbits. The first and second qbit being control qits and the paulix gate is applied to the third qbit.
-
symbol
¶ a string used to represent gate for provider transpiler
- Type
str
-
qbits
¶ qbit indices to which CCNOT gate is applied
- Type
int
-
dimension
¶ number of qbits CCNOT gate is applied to
- Type
int
-
symbol
= 'CCX'¶
-
-
class
shor.gates.
CH
(*qbits, **kwargs)[source]¶ Bases:
shor.gates._Gate
Apply the CH gate to two qbits. The first being the control qbit and the second applies the hadarmard gate to the target qbit
-
symbol
¶ a string used to represent gate for provider transpiler
- Type
str
-
qbits
¶ qbit index CH gate is applied to
- Type
int
-
dimension
¶ number of qbits CH gate is applied to
- Type
int
-
symbol
= 'CH'¶
-
-
class
shor.gates.
CNOT
(*qbits, **kwargs)[source]¶ Bases:
shor.gates._Gate
Apply the controlled X gate to control and target qbit Inherits from gate class
-
symbol
¶ a string used to represent gate for provider transpiler
- Type
str
-
qbits
¶ list of length 2 containing qbit indices to which the controlled X gate is applied
- Type
int
-
dimension
¶ number of qbits to which the controlled X gate is applied
- Type
int
-
symbol
= 'CX'¶
-
-
class
shor.gates.
CRZ
(*qbits, angle=0, **kwargs)[source]¶ Bases:
shor.gates._Gate
Apply the CRZ gate to two qbits. The first being the control qbit and the Rz gate is applied to the target qbit.
-
symbol
¶ a string used to represent gate for provider transpiler
- Type
str
-
qbits
¶ qbit index CRZ gate is applied to
- Type
int
-
angle
¶ angle by which the CRZ gate rotates the second target qbit around the z-axis
- Type
float
-
dimension
¶ number of qbits CRZ gate is applied to
- Type
int
-
symbol
= 'CRZ'¶
-
-
class
shor.gates.
CRk
(*qbits, k, **kwargs)[source]¶ Bases:
shor.gates._Gate
Apply the parameterized control phase shift gate Crk with angle pi/2**k. First qbit being the control and second target qbit has a phase shift applied.
-
symbol
¶ a string used to represent gate for provider transpiler
- Type
str
-
qbits
¶ qbit indices to which Crk gate is applied
- Type
int
-
angle
¶ Floating point number containing angle of phase shift
- Type
float
-
dimension
¶ number of qbits Cr gate is applied to
- Type
int
-
-
class
shor.gates.
CSWAP
(*qbits, **kwargs)[source]¶ Bases:
shor.gates._Gate
Apply the Fredkin gate or sometimes called the CSWAP gate to three qbits
-
symbol
¶ a string used to represent gate for provider transpiler
- Type
str
-
qbits
¶ qbit indices CSWAP gate is applied to: the first being a control qbit and the SWAP gate is applied to the second and third target qbits.
- Type
int
-
dimension
¶ number of qbits to which the CSWAP gate is applied
- Type
int
-
symbol
= 'CSWAP'¶
-
-
shor.gates.
CX
¶ alias of
shor.gates.CNOT
-
class
shor.gates.
CY
(*qbits, **kwargs)[source]¶ Bases:
shor.gates._Gate
Apply the controlled Y gate to control and target qbit
-
symbol
¶ a string used to represent gate for provider transpiler
- qbitsint
list of length 2 containing qbit indices controlled Y gate is applied to
- Type
str
-
dimension
¶ number of qbits to which the controlled Y gate is applied
- Type
int
-
symbol
= 'CY'¶
-
-
class
shor.gates.
Cr
(*qbits, angle, **kwargs)[source]¶ Bases:
shor.gates._Gate
Apply the control phase shift gate Cr or sometimes referred as CU1. First qbit being the control and second target qbit has a phase shift applied.
-
symbol
¶ a string used to represent gate for provider transpiler
- Type
str
-
qbits
¶ qbit index to which the Cr gate is applied
- Type
int
-
angle
¶ Floating point number containing angle of phase shift
- Type
float
-
dimension
¶ number of qbits Cr gate is applied to
- Type
int
-
symbol
= 'CU1'¶
-
-
class
shor.gates.
Cx
(*qbits, **kwargs)[source]¶ Bases:
shor.gates._Gate
Apply the the Cx gate to a single qbit
-
symbol
¶ a string used to represent gate for provider transpiler
- Type
str
-
qbits
¶ qbit indices Cx gate is applied to
- Type
int
-
dimension
¶ number of qbits Cx gate is applied to
- Type
int
-
symbol
= 'CX'¶
-
-
class
shor.gates.
Cz
(*qbits, **kwargs)[source]¶ Bases:
shor.gates._Gate
Apply the Cz gate to a two qbits. First is control qbit and PauliZ gate is applied to the target qbit
-
symbol
¶ a string used to represent gate for provider transpiler
- Type
str
-
qbits
¶ qbit index U1 gate is applied to
- Type
int
-
dimension
¶ number of qbits U1 gate is applied to
- Type
int
-
symbol
= 'CZ'¶
-
-
shor.gates.
Fredkin
¶ alias of
shor.gates.CSWAP
-
shor.gates.
H
¶ alias of
shor.gates.Hadamard
-
class
shor.gates.
Hadamard
(*qbits, **kwargs)[source]¶ Bases:
shor.gates._Gate
Apply the hadamard gate to a single qbit
-
symbol
¶ a string used to represent gate for provider transpiler
- Type
str
-
qbits
¶ qbit index to which the hadamard gate is applied
- Type
int
-
dimension
¶ number of qbits to which the hardamard gate is applied
- Type
int
-
symbol
= 'H'¶
-
-
class
shor.gates.
ID
(*qbits, **kwargs)[source]¶ Bases:
shor.gates._Gate
Apply the identity (ID) gate to a single qbit
-
symbol
¶ a string used to represent gate for provider transpiler
- Type
str
-
qbits
¶ qbit index to which ID gate is applied
- Type
int
-
dimension
¶ number of qbits to which ID gate is applied
- Type
int
-
symbol
= 'I'¶
-
-
class
shor.gates.
Init_x
(*qbits, **kwargs)[source]¶ Bases:
shor.gates._Gate
Initialize the qbits along x axis or |+> basis Currently not implemented in qiskit and can only be used on shor simulator
-
qbits
¶ qbit index init_x gate is applied to
- Type
int
-
dimension
¶ number of qbits init_x gate is applied to
- Type
int
-
-
class
shor.gates.
Init_y
(*qbits, **kwargs)[source]¶ Bases:
shor.gates._Gate
Initialize the qbits along y axis or |-> basis Currently not implimented in qiskit and can only be used on shor simulator
-
qbits
¶ qbit index init_y gate is applied to
- Type
int
-
dimension
¶ number of qbits init_y gate is applied to
- Type
int
-
-
class
shor.gates.
PauliX
(*qbits, **kwargs)[source]¶ Bases:
shor.gates._Gate
Apply the PauliX gate to a single qbit
-
symbol
¶ a string used to represent gate for provider transpiler
- Type
str
-
qbits
¶ qbit index to which the PauliX gate is applied
- Type
int
-
dimension
¶ number of qbits to which the PauliX gate is applied
- Type
int
-
symbol
= 'X'¶
-
-
class
shor.gates.
PauliY
(*qbits, **kwargs)[source]¶ Bases:
shor.gates._Gate
Apply the PauliY gate to a single qbit
-
symbol
¶ a string used to represent gate for provider transpiler
- Type
str
-
qbits
¶ qbit indices to which the PauliY gate is applied
- Type
int
-
dimension
¶ number of qbits to which the PauliY gate is applied
- Type
int
-
symbol
= 'Y'¶
-
-
class
shor.gates.
PauliZ
(*qbits, **kwargs)[source]¶ Bases:
shor.gates._Gate
Apply the PauliZ gate to a single qbit
-
symbol
¶ a string used to represent gate for provider transpiler
- Type
str
-
qbits
¶ qbit indices to which the PauliZ gate is applied
- Type
int
-
dimension
¶ number of qbits to which the PauliZ gate is applied
- Type
int
-
symbol
= 'Z'¶
-
-
class
shor.gates.
QFT
(*qbits, **kwargs)[source]¶ Bases:
shor.gates._Gate
Apply the Quantum Fourier Transform gate to two qbits
-
symbol
¶ a string used to represent gate for provider transpiler
- Type
str
-
qbits
¶ qbit indices to which the QFT gate is applied
- Type
int
-
dimension
¶ number of qbits to which the QFT gate is applied
- Type
int
-
to_matrixSelf) -> np.ndarray
Returns matrix form of gate as numpy array
-
-
class
shor.gates.
Rx
(*qbits, angle=1.5707963267948966, **kwargs)[source]¶ Bases:
shor.gates._Gate
Apply the Rx gate to a single qbit
-
symbol
¶ a string used to represent gate for provider transpiler
- Type
str
-
qbits
¶ qbit index tow which Rx gate is applied
- Type
int
-
dimension
¶ number of qbits to which Rx gate is applied
- Type
int
-
symbol
= 'RX'¶
-
-
class
shor.gates.
Ry
(*qbits, angle=1.5707963267948966, **kwargs)[source]¶ Bases:
shor.gates._Gate
Apply the Ry gate to a single qbit
-
symbol
¶ a string used to represent gate for provider transpiler
- Type
str
-
qbits
¶ qbit index to which the Ry gate is applied
- Type
int
-
dimension
¶ number of qbits to which the Ry gate is applied
- Type
int
-
symbol
= 'RY'¶
-
-
class
shor.gates.
Rz
(*qbits, angle, **kwargs)[source]¶ Bases:
shor.gates._Gate
Apply the Rz gate to a single qbit
-
symbol
¶ a string used to represent gate for provider transpiler
- Type
str
-
qbits
¶ qbit index to which the Rz gate is applied
- Type
int
-
dimension
¶ number of qbits to which the Rz gate is applied
- Type
int
-
symbol
= 'RZ'¶
-
-
class
shor.gates.
S
(*qbits, **kwargs)[source]¶ Bases:
shor.gates._Gate
Apply the S gate to a single qbit
-
symbol
¶ a string used to represent gate for provider transpiler
- Type
str
-
qbits
¶ qbit index S gate is applied to
- Type
int
-
dimension
¶ number of qbits S gate is applied to
- Type
int
-
symbol
= 'S'¶
-
-
class
shor.gates.
SWAP
(*qbits, **kwargs)[source]¶ Bases:
shor.gates._Gate
Apply the SWAP gate to two qbits
-
symbol
¶ a string used to represent gate for provider transpiler
- Type
str
-
qbits
¶ qbit indices SWAP gate is applied to
- Type
int
-
dimension
¶ number of qbits SWAP gate is applied to
- Type
int
-
symbol
= 'SWAP'¶
-
-
class
shor.gates.
Sdg
(*qbits, **kwargs)[source]¶ Bases:
shor.gates._Gate
Apply the Sdg gate to a single qbit
-
symbol
¶ a string used to represent gate for provider transpiler
- Type
str
-
qbits
¶ qbit index to which the Sdg gate is applied
- Type
int
-
dimension
¶ number of qbits to which the Sdg gate is applied
- Type
int
-
symbol
= 'Sdg'¶
-
-
class
shor.gates.
T
(*qbits, **kwargs)[source]¶ Bases:
shor.gates._Gate
Apply the T gate to a single qbit
-
symbol
¶ a string used to represent gate for provider transpiler
- Type
str
-
qbits
¶ qbit index to which the T gate is applied
- Type
int
-
dimension
¶ number of qbits to which the T gate is applied
- Type
int
-
symbol
= 'T'¶
-
-
class
shor.gates.
Tdg
(*qbits, **kwargs)[source]¶ Bases:
shor.gates._Gate
Apply the Tdg gate to a single qbit
-
symbol
¶ a string used to represent gate for provider transpiler
- Type
str
-
qbits
¶ qbit index to which Tdg gate is applied
- Type
int
-
dimension
¶ number of qbits to which Tdg gate is applied
- Type
int
-
symbol
= 'Tdg'¶
-
-
class
shor.gates.
U1
(*qbits, angle=0, **kwargs)[source]¶ Bases:
shor.gates._Gate
Apply the U1 gate to a single qbit
-
symbol
¶ a string used to represent gate for provider transpiler
- Type
str
-
qbits
¶ qbit index U1 gate is applied to
- Type
int
-
angle
¶ angle used to rotate qbit of choice around the z-axis
- Type
float
-
dimension
¶ number of qbits U1 gate is applied to
- Type
int
-
symbol
= 'U1'¶
-
-
class
shor.gates.
U2
(*qbits, phi=0, lam=0, **kwargs)[source]¶ Bases:
shor.gates.U3
apply U2 gate for single qbit rotation with 2 euler angles
-
symbol
¶ a string used to represent gate for provider transpiler
- Type
str
-
qbits
¶ qbit index Rz gate is applied to
- Type
int
-
phi
¶ second angle used to rotate single qbit
- Type
float
-
lam
¶ third angle used to rotate single qbit
- Type
float
-
dimension
¶ number of qbits Rz gate is applied to
- Type
int
-
to_matrix
(self) → np.ndarray¶ Returns matrix form of gate as numpy array
-
symbol
= 'U2'¶
-
-
class
shor.gates.
U3
(*qbits, theta=0, phi=0, lam=0, **kwargs)[source]¶ Bases:
shor.gates._Gate
apply U3 gate for single qbit rotation with 3 euler angles
-
symbol
¶ a string used to represent gate for provider transpiler
- Type
str
-
qbits
¶ qbit index to which the Rz gate is applied
- Type
int
-
theta
¶ first angle used to rotate single qbit
- Type
float
-
phi
¶ second angle used to rotate single qbit
- Type
float
-
lam
¶ third angle used to rotate single qbit
- Type
float
-
dimension
¶ number of qbits to which the Rz gate is applied
- Type
int
-
symbol
= 'U3'¶
-
-
shor.gates.
X
¶ alias of
shor.gates.PauliX
-
shor.gates.
Y
¶ alias of
shor.gates.PauliY
-
shor.gates.
Z
¶ alias of
shor.gates.PauliZ
-
shor.gates.
cswap
¶ alias of
shor.gates.CSWAP
-
shor.gates.
cx
¶ alias of
shor.gates.CNOT
-
shor.gates.
h
¶ alias of
shor.gates.Hadamard
-
shor.gates.
swap
¶ alias of
shor.gates.SWAP
-
shor.gates.
x
¶ alias of
shor.gates.PauliX
-
shor.gates.
y
¶ alias of
shor.gates.PauliY
-
shor.gates.
z
¶ alias of
shor.gates.PauliZ
shor.layers module¶
-
class
shor.layers.
Qbits
(num, state=0, **kwargs)[source]¶ Bases:
shor.layers._Layer
,collections.abc.Iterable
-
shor.layers.
Qubits
¶ alias of
shor.layers.Qbits
shor.operations module¶
-
shor.operations.
M
¶ alias of
shor.operations.Measure
-
class
shor.operations.
Measure
(*qbits, output_bits=None, axis='z', **kwargs)[source]¶ Bases:
shor.operations._Operation
-
symbol
= 'measure'¶
-
-
shor.operations.
m
¶ alias of
shor.operations.Measure
shor.quantum module¶
-
shor.quantum.
Circuit
¶ alias of
shor.quantum.QuantumCircuit
-
shor.quantum.
QC
¶ alias of
shor.quantum.QuantumCircuit
-
class
shor.quantum.
QuantumCircuit
[source]¶ Bases:
object
-
add
(layer_or_circuit: Union[shor.layers._Layer, shor.quantum.QuantumCircuit])[source]¶
-