mimiqcircuits.operations.gates.generalized.paulistring¶
PauliString definition.
Functions
|
Return the single qubit gate for a Pauli character. |
Classes
|
Tensor product of Pauli operators on \(N\) qubits. |
- class PauliString(pauli)[source]¶
Bases:
GateTensor product of Pauli operators on \(N\) qubits.
Represents \(P_1 \otimes P_2 \otimes \dots \otimes P_N\) with each \(P_i \in \{I, X, Y, Z\}\). The \(i\)-th character of the string acts on the \(i\)-th target qubit. A Pauli string is its own inverse and can only be raised to integer powers.
- Parameters:
pauli (str | chr) – A non-empty string of
"I","X","Y"and"Z"characters, for example"IXXYZ".- Raises:
ValueError – If the string is empty or contains other characters.
Examples
>>> from mimiqcircuits import * >>> g = PauliString("XYZ") >>> g.matrix() [0, 0, 0, 0, 0, 0, 0.0 - 1.0*I, 0] [0, 0, 0, 0, 0, 0, 0, 0.0 + 1.0*I] [0, 0, 0, 0, 0.0 + 1.0*I, 0, 0, 0] [0, 0, 0, 0, 0, 0.0 - 1.0*I, 0, 0] [0, 0, 0.0 - 1.0*I, 0, 0, 0, 0, 0] [0, 0, 0, 0.0 + 1.0*I, 0, 0, 0, 0] [0.0 + 1.0*I, 0, 0, 0, 0, 0, 0, 0] [0, 0.0 - 1.0*I, 0, 0, 0, 0, 0, 0] >>> c = Circuit() >>> c.push(PauliString("XYZ"), 0, 1, 2) 3-qubit circuit with 1 instruction: └── XYZ @ q[0:2] >>> g.power(2), g.inverse() (III, XYZ) >>> g.decompose() 3-qubit circuit with 3 instructions: ├── X @ q[0] ├── Y @ q[1] └── Z @ q[2]
- classmethod from_string(pauli_expr)[source]¶
Build a
PauliStringfrom a string; same asPauliString(pauli_expr).
- property num_qubits¶
Number of qubits, the length of the string.
- property parnames¶
("pauli",).- Type:
Parameter names
- inverse()[source]¶
Return the inverse of the gate.
Gates with a known inverse return it directly (for example
GateS().inverse()isGateSDG()); otherwise the gate is wrapped inInverse.
- is_identity()[source]¶
Return
Trueif every character is"I". Same asisidentity().