String¶
- class zixy.qubit.pauli.String(qubits: int | Qubits | None = None, source: SpecT | None = None)[source]¶
Bases:
String[QubitPauliArray,None|Sequence[PauliMatrix] |dict[int,PauliMatrix] |str,PauliMatrix]A Pauli string.
A single qubit-based Pauli string that may be an owning instance referencing a single element in a Rust-bound data object, or a view on an element in another collection.
- __getitem__(i: int) PauliMatrix[source]¶
Return the element of the string at index
i.
- __init__(qubits: int | Qubits | None = None, source: SpecT | None = None)[source]¶
Initialize the string.
- Parameters:
qubits – The qubit register or qubit count.
source – The string specifier to use for default qubits and initial value.
- __mul__(rhs: CoeffT | String) Term[CoeffT] | Term[ComplexSign][source]¶
- Overloads:
self, rhs (String) → Term[ComplexSign]
self, rhs (CoeffT) → Term[CoeffT]
Multiplication of
selfbyrhs.
- __setitem__(i: int, pauli: PauliMatrix | str) None[source]¶
Set the element of the string at index
i.
- aliases(other: Cmpnt[ImplT, SpecT]) bool¶
Determine whether
selfis a view of the same component asother.
- count(elem: ElemT) int[source]¶
Return the number of occurrences of
elemin the string.- Parameters:
elem – The element to count.
- Returns:
The number of occurrences of
elemin the string.
- classmethod from_str(source: str, qubits: int | Qubits | None = None) String[source]¶
Create a new instance of
clsby parsing an input string.- Parameters:
source – Input string to parse.
qubits – Space of qubits or a number of qubits. If
None, infer from the max qubit index in the input string.
- Returns:
A new instance containing the Pauli string in the
source.
- get_dict() dict[int, PauliMatrix][source]¶
Get the string as a dictionary of its elements.
- impl_type¶
alias of
QubitPauliArray
- imul_get_phase(rhs: String) ComplexSign[source]¶
In-place multiplication of
selfbyrhs, returning the phase.See also
imul_ignore_phase()for in-place multiplication that ignores the phase.
- imul_ignore_phase(rhs: String) None[source]¶
In-place multiplication of
selfbyrhs, ignoring the scalar phase.
- into(t: type[OutT]) OutT¶
Clone
selfinto a new related container of typet.- Parameters:
t – Type of the new container to create.
- Returns:
A new instance of
tcontaining the same data asself.
- phase_of_mul(rhs: String) ComplexSign[source]¶
Get the phase resulting from the multiplication of
selfandrhs.
- set(source: None | Sequence[PauliMatrix] | dict[int, PauliMatrix] | str | String[QubitPauliArray, None | Sequence[PauliMatrix] | dict[int, PauliMatrix] | str, PauliMatrix]) None[source]¶
Set the value of the string.
- Parameters:
source – Specification for the new value.
Note
This method operates in-place.
- set_mul(lhs: String, rhs: String) ComplexSign[source]¶
Set
selfto the product oflhsandrhs, and return the phase.- Parameters:
lhs – Left hand side of the product.
rhs – Right hand side of the product.
- Returns:
The phase factor of the multiplication.