braket.default_simulator.observables module¶

class
braket.default_simulator.observables.
Identity
(targets: Optional[List[int]] = None)[source]¶ Bases:
braket.default_simulator.operation.Observable
Identity observable
Note
This observable refers to the same mathematical object as the gate operation of the same name, but is meant to be used differently; the observable is viewed as a Hermitian operator to be measured, while the gate is viewed as a unitary operator to evolve the state of the system.

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. nonidentity) 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, ..]

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

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 singlequbit 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.


class
braket.default_simulator.observables.
Hadamard
(targets: Optional[List[int]] = None)[source]¶ Bases:
braket.default_simulator.observables._InvolutoryMatrixObservable
Hadamard observable
Note
This observable refers to the same mathematical object as the gate operation of the same name, but is meant to be used differently; the observable is viewed as a Hermitian operator to be measured, while the gate is viewed as a unitary operator to evolve the state of the system.

is_standard
¶ Whether the observable is Paulilike, 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

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 singlequbit 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.


class
braket.default_simulator.observables.
PauliX
(targets: Optional[List[int]] = None)[source]¶ Bases:
braket.default_simulator.observables._InvolutoryMatrixObservable
PauliX observable
Note
This observable refers to the same mathematical object as the gate operation of the same name, but is meant to be used differently; the observable is viewed as a Hermitian operator to be measured, while the gate is viewed as a unitary operator to evolve the state of the system.

is_standard
¶ Whether the observable is Paulilike, 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

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 singlequbit 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.


class
braket.default_simulator.observables.
PauliY
(targets: Optional[List[int]] = None)[source]¶ Bases:
braket.default_simulator.observables._InvolutoryMatrixObservable
PauliY observable
Note
This observable refers to the same mathematical object as the gate operation of the same name, but is meant to be used differently; the observable is viewed as a Hermitian operator to be measured, while the gate is viewed as a unitary operator to evolve the state of the system.

is_standard
¶ Whether the observable is Paulilike, 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

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 singlequbit 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.


class
braket.default_simulator.observables.
PauliZ
(targets: Optional[List[int]] = None)[source]¶ Bases:
braket.default_simulator.observables._InvolutoryMatrixObservable
PauliZ observable
Note
This observable refers to the same mathematical object as the gate operation of the same name, but is meant to be used differently; the observable is viewed as a Hermitian operator to be measured, while the gate is viewed as a unitary operator to evolve the state of the system.

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. nonidentity) 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, ..]

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 Paulilike, 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

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 singlequbit 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.


class
braket.default_simulator.observables.
Hermitian
(matrix: numpy.ndarray, targets: Optional[List[int]] = None)[source]¶ Bases:
braket.default_simulator.operation.Observable
Arbitrary Hermitian observable

matrix
¶ The Hermitian matrix defining the observable.
Type: np.ndarray

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. nonidentity) 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, ..]

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 singlequbit 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.


class
braket.default_simulator.observables.
TensorProduct
(factors: List[braket.default_simulator.operation.Observable])[source]¶ Bases:
braket.default_simulator.operation.Observable
Tensor product of multiple observables.
Parameters: factors (List[Observable]) – The observables to combine together into a tensor product 
factors
¶

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. nonidentity) 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, ..]

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

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 singlequbit 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.
