qrunch.quantum.operators.pauli
Module that contains the abstract Pauli operators \(X\), \(Y\), \(Z\), and \(I\).
These operators correspond to Pauli matrices acting on specified qubits.
A general Hermitian operator can be expressed as a combination of these fundamental operators through addition and multiplication, applied to specific qubits.
from qrunch.quantum.operators.pauli import X, Y, Z
Obs = 0.5 * X(1) * X(2) + 1.2 * Y(3) * Y(4) - 0.7 * Z(1) * Z(2) * Z(3) * Z(4)
A Hermitian operator like this can be used as input for various tools, such as estimators, which calculate the expectation value of the operator for a given quantum state represented by a quantum circuit.
Classes
Pauli identity operator. |
|
Pauli \(X\) operator. |
|
Pauli \(Y\) operator. |
|
Pauli \(Z\) operator. |
- class I
Bases:
PauliOperatorPauli identity operator.
- __init__(qubit: AbstractIndex | int) None
Initialize Pauli operator that operates on the specified qubit.
The index can be a concrete integer or an
AbstractIndex. When an abstract index is used it can be set usingwith_indices(), returning a new instance of the operator with the index set to the concrete value.- Parameters:
qubit (AbstractIndex | int) – The qubit to operate on.
- Return type:
None
- get_indices() tuple[AbstractIndex | int]
Get index of the operator (abstract or concrete).
- Return type:
tuple[AbstractIndex | int]
- property qubit: AbstractIndex | int
The qubit the operator acts on.
- with_indices(index_value_pairs: IndexValuePairs) PauliOperator
Create a new copy of the operator with the AbstractIndex set to the given value.
- Parameters:
index_value_pairs (IndexValuePairs) – Map of abstract indices to concrete values.
- Return type:
- class X
Bases:
PauliOperatorPauli \(X\) operator.
- __init__(qubit: AbstractIndex | int) None
Initialize Pauli operator that operates on the specified qubit.
The index can be a concrete integer or an
AbstractIndex. When an abstract index is used it can be set usingwith_indices(), returning a new instance of the operator with the index set to the concrete value.- Parameters:
qubit (AbstractIndex | int) – The qubit to operate on.
- Return type:
None
- get_indices() tuple[AbstractIndex | int]
Get index of the operator (abstract or concrete).
- Return type:
tuple[AbstractIndex | int]
- property qubit: AbstractIndex | int
The qubit the operator acts on.
- with_indices(index_value_pairs: IndexValuePairs) PauliOperator
Create a new copy of the operator with the AbstractIndex set to the given value.
- Parameters:
index_value_pairs (IndexValuePairs) – Map of abstract indices to concrete values.
- Return type:
- class Y
Bases:
PauliOperatorPauli \(Y\) operator.
- __init__(qubit: AbstractIndex | int) None
Initialize Pauli operator that operates on the specified qubit.
The index can be a concrete integer or an
AbstractIndex. When an abstract index is used it can be set usingwith_indices(), returning a new instance of the operator with the index set to the concrete value.- Parameters:
qubit (AbstractIndex | int) – The qubit to operate on.
- Return type:
None
- get_indices() tuple[AbstractIndex | int]
Get index of the operator (abstract or concrete).
- Return type:
tuple[AbstractIndex | int]
- property qubit: AbstractIndex | int
The qubit the operator acts on.
- with_indices(index_value_pairs: IndexValuePairs) PauliOperator
Create a new copy of the operator with the AbstractIndex set to the given value.
- Parameters:
index_value_pairs (IndexValuePairs) – Map of abstract indices to concrete values.
- Return type:
- class Z
Bases:
PauliOperatorPauli \(Z\) operator.
- __init__(qubit: AbstractIndex | int) None
Initialize Pauli operator that operates on the specified qubit.
The index can be a concrete integer or an
AbstractIndex. When an abstract index is used it can be set usingwith_indices(), returning a new instance of the operator with the index set to the concrete value.- Parameters:
qubit (AbstractIndex | int) – The qubit to operate on.
- Return type:
None
- get_indices() tuple[AbstractIndex | int]
Get index of the operator (abstract or concrete).
- Return type:
tuple[AbstractIndex | int]
- property qubit: AbstractIndex | int
The qubit the operator acts on.
- with_indices(index_value_pairs: IndexValuePairs) PauliOperator
Create a new copy of the operator with the AbstractIndex set to the given value.
- Parameters:
index_value_pairs (IndexValuePairs) – Map of abstract indices to concrete values.
- Return type:
Modules
Base class for all Pauli operators, which define internal logic and enables simplification of Pauli expressions. |
|
Efficient representation of a Pauli string. |
|
Efficient representation of a Pauli sum. |