mimiqcircuits.operations.gates.generalized.paulistring

PauliString definition.

Functions

convert_pauli(x)

Classes

PauliString(pauli)

PauliString.

class mimiqcircuits.operations.gates.generalized.paulistring.PauliString(pauli)[source]

Bases: Gate

PauliString.

N-qubit tensor product of Pauli operators.

The PauliString gate can represent any N-qubit tensor product of operators of the form P_1 ⊗ P_2 ⊗ P_3 ⊗ … ⊗ P_N, where each P_i ∈ { I, X, Y, Z } is a Pauli operator, including the identity.

This gate can be initialized by passing as argument a string of length N where each element is either ‘I’, ‘X’, ‘Y’, or ‘Z’. For example, PauliString(“IXXYZ”)

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]

>>> c.decompose()
3-qubit circuit with 3 instructions:
├── U(pi, 0, pi, 0.0) @ q[0]
├── U(pi, (1/2)*pi, (1/2)*pi, 0.0) @ q[1]
└── U(0, 0, pi, 0.0) @ q[2]
__init__(pauli)[source]
classmethod from_string(pauli_expr)[source]
property num_qubits
property parnames
inverse()[source]

Raise an error, as non-unitary operators cannot be inverted.

This method is not implemented for non-unitary operators and will raise a NotImplementedError if called.

Raises:

NotImplementedError – If the method is called.

unwrapped_matrix()[source]
is_identity()[source]
evaluate(d)[source]

Substitute the symbolic parameters of the operator with numerical values.

This method evaluates the operator’s symbolic parameters using the values provided in the dictionary d. If the operator has no parameters, it returns the same instance. Otherwise, it creates a new instance of the operator with updated numerical parameters.

Parameters:

d (dict) – A dictionary where keys are symbolic parameter names and values are values for substitution.

Example

>>> from symengine import *
>>> from mimiqcircuits import *
>>> theta = symbols('theta')
>>> op = GateRX(theta)
>>> evaluated_op = op.evaluate({'theta': 0.5})
>>> print(evaluated_op)
RX(0.5)
isidentity()[source]
asciiwidth(qubits, bits, zvars)[source]