program
¶
Circuit program independent of any execution framework.
Prepare
¶
Statevector written onto a set of qubits.
Attributes:
-
amplitudes(NDArray[complex128]) –Complex amplitudes, one per basis state of
qubits. -
qubits(tuple[int, ...]) –Qubits that receive the state, in the order the amplitudes use.
Source code in shadowsim/backends/program.py
__init__
¶
Record amplitudes on qubits.
Parameters:
-
amplitudes(ArrayLike) –One complex amplitude per basis state of
qubits. -
qubits(Sequence[int]) –Qubits that receive the state, in the order the amplitudes use.
Raises:
-
ValueError–qubitsis empty, contains a duplicate or a negative index, oramplitudesdoes not have one entry per basis state.
Source code in shadowsim/backends/program.py
__eq__
¶
Return whether both prepares carry the same qubits and amplitudes.
Source code in shadowsim/backends/program.py
Unitary
¶
Matrix applied to a set of qubits.
The matrix is stored in the qubit order it was given. It is not transposed.
Attributes:
-
matrix(NDArray[complex128]) –Square complex matrix of shape
(2**n, 2**n)fornqubits. -
qubits(tuple[int, ...]) –Qubits the matrix acts on, in the order
matrixuses.
Source code in shadowsim/backends/program.py
__init__
¶
Record matrix on qubits.
Parameters:
-
matrix(ArrayLike) –Square matrix whose dimension is
2 ** len(qubits). -
qubits(Sequence[int]) –Qubits the matrix acts on, in the order
matrixuses.
Raises:
-
ValueError–qubitsis empty, contains a duplicate or a negative index, ormatrixdoes not have shape(2**n, 2**n).
Source code in shadowsim/backends/program.py
__eq__
¶
Return whether both unitaries carry the same qubits and matrix.
Source code in shadowsim/backends/program.py
Hadamard
¶
Hadamard on one qubit.
Attributes:
-
qubit(int) –Qubit that receives the Hadamard.
Source code in shadowsim/backends/program.py
Reset
¶
Return one qubit to the zero state.
Attributes:
-
qubit(int) –Qubit that is reset.
Source code in shadowsim/backends/program.py
Barrier
¶
Barrier across one or more qubits.
Attributes:
-
qubits(tuple[int, ...]) –Qubits the barrier spans.
Source code in shadowsim/backends/program.py
Measure
¶
Computational-basis measurement of one qubit into one classical bit.
Attributes:
-
qubit(int) –Qubit that is measured.
-
clbit(int) –Classical bit that receives the outcome.
Source code in shadowsim/backends/program.py
__init__
¶
Record a measurement of qubit into clbit.
Parameters:
-
qubit(int) –Qubit that is measured.
-
clbit(int) –Classical bit that receives the outcome.
Raises:
-
ValueError–qubitorclbitis not a non-negative index.
Source code in shadowsim/backends/program.py
__eq__
¶
Return whether both measurements use the same qubit and classical bit.
Source code in shadowsim/backends/program.py
Program
¶
Ordered circuit operations on a fixed register.
Qubit indexes are positions in that register. An ancilla added before the body occupies the lower indexes.
Attributes:
-
num_qubits(int) –Number of qubits in the register.
-
num_clbits(int) –Number of classical bits in the register.
-
operations(tuple[Operation, ...]) –Operations in the order they are applied.
Source code in shadowsim/backends/program.py
__init__
¶
Record operations on registers of the given sizes.
Parameters:
-
num_qubits(int) –Number of qubits in the register.
-
num_clbits(int) –Number of classical bits in the register.
-
operations(Sequence[Operation]) –Operations in the order they are applied.
Raises:
-
TypeError–An entry of
operationsis not a program operation. -
ValueError–A register size is negative, or an operation names a qubit or classical bit outside the register.
Source code in shadowsim/backends/program.py
__eq__
¶
Return whether both programs have the same registers and operations.