qrunch.quantum.measurement.bases.qubit_wise_measurement_basis
Module defining a measurement basis for qubit-wise measurements.
Classes
Class representing the computational basis. |
|
Class that makes it possible to identify a measurement group of qubit wise commuting operators. |
- class ComputationalBasis
Bases:
QubitWiseMeasurementBasisClass representing the computational basis.
- __init__(num_qubits: int) None
Initialize the computational basis.
- Parameters:
num_qubits (int)
- Return type:
None
- static as_ints(pauli_x_indices: tuple[int, ...], pauli_y_indices: tuple[int, ...], pauli_z_indices: tuple[int, ...]) tuple[int, int, int]
Get the x-mask, y-mask and z-mask defining the group identifier as integers.
- Parameters:
pauli_x_indices (tuple[int, ...])
pauli_y_indices (tuple[int, ...])
pauli_z_indices (tuple[int, ...])
- Return type:
tuple[int, int, int]
- calculate_expectation_value(pauli_sum: HermitianPauliSum, measurement: QuantumMeasurement) ExpectationValue
Calculate expectation value for an observable given a qubit-wise quantum measurement.
It is assumed that the states are in a diagonal basis corresponding to the Pauli operators in the observable.
- Parameters:
pauli_sum (HermitianPauliSum) – Pauli sum to calculate expectation value for.
measurement (QuantumMeasurement) – Quantum measurement.
- Return type:
- difference_size(other: QubitWiseMeasurementBasis) int
Calculate the difference in size between this and the other group identifier.
- Parameters:
other (QubitWiseMeasurementBasis) – Other group identifier.
- Return type:
int
Returns: The size of the difference of the group identifiers.
- classmethod from_pauli_string(pauli_string: PauliString) QubitWiseMeasurementBasis
Create a group identifier from a Pauli string.
- Parameters:
pauli_string (PauliString) – Pauli string to create the identifier for.
- Return type:
Returns: A group identifier for the given Pauli string.
- get_diagonalizing_circuit(num_qubits: int) Circuit
Get the diagonalizing circuit for the given circuit.
- Parameters:
num_qubits (int) – Number of qubits in the circuit.
- Return type:
- is_compatible_with(other: PauliString) bool
Check if compatible with other.
- Parameters:
other (PauliString) – Other PauliString to check compatibility with.
- Return type:
bool
Returns: True if compatible.
- is_compatible_with_qubitwise_basis(other: QubitWiseMeasurementBasis) bool
Check if another group identifier is compatible, i.e. can be measured simultaneous.
- Parameters:
other (QubitWiseMeasurementBasis) – Other group identifier to check compatibility with.
- Return type:
bool
Returns: True if compatible.
- is_diagonal() bool
Check if the measurement basis is diagonal, i.e., measured in the Z basis only.
- Return type:
bool
- property pauli_x_indices: tuple[int, ...]
Get all qubit indices of Pauli X operators.
- pauli_x_mask: int
- property pauli_y_indices: tuple[int, ...]
Get all qubit indices of Pauli Y operators.
- pauli_y_mask: int
- property pauli_z_indices: tuple[int, ...]
Get all qubit indices of Pauli Z operators.
- pauli_z_mask: int
- union(other: QubitWiseMeasurementBasis) QubitWiseMeasurementBasis
Create the union with the other group identifier.
- Parameters:
other (QubitWiseMeasurementBasis) – Other identifier.
- Return type:
Returns: A new group identifier that is the union of this and the other.
- class QubitWiseMeasurementBasis
Bases:
MeasurementBasisClass that makes it possible to identify a measurement group of qubit wise commuting operators.
All fields are immutable (
frozen=True) so an instance can be safely reused.- Parameters:
pauli_x_mask – Integer corresponding to the bit-string of hit qubit indices.
pauli_y_mask – Integer corresponding to the bit-string of hit qubit indices.
pauli_z_mask – Integer corresponding to the bit-string of hit qubit indices.
- __init__(pauli_x_mask: int, pauli_y_mask: int, pauli_z_mask: int) None
- Parameters:
pauli_x_mask (int)
pauli_y_mask (int)
pauli_z_mask (int)
- Return type:
None
- static as_ints(pauli_x_indices: tuple[int, ...], pauli_y_indices: tuple[int, ...], pauli_z_indices: tuple[int, ...]) tuple[int, int, int]
Get the x-mask, y-mask and z-mask defining the group identifier as integers.
- Parameters:
pauli_x_indices (tuple[int, ...])
pauli_y_indices (tuple[int, ...])
pauli_z_indices (tuple[int, ...])
- Return type:
tuple[int, int, int]
- calculate_expectation_value(pauli_sum: HermitianPauliSum, measurement: QuantumMeasurement) ExpectationValue
Calculate expectation value for an observable given a qubit-wise quantum measurement.
It is assumed that the states are in a diagonal basis corresponding to the Pauli operators in the observable.
- Parameters:
pauli_sum (HermitianPauliSum) – Pauli sum to calculate expectation value for.
measurement (QuantumMeasurement) – Quantum measurement.
- Return type:
- difference_size(other: QubitWiseMeasurementBasis) int
Calculate the difference in size between this and the other group identifier.
- Parameters:
other (QubitWiseMeasurementBasis) – Other group identifier.
- Return type:
int
Returns: The size of the difference of the group identifiers.
- classmethod from_pauli_string(pauli_string: PauliString) QubitWiseMeasurementBasis
Create a group identifier from a Pauli string.
- Parameters:
pauli_string (PauliString) – Pauli string to create the identifier for.
- Return type:
Returns: A group identifier for the given Pauli string.
- get_diagonalizing_circuit(num_qubits: int) Circuit
Get the diagonalizing circuit for the given circuit.
- Parameters:
num_qubits (int) – Number of qubits in the circuit.
- Return type:
- is_compatible_with(other: PauliString) bool
Check if compatible with other.
- Parameters:
other (PauliString) – Other PauliString to check compatibility with.
- Return type:
bool
Returns: True if compatible.
- is_compatible_with_qubitwise_basis(other: QubitWiseMeasurementBasis) bool
Check if another group identifier is compatible, i.e. can be measured simultaneous.
- Parameters:
other (QubitWiseMeasurementBasis) – Other group identifier to check compatibility with.
- Return type:
bool
Returns: True if compatible.
- is_diagonal() bool
Check if the measurement basis is diagonal, i.e., measured in the Z basis only.
- Return type:
bool
- property pauli_x_indices: tuple[int, ...]
Get all qubit indices of Pauli X operators.
- pauli_x_mask: int
- property pauli_y_indices: tuple[int, ...]
Get all qubit indices of Pauli Y operators.
- pauli_y_mask: int
- property pauli_z_indices: tuple[int, ...]
Get all qubit indices of Pauli Z operators.
- pauli_z_mask: int
- union(other: QubitWiseMeasurementBasis) QubitWiseMeasurementBasis
Create the union with the other group identifier.
- Parameters:
other (QubitWiseMeasurementBasis) – Other identifier.
- Return type:
Returns: A new group identifier that is the union of this and the other.