braket.default_simulator.operation module
- class braket.default_simulator.operation.Operation[source]
Bases:
ABC
Encapsulates an operation acting on a set of target qubits.
- abstract property targets: tuple[int, ...]
The indices of the qubits the operation applies to.
Note: For an index to be a target of an observable, the observable must have a nontrivial (i.e. non-identity) action on that index. For example, a tensor product observable with a Z factor on qubit j acts trivially on j, so j would not be a target. This does not apply to gate operations.
- Type:
tuple[int, …]
- class braket.default_simulator.operation.GateOperation(targets, *params, ctrl_modifiers=(), power=1)[source]
Bases:
Operation
,ABC
Encapsulates a unitary quantum gate operation acting on a set of target qubits.
- property targets: tuple[int, ...]
The indices of the qubits the operation applies to.
Note: For an index to be a target of an observable, the observable must have a nontrivial (i.e. non-identity) action on that index. For example, a tensor product observable with a Z factor on qubit j acts trivially on j, so j would not be a target. This does not apply to gate operations.
- Type:
tuple[int, …]
- property matrix: ndarray
- class braket.default_simulator.operation.KrausOperation[source]
Bases:
Operation
,ABC
Encapsulates a quantum channel acting on a set of target qubits in the Kraus operator representation.
- abstract property matrices: list[ndarray]
A list of matrices representing Kraus operators.
- Type:
list[np.ndarray]
- class braket.default_simulator.operation.Observable[source]
Bases:
Operation
,ABC
Encapsulates an observable to be measured in the computational basis.
- property measured_qubits: tuple[int, ...]
The indices of the qubits that are measured for this observable.
Unlike
targets
, this includes indices on which the observable acts trivially. For example, a tensor product observable made entirely of n Z factors will have n measured qubits.- Type:
tuple[int, …]
- property is_standard: bool
Whether the observable is Pauli-like, that is, has eigenvalues of \(\pm 1\).
Examples include the Pauli and Hadamard observables.
- Type:
bool
- abstract property eigenvalues: ndarray
The eigenvalues of the observable ordered by computational basis state.
- Type:
np.ndarray
- abstract apply(state: ndarray) ndarray [source]
Applies this observable to the given state.
- Parameters:
state (np.ndarray) – The state to apply the observable to.
- Returns:
np.ndarray – The state after the observable has been applied.
- abstract fix_qubit(qubit: int) Observable [source]
Creates a copy of it acting on the given qubit.
Only defined for observables that act on 1 qubit.
- Parameters:
qubit (int) – The target qubit of the new observable.
- Returns:
Observable – A copy of this observable, acting on the new qubit.
- abstract diagonalizing_gates(num_qubits: int | None = None) tuple[GateOperation, ...] [source]
The gates that diagonalize the observable in the computational basis.
- Parameters:
num_qubits (int, optional) – The number of qubits the observable acts on. Only used if no target is specified, in which case a gate is created for each target qubit. This only makes sense for single-qubit observables.
- Returns:
tuple[GateOperation, …] – The gates that diagonalize the observable in the computational basis, if it is not already in the computational basis. If there is no explicit target, this method returns a tuple of gates acting on every qubit.