Symbols#
Qibo provides a basic set of symbols which inherit the sympy.Symbol object
and can be used to construct qibo.hamiltonians.SymbolicHamiltonian
objects as described in the Hamiltonians section.
- class qibo.symbols.Symbol(q, matrix, name='Symbol', commutative=False, **assumptions)[source]#
Qibo specialization for
sympysymbols.These symbols can be used to create
qibo.hamiltonians.hamiltonians.SymbolicHamiltonian. See How to define custom Hamiltonians using symbols? for more details.Example
from qibo.hamiltonians import SymbolicHamiltonian from qibo.symbols import X, Y, Z # construct a XYZ Hamiltonian on two qubits using Qibo symbols form = X(0) * X(1) + Y(0) * Y(1) + Z(0) * Z(1) ham = SymbolicHamiltonian(form)
- Parameters:
q (int) – Target qubit id.
matrix (np.ndarray) – 2x2 matrix represented by this symbol.
name (str) – Name of the symbol which defines how it is represented in symbolic expressions.
commutative (bool) – If
Truethe constructed symbols commute with each other. Default isFalse. This argument should be used with caution because quantum operators are not commutative objects and therefore switching this toTruemay lead to wrong results. It is useful for improving performance in symbolic calculations in cases where the user is sure that the operators participating in the Hamiltonian form are commuting (for example when the Hamiltonian consists of Z terms only).
- property gate#
Qibo gate that implements the action of the symbol on states.
- class qibo.symbols.I(q, commutative=False, **assumptions)[source]#
Qibo symbol for the identity operator.
- Parameters:
q (int) – Target qubit id.
- class qibo.symbols.X(q, commutative=False, **assumptions)[source]#
Qibo symbol for the Pauli-X operator.
- Parameters:
q (int) – Target qubit id.