pytket.pauli
pytket.pauli#
- class pytket.pauli.Pauli#
Members:
I
X
Y
Z
- __init__(self: pytket.pauli.Pauli, value: int) None #
- property name#
- class pytket.pauli.PauliStabiliser#
A string of Pauli letters from the alphabet {I, X, Y, Z} with a +/- 1 coefficient.
- __init__(*args, **kwargs)#
Overloaded function.
__init__(self: pytket.pauli.PauliStabiliser) -> None
Constructs an empty QubitPauliString.
__init__(self: pytket.pauli.PauliStabiliser, string: List[pytket.pauli.Pauli], coeff: int) -> None
Constructs a PauliStabiliser with a list of Pauli terms.
- property coeff#
The coefficient of the stabiliser
- property string#
The list of Pauli terms
- class pytket.pauli.QubitPauliString#
A string of Pauli letters from the alphabet {I, X, Y, Z},implemented as a sparse list, indexed by qubit.
- __init__(*args, **kwargs)#
Overloaded function.
__init__(self: pytket.pauli.QubitPauliString) -> None
Constructs an empty QubitPauliString.
__init__(self: pytket.pauli.QubitPauliString, qubit: pytket.circuit.Qubit, pauli: pytket.pauli.Pauli) -> None
Constructs a QubitPauliString with a single Pauli term.
__init__(self: pytket.pauli.QubitPauliString, qubits: List[pytket.circuit.Qubit], paulis: List[pytket.pauli.Pauli]) -> None
Constructs a QubitPauliString from two matching lists of Qubits and Paulis.
__init__(self: pytket.pauli.QubitPauliString, map: Dict[pytket.circuit.Qubit, pytket.pauli.Pauli]) -> None
Construct a QubitPauliString from a QubitPauliMap.
- commutes_with(self: pytket.pauli.QubitPauliString, other: pytket.pauli.QubitPauliString) bool #
- Returns
True if the two strings commute, else False
- compress(self: pytket.pauli.QubitPauliString) None #
Removes I terms to compress the sparse representation.
- dot_state(*args, **kwargs)#
Overloaded function.
dot_state(self: pytket.pauli.QubitPauliString, state: numpy.ndarray[numpy.complex128[m, 1]]) -> numpy.ndarray[numpy.complex128[m, 1]]
Performs the dot product of the state with the pauli string. Maps the qubits of the statevector with sequentially-indexed qubits in the default register, with
Qubit(0)
being the most significant qubit.- Parameters
state – statevector for qubits
Qubit(0)
toQubit(n-1)
- Returns
dot product of operator with state
dot_state(self: pytket.pauli.QubitPauliString, state: numpy.ndarray[numpy.complex128[m, 1]], qubits: List[pytket.circuit.Qubit]) -> numpy.ndarray[numpy.complex128[m, 1]]
Performs the dot product of the state with the pauli string. Maps the qubits of the statevector according to the ordered list qubits, with
qubits[0]
being the most significant qubit.- Parameters
state – statevector
qubits – order of qubits in state from most to least significant
- Returns
dot product of operator with state
- static from_list(arg0: json) pytket.pauli.QubitPauliString #
Construct a new QubitPauliString instance from a JSON serializable list representation.
- state_expectation(*args, **kwargs)#
Overloaded function.
state_expectation(self: pytket.pauli.QubitPauliString, state: numpy.ndarray[numpy.complex128[m, 1]]) -> complex
Calculates the expectation value of the state with the pauli string. Maps the qubits of the statevector with sequentially-indexed qubits in the default register, with
Qubit(0)
being the most significant qubit.- Parameters
state – statevector for qubits
Qubit(0)
toQubit(n-1)
- Returns
expectation value with respect to state
state_expectation(self: pytket.pauli.QubitPauliString, state: numpy.ndarray[numpy.complex128[m, 1]], qubits: List[pytket.circuit.Qubit]) -> complex
Calculates the expectation value of the state with the pauli string. Maps the qubits of the statevector according to the ordered list qubits, with
qubits[0]
being the most significant qubit.- Parameters
state – statevector
qubits – order of qubits in state from most to least significant
- Returns
expectation value with respect to state
- to_list(self: pytket.pauli.QubitPauliString) json #
A JSON-serializable representation of the QubitPauliString. :return: a list of
Qubit
-to-Pauli
entries, represented as dicts.
- to_sparse_matrix(*args, **kwargs)#
Overloaded function.
to_sparse_matrix(self: pytket.pauli.QubitPauliString) -> scipy.sparse.csc_matrix[numpy.complex128]
Represents the sparse string as a dense string (without padding for extra qubits) and generates the matrix for the tensor. Uses the ILO-BE convention, so
Qubit("a", 0)
is more significant thatQubit("a", 1)
andQubit("b")
for indexing into the matrix.- Returns
a sparse matrix corresponding to the operator
to_sparse_matrix(self: pytket.pauli.QubitPauliString, n_qubits: int) -> scipy.sparse.csc_matrix[numpy.complex128]
Represents the sparse string as a dense string over n_qubits qubits (sequentially indexed from 0 in the default register) and generates the matrix for the tensor. Uses the ILO-BE convention, so
Qubit(0)
is the most significant bit for indexing into the matrix.- Parameters
n_qubits – the number of qubits in the full operator
- Returns
a sparse matrix corresponding to the operator
to_sparse_matrix(self: pytket.pauli.QubitPauliString, qubits: List[pytket.circuit.Qubit]) -> scipy.sparse.csc_matrix[numpy.complex128]
Represents the sparse string as a dense string and generates the matrix for the tensor. Orders qubits according to qubits (padding with identities if they are not in the sparse string), so
qubits[0]
is the most significant bit for indexing into the matrix.- Parameters
qubits – the ordered list of qubits in the full operator
- Returns
a sparse matrix corresponding to the operator
- pytket.pauli.pauli_string_mult(qubitpaulistring1: pytket.pauli.QubitPauliString, qubitpaulistring2: pytket.pauli.QubitPauliString) Tuple[pytket.pauli.QubitPauliString, complex] #
- Returns
the product of two QubitPauliString objects as a pair (QubitPauliString, complex)