braket.default_simulator.operation module

class braket.default_simulator.operation.Operation[source]

Bases: abc.ABC

Encapsulates an operation acting on a set of target qubits.

targets

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[source]

Bases: braket.default_simulator.operation.Operation, abc.ABC

Encapsulates a unitary quantum gate operation acting on a set of target qubits.

matrix

The matrix representation of the operation.

Type:np.ndarray
class braket.default_simulator.operation.KrausOperation[source]

Bases: braket.default_simulator.operation.Operation, abc.ABC

Encapsulates a quantum channel acting on a set of target qubits in the Kraus operator representation.

matrices

A list of matrices representing Kraus operators.

Type:List[np.ndarray]
class braket.default_simulator.operation.Observable[source]

Bases: braket.default_simulator.operation.Operation, abc.ABC

Encapsulates an observable to be measured in the computational basis.

measured_qubits

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, ..]
is_standard

Whether the observable is Pauli-like, that is, has eigenvalues of \(\pm 1\).

Examples include the Pauli and Hadamard observables.

Type:bool
eigenvalues

The eigenvalues of the observable ordered by computational basis state.

Type:np.ndarray
apply(state: numpy.ndarray) → numpy.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.
fix_qubit(qubit: int) → braket.default_simulator.operation.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.
diagonalizing_gates(num_qubits: Optional[int] = None) → Tuple[braket.default_simulator.operation.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.