Skip to main content

PauliString

Base class: Object

Object that represents a numerically efficient Pauli String

Represents a Pauli string and it's complex coefficient efficiently using a bitstring representation. This class leverages bit logic to perform common operations on pauli strings much faster than those represented by OperatorProducts and OperatorSums of OperatorNamed Pauli operators. Each Pauli string is represented via a complex coefficient and two integers called xbits and zbits. Bits at the same locations in the integer encode the information of one pauli operator with the following mapping: 00 (I), 10 (X), 01 (Z), 11 (Y). The class takes care of handling the phase accrued during multiplication of different terms.

Constructors​

PauliString(const PauliString other) -> PauliString​

Copy constructs a PauliString from another PauliString

Parameters​

PauliString(integer num_spins) -> PauliString​

Constructs an identity PauliString for a system.

Parameters​

  • num_spins: The number of spins in the system, from 1 through 256.

PauliString(const string characters, const List<integer> sites, integer num_spins) -> PauliString​

Constructs a PauliString from Pauli characters and their sites.

Parameters​

  • characters: String containing the characters I, X, Y, or Z.
  • sites: Sites corresponding to the supplied characters.
  • num_spins: The number of spins in the system.

Members​

NameDescription
coefficientReturns the complex coefficient of a PauliString.
commutes_withChecks whether two PauliStrings commute: [P,Q]=0[P,Q] = 0.‌
displayDisplays the coefficient and bit representation of a PauliString.
expvalCalculates the expectation value ⟨ψ∥P∥ψ⟩\langle\psi\|P\|\psi\rangle of a PauliString PP.‌
multipliedRight-multiplies the PauliString PP by another PauliString QQ out of place: R=PQR = PQ.‌
multiplyRight-multiplies the PauliString PP by another PauliString QQ in place: P=PQP = PQ.‌
num_spinsReturns the number of spins represented by a PauliString.
weightReturns the weight of a PauliString—the number of non-identity operators.
xbitsReturns the X bits of a PauliString as a list of 64-bit chunks. Chunk n contains sites 64n through 64n+63.
zbitsReturns the Z bits of a PauliString as a list of 64-bit chunks. Chunk n contains sites 64n through 64n+63.