paulie.common.pauli_string_linear.PauliStringLinear#
- class paulie.common.pauli_string_linear.PauliStringLinear(combinations)#
Bases:
PauliStringRepresentation of a linear combination of Pauli string.
- adjoint_map(other)#
Compute the adjoint map \(ad_{A}(B) = [A,B]\).
- Parameters:
other – Linear combinations for the adjoint map.
- Returns:
None if the commutator is zero (i.e., if A and B commute). Otherwise, returns a PauliString proportional to the commutator.
- Raises:
PauliStringLinearException – Not implemented
- commutes_with(other)#
Check if this Pauli string commutes with another.
- Parameters:
other – Linear combinations for checking commutes.
- Returns:
True if they commute, False if they anticommute.
- copy()#
Copy Linear combination of Pauli strings.
- Returns:
Copy of self.
- expand(n)#
Increasing the size of the Pauli string by taking the tensor product with identities in the end.
- Parameters:
n (int) – New Pauli string length.
- Returns:
Pauli string of extend length.
- Raises:
PauliStringLinearException – Not implemented
- exponential()#
Get the exponential of a linear combination of Pauli strings.
- Returns:
Exponential of a linear combination of Pauli strings.
- gen_all_pauli_strings()#
Generate a list of Pauli strings that commute with this string.
- Yields:
Commutant of the Pauli string
- Raises:
PauliStringLinearException – Not implemented
- get_anti_commutants(generators=None)#
Get a list of Pauli strings that no-commute with this string.
- Parameters:
generators – Collection of Pauli strings on which commutant is searched.
specified (If not)
size. (then the search area is all Pauli strings of the same)
- Returns:
List of Pauli strings that no-commute with this string.
- Raises:
PauliStringLinearException – Not implemented
- get_commutants(generators=None)#
Get a list of linear combinations that commute with this string.
- Parameters:
generators – Collection of Pauli strings on which commutant is searched.
specified (If not)
size. (then the search area is all Pauli strings of the same)
- Returns:
List of linear combinations that commute with this string.
- Raises:
PauliStringLinearException – Not implemented
- get_matrix()#
Get matrix representation for Pauli string.
- Returns:
Matrix representation for the Pauli string.
- get_nested(generators=None)#
Get nested of Pauli string
- Parameters:
generators – Collection of Pauli strings on which nested is searched.
specified (If not)
size. (then the search area is all Pauli strings of the same)
- Returns:
Nested of Pauli string.
- Raises:
PauliStringLinearException – Not implemented
- get_size()#
Get the length of the Pauli Strings in this linear combination.
- Returns:
Length of the Pauli Strings in this linear combination.
- get_substring(start, length=1)#
Get a substring of Paulis inside the Pauli string.
- Parameters:
start – Index to begin extracting the string.
length – Length of each substring.
- Returns:
substring of the Pauli string.
- Raises:
PauliStringLinearException – Not implemented
- property h#
Get the Hermitian conjugate of this linear combination. This is found by taking the complex conjugate of all coefficients, as the Pauli matrices themselves are Hermitian.
- Returns:
Hermitian conjugate of this linear combination.
- inc()#
Pauli string increment operator.
- Returns:
Pauli string whose bit representation is greater than 1.
- Raises:
PauliStringLinearException – Not implemented
- is_identity()#
Check if this Pauli string is the identity.
- Returns:
True if self is the identity.
- Raises:
PauliStringLinearException – Not implemented
- is_zero()#
Check if the linear combination is effectively zero. This can be done by checking if all coefficients are close to zero.
- Returns:
True if the linear combination is zero, False otherwise.
- kron(other)#
Kroniker multiplication pauli string on linear combination of Pauli strings.
- Parameters:
other – Linear combinations for Kroniker multiplication.
- Returns:
Linera combination of PauliString.
- multiply(other)#
Multiplication operator of two linear combination of Pauli strings.
- Parameters:
other – Linear combinations for multiplication.
- Returns:
PauliString proportional to the multiplication.
- norm()#
Calculates the Frobenius norm of the coefficient vector. The norm is \(sqrt(∑ |cᵢ|²)\), where cᵢ are the coefficients of the Pauli strings in the linear combination.
- Returns:
Frobenius norm of the coefficient vector.
- quadratic(basis)#
Computes the quadratic form \(Q_{j} = \sum_{S \in \mathrm{self}} S \otimes (L_{j} * S)\) where self represents the component \(C_{k} = \sum S\), and basis is the linear symmetry \(L_{j}\).
- Parameters:
basis – Linear symmetry \(L_{j}\).
- Returns:
Linear combination of PauliString.
- rkron(other)#
Right Kroniker multiplication pauli string on linear combination of Pauli strings.
- Parameters:
other – Linear combinations for right Kroniker multiplication.
- Returns:
Linera comination of PauliString.
- set_substring(start, pauli_string)#
Set substring starting at position start.
- Parameters:
start – Index to begin the string.
pauli_string – Substring of PauliString.
- Returns:
None
- Raises:
PauliStringLinearException – Not implemented
- simplify()#
Combines terms with the same Pauli string by summing their coefficients. Removes terms with coefficients close to zero. This version assumes the PauliStringLinear object is directly iterable.
- Returns:
Linear combination.
- tensor(other)#
Tensor product of this linear combination with another.
- Parameters:
other – Linear combinations to tensor product.
- Returns:
Result of the tensor product self on others.
- Raises:
PauliStringLinearException – Not implemented
- trace()#
Computes the trace of the operator represented by this linear combination.
The trace is non-zero only if the Identity operator is present in the sum. \(Tr(self) = (\textit{coefficient of Identity}) * 2^{n}\).
- Returns:
Complex value of the trace.